28 inline double combinedSum(
29 const int* conf,
const std::vector<double>** valuesContainer,
int dimNumber
32 for(
int i=0; i<dimNumber;i++)
33 res += (*(valuesContainer[i]))[conf[i]];
37 inline int* getConf(
void* conf)
39 return reinterpret_cast<int*>(
40 reinterpret_cast<char*>(conf) +
sizeof(
double)
44 inline double getLProb(
void* conf)
46 double ret = *reinterpret_cast<double*>(conf);
51 inline double unnormalized_logProb(
const int* conf,
const double* logProbs,
int dim)
55 int curr_method = fegetround();
57 fesetround(FE_TOWARDZERO);
59 for(
int i=0; i < dim; i++)
60 res += minuslogFactorial(conf[i]);
62 fesetround(FE_UPWARD);
64 for(
int i=0; i < dim; i++)
65 res += conf[i] * logProbs[i];
67 fesetround(curr_method);
72 inline double mass(
const int* conf,
const double* masses,
int dim)
76 for(
int i=0; i < dim; i++)
78 res += conf[i] * masses[i];
86 std::tuple<double,double,int*> t1,
87 std::tuple<double,double,int*> t2
89 return std::get<1>(t1) > std::get<1>(t2);
92 template<
typename T>
void printArray(
const T* array,
int size)
94 for (
int i=0; i<size; i++)
95 std::cout << array[i] <<
" ";
96 std::cout << std::endl;
99 template<
typename T>
void printVector(
const std::vector<T>& vec)
101 printArray<T>(vec.data(), vec.size());
105 template<
typename T>
void printNestedArray(
const T** array,
const int* shape,
int size)
107 for (
int i=0; i<size; i++)
108 printArray(array[i], shape[i]);
109 std::cout << std::endl;
112 #define mswap(x, y) swapspace = x; x = y; y=swapspace;
116 void*
quickselect(
void** array,
int n,
int start,
int end);
119 template <
typename T>
inline static T* array_copy(
const T* A,
int size)
121 T* ret =
new T[size];
122 memcpy(ret, A, size*
sizeof(T));
126 template<
typename T>
void dealloc_table(T* tbl,
int dim)
128 for(
int i=0; i<dim; i++)