Sparse Matrices
Sparse matrix creation, manipulation, and iterative solvers for large-scale linear systems.
sparse
Create sparse matrix
S = sparse(A)
speye
Sparse identity matrix
S = speye(n)
sprand
Sparse uniformly distributed random matrix
S = sprand(m, n, density)
sprandn
Sparse normally distributed random matrix
S = sprandn(m, n, density)
sprandsym
Sparse symmetric random matrix
S = sprandsym(n, density)
spdiags
Sparse matrix formed from diagonals
S = spdiags(B, d, m, n)
spalloc
Allocate space for sparse matrix
S = spalloc(m, n, nz)
spconvert
Import sparse matrix from triplet data
S = spconvert(D)
issparse
Determine if matrix is sparse
tf = issparse(S)
nnz
Number of nonzero matrix elements
n = nnz(S)
nonzeros
Nonzero matrix elements
v = nonzeros(S)
nzmax
Amount of storage allocated for nonzero elements
n = nzmax(S)
full
Convert sparse matrix to full storage
A = full(S)
spones
Replace nonzero sparse matrix elements with ones
R = spones(S)
spfun
Apply function to nonzero sparse matrix elements
F = spfun(func, S)
spparms
Set parameters for sparse matrix routines
spparms
gmres
Generalized minimum residual method
x = gmres(A, b)
bicgstab
BiConjugate Gradients Stabilized method
x = bicgstab(A, b)
pcg
Preconditioned conjugate gradients
x = pcg(A, b)
lsqr
Least-squares solution via iterative method
x = lsqr(A, b)
eigs
Largest eigenvalues and eigenvectors of sparse matrix
d = eigs(A, k)
svds
Largest singular values of sparse matrix
s = svds(A, k)
ilu
Incomplete LU factorization
[L, U] = ilu(A)
ichol
Incomplete Cholesky factorization
L = ichol(A)
sprank
Structural rank of sparse matrix
r = sprank(A)