Download MATLAB Compiler
Transcript
static mwArray NewSparse(rowindex_size, mwIndex*
rowindex, colindex_size, mwIndex* colindex,
data_size, mxLogical* rdata, num_rows, num_cols,
nzmax)
nzmax
Reserved storage for sparse matrix. If nzmax is zero, storage will
be set to max{rowindex_size, colindex_size, data_size}.
Outputs
mwArray
mwArray containing the sparse array.
Description
The lengths of input row and column index and data arrays must all be
the same or equal to 1. In the case where any of these arrays are equal
to 1, the value is repeated throughout the construction of the matrix.
If any element of the rowindex or colindex array is greater than the
specified values in num_rows, num_cols, respectively, then an exception
is thrown.
Example
This example creates a sparse logical 4 X 4 tridiagonal matrix, assigning
true to each non-zero value:
mxLogical one = true;
mwIndex row_tridiag[] =
{1,
2,
1,
2,
2,
3,
4,
3,
mwIndex col_tridiag[] =
{1,
1,
2,
2,
3,
3,
3,
4,
3,
4};
2,
4};
mwArray mysparse =
mwArray::NewSparse(10, row_tridiag,
10, col_tridiag,
1, &one,
4, 4, 10);
std::cout << mysparse << std::endl;
(1,1)
(2,1)
(1,2)
1
1
1
D-103