mxCreateSparse (C and Fortran)
2-D sparse array
C Syntax
#include "matrix.h"
mxArray *mxCreateSparse(mwSize m, mwSize n, mwSize nzmax,
mxComplexity ComplexFlag);Fortran Syntax
#include "fintrf.h" mwPointer mxCreateSparse(m, n, nzmax, ComplexFlag) mwSize m, n, nzmax integer*4 ComplexFlag
Arguments
mNumber of rows
nNumber of columns
nzmaxNumber of elements that
mxCreateSparseshould allocate to hold thepr,ir, and, ifComplexFlagismxCOMPLEXin C (1in Fortran),piarrays. Set the value ofnzmaxto be greater than or equal to the number of nonzero elements you plan to put into themxArray, but make sure thatnzmaxis less than or equal tom*n.nzmaxis greater than or equal to 1.ComplexFlagIf the
mxArrayyou are creating is to contain imaginary data, setComplexFlagtomxCOMPLEXin C (1in Fortran). Otherwise, setComplexFlagtomxREALin C (0in Fortran).
Returns
Pointer to the created mxArray. If
unsuccessful in a standalone (non-MEX file) application, returns NULL in C
(0 in Fortran). If unsuccessful in a MEX file, the MEX file terminates
and returns control to the MATLAB® prompt. The function is unsuccessful when there is not enough free heap space to
create the mxArray. In that case, try reducing nzmax,
m, or n.
Description
Call mxCreateSparse to create an unpopulated sparse
double mxArray. The returned sparse
mxArray contains no sparse information and
cannot be passed as an argument to any MATLAB sparse functions. To make the returned sparse
mxArray useful, initialize the
pr, ir,
jc, and (if it exists) pi
arrays.
mxCreateSparse allocates space for:
A
prarray of lengthnzmax.A
piarray of lengthnzmax, but only ifComplexFlagismxCOMPLEXin C (1in Fortran).An
irarray of lengthnzmax.A
jcarray of lengthn+1.
When you finish using the sparse mxArray, call
mxDestroyArray to reclaim all its heap
space.
Examples
To open an example, type:
edit([fullfile(matlabroot,"extern","examples","refbook","filename")]);
where filename is:
Version History
Introduced before R2006a
See Also
mxDestroyArray | mxSetNzmax | mxSetIr | mxSetJc | mxComplexity