Skip to main content
`Ctrl`+`K`

# Sparse linear algebra (`scipy.sparse.linalg`)

## Abstract linear operators

`LinearOperator`(*args, **kwargs) | Common interface for performing matrix vector products
`aslinearoperator`(A) | Return A as a LinearOperator.

## Matrix Operations

`inv`(A) | Compute the inverse of a sparse arrays
`expm`(A) | Compute the matrix exponential using Pade approximation.
`expm_multiply`(A, B[, start, stop, num, ...]) | Compute the action of the matrix exponential of A on B.
`matrix_power`(A, power) | Raise a square matrix to the integer power, power.

## Matrix norms

`norm`(x[, ord, axis]) | Norm of a sparse matrix
`onenormest`(A[, t, itmax, compute_v, compute_w]) | Compute a lower bound of the 1-norm of a sparse array.

## Solving linear problems

Direct methods for linear equation systems:

`spsolve`(A, b[, permc_spec, use_umfpack]) | Solve the sparse linear system Ax=b, where b may be a vector or a matrix.
`spsolve_triangular`(A, b[, lower, ...]) | Solve the equation `A x = b` for x, assuming A is a triangular matrix.
`is_sptriangular`(A) | Returns 2-tuple indicating lower/upper triangular structure for sparse `A`
`spbandwidth`(A) | Return the lower and upper bandwidth of a 2D numeric array.
`factorized`(A) | Return a function for solving a sparse linear system, with A pre-factorized.
`MatrixRankWarning` | Warning for exactly singular matrices.
`use_solver`(**kwargs) | Select default sparse direct solver to be used.

Iterative methods for linear equation systems:

`bicg`(A, b[, x0, rtol, atol, maxiter, M, ...]) | Solve `Ax = b` with the BIConjugate Gradient method.
`bicgstab`(A, b[, x0, rtol, atol, maxiter, M, ...]) | Solve `Ax = b` with the BIConjugate Gradient STABilized method.
`cg`(A, b[, x0, rtol, atol, maxiter, M, callback]) | Solve `Ax = b` with the Conjugate Gradient method, for a symmetric, positive-definite A.
`cgs`(A, b[, x0, rtol, atol, maxiter, M, callback]) | Solve `Ax = b` with the Conjugate Gradient Squared method.
`gmres`(A, b[, x0, rtol, atol, restart, ...]) | Solve `Ax = b` with the Generalized Minimal RESidual method.
`lgmres`(A, b[, x0, rtol, atol, maxiter, M, ...]) | Solve `Ax = b` with the LGMRES algorithm.
`minres`(A, b[, x0, rtol, shift, maxiter, M, ...]) | Solve `Ax = b` with the MINimum RESidual method, for a symmetric A.
`qmr`(A, b[, x0, rtol, atol, maxiter, M1, M2, ...]) | Solve `Ax = b` with the Quasi-Minimal Residual method.
`gcrotmk`(A, b[, x0, rtol, atol, maxiter, M, ...]) | Solve `Ax = b` with the flexible GCROT(m,k) algorithm.
`tfqmr`(A, b[, x0, rtol, atol, maxiter, M, ...]) | Solve `Ax = b` with the Transpose-Free Quasi-Minimal Residual method.

Iterative methods for least-squares problems:

`lsqr`(A, b[, damp, atol, btol, conlim, ...]) | Find the least-squares solution to a large, sparse, linear system of equations.
`lsmr`(A, b[, damp, atol, btol, conlim, ...]) | Iterative solver for least-squares problems.

## Matrix factorizations

Eigenvalue problems:

`eigs`(A[, k, M, sigma, which, v0, ncv, ...]) | Find k eigenvalues and eigenvectors of the square matrix A.
`eigsh`(A[, k, M, sigma, which, v0, ncv, ...]) | Find k eigenvalues and eigenvectors of the real symmetric square matrix or complex Hermitian matrix A.
`lobpcg`(A, X[, B, M, Y, tol, maxiter, ...]) | Locally Optimal Block Preconditioned Conjugate Gradient Method (LOBPCG).

Singular values problems:

`svds`(A[, k, ncv, tol, which, v0, maxiter, ...]) | Partial singular value decomposition of a sparse matrix.

The `svds` function supports the following solvers:

Complete or incomplete LU factorizations

`splu`(A[, permc_spec, diag_pivot_thresh, ...]) | Compute the LU decomposition of a sparse, square matrix.
`spilu`(A[, drop_tol, fill_factor, drop_rule, ...]) | Compute an incomplete LU decomposition for a sparse, square matrix.
`SuperLU`() | LU factorization of a sparse matrix.

## Sparse arrays with structure

`LaplacianNd`(*args, **kwargs) | The grid Laplacian in `N` dimensions and its eigenvalues/eigenvectors.

## Exceptions

`ArpackNoConvergence`(msg, eigenvalues, ...) | ARPACK iteration did not converge
`ArpackError`(info[, infodict]) | ARPACK error