Module compute::linalg[][src]

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

Utilities for 3D rotations.

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.

broadcast_add
broadcast_div
broadcast_mul
broadcast_sub
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.

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.

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.

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.

svadd

Implements a loop-unrolled version of the + function to be applied element-wise between a scalar and a vector (in that order).

svdiv

Implements a loop-unrolled version of the / function to be applied element-wise between a scalar and a vector (in that order).

svmul

Implements a loop-unrolled version of the `

svsub

Implements a loop-unrolled version of the `

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.

vabs

Implements a loop-unrolled version of the abs function to be applied element-wise to a vector.

vacos

Implements a loop-unrolled version of the acos function to be applied element-wise to a vector.

vacosh

Implements a loop-unrolled version of the acosh function to be applied element-wise to a vector.

vadd

Implements a loop-unrolled version of the + function to be applied element-wise to two vectors.

vadd_mut

Implements a loop-unrolled version of the += function to be applied element-wise to two vectors.

vandermonde

Given some length m data x, create an nth order Vandermonde matrix.

vasin

Implements a loop-unrolled version of the asin function to be applied element-wise to a vector.

vasinh

Implements a loop-unrolled version of the asinh function to be applied element-wise to a vector.

vatan

Implements a loop-unrolled version of the atan function to be applied element-wise to a vector.

vatanh

Implements a loop-unrolled version of the atanh function to be applied element-wise to a vector.

vcbrt

Implements a loop-unrolled version of the cbrt function to be applied element-wise to a vector.

vceil

Implements a loop-unrolled version of the ceil function to be applied element-wise to a vector.

vcos

Implements a loop-unrolled version of the cos function to be applied element-wise to a vector.

vcosh

Implements a loop-unrolled version of the cosh function to be applied element-wise to a vector.

vdiv

Implements a loop-unrolled version of the / function to be applied element-wise to two vectors.

vdiv_mut

Implements a loop-unrolled version of the /= function to be applied element-wise to two vectors.

vexp

Implements a loop-unrolled version of the exp function to be applied element-wise to a vector.

vexp2

Implements a loop-unrolled version of the exp2 function to be applied element-wise to a vector.

vexpm1

Implements a loop-unrolled version of the exp_m1 function to be applied element-wise to a vector.

vfloor

Implements a loop-unrolled version of the floor function to be applied element-wise to a vector.

vln

Implements a loop-unrolled version of the ln function to be applied element-wise to a vector.

vln1p

Implements a loop-unrolled version of the ln_1p function to be applied element-wise to a vector.

vlog2

Implements a loop-unrolled version of the log2 function to be applied element-wise to a vector.

vlog10

Implements a loop-unrolled version of the log10 function to be applied element-wise to a vector.

vmul

Implements a loop-unrolled version of the `

vmul_mut

Implements a loop-unrolled version of the *= function to be applied element-wise to two vectors.

vpowf

Implements a loop-unrolled version of the powf function to be applied element-wise to a vector.

vpowi

Implements a loop-unrolled version of the powi function to be applied element-wise to a vector.

vrecip

Implements a loop-unrolled version of the recip function to be applied element-wise to a vector.

vround

Implements a loop-unrolled version of the round function to be applied element-wise to a vector.

vsadd

Implements a loop-unrolled version of the + function to be applied element-wise between a vector and a scalar (in that order).

vsadd_mut

Implements a loop-unrolled version of the += function to be applied element-wise between a vector and a scalar (in that order).

vsdiv

Implements a loop-unrolled version of the / function to be applied element-wise between a vector and a scalar (in that order).

vsdiv_mut

Implements a loop-unrolled version of the /= function to be applied element-wise between a vector and a scalar (in that order).

vsignum

Implements a loop-unrolled version of the signum function to be applied element-wise to a vector.

vsin

Implements a loop-unrolled version of the sin function to be applied element-wise to a vector.

vsinh

Implements a loop-unrolled version of the sinh function to be applied element-wise to a vector.

vsmul

Implements a loop-unrolled version of the `

vsmul_mut

Implements a loop-unrolled version of the *= function to be applied element-wise between a vector and a scalar (in that order).

vsqrt

Implements a loop-unrolled version of the sqrt function to be applied element-wise to a vector.

vssub

Implements a loop-unrolled version of the `

vssub_mut

Implements a loop-unrolled version of the -= function to be applied element-wise between a vector and a scalar (in that order).

vsub

Implements a loop-unrolled version of the `

vsub_mut

Implements a loop-unrolled version of the -= function to be applied element-wise to two vectors.

vtan

Implements a loop-unrolled version of the tan function to be applied element-wise to a vector.

vtanh

Implements a loop-unrolled version of the tanh function to be applied element-wise to a vector.

vtodegrees

Implements a loop-unrolled version of the to_degrees function to be applied element-wise to a vector.

vtoradians

Implements a loop-unrolled version of the to_radians function to be applied element-wise to a vector.

xtx

Given a matrix X with k rows, return X transpose times X, which is a symmetric matrix.