Rev | Line | |
---|
[37] | 1 | /* Simple test of using initialized vs. uninitialized arrays. |
---|
| 2 | * The uninitialized version runs nearly twice as fast. |
---|
| 3 | */ |
---|
| 4 | /* |
---|
| 5 | mex.bat -c mexutil.c |
---|
| 6 | mex.bat xones.c mexutil.obj |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include "mexutil.h" |
---|
| 10 | |
---|
| 11 | void mexFunction(int nlhs, mxArray *plhs[], |
---|
| 12 | int nrhs, const mxArray *prhs[]) |
---|
| 13 | { |
---|
| 14 | int m,n,i,sz; |
---|
| 15 | double *p; |
---|
| 16 | if(nrhs != 2) mexErrMsgTxt("xones(m,n)"); |
---|
| 17 | m = (int)*mxGetPr(prhs[0]); |
---|
| 18 | n = (int)*mxGetPr(prhs[1]); |
---|
| 19 | sz = m*n; |
---|
| 20 | #if 0 |
---|
| 21 | plhs[0] = mxCreateDoubleMatrix(m,n,mxREAL); |
---|
| 22 | p = (double*)mxGetPr(plhs[0]); |
---|
| 23 | #else |
---|
| 24 | plhs[0] = mxCreateDoubleMatrixE(m,n,mxREAL); |
---|
| 25 | p = (double*)mxGetPr(plhs[0]); |
---|
| 26 | #endif |
---|
| 27 | for(i=0;i<sz;i++) *p++ = 1; |
---|
| 28 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.