This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest /docs

Doc

Sparse Matrix Legacy Interface (scipy.sparse)

docs/reference:sparse.spmatrix_api

SciPy 2-D sparse matrix interface for numeric data.

Sparse matrix classes

.. autosummary:: 
    :toctree:generated/
    bsr_matrix - Block Sparse Row matrix
    coo_matrix - A sparse matrix in COOrdinate format
    csc_matrix - Compressed Sparse Column matrix
    csr_matrix - Compressed Sparse Row matrix
    dia_matrix - Sparse matrix with DIAgonal storage
    dok_matrix - Dictionary Of Keys based sparse matrix
    lil_matrix - Row-based list of lists sparse matrix
    spmatrix - Sparse matrix base class

Building sparse matrices

.. autosummary:: 
    :toctree:generated/
    eye - Sparse MxN matrix whose k-th diagonal is all ones
    identity - Identity matrix in sparse matrix format
    diags - Return a sparse matrix from diagonals
    spdiags - Return a sparse matrix from diagonals
    bmat - Build a sparse matrix from sparse sub-blocks
    random - Random values in a given shape matrix
    rand - Random values in a given shape matrix (old interface)

To combine matrices use the same functions as for combining-arrays.

Identifying sparse matrices

issparse(x)

Check if the argument is a sparse object (array or matrix).

isspmatrix(x)

Check if the argument is an old style sparse matrix.

.. autosummary:: 
    :toctree:generated/
    isspmatrix_csc
    isspmatrix_csr
    isspmatrix_bsr
    isspmatrix_lil
    isspmatrix_dok
    isspmatrix_coo
    isspmatrix_dia