Some Useful Array and Linear Algebra Functions
- (%* a b) [Function]
Returns the matrix product of matrices a and b. If a is a vector it is treated
as a row vector; if b is a vector it is treated as a column vector.
- (aref array &rest subscripts) [Function]
Returns the element of ARRAY specified by SUBSCRIPTS.
- (array-dimension array) [Function]
Returns a list whose elements are the dimensions of ARRAY
- (array-dimensions array) [Function]
Returns a list whose elements are the dimensions of ARRAY
- (array-in-bounds-p array &rest subscripts) [Function]
Returns T if SUBSCRIPTS are valid subscripts for ARRAY; NIL otherwise.
- (array-rank array) [Function]
Returns the number of dimensions of ARRAY.
- (array-row-major-index array &rest subscripts) [Function]
Returns the index into the data vector of ARRAY for the element of ARRAY
specified by SUBSCRIPTS.
- (array-total-size array) [Function]
Returns the total number of elements of ARRAY.
- (arrayp x) [Function]
Returns T if X is an array; NIL otherwise.
- (bind-columns &rest args) [Function]
The ARGS can be matrices, vectors, or lists. Arguments are bound into a matrix
along their columns.
- (bind-rows &rest args) [Function]
The ARGS can be matrices, vectors, or lists. Arguments are bound into a matrix
along their rows.
- (chol-decomp a) [Function]
Modified Cholesky decomposition. A should be a square, symmetric matrix.
Computes lower triangular matrix L such that
LLT = A + D where D is a
diagonal matrix. If A is strictly positive definite D will be zero. Otherwise
D is as small as possible to make A + D numerically strictly positive
definite. Returns a list (L (max D)).
- (column-list m) [Function]
Returns a list of the columns of M as vectors
- (copy-array array) [Function]
Returns a copy of ARRAY with elements eq to the elements of ARRAY.
- (copy-list list) [Function]
Returns a new copy of LIST.
- (copy-vector vector) [Function]
Returns a copy of VECTOR with elements eq to the elements of VECTOR
- (count-elements number &rest more-numbers) [Function]
Returns the number of its arguments. Vector reducing
- (cross-product x) [Function]
If X is a matrix returns (%* (TRANSPOSE X) X). If X is a vector returns
(INNER-PRODUCT X X).
- (determinant m) [Function]
Returns the determinant of the square matrix M.
- (diagonal x) [Function]
If X is a matrix, returns the diagonal of X. If X is a sequence, returns a
diagonal matrix of rank (length X) with diagonal elements eq to the elements
of X.
- (identity-matrix n) [Function]
Returns the identity matrix of rank N.
- (inner-product x y) [Function]
Returns inner product of sequences X and Y.
- (inverse m) [Function]
Returns the inverse of the the square matrix M; signals an error if M is ill
conditioned or singular
- (lu-decomp a) [Function]
A is a square matrix of numbers (real or complex). Computes the LU
decomposition of A and returns a list of the form (LU IV D FLAG), where
LU is a matrix with the L part in the lower triangle, the U part in the
upper triangle (the diagonal entries of L are taken to be 1), IV is a vector
describing the row permutation used, D is 1 if the number of permutations
is odd, -1 if even, and FLAG is T if A is numerically singular, NIL otherwise.
Used bu LU-SOLVE.
- (lu-solve lu b) [Function]
LU is the result of (LU-DECOMP A) for a square matrix A, B is a sequence.
Returns the solution to the equation Ax = B. Signals an error if A is singular.
- (make-list size &key (initial-element nil)) [Function]
Creates and returns a list containing SIZE elements, each of which is
initialized to INITIAL-ELEMENT.
- (make-sweep-matrix x y &optional weights) [Function]
X is a matrix, Y and WEIGHTS are sequences. Returns the sweep matrix for the
(possibly weighted) regression of Y on X.
- (map-elements function data &rest more-data) [Function]
FUNCTION must take as many arguments as there are DATA arguments supplied.
DATA arguments must either all be sequences or all be arrays of the same
shape. The result is of the same type and shape as the first DATA argument,
with elements the result of applying FUNCTION elementwise to the DATA
arguments
- (matmult a b) [Function]
Returns the matrix product of matrices a and b. If a is a vector it is treated
as a row vector; if b is a vector it is treated as a column vector.
- (matrix dim data) [Function]
returns a matrix of dimensions DIM initialized using sequence DATA
in row major order.
- (matrixp m) [Function]
Returns T if M is a matrix, NIL otherwise.
- (outer-product x y &optional (fcn (function *))) [Function]
Returns the generalized outer product of x and y, using fcn. Tat is, the result
is a matrix of dimension ((length x) (length y)) and the (i j) element of the
result is computed as (apply fcn (aref x i) (aref y j)).
- (permute-array a p) [Function]
Returns a copy of the array A permuted according to the permutation P.
- (qr-decomp a) [Function]
A is a matrix of real numbers with at least as many rows as columns. Computes
the QR factorization of A and returns the result in a list of the form (Q R).
- (rcondest a) [Function]
Returns an estimate of the reciprocal of the L1 condition number of an upper
triangular matrix a.
- (row-list m) [Function]
Returns a list of the rows of M as vectors
- (solve a b) [Function]
Solves A x = B using LU decomposition and backsolving. B can be a sequence
or a matrix.
- (split-list list cols) [Function]
Returns a list of COLS lists of equal length of the elements of LIST.
- (sum &rest number-data) [Function]
Returns the sum of all the elements of its arguments. Returns 0 if there
are no arguments. Vector reducing.
- (sv-decomp a) [Function]
A is a matrix of real numbers with at least as many rows as columns.
Computes the singular value decomposition of A and returns a list of the form
(U W V FLAG) where U and V are matrices whose columns are the left and right
singular vectors of A and W is the sequence of singular values of A. FLAG is T
if the algorithm converged, NIL otherwise.
- (sweep-operator a indices &optional tolerances) [Function]
A is a matrix, INDICES a sequence of the column indices to be swept. Returns
a list of the swept result and the list of the columns actually swept. (See
MULTREG documentation.) If supplied, TOLERANCES should be a list of real
numbers the same length as INDICES. An index will only be swept if its pivot
element is larger than the corresponding element of TOLERANCES.
- (transpose m) [Function]
Returns the transpose of the matrix M.
- (vectorp m) [Function]
Returns T if M is a vector, NIL otherwise.