scipy.sparse.linalg

Sparse linear algebra (scipy.sparse.linalg)

Abstract linear operators

LinearOperator(shape, matvec[, rmatvec, ...]) Common interface for performing matrix vector products
aslinearoperator(A) Return A as a LinearOperator.

Solving linear problems

Direct methods for linear equation systems:

spsolve(A, b[, permc_spec, use_umfpack]) Solve the sparse linear system Ax=b
factorized(A) Return a fuction for solving a sparse linear system, with A pre-factorized.

Iterative methods for linear equation systems:

bicg(A, b[, x0, tol, maxiter, xtype, M, ...]) Use BIConjugate Gradient iteration to solve A x = b
bicgstab(A, b[, x0, tol, maxiter, xtype, M, ...]) Use BIConjugate Gradient STABilized iteration to solve A x = b
cg(A, b[, x0, tol, maxiter, xtype, M, callback]) Use Conjugate Gradient iteration to solve A x = b
cgs(A, b[, x0, tol, maxiter, xtype, M, callback]) Use Conjugate Gradient Squared iteration to solve A x = b
gmres(A, b[, x0, tol, restart, maxiter, ...]) Use Generalized Minimal RESidual iteration to solve A x = b.
lgmres(A, b[, x0, tol, maxiter, M, ...]) Solve a matrix equation using the LGMRES algorithm.
minres(A, b[, x0, shift, tol, maxiter, ...]) Use MINimum RESidual iteration to solve Ax=b
qmr(A, b[, x0, tol, maxiter, xtype, M1, M2, ...]) Use Quasi-Minimal Residual iteration to solve A x = b

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
lobpcg(A, X[, B, M, Y, tol, maxiter, ...]) Solve symmetric partial eigenproblems with optional preconditioning

Singular values problems:

svds(A[, k, ncv, tol]) Compute the largest k singular values/vectors for a sparse matrix.

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 A.

Exceptions

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

Functions

aslinearoperator(A) Return A as a LinearOperator.
bicg(A, b[, x0, tol, maxiter, xtype, M, ...]) Use BIConjugate Gradient iteration to solve A x = b
bicgstab(A, b[, x0, tol, maxiter, xtype, M, ...]) Use BIConjugate Gradient STABilized iteration to solve A x = b
cg(A, b[, x0, tol, maxiter, xtype, M, callback]) Use Conjugate Gradient iteration to solve A x = b
cgs(A, b[, x0, tol, maxiter, xtype, M, callback]) Use Conjugate Gradient Squared iteration to solve A x = b
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
factorized(A) Return a fuction for solving a sparse linear system, with A pre-factorized.
gmres(A, b[, x0, tol, restart, maxiter, ...]) Use Generalized Minimal RESidual iteration to solve A x = b.
lgmres(A, b[, x0, tol, maxiter, M, ...]) Solve a matrix equation using the LGMRES algorithm.
lobpcg(A, X[, B, M, Y, tol, maxiter, ...]) Solve symmetric partial eigenproblems with optional preconditioning
lsmr(A, b[, damp, atol, btol, conlim, ...]) Iterative solver for least-squares problems.
lsqr(A, b[, damp, atol, btol, conlim, ...]) Find the least-squares solution to a large, sparse, linear system of equations.
minres(A, b[, x0, shift, tol, maxiter, ...]) Use MINimum RESidual iteration to solve Ax=b
qmr(A, b[, x0, tol, maxiter, xtype, M1, M2, ...]) Use Quasi-Minimal Residual iteration to solve A x = b
spilu(A[, drop_tol, fill_factor, drop_rule, ...]) Compute an incomplete LU decomposition for a sparse, square matrix A.
splu(A[, permc_spec, diag_pivot_thresh, ...]) Compute the LU decomposition of a sparse, square matrix.
spsolve(A, b[, permc_spec, use_umfpack]) Solve the sparse linear system Ax=b
svds(A[, k, ncv, tol]) Compute the largest k singular values/vectors for a sparse matrix.
use_solver(**kwargs) Valid keyword arguments with defaults (other ignored):

Classes

LinearOperator(shape, matvec[, rmatvec, ...]) Common interface for performing matrix vector products
Tester Nose test runner.

Exceptions

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