User`s manual
2 Creating C Language MEX-Files
2-30
*
*=============================================================*/
/* $Revision: 1.5 $ */
#include <math.h> /* Needed for the ceil() prototype. */
#include "mex.h"
/* If you are using a compiler that equates NaN to be zero, you
* must compile this example using the flag -DNAN_EQUALS_ZERO.
* For example:
*
* mex -DNAN_EQUALS_ZERO fulltosparse.c
*
* This will correctly define the IsNonZero macro for your C
* compiler.
*/
#if defined(NAN_EQUALS_ZERO)
#define IsNonZero(d) ((d) != 0.0 || mxIsNaN(d))
#else
#define IsNonZero(d) ((d) != 0.0)
#endif
void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[]
)
{
/* Declare variables. */
int j,k,m,n,nzmax,*irs,*jcs,cmplx,isfull;
double *pr,*pi,*si,*sr;
double percent_sparse;
/* Check for proper number of input and output arguments. */
if(nrhs != 1) {
mexErrMsgTxt("One input argument required.");
}
if(nlhs > 1) {
mexErrMsgTxt("Too many output arguments.");