Module compute::linalg[][src]

Functions

design

Create a design matrix from a given matrix. Note that this follows column-major ordering, so the resulting vector simply has some 1s appended to the front.

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.

invert_matrix

Given an n by n matrix, invert it. The resulting matrix is returned as a flattened array.

is_square

Check if matrix is square.

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.

matmul

Multiply two matrices together, optionally transposing one or both of them. Note that the matrices must be in column-major ordering.

norm

Calculates the norm of a vector.

solve

Solve the linear system Ax = b with LU decomposition.

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. Note that this returns a vector with column-major ordering.

xtx

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