5. numpy.linalg

5.1. Core Linear Algebra Tools

Linear algebra basics:

  • norm Vector or matrix norm

  • inv Inverse of a square matrix

  • solve Solve a linear system of equations

  • det Determinant of a square matrix

  • lstsq Solve linear least-squares problem

  • pinv Pseudo-inverse (Moore-Penrose) calculated using a singular

    value decomposition

  • matrix_power Integer power of a square matrix

Eigenvalues and decompositions:

  • eig Eigenvalues and vectors of a square matrix
  • eigh Eigenvalues and eigenvectors of a Hermitian matrix
  • eigvals Eigenvalues of a square matrix
  • eigvalsh Eigenvalues of a Hermitian matrix
  • qr QR decomposition of a matrix
  • svd Singular value decomposition of a matrix
  • cholesky Cholesky decomposition of a matrix

Tensor operations:

  • tensorsolve Solve a linear tensor equation
  • tensorinv Calculate an inverse of a tensor

Exceptions:

  • LinAlgError Indicates a failed linear algebra operation

5.2. Functions

cholesky(a) Cholesky decomposition.
cond(x[, p]) Compute the condition number of a matrix.
det(a) Compute the determinant of an array.
eig(a) Compute the eigenvalues and right eigenvectors of a square array.
eigh(a[, UPLO]) Return the eigenvalues and eigenvectors of a Hermitian or symmetric matrix.
eigvals(a) Compute the eigenvalues of a general matrix.
eigvalsh(a[, UPLO]) Compute the eigenvalues of a Hermitian or real symmetric matrix.
inv(a) Compute the (multiplicative) inverse of a matrix.
lstsq(a, b[, rcond]) Return the least-squares solution to a linear matrix equation.
matrix_power(M, n) Raise a square matrix to the (integer) power n.
matrix_rank(M[, tol]) Return matrix rank of array using SVD method
multi_dot(arrays) Compute the dot product of two or more arrays in a single function call, while automatically selecting the fastest evaluation order.
norm(x[, ord, axis, keepdims]) Matrix or vector norm.
pinv(a[, rcond]) Compute the (Moore-Penrose) pseudo-inverse of a matrix.
qr(a[, mode]) Compute the qr factorization of a matrix.
slogdet(a) Compute the sign and (natural) logarithm of the determinant of an array.
solve(a, b) Solve a linear matrix equation, or system of linear scalar equations.
svd(a[, full_matrices, compute_uv]) Singular Value Decomposition.
tensorinv(a[, ind]) Compute the ‘inverse’ of an N-dimensional array.
tensorsolve(a, b[, axes]) Solve the tensor equation a x = b for x.

5.3. Classes

Tester alias of NoseTester

5.4. Exceptions

LinAlgError Generic Python-exception-derived object raised by linalg functions.