4#define COMB_ERROR 1001lu
6#include "util/se_util.hpp"
33template<
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++)
285 inline signed char value(
int i)
const
296 inline int n_zero()
const
300 for (
size_t i = 0 ; i < dim ; i++)
302 if (
c[i] == 0)
zero++;
317 comb(std::initializer_list<signed char>
c)
320 for(
signed char x :
c)
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;
495 inline signed char value(
int i)
const
comb< 0 > * ptr
Pointer to nothing.
comb< 0 > & operator[](size_t i)
Do nothing.
void push_back(comb< 0 > &obj)
Do nothing.
bool isSub(comb< 0 > cmb)
Check if the combination is a sub-element.
signed char * getComb()
get the combination array pointer
signed char value(int i) const
get the index i of the combination
bool operator!=(const comb< 0 > &t) const
Compare two combination.
bool isValid()
check if it is a valid combination
bool operator==(const comb< 0 > &t) const
Compare two combination.
signed char operator[](int i)
Get the i combination coefficient.
void zero()
Set all the elements to zero.
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 > flip()
flip the coefficent of the combination to be < 0
bool isSub(comb< dim > cmb)
Check if the combination is a sub-element.
signed char * getComb()
get the combination array pointer
void mone()
Set all the elements to -1.
signed char value(int i) const
get the index i of the combination
comb< dim > operator-(const comb< dim > &t)
Subtract the combinations and return the result.
const signed char * getComb() const
get the combination array pointer
void zero()
Set all the elements to zero.
comb< dim > operator-()
Subtract the combinations and return the result.
void sign_flip()
Flip the sign of the combination.
comb(std::initializer_list< signed char > c)
Constructor from a list of numbers.
bool isNegative()
Check if any alement in the combination is <= 0.
signed char c[dim]
Array that store the combination.
comb< dim > operator&(signed char c_)
Bitwise operator &.
comb()
Default constructor.
bool operator!=(const comb< dim > &t) const
Compare two combination.
signed char operator[](int i) const
Get the i combination coefficient.
size_t lin() const
Linearization.
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 isValid()
check if it is a valid combination