From d048e8507ed5a99b6e8f1f78794375ec20e573ac Mon Sep 17 00:00:00 2001 From: Ilya Shestakov Date: Wed, 11 Nov 2015 20:47:45 +0300 Subject: [PATCH] Chain interface --- mathjs/mathjs.d.ts | 767 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 761 insertions(+), 6 deletions(-) diff --git a/mathjs/mathjs.d.ts b/mathjs/mathjs.d.ts index 1154e10b1..7273a0dc5 100644 --- a/mathjs/mathjs.d.ts +++ b/mathjs/mathjs.d.ts @@ -1184,20 +1184,20 @@ declare module mathjs { * @param x A one dimensional matrix or array to filter * @param test */ - filter(x: MathArray|Matrix, test: RegExp|((any)=>boolean)): MathArray|Matrix; + filter(x: MathArray|Matrix, test: RegExp|((item: any)=>boolean)): MathArray|Matrix; /** * Iterate over all elements of a matrix/array, and executes the given callback function. * @param x The matrix to iterate on. * @param callback The callback function is invoked with three parameters: the value of the element, the index of the element, and the Matrix/array being traversed. */ - forEach(x: MathArray|Matrix, callback: (any)=>any); + forEach(x: MathArray|Matrix, callback: (item: any)=>any): void; /** * Format a value of any type into a string. * @param value The value to be formatted */ - format(value, options?: IFormatOptions|number|((any)=>string)): string; + format(value: any, options?: IFormatOptions|number|((item: any)=>string)): string; /** * Test whether a value is an integer number. The function supports number, BigNumber, and Fraction. @@ -1233,7 +1233,7 @@ declare module mathjs { * @param x The matrix to iterate on. * @param callback The callback method is invoked with three parameters: the value of the element, the index of the element, and the matrix being traversed. */ - map(x: MathArray|Matrix, callback: (any)=>any): MathArray|Matrix; + map(x: MathArray|Matrix, callback: (item: any)=>any): MathArray|Matrix; /** * Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect. @@ -1250,7 +1250,7 @@ declare module mathjs { * @param values An object containing variables which will be filled in in the template. * @param precision Number of digits to format numbers. If not provided, the value will not be rounded. */ - print(template:string, values: any, precision?: number); + print(template:string, values: any, precision?: number): void; /** * Sort the items in a matrix. @@ -1343,7 +1343,7 @@ declare module mathjs { * A custom formatting function. Can be used to override the built-in notations. Function fn is called with * value as parameter and must return a string. Is useful for example to format all values inside a matrix in a particular way. * */ - fn?: (any)=>string; + fn?: (item: any)=>string; } export interface Help { @@ -1352,6 +1352,761 @@ declare module mathjs { } export interface IMathJsChain { + /** + * Solves the linear equation system by forwards substitution. Matrix must be a lower triangular matrix. + * @param b A column vector with the b values + */ + lsolve(b: Matrix|MathArray): IMathJsChain; + + /** + * 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 + */ + lup(): IMathJsChain; + + /** + * Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector. + * @param b Column Vector + */ + lusolve(b: Matrix|MathArray): IMathJsChain; + + /** + * 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 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. + */ + slu(order: Number, threshold: Number): IMathJsChain; + + /** + * Solves the linear equation system by backward substitution. Matrix must be an upper triangular matrix. U * x = b + * @param b A column vector with the b values + * @returns A column vector with the linear system solution (x) + */ + usolve(b:Matrix|MathArray): IMathJsChain; + + /** + * Calculate the absolute value of a number. For matrices, the function is evaluated element wise. + */ + abs(): IMathJsChain; + + /** + * Add two values, x + y. For matrices, the function is evaluated element wise. + * @param y Second value to add + */ + add(y: MathType): IMathJsChain; + + /** + * Calculate the cubic root of a value. For matrices, the function is evaluated element wise. + * @param allRoots Optional, false by default. Only applicable when x is a number or complex number. If true, all complex roots are returned, if false (default) the principal root is returned. + */ + cbrt(allRoots?: boolean): IMathJsChain; + + /** + * Round a value towards plus infinity If x is complex, both real and imaginary part are rounded towards plus infinity. For matrices, the function is evaluated element wise. + */ + ceil(): IMathJsChain; + + /** + * Compute the cube of a value, x * x * x. For matrices, the function is evaluated element wise. + */ + cube(): IMathJsChain; + + /** + * Divide two values, x / y. To divide matrices, x is multiplied with the inverse of y: x * inv(y). + * @param y Denominator + */ + divide(y:MathType): IMathJsChain; + + /** + * Divide two matrices element wise. The function accepts both matrices and scalar values. + * @param y Denominator + */ + dotDivide(y: MathType): IMathJsChain; + + /** + * Multiply two matrices element wise. The function accepts both matrices and scalar values. + * @param y Right hand value + */ + dotMultiply(y: MathType): IMathJsChain; + + /** + * Calculates the power of x to y element wise. + * @param y The exponent + */ + dotPow(y: MathType): IMathJsChain; + + /** + * Calculate the exponent of a value. For matrices, the function is evaluated element wise. + */ + exp(): IMathJsChain; + + /** + * Round a value towards zero. For matrices, the function is evaluated element wise. + */ + fix(): IMathJsChain; + + /** + * Round a value towards minus infinity. For matrices, the function is evaluated element wise. + */ + floor(): IMathJsChain; + + /** + * Calculate the greatest common divisor for two or more values or arrays. For matrices, the function is evaluated element wise. + */ + gcd(...args: number[]): IMathJsChain; + gcd(...args: BigNumber[]): IMathJsChain ; + gcd(...args: Fraction[]): IMathJsChain ; + gcd(...args: MathArray[]): IMathJsChain ; + gcd(...args: Matrix[]): IMathJsChain; + + /** + * Calculate the hypotenusa of a list with values. The hypotenusa is defined as: + * hypot(a, b, c, ...) = sqrt(a^2 + b^2 + c^2 + ...) + * For matrix input, the hypotenusa is calculated for all values in the matrix. + */ + hypot(...args: number[]): IMathJsChain; + hypot(...args: BigNumber[]): IMathJsChain; + + /** + * Calculate the least common multiple for two or more values or arrays. lcm is defined as: + * lcm(a, b) = abs(a * b) / gcd(a, b) + * For matrices, the function is evaluated element wise. + */ + lcm(b: number): IMathJsChain; + lcm(b: BigNumber ): IMathJsChain ; + lcm(b: MathArray): IMathJsChain; + lcm(b: Matrix): IMathJsChain; + + /** + * Calculate the logarithm of a value. For matrices, the function is evaluated element wise. + * @param base Optional base for the logarithm. If not provided, the natural logarithm of x is calculated. Default value: e. + */ + log(base?: number|BigNumber|Complex): IMathJsChain; + + /** + * Calculate the 10-base of a value. This is the same as calculating log(x, 10). For matrices, the function is evaluated element wise. + */ + log10(): IMathJsChain; + + /** + * Calculates the modulus, the remainder of an integer division. For matrices, the function is evaluated element wise. + * The modulus is defined as: + * x - y * floor(x / y) + * See http://en.wikipedia.org/wiki/Modulo_operation. + * @param y Divisor + */ + mod(y: number|BigNumber|Fraction|MathArray|Matrix): IMathJsChain; + + /** + * Multiply two values, x * y. The result is squeezed. For matrices, the matrix product is calculated. + */ + multiply(y: MathType): IMathJsChain; + + /** + * Calculate the norm of a number, vector or matrix. The second parameter p is optional. If not provided, it defaults to 2. + * @param p Vector space. Supported numbers include Infinity and -Infinity. Supported strings are: 'inf', '-inf', and 'fro' (The Frobenius norm) Default value: 2. + */ + norm(p?: number|BigNumber|string): IMathJsChain; + + /** + * Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation + * x^root = A + * For matrices, the function is evaluated element wise. + * @param root The root. Default value: 2. + */ + nthRoot(root?: number|BigNumber): IMathJsChain; + + /** + * Calculates the power of x to y, x ^ y. Matrix exponentiation is supported for square matrices x, and positive integer exponents y. + * @param y The exponent + */ + pow(y: number|BigNumber|Complex): IMathJsChain; + + /** + * Round a value towards the nearest integer. For matrices, the function is evaluated element wise. + * @param n Number of decimals Default value: 0. + */ + round(n?: number|BigNumber|MathArray): IMathJsChain; + + /** + * Compute the sign of a value. The sign of a value x is: + * 1 when x > 1 + * -1 when x < 0 + * 0 when x == 0 + * For matrices, the function is evaluated element wise. + */ + sign(): IMathJsChain; + + /** + * Calculate the square root of a value. For matrices, the function is evaluated element wise. + */ + sqrt(): IMathJsChain; + + /** + * Compute the square of a value, x * x. For matrices, the function is evaluated element wise. + */ + square(): IMathJsChain; + + /** + * Subtract two values, x - y. For matrices, the function is evaluated element wise. + */ + subtract(y: MathType): IMathJsChain; + + /** + * Inverse the sign of a value, apply a unary minus operation. + * For matrices, the function is evaluated element wise. Boolean values and strings will be converted to a number. For complex numbers, both real and complex value are inverted. + */ + unaryMinus(): IMathJsChain; + + /** + * Unary plus operation. Boolean values and strings will be converted to a number, numeric values will be returned as is. + * For matrices, the function is evaluated element wise. + */ + unaryPlus(): IMathJsChain; + + /** + * Calculate the extended greatest common divisor for two values. See http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm. + */ + xgcd(b: number|BigNumber): IMathJsChain; + + /** + * Bitwise AND two values, x & y. For matrices, the function is evaluated element wise. + */ + bitAnd(y: number|BigNumber|MathArray|Matrix): IMathJsChain; + + /** + * Bitwise NOT value, ~x. For matrices, the function is evaluated element wise. For units, the function is evaluated on the best prefix base. + */ + bitNot(): IMathJsChain; + + /** + * Bitwise OR two values, x | y. For matrices, the function is evaluated element wise. For units, the function is evaluated on the lowest print base. + */ + bitOr(): IMathJsChain; + + /** + * Bitwise XOR two values, x ^ y. For matrices, the function is evaluated element wise. + */ + bitXor(y: number|BigNumber|MathArray|Matrix): IMathJsChain; + + /** + * Bitwise left logical shift of a value x by y number of bits, x << y. For matrices, the function is evaluated element wise. For units, the function is evaluated on the best prefix base. + * @param x Value to be shifted + * @param y Amount of shifts + */ + leftShift(y: number|BigNumber): IMathJsChain; + + /** + * Bitwise right arithmetic shift of a value x by y number of bits, x >> y. For matrices, the function is evaluated element wise. For units, the function is evaluated on the best prefix base. + * @param x Value to be shifted + * @param y Amount of shifts + */ + rightArithShift(y: number|BigNumber): IMathJsChain; + + /** + * Bitwise right logical shift of value x by y number of bits, x >>> y. For matrices, the function is evaluated element wise. For units, the function is evaluated on the best prefix base. + * @param x Value to be shifted + * @param y Amount of shifts + */ + rightLogShift(y: number): IMathJsChain; + + /** + * The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. bellNumbers only takes integer arguments. The following condition must be enforced: n >= 0 + * @param n Total number of objects in the set + */ + bellNumbers(): IMathJsChain; + + /** + * The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0 + * @pararm n nth Catalan number + */ + catalan(): IMathJsChain; + + /** + * The composition counts of n into k parts. Composition only takes integer arguments. The following condition must be enforced: k <= n. + * @param n Total number of objects in the set + * @param k Number of objects in the subset + * @returns Returns the composition counts of n into k parts. + */ + composition(k: Number|BigNumber): IMathJsChain; + + /** + * The Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. stirlingS2 only takes integer arguments. The following condition must be enforced: k <= n. + * If n = k or k = 1, then s(n,k) = 1 + * @param n Total number of objects in the set + * @param k Number of objects in the subset + */ + stirlingS2(k: Number|BigNumber): IMathJsChain; + + /** + * Compute the argument of a complex value. For a complex number a + bi, the argument is computed as atan2(b, a). For matrices, the function is evaluated element wise. + * @param x A complex number or array with complex numbers + */ + arg(): IMathJsChain; + + /** + * Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate of x is a - bi. For matrices, the function is evaluated element wise. + * @param x A complex number or array with complex numbers + */ + conj(): IMathJsChain; + + /** + * Get the imaginary part of a complex number. For a complex number a + bi, the function returns b. + * For matrices, the function is evaluated element wise. + */ + im(): IMathJsChain; + + /** + * Get the real part of a complex number. For a complex number a + bi, the function returns a. + * For matrices, the function is evaluated element wise. + */ + re(): IMathJsChain; + + /** + * 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: (x−x0, y−y0, z−z0) = t(a, b, c) + */ + distance(y: MathArray|Matrix|any): IMathJsChain; + + /** + * 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(x: MathArray|Matrix, y: MathArray|Matrix, z: MathArray|Matrix): IMathJsChain; + + /** + * Logical and. Test whether two values are both defined with a nonzero/nonempty value. For matrices, the function is evaluated element wise. + */ + and(y: number|BigNumber|Complex|Unit|MathArray|Matrix): IMathJsChain; + + /** + * Logical not. Flips boolean value of a given parameter. For matrices, the function is evaluated element wise. + */ + not(): IMathJsChain; + + /** + * Logical or. Test if at least one value is defined with a nonzero/nonempty value. For matrices, the function is evaluated element wise. + */ + or(y: number|BigNumber|Complex|Unit|MathArray|Matrix): IMathJsChain; + + /** + * 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(y: number|BigNumber|Complex|Unit|MathArray|Matrix): IMathJsChain; + + /** + * 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(y: MathArray|Matrix): IMathJsChain; + + /** + * Calculate the determinant of a matrix. + */ + det(): IMathJsChain; + + /** + * 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(size: MathArray|Matrix, defaultValue?: number|string): IMathJsChain; + + /** + * Calculate the size of a matrix or scalar. + */ + size(): IMathJsChain; + + /** + * Squeeze a matrix, remove inner and outer singleton dimensions from a matrix. + */ + squeeze(): IMathJsChain; + + /** + * 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(index: Index, replacement?: any, defaultValue?: any): IMathJsChain; + + /** + * Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix. + */ + trace(): IMathJsChain; + + /** + * Transpose a matrix. All values of the matrix are reflected over its main diagonal. Only two dimensional matrices are supported. + */ + transpose(): IMathJsChain; + + /** + * Random pick a value from a one dimensional array. Array element is picked using a random function with uniform distribution. + */ + pickRandom(): IMathJsChain; + + /** + * Return a random number larger or equal to min and smaller than max using a uniform distribution. + */ + random(): IMathJsChain; + random(max?: number): IMathJsChain; + random(min:number, max: number): IMathJsChain; + + /** + * Return a random integer number larger or equal to min and smaller than max using a uniform distribution. + */ + randomInt(max?: number): IMathJsChain; + randomInt(min:number, max: number): IMathJsChain; + + /** + * Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y. + * x and y are considered equal when the relative difference between x and y is smaller than the configured epsilon. + * The function cannot be used to compare values smaller than approximately 2.22e-16. + * For matrices, the function is evaluated element wise. + */ + compare(y: MathType): IMathJsChain; + + /** + * Test element wise whether two matrices are equal. The function accepts both matrices and scalar values. + */ + deepEqual(y: MathType): IMathJsChain; + + /** + * Test whether two values are equal. + * + * The function tests whether the relative difference between x and y is smaller than the configured epsilon. + * The function cannot be used to compare values smaller than approximately 2.22e-16. + * + * For matrices, the function is evaluated element wise. In case of complex numbers, x.re must equal y.re, and x.im must equal y.im. + * + * Values null and undefined are compared strictly, thus null is only equal to null and nothing else, and undefined is only equal to undefined and nothing else. + */ + equal(y: MathType): IMathJsChain; + + /** + * Test whether value x is larger than y. + * + * The function returns true when x is larger than y and the relative difference between x and y is larger than the configured epsilon. + * The function cannot be used to compare values smaller than approximately 2.22e-16. + * + * For matrices, the function is evaluated element wise. + */ + larger(y: MathType): IMathJsChain; + + /** + * Test whether value x is larger or equal to y. + * + * The function returns true when x is larger than y or the relative difference between x and y is smaller than the configured epsilon. + * The function cannot be used to compare values smaller than approximately 2.22e-16. + * + * For matrices, the function is evaluated element wise. + */ + largerEq(y: MathType): IMathJsChain; + + /** + * Test whether value x is smaller than y. + * + * The function returns true when x is smaller than y and the relative difference between x and y is smaller than the configured epsilon. + * The function cannot be used to compare values smaller than approximately 2.22e-16. + * + * For matrices, the function is evaluated element wise. + */ + smaller(IMathJsChainy: MathType): IMathJsChain; + + /** + * Test whether value x is smaller or equal to y. + * + * The function returns true when x is smaller than y or the relative difference between x and y is smaller than the configured epsilon. + * The function cannot be used to compare values smaller than approximately 2.22e-16. For matrices, the function is evaluated element wise. + */ + smallerEq(IMathJsChainy: MathType): IMathJsChain; + + /** + * Test whether two values are unequal. + * + * The function tests whether the relative difference between x and y is larger than the configured epsilon. The function cannot + * be used to compare values smaller than approximately 2.22e-16. + * + * For matrices, the function is evaluated element wise. In case of complex numbers, x.re must unequal y.re, or x.im must unequal y.im. + * + * Values null and undefined are compared strictly, thus null is unequal with everything except null, and undefined is unequal with + * everying except. undefined. + */ + unequal(IMathJsChainy: MathType): IMathJsChain; + + /** + * Compute the maximum value of a matrix or a list with values. In case of a multi dimensional array, the maximum of the flattened + * array will be calculated. When dim is provided, the maximum over the selected dimension will be calculated. Parameter dim is zero-based. + */ + max(dim?: number): IMathJsChain; + + /** + * Compute the mean value of matrix or a list with values. In case of a multi dimensional array, the mean of the flattened array will be + * calculated. When dim is provided, the maximum over the selected dimension will be calculated. Parameter dim is zero-based. + */ + mean(dim?: number): IMathJsChain; + + /** + * Compute the median of a matrix or a list with values. The values are sorted and the middle value is returned. In case of an + * even number of values, the average of the two middle values is returned. Supported types of values are: Number, BigNumber, Unit + * + * In case of a (multi dimensional) array or matrix, the median of all elements will be calculated. + */ + median(): IMathJsChain; + + /** + * Compute the maximum value of a matrix or a list of values. In case of a multi dimensional array, the maximum of the flattened + * array will be calculated. When dim is provided, the maximum over the selected dimension will be calculated. Parameter dim is zero-based. + */ + min(dim?: number): IMathJsChain; + + /** + * Computes the mode of a set of numbers or a list with values(numbers or characters). If there are more than one modes, it returns a list of those values. + */ + mode(): IMathJsChain; + + /** + * Compute the product of a matrix or a list with values. In case of a (multi dimensional) array or matrix, the sum of all elements will be calculated. + */ + prod(): IMathJsChain; + + /** + * Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. + * Supported types of sequence values are: Number, BigNumber, Unit Supported types of probability are: Number, BigNumber + * + * In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated. + */ + quantileSeq(prob: Number|BigNumber|MathArray, sorted?: boolean): IMathJsChain; + + /** + * Compute the standard deviation of a matrix or a list with values. The standard deviations is defined as the square root of the + * variance: std(A) = sqrt(var(A)). In case of a (multi dimensional) array or matrix, the standard deviation over all elements will + * be calculated. + * + * Optionally, the type of normalization can be specified as second parameter. The parameter normalization can be one of the following + * values: + * + * 'unbiased' (default) The sum of squared errors is divided by (n - 1) + * 'uncorrected' The sum of squared errors is divided by n + * 'biased' The sum of squared errors is divided by (n + 1) + */ + std(normalization?: string): IMathJsChain; + + /** + * Compute the sum of a matrix or a list with values. In case of a (multi dimensional) array or matrix, the sum of all elements will be calculated. + */ + sum(): IMathJsChain; + + /** + * Compute the variance of a matrix or a list with values. In case of a (multi dimensional) array or matrix, the variance over all + * elements will be calculated. + * + * Optionally, the type of normalization can be specified as second parameter. The parameter normalization can be one of the + * following values: + * + * 'unbiased' (default) The sum of squared errors is divided by (n - 1) + * 'uncorrected' The sum of squared errors is divided by n + * 'biased' The sum of squared errors is divided by (n + 1) + * Note that older browser may not like the variable name var. In that case, the function can be called as math['var'](...) + * instead of math.var(...). + */ + var(normalization?: string): IMathJsChain; + + /** + * Calculate the inverse cosine of a value. For matrices, the function is evaluated element wise. + */ + acos(): IMathJsChain; + + /** + * Calculate the hyperbolic arccos of a value, defined as acosh(x) = ln(sqrt(x^2 - 1) + x). + * For matrices, the function is evaluated element wise. + */ + acosh(): IMathJsChain; + + /** + * Calculate the inverse cotangent of a value. For matrices, the function is evaluated element wise. + */ + acot(): IMathJsChain; + + /** + * Calculate the hyperbolic arccotangent of a value, defined as acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2. + * For matrices, the function is evaluated element wise. + */ + acoth(): IMathJsChain; + + /** + * Calculate the inverse cosecant of a value. For matrices, the function is evaluated element wise. + */ + acsc(): IMathJsChain; + + /** + * Calculate the hyperbolic arccosecant of a value, defined as acsch(x) = ln(1/x + sqrt(1/x^2 + 1)). + * For matrices, the function is evaluated element wise. + */ + acsch(): IMathJsChain; + + /** + * Calculate the inverse secant of a value. For matrices, the function is evaluated element wise. + */ + asec(): IMathJsChain; + + /** + * Calculate the hyperbolic arcsecant of a value, defined as asech(x) = ln(sqrt(1/x^2 - 1) + 1/x). For matrices, the function is evaluated element wise. + */ + asech(): IMathJsChain; + + /** + * Calculate the inverse sine of a value. For matrices, the function is evaluated element wise. + */ + asin(): IMathJsChain; + + /** + * Calculate the hyperbolic arcsine of a value, defined as asinh(x) = ln(x + sqrt(x^2 + 1)). For matrices, the function is evaluated element wise. + */ + asinh(): IMathJsChain; + + /** + * Calculate the inverse tangent of a value. For matrices, the function is evaluated element wise. + */ + atan(): IMathJsChain; + + /** + * Calculate the inverse tangent function with two arguments, y/x. By providing two arguments, the right quadrant of the + * computed angle can be determined. + * + * For matrices, the function is evaluated element wise. + */ + atan2(x: number): IMathJsChain; + atan2(x: MathArray|Matrix): IMathJsChain; + + /** + * Calculate the hyperbolic arctangent of a value, defined as atanh(x) = ln((1 + x)/(1 - x)) / 2. + * For matrices, the function is evaluated element wise. + */ + atanh(): IMathJsChain; + + /** + * Calculate the cosine of a value. For matrices, the function is evaluated element wise. + */ + asin(): IMathJsChain; + + /** + * Calculate the hyperbolic cosine of a value, defined as cosh(x) = 1/2 * (exp(x) + exp(-x)). For matrices, the function is evaluated element wise. + */ + cosh(): IMathJsChain; + + /** + * Calculate the cotangent of a value. cot(x) is defined as 1 / tan(x). For matrices, the function is evaluated element wise. + */ + cot(): IMathJsChain; + + /** + * Calculate the hyperbolic cotangent of a value, defined as coth(x) = 1 / tanh(x). For matrices, the function is evaluated element wise. + */ + coth(): IMathJsChain; + + /** + * Calculate the cosecant of a value, defined as csc(x) = 1/sin(x). For matrices, the function is evaluated element wise. + */ + csc(): IMathJsChain; + + /** + * Calculate the hyperbolic cosecant of a value, defined as csch(x) = 1 / sinh(x). For matrices, the function is evaluated element wise. + */ + csch(): IMathJsChain; + + /** + * Calculate the secant of a value, defined as sec(x) = 1/cos(x). For matrices, the function is evaluated element wise. + */ + sec(): IMathJsChain; + + /** + * Calculate the hyperbolic secant of a value, defined as sech(x) = 1 / cosh(x). For matrices, the function is evaluated element wise. + */ + sech(): IMathJsChain; + + /** + * Calculate the sine of a value. For matrices, the function is evaluated element wise. + */ + sin(): IMathJsChain; + + /** + * Calculate the hyperbolic sine of a value, defined as sinh(x) = 1/2 * (exp(x) - exp(-x)). For matrices, the function is evaluated element wise. + */ + sinh(): IMathJsChain; + + /** + * Calculate the tangent of a value. tan(x) is equal to sin(x) / cos(x). For matrices, the function is evaluated element wise. + */ + tan(): IMathJsChain; + + /** + * Calculate the hyperbolic tangent of a value, defined as tanh(x) = (exp(2 * x) - 1) / (exp(2 * x) + 1). For matrices, the function is evaluated element wise. + */ + tanh(): IMathJsChain; + + /** + * Change the unit of a value. For matrices, the function is evaluated element wise. + * @param x The unit to be converted. + * @param unit New unit. Can be a string like "cm" or a unit without value. + */ + to(unit: Unit|string): IMathJsChain; + + /** + * Clone an object. + */ + clone(): IMathJsChain; + + /** + * Filter the items in an array or one dimensional matrix. + * @param x A one dimensional matrix or array to filter + * @param test + */ + filter(test: RegExp|((item: any)=>boolean)): IMathJsChain; + + /** + * Format a value of any type into a string. + */ + format(options?: IFormatOptions|number|((item: any)=>string)): IMathJsChain; + + /** + * Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array. + * @param callback The callback method is invoked with three parameters: the value of the element, the index of the element, and the matrix being traversed. + */ + map(callback: (item: any)=>any): IMathJsChain; + + /** + * Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect. + * @param k The kth smallest value to be retrieved; zero-based index + * @param compare An optional comparator function. The function is called as compare(a, b), and must return 1 when a > b, -1 when a < b, and 0 when a == b. Default value: 'asc'. + * @returns Returns the kth lowest value. + */ + partitionSelect(k: number, compare?: string|((a: any, b: any)=>number)): IMathJsChain; + + /** + * Sort the items in a matrix. + * @param compare An optional comparator function. The function is called as compare(a, b), and must return 1 when a > b, -1 when a < b, and 0 when a == b. Default value: 'asc'. + */ + sort(compare?: string|((a: any, b: any)=>number)): IMathJsChain; done(): any; valueOf(): any;