Next: spatan2, Previous: spalloc, Up: Function Reference
SPARSE: create a sparse matrix
sparse can be called in the following ways:
- S = sparse(A) where A is a full matrix
- S = sparse(A,1) where A is a full matrix, result is forced back to a full matrix is resulting matrix is sparse
- S = sparse(i,j,s,m,n,nzmax) where
i,j are integer index vectors (1 x nnz)
s is the vector of real or complex entries (1 x nnz)
m,n are the scalar dimentions of S
nzmax is ignored (here for compatability with Matlab)
if multiple values are specified with the same i,j position, the corresponding values in s will be added
- The following usages are equivalent to (2) above:
S = sparse(i,j,s,m,n)
S = sparse(i,j,s,m,n,'summation')
S = sparse(i,j,s,m,n,'sum')
- S = sparse(i,j,s,m,n,'unique')
same as (2) above, except that rather than adding, if more than two values are specified for the same i,j position, then the last specified value will be kept
- S= sparse(i,j,sv) uses m=max(i), n=max(j)
- S= sparse(m,n) does sparse([],[],[],m,n,0)
sv, and i or j may be scalars, in which case they are expanded to all have the same length
See also: full.