Daniel@0: /* marg_sparse_table.c ../potential/tables*/ Daniel@0: Daniel@0: /******************************************/ Daniel@0: /* 5 input & 1 output */ Daniel@0: /* Big sparse table */ Daniel@0: /* Big domain */ Daniel@0: /* Big sizes */ Daniel@0: /* onto */ Daniel@0: /* maximize, if missed, maximize=0 */ Daniel@0: /* */ Daniel@0: /* small sparse table */ Daniel@0: /******************************************/ Daniel@0: Daniel@0: #include Daniel@0: #include Daniel@0: #include "mex.h" Daniel@0: Daniel@0: int compare(const void* src1, const void* src2){ Daniel@0: int i1 = *(int*)src1 ; Daniel@0: int i2 = *(int*)src2 ; Daniel@0: return i1-i2 ; Daniel@0: } Daniel@0: Daniel@0: void ind_subv(int index, const int *cumprod, int n, int *bsubv){ Daniel@0: int i; Daniel@0: Daniel@0: for (i = n-1; i >= 0; i--) { Daniel@0: bsubv[i] = ((int)floor(index / cumprod[i])); Daniel@0: index = index % cumprod[i]; Daniel@0: } Daniel@0: } Daniel@0: Daniel@0: int subv_ind(const int n, const int *cumprod, const int *subv){ Daniel@0: int i, index=0; Daniel@0: Daniel@0: for(i=0; i