Sparse Matrices

In this lesson, we will learn about different sparse matrices in Python and the conversion between sparse and dense matrices.

Sparse matrices in Python #

The procedure we have used so far to construct the matrix for a is not very efficient. A full matrix is created, which consists mostly of zeros with non-zero values only appearing on diagonals. There are more efficient routines that store what are called sparse matrices. In a sparse matrix, only the value and location of non-zero values in a matrix are stored. Functionality for sparse matrices is available in the scipy submodule sparse.

We will import the scipy.sparse submodule as sp. ...