mathjslab
Version:
MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.
115 lines (114 loc) • 3.79 kB
TypeScript
import { ComplexType } from './Complex';
import { MultiArray } from './MultiArray';
import { type NodeReturnList } from './AST';
/**
* # LinearAlgebra
*
* LinearAlgebra abstract class. Implements static methods related to linear algebra operations and algorithms.
*
* ## References
*
* * [Linear Algebra at Wolfram MathWorld](https://mathworld.wolfram.com/LinearAlgebra.html)
* * [Fundamental Theorem of Linear Algebra at Wolfram MathWorld](https://mathworld.wolfram.com/FundamentalTheoremofLinearAlgebra.html)
* * [Linear algebra at Wikipedia](https://en.wikipedia.org/wiki/Linear_algebra)
*/
declare abstract class LinearAlgebra {
/**
* LinearAlgebra functions.
*/
static functions: {
[name: string]: Function;
};
/**
* Identity matrix
* @param args
* * `eye(N)` - create identity N x N
* * `eye(N,M)` - create identity N x M
* * `eye([N,M])` - create identity N x M
* @returns Identity matrix
*/
static eye(...args: MultiArray[] | ComplexType[]): MultiArray | ComplexType;
/**
* Sum of diagonal elements.
* @param M Matrix.
* @returns Trace of matrix.
*/
static trace(M: MultiArray): ComplexType;
/**
* Transpose and apply function.
* @param M Matrix.
* @returns Transpose matrix with `func` applied to each element.
*/
private static applyTranspose;
/**
* Transpose.
* @param M Matrix.
* @returns Transpose matrix.
*/
static transpose(M: MultiArray): MultiArray;
/**
* Complex conjugate transpose.
* @param M Matrix.
* @returns Complex conjugate transpose matrix.
*/
static ctranspose(M: MultiArray): MultiArray;
/**
* Matrix product.
* @param left Matrix.
* @param right Matrix.
* @returns left * right.
*/
static mul(left: MultiArray, right: MultiArray): MultiArray;
/**
* Matrix power (multiple multiplication).
* @param left
* @param right
* @returns
*/
static power(left: MultiArray, right: ComplexType): MultiArray;
/**
* Matrix determinant.
* @param M Matrix.
* @returns Matrix determinant.
*/
static det(M: MultiArray): ComplexType;
/**
* Returns the inverse of matrix `M`.
* Source: http://blog.acipo.com/matrix-inversion-in-javascript/
* This method uses Guassian Elimination to calculate the inverse:
* (1) 'Augment' the matrix (M) by the identity (on the right).
* (2) Turn the matrix on the M into the identity by elemetry row ops.
* (3) The matrix on the right is the inverse (was the identity matrix).
* There are 3 elementary row ops: (b and c are combined in the code).
* (a) Swap 2 rows.
* (b) Multiply a row by a scalar.
* (c) Add 2 rows.
* @param M Matrix.
* @returns Inverted matrix.
*/
static inv(M: MultiArray): MultiArray;
/**
* Gaussian elimination algorithm for solving systems of linear equations.
* Adapted from: https://github.com/itsravenous/gaussian-elimination
* ## References
* * https://mathworld.wolfram.com/GaussianElimination.html
* @param M Matrix.
* @param m Vector.
* @returns Solution of linear system.
*/
static gauss(M: MultiArray, m: MultiArray): MultiArray;
/**
* PLU matrix factorization.
* @param M Matrix.
* @returns L, U and P matrices as multiple output.
* ## References
* * https://www.codeproject.com/Articles/1203224/A-Note-on-PA-equals-LU-in-Javascript
* * https://rosettacode.org/wiki/LU_decomposition#JavaScript
*/
static lu(M: MultiArray): NodeReturnList;
}
export { LinearAlgebra };
declare const _default: {
LinearAlgebra: typeof LinearAlgebra;
};
export default _default;