4 #define COMB_ERROR 1001lu 6 #include "util/se_util.hpp" 33 template<
unsigned int dim>
47 for (
size_t i = 0 ; i < dim ; i++)
49 if (
c[i] != 1 &&
c[i] != -1 &&
c[i] != 0)
68 for (
size_t i = 0 ; i < dim ; i++)
70 if (
c[i] != 0 &&
c[i] != cmb.
c[i])
85 for (
size_t i = 0 ; i < dim ; i++)
97 for (
size_t i = 0 ; i < dim ; i++)
112 for (
size_t i = 0 ; i < dim ; i++)
114 ret.
c[i] =
c[i] & c_;
126 for (
size_t i = 0 ; i < dim ; i++)
141 for (
size_t i = 0 ; i < dim ; i++)
143 ret.
c[i] =
c[i] - t.
c[i];
164 for (
size_t i = 0 ; i < dim ; i++)
166 ret.
c[i] = -abs(
c[i]);
181 for (
size_t i = 0 ; i < dim ; i++)
198 for (
size_t i = 0 ; i < dim ; i++)
200 ret.
c[i] =
c[i] + t.
c[i];
218 for (
size_t i = 0 ; i < dim ; i++)
296 inline int n_zero()
const 300 for (
size_t i = 0 ; i < dim ; i++)
302 if (
c[i] == 0)
zero++;
321 {this->c[
c.size() - i - 1] = x;i++;}
339 for (
size_t i = 0; i < dim ; i++)
357 std::stringstream str;
361 for (i = 0 ; i < dim - 1 ; i++)
362 str << std::to_string(
c[i]) <<
",";
364 str << std::to_string(
c[i]) <<
")";
381 for (
size_t i = 0 ; i < dim ; i++)
383 ret += (
c[i] + 1) * accu;
char operator[](int i)
Get the i combination coefficient.
void zero()
Set all the elements to zero.
bool operator==(const comb< 0 > &t) const
Compare two combination.
Position of the element of dimension d in the hyper-cube of dimension dim.
bool operator==(const comb< dim > &t) const
Compare two combination.
comb< dim > operator-(const comb< dim > &t)
Subtract the combinations and return the result.
std::string to_string() const
Convert a combination into string.
comb< dim > operator &(char c_)
Bitwise operator &.
char value(int i) const
get the index i of the combination
void sign_flip()
Flip the sign of the combination.
const char * getComb() const
get the combination array pointer
comb< dim > operator-()
Subtract the combinations and return the result.
bool isValid()
check if it is a valid combination
char operator[](int i) const
Get the i combination coefficient.
comb< dim > operator+(const comb< dim > &t)
sum the combinations and return the result
bool isSub(comb< dim > cmb)
Check if the combination is a sub-element.
void push_back(comb< 0 > &obj)
Do nothing.
comb()
Default constructor.
size_t lin() const
Linearization.
char * getComb()
get the combination array pointer
comb< dim > flip()
flip the coefficent of the combination to be < 0
comb(std::initializer_list< char > c)
Constructor from a list of numbers.
void mone()
Set all the elements to -1.
comb< 0 > & operator[](size_t i)
Do nothing.
void zero()
Set all the elements to zero.
bool isSub(comb< 0 > cmb)
Check if the combination is a sub-element.
bool operator!=(const comb< 0 > &t) const
Compare two combination.
char value(int i) const
get the index i of the combination
bool isValid()
check if it is a valid combination
bool isNegative()
Check if any alement in the combination is <= 0.
comb< 0 > * ptr
Pointer to nothing.
bool operator!=(const comb< dim > &t) const
Compare two combination.
char * getComb()
get the combination array pointer
char c[dim]
Array that store the combination.