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_;
129 for (
size_t i = 0 ; i < dim ; i++)
131 ret.
c[i] =
c[i] - t.
c[i];
152 for (
size_t i = 0 ; i < dim ; i++)
154 ret.
c[i] = -abs(
c[i]);
169 for (
size_t i = 0 ; i < dim ; i++)
186 for (
size_t i = 0 ; i < dim ; i++)
188 ret.
c[i] =
c[i] + t.
c[i];
206 for (
size_t i = 0 ; i < dim ; i++)
284 inline int n_zero()
const
288 for (
size_t i = 0 ; i < dim ; i++)
290 if (
c[i] == 0) zero++;
309 {this->c[c.size() - i - 1] = x;i++;}
327 for (
size_t i = 0; i < dim ; i++)
345 std::stringstream str;
349 for (i = 0 ; i < dim - 1 ; i++)
350 str << std::to_string(
c[i]) <<
",";
352 str << std::to_string(
c[i]) <<
")";
369 for (
size_t i = 0 ; i < dim ; i++)
371 ret += (
c[i] + 1) * accu;
char operator[](int i)
Get the i combination coefficient.
bool operator==(const comb< dim > &t) const
Compare two combination.
void zero()
Set all the elements to zero.
Position of the element of dimension d in the hyper-cube of dimension dim.
comb< dim > operator-(const comb< dim > &t)
Subtract the combinations and return the result.
comb< dim > operator-()
Subtract the combinations and return the result.
bool operator!=(const comb< 0 > &t) const
Compare two combination.
bool isValid()
check if it is a valid combination
std::string to_string() const
Convert a combination into string.
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.
size_t lin() const
Linearization.
char value(int i) const
get the index i of the combination
const char * getComb() const
get the combination array pointer
void push_back(comb< 0 > &obj)
Do nothing.
comb()
Default constructor.
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.
comb< dim > operator&(char c_)
Bitwise operator &.
bool operator!=(const comb< dim > &t) const
Compare two combination.
bool isSub(comb< 0 > cmb)
Check if the combination is a sub-element.
bool operator==(const comb< 0 > &t) const
Compare two 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.
char value(int i) const
get the index i of the combination
char * getComb()
get the combination array pointer
char operator[](int i) const
Get the i combination coefficient.
char c[dim]
Array that store the combination.