MATLAB Application Program Interface Reference Help Desk

mxSetNzmax

Purpose

Set the storage space for nonzero elements

Fortran Syntax

Arguments

pm

Pointer to a sparse mxArray.

nzmax

The number of elements that 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.

Description

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.

See Also

mxGetNzmax



[ Previous | Help Desk | Next ]