Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Equivalent to mxCreateDoubleMatrix for unsigned long
Replies: 1   Last Post: May 30, 2013 1:23 PM

 Messages: [ Previous | Next ]
 Veneree Posts: 19 Registered: 11/27/12
Equivalent to mxCreateDoubleMatrix for unsigned long
Posted: May 30, 2013 11:42 AM

Hi,
I'd like to write mex functions from a 3rd party lib. The data type are all unsigned long. While looking at mex examples to create input and output, they are using mxCreateDoubleMatrix() with double type for both input and output.

Ex in timestwo.c:
===
void timestwo(double y[], double x[])
{
y[0] = 2.0*x[0];
}

void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{
double *x,*y;
mwSize mrows,ncols;

/* Check for proper number of arguments. */
if(nrhs!=1) {
mexErrMsgTxt("One input required.");
} else if(nlhs>1) {
mexErrMsgTxt("Too many output arguments.");
}

/* The input must be a noncomplex scalar double.*/
mrows = mxGetM(prhs[0]);
ncols = mxGetN(prhs[0]);
if( !mxIsDouble(prhs[0]) || mxIsComplex(prhs[0]) ||
!(mrows==1 && ncols==1) ) {
mexErrMsgTxt("Input must be a noncomplex scalar double.");
}

/* Create matrix for the return argument. */
plhs[0] = mxCreateDoubleMatrix(mrows,ncols, mxREAL);

/* Assign pointers to each input and output. */
x = mxGetPr(prhs[0]);
y = mxGetPr(plhs[0]);

/* Call the timestwo subroutine. */
timestwo_usb(y,x);
}

I had a look at matrix.h but couldn't figure out how to create unsigned long type.
So, my question is, what is the equivalent of mxCreateDoubleMatrix() for unsigned long ?

Thanks for helping.

Date Subject Author
5/30/13 Veneree
5/30/13 James Tursa