scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
spsolve(A, b, permc_spec=None, use_umfpack=True)

Notes

For solving the matrix expression AX = B, this solver assumes the resulting matrix X is sparse, as is often the case for very sparse inputs. If the resulting X is dense, the construction of this sparse result will be relatively expensive. In that case, consider converting A to a dense matrix and using scipy.linalg.solve or its variants.

Parameters

A : ndarray or sparse matrix

The square matrix A will be converted into CSC or CSR form

b : ndarray or sparse matrix

The matrix or vector representing the right hand side of the equation. If a vector, b.shape must be (n,) or (n, 1).

permc_spec : str, optional

How to permute the columns of the matrix for sparsity preservation. (default: 'COLAMD')

  • NATURAL : natural ordering.

  • MMD_ATA : minimum degree ordering on the structure of A^T A.

  • MMD_AT_PLUS_A : minimum degree ordering on the structure of A^T+A.

  • COLAMD : approximate minimum degree column ordering

use_umfpack : bool, optional

if True (default) then use umfpack for the solution. This is only referenced if b is a vector and scikit-umfpack is installed.

Returns

x : ndarray or sparse matrix

the solution of the sparse linear equation. If b is a vector, then x is a vector of size A.shape[1] If b is a matrix, then x is a matrix of size (A.shape[1], b.shape[1])

Solve the sparse linear system Ax=b, where b may be a vector or a matrix.

Examples

>>> from scipy.sparse import csc_matrix
... from scipy.sparse.linalg import spsolve
... A = csc_matrix([[3, 2, 0], [1, -1, 0], [0, 5, 1]], dtype=float)
... B = csc_matrix([[2, 0], [-1, 0], [2, 0]], dtype=float)
... x = spsolve(A, B)
... np.allclose(A.dot(x).toarray(), B.toarray()) True
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.sparse.linalg._dsolve.linsolve.spsolve

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/sparse/linalg/_dsolve/linsolve.py#91
type: <class 'function'>
Commit: