Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

mxSetNzmax (C and Fortran) - Set storage space for nonzero elements

C Syntax

#include "matrix.h"
void mxSetNzmax(mxArray *pm, mwSize nzmax);

Fortran Syntax

mxSetNzmax(pm, nzmax)
mwPointer pm
mwSize nzmax

Arguments

pm

Pointer to a sparse mxArray.

nzmax

Number of elements mxCreateSparse should allocate to hold the arrays pointed to by ir, pr, and pi (if it exists). Set nzmax greater than or equal to the number of nonzero elements in the mxArray, but 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. To change the size of one of these arrays:

  1. Call mxRealloc with a pointer to the array, setting the size to the new value of nzmax.

  2. Call the appropriate mxSet routine (mxSetIr, mxSetPr, or mxSetPi) to establish the new memory area as the current one.

Two ways of determining how big you should make nzmax are

C Examples

See mxsetnzmax.c in the matlabroot/extern/examples/mx folder .

See Also

mxGetNzmax, mxRealloc

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS