Linear Algebra

The following table shows linear algebra routines provided by NLCPy.

Matrix and Vector Products

nlcpy.dot

Computes a dot product of two arrays.

nlcpy.inner

Computes an inner product of two arrays.

nlcpy.outer

Computes an outer product of two vectors.

nlcpy.matmul

Matrix product of two arrays.

Decompositions

nlcpy.linalg.svd

Singular Value Decomposition.

nlcpy.linalg.cholesky

Cholesky decomposition.

nlcpy.linalg.qr

Computes the qr factorization of a matrix.

Matrix Eigenvalues

nlcpy.linalg.eig

Computes the eigenvalues and right eigenvectors of a square array.

nlcpy.linalg.eigh

Computes the eigenvalues and eigenvectors of a complex Hermitian or a real symmetric matrix.

nlcpy.linalg.eigvals

Computes the eigenvalues of a general matrix.

nlcpy.linalg.eigvalsh

Computes the eigenvalues of a complex Hermitian or real symmetric matrix.

Norms and Other Numbers

nlcpy.linalg.norm

Returns matrix or vector norm.

Solving Equations and Inverting Matrices

nlcpy.linalg.solve

Solves a linear matrix equation, or system of linear scalar equations.

nlcpy.linalg.lstsq

Returns the least-squares solution to a linear matrix equation.

nlcpy.linalg.inv

Computes the (multiplicative) inverse of a matrix.

Exceptions

nlcpy.linalg.LinAlgError

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

Linear Algebra on Several Matrices at Once

Several of the linear algebra routines listed above are able to compute results for several matrices at once, if they are stacked into the same array. This is indicated in the documentation via input parameter specifications such as a : (..., M, M) array_like. This means that if for instance given an input array a.shape == (N, M, M), it is interpreted as a “stack” of N matrices, each of size M-by-M. Similar specification applies to return values, for instance the inverse has ainv : (..., M, M) and will in this case return an array of shape inv(a).shape == (N,M,M). This generalizes to linear algebra operations on higher-dimensional arrays: the last 1 or 2 dimensions of a multidimensional array are interpreted as vectors or matrices, as appropriate for each operation.