[null, {"document_url": "https://www.computerhope.com/jargon/s/sparse-matrix.htm", "unformatted_src": "/jargon/s/sparse-matrix.jpg", "src": "https://www.computerhope.com/jargon/s/sparse-matrix.jpg", "formatted_filename": "sparse matrix", "alt_text": "sparse matrix", "rendered_width": 300, "rendered_height": 315}, null]

Sparse matrix A 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]]


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