<< nzmax | Sparse type | speye >> |
sp = sparse(M) |
sp = sparse(m, n) |
sp = sparse(I, J, V) |
sp = sparse(I, J, V, m, n) |
sp = sparse(I, J, V, m, n, nz) |
a matrix: double or logical.
an integer value: rows dimension.
an integer value: columns dimension
a vector.
a vector.
a vector.
an integer value: storage allocation for nonzero elements.
a single.
sparse is used to build a sparse matrix. Only non-zero entries are stored.
If Mis a full matrix, sparse converts it to a sparse matrix representation, removing all zero values.
If nz is not specified, sparse uses as default value: nz = max([numel(i), numel(j), numel(v)])
If multiple values are specified with the same i, j indices, the associated value will be the sum of the values at the repeated index.
sp = sparse(eye(3,3))
sp = sparse(3, 3)
I = [1 2 3];
J = [3 1 2];
V = [32 42 53];
sp = sparse(I, J, V)
size(sp)
I = [1 2 3];
J = [3 1 2];
V = [32 42 53];
sp = sparse(I, J, V, 5, 4)
size(sp)
nnz(sp)
nzmax(sp)
I = [1 2 3];
J = [3 1 2];
V = [32 42 53];
sp = sparse(I, J, V, 5, 4, 10)
size(sp)
nnz(sp)
nzmax(sp)
Version | Description |
---|---|
1.0.0 | initial version |
Allan CORNET