#include "mex.h" #include #include /* The gateway routine */ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { /* y = sC(A,x) */ /* A is assumed to be sparse, m by n */ /* x is N by n */ /* y is N by 1 */ /* Sparse matrix manipulation taken from explore.c */ /* From Matlab 7.1 in ../extern/examples/mex/ */ double *x, *y, *temp; int mA,nA,Nx,i,j,k; /* Set up sparse variables */ double *pr, *pi; int *ir, *jc; int col, total; int starting_row_index, stopping_row_index, current_row_index; /* Create pointer to x */ x = mxGetPr(prhs[1]); mA = mxGetM(prhs[0]); nA = mxGetN(prhs[0]); Nx = mxGetM(prhs[1]); /* Get the starting positions of all four sparse data arrays */ pr = mxGetPr(prhs[0]); pi = mxGetPi(prhs[0]); ir = mxGetIr(prhs[0]); jc = mxGetJc(prhs[0]); /* Set output pointer to point to y */ plhs[0] = mxCreateDoubleMatrix(Nx,1, mxREAL); /* Create a pointer to a copy of y */ y = mxGetPr(plhs[0]); temp = ((double*)mxCalloc(mA, sizeof(double))); for (k=0;k