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