Sparse Matrix

Using the regular dense storage scheme to store an matrix of double needs bytes of memory. If a large number of the elements of the matrix are zeros, the dense storage scheme can be wasteful and inefficient. For large sparse matrices or matrices of special formats several more effective alternative storage formats can be chosen.

sparse: an sparse matrix is created with sparse(m, n).
banded: a square matrix with subdiagonals and superdiagonals is created using band(n, l, u).
upper triangular: a square upper triangular matrix is created using upper(n).
lower triangular: a square lower triangular matrix is created using lower(n).
symmetric: a symmetric symmetric matrix is created using lower(n).
All these commands give rise to matrices whose elements are all zeros. To make the matrices useful, normal assignment statements can be used to add non-zero elements.

sparse and banded matrices use efficient storage scheme and can save on memory, while triangular and symmetric matrices use the same storage scheme as dense matrix and thus woulldn't save on memory but may be more efficient when solving some linear algebraic problems.

Note that these special storage schemes are supported only for double precision floating point numbers.

oz 2009-12-22