Module linalg

Module linalg 

Source
Expand description

Provides general linear algebra methods and matrix decompositions with a focus on low-dimensional data.

Modules§

cholesky
Implements Cholesky decomposition.
lu
Implements LU decomposition and system solving with the decomposition.
substitution
Forward and backward substitution.

Structs§

Matrix
Matrix struct.
Vector
A row-major ordering vector struct with various useful methods.

Enums§

Axis
Broadcast

Traits§

Dot
A trait for performing matrix products. Follows the behaviour of numpy’s matmul.
Solve

Functions§

arange
Generates evenly spaced values within a given interval. Values generated in the half-open interval [start, stop). That is, the stop point is not included.
backward_substitution
Solve a matrix equation of the form Ux=b, where U is an upper triangular matrix. See the Wikipedia page.
cholesky
Computes the Cholesky decomposition of the matrix a using the Cholesky-Banachiewicz algorithm.
cholesky_solve
Solves the system Lx=b, where L is a lower triangular matrix (e.g., a Cholesky decomposed matrix), and b is a one dimensional vector.
col_to_row_major
Convert a 1D matrix from column-major ordering into row-major ordering.
design
Create a design matrix from a given matrix.
diag
diag_matrix
Create a diagonal matrix with the given elements along the elements.
dot
Calculates the dot product of two equal-length vectors. When the feature “blas” is enabled, uses ddot from BLAS. Otherwise, uses a length-8 unrolled loop.
forward_substitution
Solve a matrix equation of the form Lx=b, where L is a lower triangular matrix. See the Wikipedia page.
inf_norm
Calculates the infinity norm of a matrix. That is, it sums the absolute values along each row, and then returns the largest of these values.
invert_matrix
Given an n by n matrix, invert it. The resulting matrix is returned as a flattened array.
ipiv_parity
Calculates the parity of a swap permutation array ipiv (e.g. that you get as an output from Lapack).
is_design
Checks whether a 1D array is a valid design matrix, given its number of rows.
is_matrix
Checks whether a 1D array is a valid matrix representation given the number of rows.
is_positive_definite
Checks whether a 1d array is a valid positive definite matrix.
is_square
Checks whether a 1D array is a valid square matrix.
is_symmetric
Checks whether a 1D array is a valid symmetric matrix.
linspace
Generates evenly spaced values within a given interval, with a set number of points. Both the start and stop points are included.
logmeanexp
Calculates the logarithm of the mean of the exponentials in a stable manner. Applies the LogMeanExp operator (like the LogSumExp, but mean instead of sum) to the array.
logsumexp
Calculates the logarithm of the sum of the exponentials in a stable manner. Applies the LogSumExp operator to the array.
lu
Computes the pivoted LU decomposition of a square matrix. For some matrix A, this decomposition is A = PLU. The resulting matrix has U in its upper triangle and L in its lower triangle. The unit diagonal elements of L are not stored. The pivot indices representing the permutation matrix P is also returned.
lu_solve
Solve the linear system Ax = b given a LU decomposed matrix A. The first argument should be a tuple, where the first element is the LU decomposed matrix and the second element is the pivots P.
matmatadd
matmatdiv
matmatmul
matmatsub
matmul
Multiply two matrices together, optionally transposing one or both of them.
matmul_blocked
Performs blocked matrix multiplication with block size bsize. See the API for the matmul.
norm
Calculates the norm of a vector.
prod
Calculates the product of a vector.
rotation_matrix_ccw
Returns a 3D counter-clockwise rotation matrix along the axis axis (either X, Y, or Z) with a given angle in radians.
rotation_matrix_cw
Returns a 3D clockwise rotation matrix along the axis axis (either X, Y, or Z) with a given angle in radians.
row_to_col_major
Convert a 1D matrix from row-major ordering into column-major ordering.
solve
Solve the linear system Ax = b.
solve_sys
Solves a system of linear scalar equations. a must represent a square matrix.
sum
Calculates the sum of a vector.
toeplitz
Given a vector of length n, creates n stacked duplicates, resulting in a square Toeplitz matrix. This function also assumes evenness. That is, x_i = x_{-i}.
transpose
Transpose a matrix.
vandermonde
Given some length m data x, create an nth order Vandermonde matrix.
xtx
Given a matrix X with k rows, return X transpose times X, which is a symmetric matrix.