MATLAB Application Program Interface | Search  Help Desk |
mxSetNzmax | See Also |
Set the storage space for nonzero elements
subroutine mxSetNzmax(pm, nzmax) integer*4 pm, nzmaxpm
mxArray
.
nzmax
mxCreateSparse
should allocate to hold the arrays pointed to by ir
, pr
, and pi
(if it exists). You should set nzmax
greater than or equal to the number of nonzero elements in the mxArray
, but you should set it to be less than or equal to the number of rows times the number of columns. If you specify an nzmax
value of 0, mxSetNzmax
sets the value of nzmax
to 1.
Use mxSetNzmax
to assign a new value to the nzmax
field of the specified sparse mxArray
. The nzmax
field holds the maximum possible 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.
How big should nzmax
be? One philosophy is that you should set nzmax
equal to or slightly greater than the number of nonzero elements in a sparse mxArray
. This philosophy conserves precious heap space. Another philosophy is that you should make nzmax
equal to the total number of elements in an mxArray
. This philosophy eliminates (or, at least reduces) expensive reallocations.
mxGetNzmax