Skip to content

linalg

the linear algebra submodule for numluau.


methods

matmul -> ()

linalg.matmul(
    A : ndArray,
    B : ndArray
): ndArray

returns the result of a matrix multiplication between A and B if A is ndim = 2 and B is ndim = 1 then a matrix-vector multiplication is done instead.

lu -> ()

linalg.lu(
    matrix : ndArray
): (ndArray, ndArray, {number}, number)

preforms a LU decomposition on the matrix, producing values: - lower triangular ndArray (L). - upper triangular ndArray (U). - permutation table. - swap count. given matrix = LU

det -> ()

linalg.det(
    matrix : ndArray
): ndArray

returns the determinant of the matrix.

dot -> ()

linalg.dot(
    A : ndArray,
    B : ndArray
): ndArray

returns the dot product between A and B.

cross -> ()

linalg.cross(
    A : ndArray,
    B : ndArray
): ndArray

returns the cross product between A and B

qr -> ()

linalg.qr(
    matrix : ndArray
): (ndArray,ndArray)

Performs a QR decomposition on the matrix, returning a orthogonal matrix Q and a upper triangular matrix R.

eigenval -> ()

linalg.eigenval(
    matrix : ndArray
): ndArray

Returns the eigen values of the matrix.

eig -> ()

linalg.eig(
    matrix : ndArray
): (ndArray,ndArray)

returns the eigen values and eigen vectors of the matrix the eigen vectors being given as a single 2d ndArray in column major order.

solve -> ()

linalg.solve(
    A : ndArray,
    B : ndArray
): ndArray

returns the solution to the equation \(Ax = B\)

norm -> ()

linalg.norm(
    matrix : ndArray,
    axis : ndArray,
    order : ndArray
): ndArray

Normalises a matrix across a axis order = 1 does a manhattan normalisation order = 2 does a euclidean normalisation order defaults to 2 axis defaults to 0

svd -> ()

linalg.svd(
    matrix : ndArray
): (ndArray,ndArray,ndArray)

Performs a SVD decomposition, returning U, Vt and the matrix's singular values.

lstsq -> ()

linalg.lstsq(
    x : ndArray,
    y : ndArray,
    degree : number
): ndArray

Preforms a least squares fit on x and y, producing the coefficents of degree degree in descending order degree defaults to 0.