/* multiply_one_marginals.c */ /* the first operand can be a joint marginals of nodes set,*/ /* but the second operand nust be a single node's marginal.*/ /* and the result joint marginal has domain like [prhs[0].domain, prhs[2].domain]*/ /* i.e. cat the second domain at the end of the first domain*/ /* the third operands will be the eff_node_sizes */ #include "mex.h" void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { mxArray *ptemp, *ptemp1; double *xdom, *ydom, *xp, *yp, *zp, *pr, *pSizes; int N, xElements, numElements; int i, j, nxdom, ndim, ydim; int *xdim, *s, *sx, *sy, *cpsx, *cpsy; int *subs, *s1, *cpsx2, *cpsy2; int rdims[2]; const char *field_names[] = {"domain", "T", "mu", "Sigma"}; if (nrhs != 3) mexErrMsgTxt("Incorrect number of inputs."); if (nlhs > 1) mexErrMsgTxt("Too many output arguments."); if(mxIsEmpty(prhs[0])){ plhs[0] = mxDuplicateArray(prhs[1]); return; } N = mxGetNumberOfElements(prhs[2]); pSizes = mxGetPr(prhs[2]); ptemp = mxGetField(prhs[0], 0, "domain"); nxdom = mxGetNumberOfElements(ptemp); xdom = mxGetPr(ptemp); ptemp = mxGetField(prhs[1], 0, "domain"); ydom = mxGetPr(ptemp); ndim = nxdom + 1; rdims[0] = 1; rdims[1] = 1; plhs[0] = mxCreateStructArray(2, rdims, 4, field_names); ptemp = mxCreateDoubleMatrix(1, ndim, mxREAL); mxSetField(plhs[0], 0, "domain", ptemp); pr = mxGetPr(ptemp); for(i=0; i