linalg.q

Quasar library for linear algebra routines.  Please feel free and help me to extend this library.

Summary
linalg.qQuasar library for linear algebra routines.
Functions
invComputes the inverse of a squared matrix
lsolveSolve the linear system of equations A·X = B (where X is a vector)
svdComputation of a singular value decomposition (SVD).
detDeterminant of a real-valued matrix
logdetLogarithm of the determinant of a real-valued matrix
symsqrtComputes the symmetric square root of a positive definite matrix
pinvComputes the pseudo-inverse of a matrix
toeplitzComputes a square toeplitz matrix
wpolyfitweighted polynomial fitting
polyfitpolynomial fitting
polyvalpolynomial curve evaluation

Functions

inv

Computes the inverse of a squared matrix

function y : mat = inv(x : mat)

lsolve

Solve the linear system of equations A·X = B (where X is a vector)

function [X : vec] = lsolve(A : mat, B : vec)

svd

Computation of a singular value decomposition (SVD).

function [p:mat,d:mat,q:mat] = svd(a:mat)

The relationship between the parameters is as follows

a = p*d*transpose(q)

where d is a diagonal matrix!

det

Determinant of a real-valued matrix

function y : scalar = det(A : mat)

See also

logdet

logdet

Logarithm of the determinant of a real-valued matrix

function y : scalar = logdet(A : mat)

The logdet evaluates the logarithm of the determinant of A by computing the sum of the logarithms of the eigenvalues of A, this results in some better numerical accuracy, especially in case the condition number of A is very high.

logdet = (A : mat) -> log(det(A))

See also

det

symsqrt

Computes the symmetric square root of a positive definite matrix

function y : mat = symsqrt(C : mat)

pinv

Computes the pseudo-inverse of a matrix

function y : mat = pinv(x : mat)

toeplitz

Computes a square toeplitz matrix

function y : mat = toeplitz(n : int, x : vec)

Parameters

nthe number of columns/rows of the output matrix
xan odd-sized vector containing the off-diagonal elements

Example

toeplitz(5, [1,2,3]) =
    [[2,3,0,0,0],
     [1,2,3,0,0],
     [0,1,2,3,0],
     [0,0,1,2,3],
     [0,0,0,1,2]]

wpolyfit

weighted polynomial fitting

function [beta : vec] = wpolyfit(x : cube, y : cube, w : cube, order : int)

polyfit

polynomial fitting

polyfit = (x, y, order) -> wpolyfit(x, y, ones(size(x)), order)

polyval

polynomial curve evaluation

function y = polyval(p : vec, x)
Logarithm of the determinant of a real-valued matrix
Determinant of a real-valued matrix
Close