Sparse matrix

Updated: 05/27/2017 by Computer Hope

sparse matrixA sparse matrix is a one in which the majority of the values are zero. The proportion of zero elements to non-zero elements is called the sparsity of the matrix. The opposite of a sparse matrix, in which the majority of its values are non-zero, is called a dense matrix.

Sparse matrix example

Here is an example of a 4 x 4 matrix containing 12 zero values and 4 non-zero values, giving it a sparsity of 3:

[[5, 0, 0, 0],
[0, 11, 0, 0],
[0, 0, 25, 0],
[0, 0, 0, 7]]

Additional information

Sparse matrices are used by scientists and engineers when solving partial differential equations. For example, a measurement of a matrix's sparsity can be useful when developing theories about the connectivity of computer networks. When using large sparse matrices in a computer program, it is important to optimize the data structures and algorithms to take advantage of the fact that most of the values will be zero.

Matrix, Programming terms, Zero