mxSetNzmax (C and Fortran)
Set storage space for nonzero elements
C Syntax
#include "matrix.h" void mxSetNzmax(mxArray *pm, mwSize nzmax);
Fortran Syntax
#include "fintrf.h" subroutine mxSetNzmax(pm, nzmax) mwPointer pm mwSize nzmax
Arguments
pmPointer to a sparse
mxArray.nzmaxNumber of elements for
mxCreateSparseto allocate to hold the arrays pointed to byir,pr, andpi(if it exists). Setnzmaxgreater than or equal to the number of nonzero elements in themxArray, but set it to be less than or equal to the number of rows times the number of columns. If you specify annzmaxvalue of0, thenmxSetNzmaxsets the value ofnzmaxto1.
Description
Use mxSetNzmax to assign a new value to the
nzmax field of the specified sparse mxArray.
The nzmax field holds the maximum number of nonzero elements in the
sparse mxArray.
The number of elements in the ir, pr, and
pi (if it exists) arrays must be equal to
nzmax. Therefore, after calling mxSetNzmax,
you must change the size of the ir, pr, and
pi arrays. To change the size of one of these arrays:
Call
mxReallocwith a pointer to the array, setting the size to the new value ofnzmax.Call the appropriate
mxSetroutine (mxSetIr,mxSetDoubles, ormxSetComplexDoubles) to establish the new memory area as the current one.
Ways to determine how large to make nzmax are:
Set
nzmaxequal to or slightly greater than the number of nonzero elements in a sparsemxArray. This approach conserves precious heap space.Make
nzmaxequal to the total number of elements in anmxArray. This approach eliminates (or, at least reduces) expensive reallocations.
Examples
To open an example, type:
edit([fullfile(matlabroot,"extern","examples","mx","filename")]);
where filename is:
Version History
Introduced before R2006a