Sparse Matrices

SparseMatrix Class Reference

sympy.matrices.sparse.SparseMatrix[source]

alias of MutableSparseMatrix

class sympy.matrices.sparse.MutableSparseMatrix(*args, **kwargs)[source]

ImmutableSparseMatrix Class Reference

class sympy.matrices.immutable.ImmutableSparseMatrix(*args, **kwargs)[source]

Create an immutable version of a sparse matrix.

Examples

>>> from sympy import eye, ImmutableSparseMatrix
>>> ImmutableSparseMatrix(1, 1, {})
Matrix([[0]])
>>> ImmutableSparseMatrix(eye(3))
Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])
>>> _[0, 0] = 42
Traceback (most recent call last):
...
TypeError: Cannot set values of ImmutableSparseMatrix
>>> _.shape
(3, 3)