Continue adding definitions

This commit is contained in:
Ilya Shestakov
2015-11-11 12:34:03 +03:00
committed by Ilya Shestakov
parent 567e5da215
commit 365a1c5b03
+333 -16
View File
@@ -9,15 +9,20 @@ declare module mathjs {
type MathArray = Array<Number>;
type MathType = number|BigNumber|Fraction|Complex|Unit|MathArray|Matrix;
type MathExpression = string|string[]|MathArray|Matrix;
export interface IMathJsStatic {
e: number;
pi: number;
/**
* 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)
*/
lsolve(L: Matrix|MathArray, b: Matrix|MathArray): DenseMatrix|MathArray;
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)
@@ -33,7 +38,7 @@ declare module mathjs {
* @param b Column Vector
* @returns Column vector with the solution to the linear system A * x = b
*/
lusolve(A: Matrix|MathArray|Number, b: Matrix|MathArray): DenseMatrix|MathArray;
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
@@ -48,7 +53,7 @@ declare module mathjs {
* @param threshold Partial pivoting threshold (1 for partial pivoting)
* @returns The lower triangular matrix, the upper triangular matrix and the permutation vectors.
*/
slu(A: SparseMatrix, order: Number, threshold: Number): any;
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
@@ -56,7 +61,7 @@ declare module mathjs {
* @param b A column vector with the b values
* @returns A column vector with the linear system solution (x)
*/
usolve(U: Matrix|MathArray, b:Matrix|MathArray): DenseMatrix|MathArray;
usolve(U: Matrix|MathArray, b:Matrix|MathArray): Matrix|MathArray;
/**
* Calculate the absolute value of a number. For matrices, the function is evaluated element wise.
@@ -469,23 +474,314 @@ declare module mathjs {
* valueOf() The same as done()
* toString() Executes math.format() onto the chain's value, returning a string representation of the value.
*/
chain(value?): IMathJsChain;
chain(value?: any): IMathJsChain;
/**
* Create a complex value or convert a value to a complex value.
*/
complex(): Complex;
complex(re, im): Complex;
complex(re: number, im: number): Complex;
complex(complex: Complex): Complex;
complex(arg: string): Complex;
complex(array: MathArray): Complex;
complex(arg): Complex;
/**
* Create a fraction convert a value to a fraction.
*/
fraction(numerator: number|string|MathArray|Matrix, denominator: number|string|MathArray|Matrix): Fraction|MathArray|Matrix;
/**
* Create an index. An Index can store ranges having start, step, and end for multiple dimensions. Matrix.get, Matrix.set, and math.subset accept an Index as input.
*/
index(...ranges: any[]): Index;
/**
* Create a Matrix. The function creates a new math.type.Matrix object from an Array. A Matrix has utility functions
* to manipulate the data in the matrix, like getting the size and getting or setting values in the matrix. Supported
* storage formats are 'dense' and 'sparse'.
*/
matrix(format?: string): Matrix;
matrix(data: MathArray|Matrix, format?: string, dataType?:string): Matrix;
/**
* Create a number or convert a string, boolean, or unit to a number. When value is a matrix, all elements will be converted to number.
*/
number(value?: string|number|boolean|MathArray|Matrix|Unit): number|MathArray|Matrix;
number(unit: Unit, valuelessUnit: Unit|string): number|MathArray|Matrix;
/**
* Create a Sparse Matrix. The function creates a new math.type.Matrix object from an Array. A Matrix has utility
* functions to manipulate the data in the matrix, like getting the size and getting or setting values in the matrix.
* @param data A two dimensional array
*/
sparse(data?: MathArray|Matrix, dataType?:string): Matrix;
/**
* Create a string or convert any object into a string. Elements of Arrays and Matrices are processed element wise.
* @param value A value to convert to a string
*/
string(value: any): string|MathArray|Matrix;
/**
* Create a unit. Depending on the passed arguments, the function will create and return a new math.type.Unit object.
* When a matrix is provided, all elements will be converted to units.
*/
unit(unit: string): Unit|MathArray|Matrix;
unit(value: number, unit: string): Unit|MathArray|Matrix;
/**
* Parse and compile an expression. Returns a an object with a function eval([scope]) to evaluate the compiled expression.
*/
compile(expr: MathExpression): EvalFunction;
compile(exprs: MathExpression[]): EvalFunction[];
/**
* Evaluate an expression.
*/
eval(expr: MathExpression, scope?: any): any;
eval(exprs: MathExpression[], scope?: any): any;
/**
* Retrieve help on a function or data type. Help files are retrieved from the documentation in math.expression.docs.
*/
help(search: any): Help;
/**
* Parse an expression. Returns a node tree, which can be evaluated by invoking node.eval();
*/
parse(expr: MathExpression, options?: any): MathNode;
parse(exprs: MathExpression[], options?: any): MathNode[];
/**
* Create a parser. The function creates a new math.expression.Parser object.
*/
parser(): Parser;
/**
* Calculates: The eucledian distance between two points in 2 and 3 dimensional spaces. Distance between point
* and a line in 2 and 3 dimensional spaces. Pairwise distance between a set of 2D or 3D points NOTE: When
* substituting coefficients of a line(a, b and c), use ax + by + c = 0 instead of ax + by = c For parametric
* equation of a 3D line, x0, y0, z0, a, b, c are from: (xx0, yy0, zz0) = t(a, b, c)
*/
distance(x: MathArray|Matrix|any, y: MathArray|Matrix|any): Number | BigNumber;
/**
* Calculates the point of intersection of two lines in two or three dimensions and of a line and a plane in
* three dimensions. The inputs are in the form of arrays or 1 dimensional matrices. The line intersection functions
* return null if the lines do not meet.
* Note: Fill the plane coefficients as x + y + z = c and not as x + y + z + c = 0.
* @param w Co-ordinates of first end-point of first line
* @param x Co-ordinates of second end-point of first line
* @param y Co-ordinates of first end-point of second line OR Co-efficients of the plane's equation
* @param z Co-ordinates of second end-point of second line OR null if the calculation is for line and plane
* @returns Returns the point of intersection of lines/lines-planes
*/
intersect(w: MathArray|Matrix, x: MathArray|Matrix, y: MathArray|Matrix, z: MathArray|Matrix): MathArray;
/**
* Logical and. Test whether two values are both defined with a nonzero/nonempty value. For matrices, the function is evaluated element wise.
*/
and(x: number|BigNumber|Complex|Unit|MathArray|Matrix, y: number|BigNumber|Complex|Unit|MathArray|Matrix): boolean|MathArray|Matrix;
/**
* Logical not. Flips boolean value of a given parameter. For matrices, the function is evaluated element wise.
*/
not(x: number|BigNumber|Complex|Unit|MathArray|Matrix): boolean|MathArray|Matrix;
/**
* Logical or. Test if at least one value is defined with a nonzero/nonempty value. For matrices, the function is evaluated element wise.
*/
or(x: number|BigNumber|Complex|Unit|MathArray|Matrix, y: number|BigNumber|Complex|Unit|MathArray|Matrix): boolean|MathArray|Matrix;
/**
* Logical xor. Test whether one and only one value is defined with a nonzero/nonempty value. For matrices, the function is evaluated element wise.
*/
xor(x: number|BigNumber|Complex|Unit|MathArray|Matrix, y: number|BigNumber|Complex|Unit|MathArray|Matrix): boolean|MathArray|Matrix;
/**
* Concatenate two or more matrices.
* dim: number is a zero-based dimension over which to concatenate the matrices. By default the last dimension of the matrices.
*/
concat(...args: (MathArray|Matrix|number)[]): MathArray|Matrix;
/**
* Calculate the cross product for two vectors in three dimensional space. The cross product of A = [a1, a2, a3]
* and B =[b1, b2, b3] is defined as:
* cross(A, B) = [ a2 * b3 - a3 * b2, a3 * b1 - a1 * b3, a1 * b2 - a2 * b1 ]
*/
cross(x: MathArray|Matrix, y: MathArray|Matrix): MathArray|Matrix;
/**
* Calculate the determinant of a matrix.
*/
det(x: MathArray|Matrix): number;
/**
* Create a diagonal matrix or retrieve the diagonal of a matrix.
* When x is a vector, a matrix with vector x on the diagonal will be returned. When x is a two dimensional matrix,
* the matrixes kth diagonal will be returned
* as vector. When k is positive, the values are placed on the super diagonal. When k is negative, the values are
* placed on the sub diagonal.
* @param X A two dimensional matrix or a vector
* @param k The diagonal where the vector will be filled in or retrieved. Default value: 0.
* @param format The matrix storage format. Default value: 'dense'.
*/
diag(X: MathArray|Matrix, format?: string): MathArray|Matrix;
diag(X: MathArray|Matrix, k: number|BigNumber, format?: string): MathArray|Matrix;
/**
* Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn]
* is defined as:
* dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn
*/
dot(x: MathArray|Matrix, y: MathArray|Matrix): number;
/**
* Create a 2-dimensional identity matrix with size m x n or n x n. The matrix has ones on the diagonal and zeros elsewhere.
*/
eye(n: number, format?: string): MathArray|Matrix|number;
eye(m: number, n: number, format?: string): MathArray|Matrix|number;
eye(size: number[], format?: string): MathArray|Matrix|number;
/**
* Flatten a multi dimensional matrix into a single dimensional matrix.
*/
flatten(x: MathArray|Matrix): MathArray|Matrix;
/**
* Calculate the inverse of a square matrix.
*/
inv(x: number|Complex|MathArray|Matrix): number|Complex|MathArray|Matrix;
/**
* Create a matrix filled with ones. The created matrix can have one or multiple dimensions.
*/
ones(n: number, format?: string): MathArray|Matrix|number;
ones(m: number, n: number, format?: string): MathArray|Matrix|number;
ones(size: number[], format?: string): MathArray|Matrix|number;
/**
* Create an array from a range. By default, the range end is excluded. This can be customized by providing an extra parameter includeEnd.
* @param str A string 'start:end' or 'start:step:end'
* @param start Start of the range
* @param end End of the range, excluded by default, included when parameter includeEnd=true
* @param step Step size. Default value is 1.
* @returns Parameters describing the ranges start, end, and optional step.
*/
range(str: string, includeEnd?: boolean): MathArray|Matrix;
range(start: number|BigNumber, end:number|BigNumber, includeEnd?:boolean): MathArray|Matrix;
range(start: number|BigNumber, end: number|BigNumber, step: number|BigNumber, includeEnd?:boolean): MathArray|Matrix;
/**
* Resize a matrix
* @param x Matrix to be resized
* @param size One dimensional array with numbers
* @param defaultValue Zero by default, except in case of a string, in that case defaultValue = ' ' Default value: 0.
*/
resize(x: MathArray|Matrix, size: MathArray|Matrix, defaultValue?: number|string): MathArray|Matrix;
/**
* Calculate the size of a matrix or scalar.
*/
size(x: boolean|number|Complex|Unit|string|MathArray|Matrix): MathArray|Matrix;
/**
* Squeeze a matrix, remove inner and outer singleton dimensions from a matrix.
*/
squeeze(x: MathArray|Matrix): Matrix|MathArray;
/**
* Get or set a subset of a matrix or string.
* @param value An array, matrix, or string
* @param index An index containing ranges for each dimension
* @param replacement An array, matrix, or scalar. If provided, the subset is replaced with replacement. If not provided, the subset is returned
* @param defaultValue Default value, filled in on new entries when the matrix is resized. If not provided, math.matrix elements will be left undefined. Default value: undefined.
*/
subset(value: MathArray|Matrix|string, index: Index, replacement?: any, defaultValue?: any): MathArray|Matrix|string;
/**
* Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.
*/
trace(x: MathArray|Matrix): number;
/**
* Transpose a matrix. All values of the matrix are reflected over its main diagonal. Only two dimensional matrices are supported.
*/
transpose(x: MathArray|Matrix): MathArray|Matrix;
/**
* Create a matrix filled with zeros. The created matrix can have one or multiple dimensions.
*/
zeros(n: number, format?: string): MathArray|Matrix|number;
zeros(m: number, n: number, format?: string): MathArray|Matrix|number;
zeros(size: number[], format?: string): MathArray|Matrix|number;
/**
* Compute the number of ways of picking k unordered outcomes from n possibilities.
* Combinations only takes integer arguments. The following condition must be enforced: k <= n.
*/
combinations(n: number|BigNumber, k: number|BigNumber): number|BigNumber;
/**
* Create a distribution object with a set of random functions for given random distribution.
* @param name Name of a distribution. Choose from 'uniform', 'normal'.
*/
distribution(name: string): Distribution;
/**
* Compute the factorial of a value
* Factorial only supports an integer value as argument. For matrices, the function is evaluated element wise.
*/
factorial(n: number|BigNumber|MathArray|Matrix): number|BigNumber|MathArray|Matrix;
/**
* Compute the gamma function of a value using Lanczos approximation for small values, and an extended
* Stirling approximation for large values.
* For matrices, the function is evaluated element wise.
*/
gamma(n: number|MathArray|Matrix): number|MathArray|Matrix;
/**
* Calculate the Kullback-Leibler (KL) divergence between two distributions
*/
kldivergence(x: MathArray|Matrix, y: MathArray|Matrix): number;
/**
* Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from n possibilities.
* multinomial takes one array of integers as an argument. The following condition must be enforced: every ai <= 0
*/
multinomial(a: number[]|BigNumber[]): number|BigNumber;
/**
* Compute the number of ways of obtaining an ordered subset of k elements from a set of n elements.
* Permutations only takes integer arguments. The following condition must be enforced: k <= n.
* @param n The number of objects in total
* @param k The number of objects in the subset
*/
permutations(n: number|BigNumber, k?:number|BigNumber): number|BigNumber;
/**
* Random pick a value from a one dimensional array. Array element is picked using a random function with uniform distribution.
*/
pickRandom(array: number[]): number;
/**
* Return a random number larger or equal to min and smaller than max using a uniform distribution.
*/
random(): number;
random(max: number): number;
random(min: number, max: number): number;
random(size: MathArray|Matrix, max?: number): MathArray|Matrix;
random(size: MathArray|Matrix, min:number, max: number): MathArray|Matrix;
/**
* Return a random integer number larger or equal to min and smaller than max using a uniform distribution.
*/
randomInt(max: number): number;
randomInt(min: number, max: number): number;
randomInt(size: MathArray|Matrix, max?: number): MathArray|Matrix;
randomInt(size: MathArray|Matrix, min:number, max: number): MathArray|Matrix;
}
@@ -493,14 +789,6 @@ declare module mathjs {
}
export interface DenseMatrix {
}
export interface SparseMatrix {
}
export interface BigNumber {
}
@@ -517,8 +805,37 @@ declare module mathjs {
}
export interface IMathJsChain {
export interface Index {
}
export interface EvalFunction {
eval(): any;
}
export interface MathNode {
compile(): EvalFunction;
}
export interface Parser {
eval(expr: string): any;
get(variable: string): any;
set(variable: string, value: any): void;
clear(): void;
}
export interface Distribution {
random(size: any, min?: any, max?: any): any;
randomInt(min: any, max?: any): any;
pickRandom(array: any): any;
}
export interface Help {
toString(): string;
toJSON(): string;
}
export interface IMathJsChain {
done(): any;
valueOf(): any;