21 #ifndef SUPPORT_H_INCLUDED 22 #define SUPPORT_H_INCLUDED 26 #include <string_view> 33 std::string toString(T obj)
35 std::ostringstream sout;
54 int PGCD(
double a,
double b);
64 long long int PGCD(
long long int a,
long long int b);
66 int PGCD(
int a,
int b);
87 long long int sgn(
long long int a);
106 double factorial(
int n);
115 int compare(std::string_view a, std::string_view b);
117 bool operator>(
const std::string& a,
const std::string& b);
119 bool operator<(
const std::string& a,
const std::string& b);
121 bool operator>=(
const std::string& a,
const std::string& b);
123 bool operator<=(
const std::string& a,
const std::string& b);
125 std::vector<size_t> range(
size_t n);
127 std::vector<size_t> range(
size_t i,
size_t n);
129 std::vector<size_t> range(
size_t i,
size_t n,
size_t step);
142 template <
typename T>
146 const size_t size = A.size();
147 if (size != B.size())
149 std::vector<int> indicesLeft(size);
150 for (
size_t i = 0; i != size; ++i)
153 for (
size_t iA = 0; iA != size; ++iA) {
154 bool matched =
false;
155 for (
size_t iLeft = 0; iLeft != indicesLeft.size(); ++iLeft) {
156 size_t iB = indicesLeft[iLeft];
157 if (A[iA] == B[iB]) {
159 indicesLeft.erase(indicesLeft.begin()+iLeft);
182 template <
typename T>
185 if (A.size() < B.size())
187 std::vector<int> indicesLeft(B.size());
188 for (
size_t i = 0; i != B.size(); ++i)
191 for (
size_t iA = 0; iA != A.size(); ++iA) {
192 for (
size_t iLeft = 0; iLeft != indicesLeft.size(); ++iLeft) {
193 size_t iB = indicesLeft[iLeft];
194 if (A[iA] == B[iB]) {
195 indicesLeft.erase(indicesLeft.begin()+iLeft);
201 return (indicesLeft.empty());
int PGCD(double a, double b)
Returns the PGCD of a and b.
Definition: support.cpp:23
Namespace for csl library.
Definition: abreviation.h:34
bool operator<=(const Expr &a, const Expr &b)
see Abstract::operator<=()
Definition: abstract.cpp:1416
bool operator>(const Expr &a, const Expr &b)
see Abstract::operator>()
Definition: abstract.cpp:1419
bool comparePlaceIndependant(std::vector< T > A, std::vector< T > B)
Template function that compares the elements in two vectors A and B, independently on their order...
Definition: support.h:143
bool operator>=(const Expr &a, const Expr &b)
see Abstract::operator>=()
Definition: abstract.cpp:1413
int internal_PGCD(long long int a, long long int b)
Returns the PGCD of a and b.
Definition: support.cpp:48
bool partialComparePlaceIndependant(std::vector< T > A, std::vector< T > B)
Template function that compares the elements in two vectors A and B, independently on their order...
Definition: support.h:183
long long int internal_factorial(long long int n)
Returns the factorial of a.
Definition: support.cpp:77
long long int sgn(long long int a)
Returns the sign of a.
Definition: support.cpp:56
bool operator<(const Expr &a, const Expr &b)
see Abstract::operator<()
Definition: abstract.cpp:1423