Skip to content

Instantly share code, notes, and snippets.

# sebastianhaas/mathjs.d.ts

Created February 26, 2016 10:18
Show Gist options
• Save sebastianhaas/09598bb21921ac9acdef to your computer and use it in GitHub Desktop.
Fixed math.js typings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 declare namespace MathJS { interface Fraction {} interface MathArray {} interface Matrix {} function config(options: any): void; /** * Solves the linear equation system by forwards substitution. Matrix must be a lower triangular matrix. * @param L A N x N matrix or array (L) * @param b A column vector with the b values * @returns A column vector with the linear system solution (x) */ function lsolve(L: Matrix|MathArray, b: Matrix|MathArray): Matrix|MathArray; /** * Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in two matrices (L, U) * and a row permutation vector p where A[p,:] = L * U * @param A A two dimensional matrix or array for which to get the LUP decomposition. * @returns The lower triangular matrix, the upper triangular matrix and the permutation matrix. */ function lup(A?: Matrix|MathArray): MathArray; /** * Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector. * @param A Invertible Matrix or the Matrix LU decomposition * @param b Column Vector * @returns Column vector with the solution to the linear system A * x = b */ function lusolve(A: Matrix|MathArray|Number, b: Matrix|MathArray): Matrix|MathArray; /** * Calculate the Sparse Matrix LU decomposition with full pivoting. Sparse Matrix A is decomposed in * two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U * @param A A two dimensional sparse matrix for which to get the LU decomposition. * @param order The Symbolic Ordering and Analysis order: 0 - Natural ordering, no permutation vector q is * returned 1 - Matrix must be square, symbolic ordering and analisis is performed on M = A + A' 2 - Symbolic * ordering and analisis is performed on M = A' * A. Dense columns from A' are dropped, A recreated from A'. * This is appropriatefor LU factorization of unsymmetric matrices. 3 - Symbolic ordering and analisis is performed * on M = A' * A. This is best used for LU factorization is matrix M has no dense rows. A dense row is a row with * more than 10*sqr(columns) entries. * @param threshold Partial pivoting threshold (1 for partial pivoting) * @returns The lower triangular matrix, the upper triangular matrix and the permutation vectors. */ function slu(A: Matrix, order: Number, threshold: Number): any; /** * Solves the linear equation system by backward substitution. Matrix must be an upper triangular matrix. U * x = b * @param U A N x N matrix or array (U) * @param b A column vector with the b values * @returns A column vector with the linear system solution (x) */ function usolve(U: Matrix|MathArray, b:Matrix|MathArray): Matrix|MathArray; /** * Calculate the absolute value of a number. For matrices, the function is evaluated element wise. * @param x A number or matrix for which to get the absolute value * @returns Absolute value of x */ function abs(x: number): number; function abs(x: Fraction): Fraction; function abs(x: MathArray): MathArray; function abs(x: Matrix): Matrix; } declare module "mathjs" { export = MathJS; }
to join this conversation on GitHub. Already have an account? Sign in to comment