Sparse Matrices - MATLAB & Simulink (original) (raw)

Main Content

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

Sparse matrices provide efficient storage of double orlogical data that has a large percentage of zeros. While_full_ (or dense) matrices store every single element in memory regardless of value, sparse matrices 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, seeComputational Advantages of Sparse Matrices and Constructing Sparse Matrices.

Functions

expand all

Creation

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

Manipulation

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 Convert sparse matrix to full storage

Reordering Algorithms

dissect Nested dissection permutation
amd Approximate minimum degree permutation
colamd Column 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

Iterative Methods and Preconditioners

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 Incomplete LU factorization

Eigenvalues and Singular Values

eigs Subset of eigenvalues and eigenvectors
svds Subset of singular values and vectors
normest 2-norm estimate
condest 1-norm condition number estimate

Structural Analysis

sprank Structural rank
etree Elimination tree
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 Convert edge matrix to coordinate and Laplacian matrices

Topics