MATLAB Application Program Interface | Search  Help Desk |
mxSetJc | Examples See Also |
Set the jc
array of a sparse mxArray
#include "matrix.h" void mxSetJc(mxArray *array_ptr, int *jc);array_ptr
mxArray
.
jc
jc
array.
Use mxSetJc
to specify a new jc
array for a sparse mxArray
. The jc
array is an integer array having n+1
elements where n
is the number of columns in the sparse mxArray
. The values in the jc
array have the meanings:
jc[j]
is the index in ir
, pr
(and pi
if it exists) of the first nonzero entry in the jth column.
jc[j+1]-1
is the index of the last nonzero entry in the jth column.
jc
[number of columns + 1
] is equal to nnz
, which is the number of nonzero entries in the entire spare mxArray
.
jc[C] - jc[C-1];For example, consider a 7-by-3 sparse
mxArray
named Sparrow
containing six nonzero elements, created by typing
>> Sparrow=zeros(7,3); >> Sparrow(2,1)=1; >> Sparrow(5,1)=1; >> Sparrow(3,2)=1; >> Sparrow(2,3)=2; >> Sparrow(5,3)=1; >> Sparrow(6,3)=1; >> Sparrow=sparse(Sparrow);The contents of the
ir
, jc
, and pr
arrays aremxArray
. Consider an 8,000 element sparse mxArray
named Spacious
containing only 3 nonzero elements. The ir
, pr
, and jc
arrays contain mxSetNzmax
reference page.
mxGetIr
, mxGetJc
, mxSetIr