00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "mex.h"
00016
00017 void
00018 mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])
00019 {
00020 mwSize nzmax;
00021 mwSize columns;
00022 mwIndex nnz;
00023
00024 (void) plhs;
00025
00026
00027 if (nrhs != 1) {
00028 mexErrMsgTxt("One input argument required.");
00029 }
00030 if(nlhs > 1){
00031 mexErrMsgTxt("Too many output arguments.");
00032 }
00033
00034 if (!mxIsSparse(prhs[0])) {
00035 mexErrMsgTxt("Input argument must be a sparse array.");
00036 }
00037 nzmax = mxGetNzmax(prhs[0]);
00038 columns = mxGetN(prhs[0]);
00039
00040
00041
00042
00043 nnz = *(mxGetJc(prhs[0]) + columns);
00044
00045 mexPrintf("Contains %d nonzero elements.\n", nnz);
00046 mexPrintf("Can store up to %d nonzero elements.\n", nzmax);
00047 }
00048