Main Content

Sparse Matrices

Elementary sparse matrices, reordering algorithms, iterative methods, sparse linear algebra

Sparse matrices provide efficient storage ofdoubleorlogicaldata that has a large percentage of zeros. Whilefull(ordense) matrices store every single element in memory regardless of value,sparsematrices store only the nonzero elements and their row indices. For this reason, using sparse matrices can significantly reduce the amount of memory required for data storage.

All MATLAB®built-in arithmetic, logical, and indexing operations can be applied to sparse matrices, or to mixtures of sparse and full matrices. Operations on sparse matrices return sparse matrices and operations on full matrices return full matrices. For more information, see有限公司mputational Advantages of Sparse Matricesand有限公司nstructing Sparse Matrices.

Functions

expand all

spalloc Allocate space for sparse matrix
spdiags Extract nonzero diagonals and create sparse band and diagonal matrices
speye Sparse identity matrix
sprand Sparse uniformly distributed random matrix
sprandn Sparse normally distributed random matrix
sprandsym Sparse symmetric random matrix
sparse Create sparse matrix
spconvert Import from sparse matrix external format
issparse Determine whether input is sparse
nnz Number of nonzero matrix elements
nonzeros Nonzero matrix elements
nzmax Amount of storage allocated for nonzero matrix elements
spfun Apply function to nonzero sparse matrix elements
spones Replace nonzero sparse matrix elements with ones
spparms Set parameters for sparse matrix routines
spy Visualize sparsity pattern of matrix
find Find indices and values of nonzero elements
full 有限公司nvert sparse matrix to full storage
dissect 嵌套说section permutation
amd Approximate minimum degree permutation
colamd 有限公司lumn approximate minimum degree permutation
colperm Sparse column permutation based on nonzero count
dmperm Dulmage-Mendelsohn decomposition
randperm Random permutation of integers
symamd Symmetric approximate minimum degree permutation
symrcm Sparse reverse Cuthill-McKee ordering
pcg Solve system of linear equations — preconditioned conjugate gradients method
lsqr Solve system of linear equations — least-squares method
minres Solve system of linear equations — minimum residual method
symmlq Solve system of linear equations — symmetric LQ method
gmres Solve system of linear equations — generalized minimum residual method
bicg Solve system of linear equations — biconjugate gradients method
bicgstab Solve system of linear equations — stabilized biconjugate gradients method
bicgstabl Solve system of linear equations — stabilized biconjugate gradients (l) method
cgs Solve system of linear equations — conjugate gradients squared method
qmr Solve system of linear equations — quasi-minimal residual method
tfqmr Solve system of linear equations — transpose-free quasi-minimal residual method
equilibrate Matrix scaling for improved conditioning
ichol Incomplete Cholesky factorization
ilu 不完全LU分解
eigs Subset of eigenvalues and eigenvectors
圣言会 Subset of singular values and vectors
normest 2-norm estimate
condest 1-norm condition number estimate
sprank Structural rank
etree 消除树
symbfact Symbolic factorization analysis
spaugment Form least-squares augmented system
dmperm Dulmage-Mendelsohn decomposition
etreeplot Plot elimination tree
treelayout Lay out tree or forest
treeplot Plot picture of tree
gplot Plot nodes and edges in adjacency matrix
unmesh 有限公司nvert edge matrix to coordinate and Laplacian matrices

Topics

有限公司nstructing Sparse Matrices

Storing sparse data as a matrix.

有限公司mputational Advantages of Sparse Matrices

Advantages of sparse matrices over full matrices.

Accessing Sparse Matrices

Indexing and visualizing sparse data.

Sparse Matrix Operations

Reordering, factoring, and computing with sparse matrices.

Iterative Methods for Linear Systems

One of the most important and common applications of numerical linear algebra is the solution of linear systems that can be expressed in the formA*x = b.

Sparse Matrix Reordering

This example shows how reordering the rows and columns of a sparse matrix can influence the speed and storage requirements of a matrix operation.

Featured Examples