/**************************************************** A = mult_by_array(big, small) implicitely copies small |big|/|small| times and then does element-wise multiplication. i.e., C = repmat(small(:), 1, length(big(:))/length(small(:))) A = reshape(big(:) .* C(:), size(big)) However, this C version avoids the expense of the repmat. Written by wei.hu@intel.com, 28 Jan 2002. /****************************************************/ #include "mex.h" void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { double *sp, *zp; int i, j, NB, NS, xnd, ynd, ndim; const int *xdim, *ydim; int *s, *sx, *sy, *cpsy, *subs, *cpsy2; if (nrhs != 2) mexErrMsgTxt("Incorrect number of inputs."); if (nlhs > 1) mexErrMsgTxt("Too many output arguments."); plhs[0] = mxDuplicateArray(prhs[0]); zp = mxGetPr(plhs[0]); sp = mxGetPr(prhs[1]); xnd = mxGetNumberOfDimensions(prhs[0]); ynd = mxGetNumberOfDimensions(prhs[1]); xdim = mxGetDimensions(prhs[0]); ydim = mxGetDimensions(prhs[1]); ndim = xnd; NB = mxGetNumberOfElements(prhs[0]); NS = mxGetNumberOfElements(prhs[1]); if(NS == 1){ for(i=0; i