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 matrix

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

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.

factorized(A)

Return a function for solving a sparse linear system, with A pre-factorized.

MatrixRankWarning

use_solver(**kwargs)

Select default sparse direct solver to be used.

Iterative methods for linear equation systems:

bicg(A, b[, x0, tol, maxiter, M, callback, atol])

Use BIConjugate Gradient iteration to solve Ax = b.

bicgstab(A, b[, x0, tol, maxiter, M, ...])

Use BIConjugate Gradient STABilized iteration to solve Ax = b.

cg(A, b[, x0, tol, maxiter, M, callback, atol])

Use Conjugate Gradient iteration to solve Ax = b.

cgs(A, b[, x0, tol, maxiter, M, callback, atol])

Use Conjugate Gradient Squared iteration to solve Ax = b.

gmres(A, b[, x0, tol, restart, maxiter, M, ...])

Use Generalized Minimal RESidual iteration to solve Ax = b.

lgmres(A, b[, x0, tol, maxiter, M, ...])

Solve a matrix equation using the LGMRES algorithm.

minres(A, b[, x0, shift, tol, maxiter, M, ...])

Use MINimum RESidual iteration to solve Ax=b

qmr(A, b[, x0, tol, maxiter, M1, M2, ...])

Use Quasi-Minimal Residual iteration to solve Ax = b.

gcrotmk(A, b[, x0, tol, maxiter, M, ...])

Solve a matrix equation using flexible GCROT(m,k) algorithm.

tfqmr(A, b[, x0, tol, maxiter, M, callback, ...])

Use Transpose-Free Quasi-Minimal Residual iteration to solve Ax = 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 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.

Exceptions#

ArpackNoConvergence(msg, eigenvalues, ...)

ARPACK iteration did not converge

ArpackError(info[, infodict])

ARPACK error