/* convert_to_sparse_table.c convert a sparse discrete CPD with evidence into sparse table */ /* convert_to_pot.m located in ../CPDs/discrete_CPD call it */ /* 3 input */ /* CPD prhs[0] with 1D sparse CPT */ /* domain prhs[1] */ /* evidence prhs[2] */ /* 1 output */ /* T plhs[0] sparse table */ #include #include "mex.h" void ind_subv(int index, const int *cumprod, const int n, int *bsubv){ int i; for (i = n-1; i >= 0; i--) { bsubv[i] = ((int)floor(index / cumprod[i])); index = index % cumprod[i]; } } int subv_ind(const int n, const int *cumprod, const int *subv){ int i, index=0; for(i=0; i