Sparse matrices provide efficient storage of double
or logical
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, see Computational Advantages of Sparse Matrices and Constructing Sparse Matrices.
Storing sparse data as a matrix.
Computational Advantages of Sparse Matrices
Advantages of sparse matrices over full matrices.
Indexing and visualizing sparse data.
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 form A*x = b
.
This example shows how reordering the rows and columns of a sparse matrix can influence the speed and storage requirements of a matrix operation.