Matrix Functions - zward/Amua GitHub Wiki

Matrix Functions

The following matrix functions are available. Matrix functions turn maroon in the formula bar.

Function Name Description Arguments
chol Cholesky Decomposition chol(X): Returns the Cholesky Decomposition (lower triangle) of X X: Symmetric positive definite (SPD) matrix
det Determinant det(X): Returns the determinant of X X: Square matrix
diag Matrix Diagonals diag(X): Returns the diagonal elements of X as a row vector X: Square matrix
iden Identity Matrix iden(n): Returns an identity matrix of size n n: Size of identity matrix (Integer >0)
interpolate Linear Interpolation interpolate(x,X,Y): Returns a linear interpolation of Yat x x: x-value at which to calculate interpolated value of y X: Row vector of x values (in increasing order) Y: Row vector of corresponding y values
inv Inverse Matrix inv(X): Returns the inverse of X using LU decomposition X: Square, non-singular matrix
ncol Number of Columns ncol(X): Returns the number of columns in X X: Matrix
norm Matrix Norm norm(X): Returns the Frobenius norm of X X: Matrix
nrow Number of Rows nrow(X): Returns the number of rows in X X: Matrix
renorm Renormalize renorm(X): Returns a row vector with the elements of X linearly renormalized to sum to 1.0 X: Row vector of real numbers >0
rep Replicate rep(x,n): Returns a row vector of size n filled with x x: Real number to replicate n: Vector size (Integer >0)
seq Sequence seq(a,b): Returns a row vector containing a sequence of numbers from a to b with default step size 1.0seq(a,b,∆): Returns a row vector containing a sequence of numbers from a to b with step size a: Start of sequence (inclusive), real number b: End of sequence (inclusive if step size allows), real number : Step size, real number >0 (optional)
softmax Softmax Function (Normalized Exponential) softmax(X): Returns a row vector with the exponentiated elements of X renormalized to sum to 1.0 X: Row vector of real numbers
stack Stack Row Vectors stack(X_1, X_2, ..., X_n): Returns a matrix of stacked row vectors X_1 to X_n: Row vectors
tp Matrix Transpose tp(X): Returns the transpose of X X: Matrix
tr Matrix Trace tr(X): Returns the trace (i.e. sum of diagonal elements) of X X: Square matrix