mathjs 9.4.0 → 9.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HISTORY.md +39 -0
- package/README.md +1 -3
- package/docs/expressions/expression_trees.md +2 -1
- package/docs/expressions/parsing.md +1 -1
- package/docs/reference/functions/intersect.md +1 -1
- package/examples/advanced/custom_datatype.js +7 -4
- package/lib/browser/math.js +7 -7
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesEigs.generated.js +6 -9
- package/lib/cjs/entry/dependenciesAny/dependenciesIntersect.generated.js +3 -0
- package/lib/cjs/entry/impureFunctionsAny.generated.js +41 -41
- package/lib/cjs/entry/pureFunctionsAny.generated.js +128 -128
- package/lib/cjs/expression/node/ArrayNode.js +15 -15
- package/lib/cjs/expression/parse.js +1 -0
- package/lib/cjs/function/geometry/intersect.js +93 -58
- package/lib/cjs/function/matrix/eigs/complexEigs.js +168 -18
- package/lib/cjs/function/matrix/eigs.js +7 -9
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/type/bignumber/BigNumber.js +3 -3
- package/lib/cjs/utils/is.js +13 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/entry/dependenciesAny/dependenciesEigs.generated.js +4 -6
- package/lib/esm/entry/dependenciesAny/dependenciesIntersect.generated.js +2 -0
- package/lib/esm/entry/impureFunctionsAny.generated.js +38 -38
- package/lib/esm/entry/pureFunctionsAny.generated.js +107 -107
- package/lib/esm/expression/node/ArrayNode.js +16 -16
- package/lib/esm/expression/parse.js +1 -0
- package/lib/esm/function/geometry/intersect.js +91 -58
- package/lib/esm/function/matrix/eigs/complexEigs.js +152 -18
- package/lib/esm/function/matrix/eigs.js +7 -9
- package/lib/esm/type/bignumber/BigNumber.js +2 -3
- package/lib/esm/utils/is.js +13 -1
- package/lib/esm/version.js +1 -1
- package/package.json +22 -20
- package/types/index.d.ts +4772 -0
- package/types/index.ts +597 -0
- package/types/tsconfig.json +18 -0
- package/types/tslint.json +6 -0
package/types/index.d.ts
ADDED
@@ -0,0 +1,4772 @@
|
|
1
|
+
import { Decimal } from 'decimal.js';
|
2
|
+
|
3
|
+
declare const math: math.MathJsStatic;
|
4
|
+
export as namespace math;
|
5
|
+
export = math;
|
6
|
+
|
7
|
+
type NoLiteralType<T> =
|
8
|
+
T extends number ? number :
|
9
|
+
T extends string ? string :
|
10
|
+
T extends boolean ? boolean :
|
11
|
+
T;
|
12
|
+
|
13
|
+
declare namespace math {
|
14
|
+
type MathArray = number[] | number[][];
|
15
|
+
type MathType = number | BigNumber | Fraction | Complex | Unit | MathArray | Matrix;
|
16
|
+
type MathExpression = string | string[] | MathArray | Matrix;
|
17
|
+
|
18
|
+
type FactoryFunction<T> = (scope: any) => T;
|
19
|
+
|
20
|
+
// FactoryFunctionMap can be nested; all nested objects will be flattened
|
21
|
+
interface FactoryFunctionMap {
|
22
|
+
[key: string]: FactoryFunction<any> | FactoryFunctionMap;
|
23
|
+
}
|
24
|
+
|
25
|
+
|
26
|
+
/** Available options for parse */
|
27
|
+
interface ParseOptions {
|
28
|
+
/** a set of custom nodes */
|
29
|
+
nodes?: Record<string, MathNode>;
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* Parse an expression. Returns a node tree, which can be evaluated by
|
33
|
+
* invoking node.evaluate().
|
34
|
+
*
|
35
|
+
* Note the evaluating arbitrary expressions may involve security risks,
|
36
|
+
* see [https://mathjs.org/docs/expressions/security.html](https://mathjs.org/docs/expressions/security.html) for more information.
|
37
|
+
*
|
38
|
+
* Syntax:
|
39
|
+
*
|
40
|
+
* math.parse(expr)
|
41
|
+
* math.parse(expr, options)
|
42
|
+
* math.parse([expr1, expr2, expr3, ...])
|
43
|
+
* math.parse([expr1, expr2, expr3, ...], options)
|
44
|
+
*
|
45
|
+
* Example:
|
46
|
+
*
|
47
|
+
* const node1 = math.parse('sqrt(3^2 + 4^2)')
|
48
|
+
* node1.compile().evaluate() // 5
|
49
|
+
*
|
50
|
+
* let scope = {a:3, b:4}
|
51
|
+
* const node2 = math.parse('a * b') // 12
|
52
|
+
* const code2 = node2.compile()
|
53
|
+
* code2.evaluate(scope) // 12
|
54
|
+
* scope.a = 5
|
55
|
+
* code2.evaluate(scope) // 20
|
56
|
+
*
|
57
|
+
* const nodes = math.parse(['a = 3', 'b = 4', 'a * b'])
|
58
|
+
* nodes[2].compile().evaluate() // 12
|
59
|
+
*
|
60
|
+
* See also:
|
61
|
+
*
|
62
|
+
* evaluate, compile
|
63
|
+
*/
|
64
|
+
interface ParseFunction {
|
65
|
+
/**
|
66
|
+
* Parse an expression. Returns a node tree, which can be evaluated by
|
67
|
+
* invoking node.evaluate();
|
68
|
+
*
|
69
|
+
* @param expr Expression to be parsed
|
70
|
+
* @param options Available options
|
71
|
+
* @returns A node
|
72
|
+
*/
|
73
|
+
(expr: MathExpression, options?: ParseOptions): MathNode;
|
74
|
+
|
75
|
+
/**
|
76
|
+
* Parse an expression. Returns a node tree, which can be evaluated by
|
77
|
+
* invoking node.evaluate();
|
78
|
+
*
|
79
|
+
* @param exprs Expressions to be parsed
|
80
|
+
* @param options Available options
|
81
|
+
* @returns An array of nodes
|
82
|
+
*/
|
83
|
+
(exprs: MathExpression[], options?: ParseOptions): MathNode[];
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Checks whether the current character `c` is a valid alpha character:
|
87
|
+
*
|
88
|
+
* - A latin letter (upper or lower case) Ascii: a-z, A-Z
|
89
|
+
* - An underscore Ascii: _
|
90
|
+
* - A dollar sign Ascii: $
|
91
|
+
* - A latin letter with accents Unicode: \u00C0 - \u02AF
|
92
|
+
* - A greek letter Unicode: \u0370 - \u03FF
|
93
|
+
* - A mathematical alphanumeric symbol Unicode: \u{1D400} - \u{1D7FF} excluding invalid code points
|
94
|
+
*
|
95
|
+
* The previous and next characters are needed to determine whether
|
96
|
+
* this character is part of a unicode surrogate pair.
|
97
|
+
*
|
98
|
+
* @param c Current character in the expression
|
99
|
+
* @param cPrev Previous character
|
100
|
+
* @param cNext Next character
|
101
|
+
*/
|
102
|
+
isAlpha(c: string, cPrev: string, cNext: string): boolean;
|
103
|
+
/**
|
104
|
+
* Test whether a character is a valid latin, greek, or letter-like character
|
105
|
+
*
|
106
|
+
* @param c
|
107
|
+
*/
|
108
|
+
isValidLatinOrGreek(c: string): boolean;
|
109
|
+
/**
|
110
|
+
* Test whether two given 16 bit characters form a surrogate pair of a
|
111
|
+
* unicode math symbol.
|
112
|
+
*
|
113
|
+
* https://unicode-table.com/en/
|
114
|
+
* https://www.wikiwand.com/en/Mathematical_operators_and_symbols_in_Unicode
|
115
|
+
*
|
116
|
+
* Note: In ES6 will be unicode aware:
|
117
|
+
* https://stackoverflow.com/questions/280712/javascript-unicode-regexes
|
118
|
+
* https://mathiasbynens.be/notes/es6-unicode-regex
|
119
|
+
*
|
120
|
+
* @param high
|
121
|
+
* @param low
|
122
|
+
*/
|
123
|
+
isValidMathSymbol(high: string, low: string): boolean;
|
124
|
+
/**
|
125
|
+
* Check whether given character c is a white space character: space, tab, or enter
|
126
|
+
*
|
127
|
+
* @param c
|
128
|
+
* @param nestingLevel
|
129
|
+
*/
|
130
|
+
isWhitespace(c: string, nestingLevel: number): boolean;
|
131
|
+
/**
|
132
|
+
* Test whether the character c is a decimal mark (dot).
|
133
|
+
* This is the case when it's not the start of a delimiter '.*', './', or '.^'
|
134
|
+
*
|
135
|
+
* @param c
|
136
|
+
* @param cNext
|
137
|
+
*/
|
138
|
+
isDecimalMark(c: string, cNext: string): boolean;
|
139
|
+
/**
|
140
|
+
* checks if the given char c is a digit or dot
|
141
|
+
*
|
142
|
+
* @param c a string with one character
|
143
|
+
*/
|
144
|
+
isDigitDot(c: string): boolean;
|
145
|
+
/**
|
146
|
+
* checks if the given char c is a digit
|
147
|
+
*
|
148
|
+
* @param c a string with one character
|
149
|
+
*/
|
150
|
+
isDigit(c: string): boolean;
|
151
|
+
/**
|
152
|
+
* checks if the given char c is a hex digit
|
153
|
+
*
|
154
|
+
* @param c a string with one character
|
155
|
+
*/
|
156
|
+
isHexDigit(c: string): boolean;
|
157
|
+
}
|
158
|
+
|
159
|
+
type MathJsFunctionName = keyof MathJsStatic;
|
160
|
+
|
161
|
+
interface MathJsStatic extends FactoryDependencies {
|
162
|
+
e: number;
|
163
|
+
pi: number;
|
164
|
+
i: number;
|
165
|
+
Infinity: number;
|
166
|
+
LN2: number;
|
167
|
+
LN10: number;
|
168
|
+
LOG2E: number;
|
169
|
+
LOG10E: number;
|
170
|
+
NaN: number;
|
171
|
+
phi: number;
|
172
|
+
SQRT1_2: number;
|
173
|
+
SQRT2: number;
|
174
|
+
tau: number;
|
175
|
+
|
176
|
+
/**
|
177
|
+
* If null were to be included in this interface, it would be
|
178
|
+
* auto-suggested as an import in VSCode. This causes issues because
|
179
|
+
* `null` is not a valid label.
|
180
|
+
*
|
181
|
+
* @see https://github.com/josdejong/mathjs/issues/2019
|
182
|
+
*/
|
183
|
+
// null: number;
|
184
|
+
|
185
|
+
uninitialized: any;
|
186
|
+
version: string;
|
187
|
+
|
188
|
+
expression: MathNode;
|
189
|
+
json: MathJsJson;
|
190
|
+
|
191
|
+
/*************************************************************************
|
192
|
+
* Core functions
|
193
|
+
************************************************************************/
|
194
|
+
|
195
|
+
/**
|
196
|
+
* Set configuration options for math.js, and get current options. Will
|
197
|
+
* emit a ‘config’ event, with arguments (curr, prev, changes).
|
198
|
+
* @param options Available options: {number} epsilon Minimum relative
|
199
|
+
* difference between two compared values, used by all comparison
|
200
|
+
* functions. {string} matrix A string ‘Matrix’ (default) or ‘Array’.
|
201
|
+
* {string} number A string ‘number’ (default), ‘BigNumber’, or
|
202
|
+
* ‘Fraction’ {number} precision The number of significant digits for
|
203
|
+
* BigNumbers. Not applicable for Numbers. {string} parenthesis How to
|
204
|
+
* display parentheses in LaTeX and string output. {string} randomSeed
|
205
|
+
* Random seed for seeded pseudo random number generator. Set to null to
|
206
|
+
* randomly seed.
|
207
|
+
* @returns Returns the current configuration
|
208
|
+
*/
|
209
|
+
config: (options: ConfigOptions) => ConfigOptions;
|
210
|
+
/**
|
211
|
+
* Create a typed-function which checks the types of the arguments and
|
212
|
+
* can match them against multiple provided signatures. The
|
213
|
+
* typed-function automatically converts inputs in order to find a
|
214
|
+
* matching signature. Typed functions throw informative errors in case
|
215
|
+
* of wrong input arguments.
|
216
|
+
* @param name Optional name for the typed-function
|
217
|
+
* @param signatures Object with one or multiple function signatures
|
218
|
+
* @returns The created typed-function.
|
219
|
+
*/
|
220
|
+
typed: (name: string, signatures: Record<string, (...args: any[]) => any>) => (...args: any[]) => any;
|
221
|
+
|
222
|
+
/*************************************************************************
|
223
|
+
* Construction functions
|
224
|
+
************************************************************************/
|
225
|
+
|
226
|
+
/**
|
227
|
+
* Create a BigNumber, which can store numbers with arbitrary precision.
|
228
|
+
* When a matrix is provided, all elements will be converted to
|
229
|
+
* BigNumber.
|
230
|
+
* @param x Value for the big number, 0 by default.
|
231
|
+
* @returns The created bignumber
|
232
|
+
*/
|
233
|
+
bignumber(x?: number | string | Fraction | BigNumber | MathArray | Matrix | boolean | Fraction | null): BigNumber;
|
234
|
+
|
235
|
+
/**
|
236
|
+
* Create a boolean or convert a string or number to a boolean. In case
|
237
|
+
* of a number, true is returned for non-zero numbers, and false in case
|
238
|
+
* of zero. Strings can be 'true' or 'false', or can contain a number.
|
239
|
+
* When value is a matrix, all elements will be converted to boolean.
|
240
|
+
* @param x A value of any type
|
241
|
+
* @returns The boolean value
|
242
|
+
*/
|
243
|
+
boolean(x: string | number | boolean | MathArray | Matrix | null): boolean | MathArray | Matrix;
|
244
|
+
|
245
|
+
/**
|
246
|
+
* Wrap any value in a chain, allowing to perform chained operations on
|
247
|
+
* the value. All methods available in the math.js library can be called
|
248
|
+
* upon the chain, and then will be evaluated with the value itself as
|
249
|
+
* first argument. The chain can be closed by executing chain.done(),
|
250
|
+
* which returns the final value. The chain has a number of special
|
251
|
+
* functions: done() Finalize the chain and return the chain's value.
|
252
|
+
* valueOf() The same as done() toString() Executes math.format() onto
|
253
|
+
* the chain's value, returning a string representation of the value.
|
254
|
+
* @param value A value of any type on which to start a chained
|
255
|
+
* operation.
|
256
|
+
* @returns The created chain
|
257
|
+
*/
|
258
|
+
chain(value?: any): MathJsChain;
|
259
|
+
|
260
|
+
/**
|
261
|
+
* Create a complex value or convert a value to a complex value.
|
262
|
+
* @param args Arguments specifying the real and imaginary part of the
|
263
|
+
* complex number
|
264
|
+
* @returns Returns a complex value
|
265
|
+
*/
|
266
|
+
complex(arg?: Complex | string | PolarCoordinates): Complex;
|
267
|
+
complex(arg?: MathArray | Matrix): MathArray | Matrix;
|
268
|
+
/**
|
269
|
+
* @param re Argument specifying the real part of the complex number
|
270
|
+
* @param im Argument specifying the imaginary part of the complex
|
271
|
+
* number
|
272
|
+
* @returns Returns a complex value
|
273
|
+
*/
|
274
|
+
complex(re: number, im: number): Complex;
|
275
|
+
|
276
|
+
/**
|
277
|
+
* Create a user-defined unit and register it with the Unit type.
|
278
|
+
* @param name The name of the new unit. Must be unique. Example: ‘knot’
|
279
|
+
* @param definition Definition of the unit in terms of existing units.
|
280
|
+
* For example, ‘0.514444444 m / s’.
|
281
|
+
* @param options (optional) An object containing any of the following
|
282
|
+
* properties:</br>- prefixes {string} “none”, “short”, “long”,
|
283
|
+
* “binary_short”, or “binary_long”. The default is “none”.</br>-
|
284
|
+
* aliases {Array} Array of strings. Example: [‘knots’, ‘kt’,
|
285
|
+
* ‘kts’]</br>- offset {Numeric} An offset to apply when converting from
|
286
|
+
* the unit. For example, the offset for celsius is 273.15. Default is
|
287
|
+
* 0.
|
288
|
+
* @returns The new unit
|
289
|
+
*/
|
290
|
+
createUnit(name: string, definition?: string | UnitDefinition, options?: CreateUnitOptions): Unit;
|
291
|
+
/**
|
292
|
+
* Create a user-defined unit and register it with the Unit type.
|
293
|
+
* @param units Definition of the unit
|
294
|
+
* @param options
|
295
|
+
* @returns The new unit
|
296
|
+
*/
|
297
|
+
createUnit(units: Record<string, string | UnitDefinition>, options?: CreateUnitOptions): Unit;
|
298
|
+
|
299
|
+
/**
|
300
|
+
* Create a fraction convert a value to a fraction.
|
301
|
+
* @param args Arguments specifying the numerator and denominator of the
|
302
|
+
* fraction
|
303
|
+
* @returns Returns a fraction
|
304
|
+
*/
|
305
|
+
fraction(args: Fraction | MathArray | Matrix): Fraction | MathArray | Matrix;
|
306
|
+
/**
|
307
|
+
* @param numerator Argument specifying the numerator of the fraction
|
308
|
+
* @param denominator Argument specifying the denominator of the
|
309
|
+
* fraction
|
310
|
+
* @returns Returns a fraction
|
311
|
+
*/
|
312
|
+
fraction(
|
313
|
+
numerator: number | string | MathArray | Matrix,
|
314
|
+
denominator?: number | string | MathArray | Matrix
|
315
|
+
): Fraction | MathArray | Matrix;
|
316
|
+
|
317
|
+
/**
|
318
|
+
* Create an index. An Index can store ranges having start, step, and
|
319
|
+
* end for multiple dimensions. Matrix.get, Matrix.set, and math.subset
|
320
|
+
* accept an Index as input.
|
321
|
+
* @param ranges Zero or more ranges or numbers.
|
322
|
+
* @returns Returns the created index
|
323
|
+
*/
|
324
|
+
index(...ranges: any[]): Index;
|
325
|
+
|
326
|
+
/**
|
327
|
+
* Create a Matrix. The function creates a new math.type.Matrix object
|
328
|
+
* from an Array. A Matrix has utility functions to manipulate the data
|
329
|
+
* in the matrix, like getting the size and getting or setting values in
|
330
|
+
* the matrix. Supported storage formats are 'dense' and 'sparse'.
|
331
|
+
* @param format The Matrix storage format
|
332
|
+
* @returns The created Matrix
|
333
|
+
*/
|
334
|
+
matrix(format?: 'sparse' | 'dense'): Matrix;
|
335
|
+
/**
|
336
|
+
* @param data A multi dimensional array
|
337
|
+
* @param format The Matrix storage format
|
338
|
+
* @param dataType The Matrix data type
|
339
|
+
* @returns The created Matrix
|
340
|
+
*/
|
341
|
+
matrix(data: MathArray | Matrix, format?: 'sparse' | 'dense', dataType?: string): Matrix;
|
342
|
+
|
343
|
+
/**
|
344
|
+
* Create a number or convert a string, boolean, or unit to a number.
|
345
|
+
* When value is a matrix, all elements will be converted to number.
|
346
|
+
* @param value Value to be converted
|
347
|
+
* @returns The created number
|
348
|
+
*/
|
349
|
+
number(value?: string | number | BigNumber | Fraction | boolean | MathArray | Matrix | Unit | null): number | MathArray | Matrix;
|
350
|
+
/**
|
351
|
+
* @param value Value to be converted
|
352
|
+
* @param valuelessUnit A valueless unit, used to convert a unit to a
|
353
|
+
* number
|
354
|
+
* @returns The created number
|
355
|
+
*/
|
356
|
+
number(unit: Unit, valuelessUnit: Unit | string): number;
|
357
|
+
|
358
|
+
/**
|
359
|
+
* Create a Sparse Matrix. The function creates a new math.type.Matrix
|
360
|
+
* object from an Array. A Matrix has utility functions to manipulate
|
361
|
+
* the data in the matrix, like getting the size and getting or setting
|
362
|
+
* values in the matrix.
|
363
|
+
* @param data A two dimensional array
|
364
|
+
* @param dataType Sparse Matrix data type
|
365
|
+
* @returns The created matrix
|
366
|
+
*/
|
367
|
+
sparse(data?: MathArray | Matrix, dataType?: string): Matrix;
|
368
|
+
|
369
|
+
/**
|
370
|
+
* Split a unit in an array of units whose sum is equal to the original
|
371
|
+
* unit.
|
372
|
+
* @param unit A unit to be split
|
373
|
+
* @param parts An array of strings or valueless units
|
374
|
+
* @returns An array of units
|
375
|
+
*/
|
376
|
+
splitUnit(unit: Unit, parts: Unit[]): Unit[];
|
377
|
+
|
378
|
+
/**
|
379
|
+
* Create a string or convert any object into a string. Elements of
|
380
|
+
* Arrays and Matrices are processed element wise.
|
381
|
+
* @param value A value to convert to a string
|
382
|
+
* @returns The created string
|
383
|
+
*/
|
384
|
+
string(value: MathType | null): string | MathArray | Matrix;
|
385
|
+
|
386
|
+
/**
|
387
|
+
* Create a unit. Depending on the passed arguments, the function will
|
388
|
+
* create and return a new math.type.Unit object. When a matrix is
|
389
|
+
* provided, all elements will be converted to units.
|
390
|
+
* @param unit The unit to be created
|
391
|
+
* @returns The created unit
|
392
|
+
*/
|
393
|
+
unit(unit: string): Unit;
|
394
|
+
/**
|
395
|
+
* @param value The value of the unit to be created
|
396
|
+
* @param unit The unit to be created
|
397
|
+
* @returns The created unit
|
398
|
+
*/
|
399
|
+
unit(value: number | MathArray | Matrix, unit: string): Unit;
|
400
|
+
|
401
|
+
/*************************************************************************
|
402
|
+
* Expression functions
|
403
|
+
************************************************************************/
|
404
|
+
|
405
|
+
/**
|
406
|
+
* Parse and compile an expression. Returns a an object with a function
|
407
|
+
* evaluate([scope]) to evaluate the compiled expression.
|
408
|
+
* @param expr The expression to be compiled
|
409
|
+
* @returns An object with the compiled expression
|
410
|
+
*/
|
411
|
+
compile(expr: MathExpression): EvalFunction;
|
412
|
+
/**
|
413
|
+
* @param exprs The expressions to be compiled
|
414
|
+
* @returns An array of objects with the compiled expressions
|
415
|
+
*/
|
416
|
+
compile(exprs: MathExpression[]): EvalFunction[];
|
417
|
+
|
418
|
+
/**
|
419
|
+
* Evaluate an expression.
|
420
|
+
* @param expr The expression to be evaluated
|
421
|
+
* @param scope Scope to read/write variables
|
422
|
+
* @returns The result of the expression
|
423
|
+
*/
|
424
|
+
evaluate(expr: MathExpression | MathExpression[] | Matrix, scope?: object): any;
|
425
|
+
|
426
|
+
/**
|
427
|
+
* Retrieve help on a function or data type. Help files are retrieved
|
428
|
+
* from the documentation in math.expression.docs.
|
429
|
+
* @param search A function or function name for which to get help
|
430
|
+
* @returns A help object
|
431
|
+
*/
|
432
|
+
help(search: () => any): Help;
|
433
|
+
|
434
|
+
/**
|
435
|
+
* Parse an expression. Returns a node tree, which can be evaluated by
|
436
|
+
* invoking node.evaluate();
|
437
|
+
*/
|
438
|
+
parse: ParseFunction;
|
439
|
+
|
440
|
+
/**
|
441
|
+
* Create a parser. The function creates a new math.expression.Parser
|
442
|
+
* object.
|
443
|
+
* @returns A Parser object
|
444
|
+
*/
|
445
|
+
parser(): Parser;
|
446
|
+
|
447
|
+
/*************************************************************************
|
448
|
+
* Algebra functions
|
449
|
+
************************************************************************/
|
450
|
+
/**
|
451
|
+
* @param expr The expression to differentiate
|
452
|
+
* @param variable The variable over which to differentiate
|
453
|
+
* @param options There is one option available, simplify, which is true
|
454
|
+
* by default. When false, output will not be simplified.
|
455
|
+
* @returns The derivative of expr
|
456
|
+
*/
|
457
|
+
derivative(expr: MathNode | string, variable: MathNode | string, options?: { simplify: boolean }): MathNode;
|
458
|
+
|
459
|
+
/**
|
460
|
+
* Solves the linear equation system by forwards substitution. Matrix
|
461
|
+
* must be a lower triangular matrix.
|
462
|
+
* @param L A N x N matrix or array (L)
|
463
|
+
* @param b A column vector with the b values
|
464
|
+
* @returns A column vector with the linear system solution (x)
|
465
|
+
*/
|
466
|
+
lsolve(L: Matrix | MathArray, b: Matrix | MathArray): Matrix | MathArray;
|
467
|
+
|
468
|
+
/**
|
469
|
+
* Calculate the Matrix LU decomposition with partial pivoting. Matrix A
|
470
|
+
* is decomposed in two matrices (L, U) and a row permutation vector p
|
471
|
+
* where A[p,:] = L * U
|
472
|
+
* @param A A two dimensional matrix or array for which to get the LUP
|
473
|
+
* decomposition.
|
474
|
+
* @returns The lower triangular matrix, the upper triangular matrix and
|
475
|
+
* the permutation matrix.
|
476
|
+
*/
|
477
|
+
lup(A?: Matrix | MathArray): { L: MathArray | Matrix; U: MathArray | Matrix; P: number[] };
|
478
|
+
|
479
|
+
/**
|
480
|
+
* Solves the linear system A * x = b where A is an [n x n] matrix and b
|
481
|
+
* is a [n] column vector.
|
482
|
+
* @param A Invertible Matrix or the Matrix LU decomposition
|
483
|
+
* @param b Column Vector
|
484
|
+
* @param order The Symbolic Ordering and Analysis order, see slu for
|
485
|
+
* details. Matrix must be a SparseMatrix
|
486
|
+
* @param threshold Partial pivoting threshold (1 for partial pivoting),
|
487
|
+
* see slu for details. Matrix must be a SparseMatrix.
|
488
|
+
* @returns Column vector with the solution to the linear system A * x =
|
489
|
+
* b
|
490
|
+
*/
|
491
|
+
lusolve(A: Matrix | MathArray | number, b: Matrix | MathArray, order?: number, threshold?: number): Matrix | MathArray;
|
492
|
+
|
493
|
+
/**
|
494
|
+
* Calculate the Matrix QR decomposition. Matrix A is decomposed in two
|
495
|
+
* matrices (Q, R) where Q is an orthogonal matrix and R is an upper
|
496
|
+
* triangular matrix.
|
497
|
+
* @param A A two dimensional matrix or array for which to get the QR
|
498
|
+
* decomposition.
|
499
|
+
* @returns Q: the orthogonal matrix and R: the upper triangular matrix
|
500
|
+
*/
|
501
|
+
qr(A: Matrix | MathArray): { Q: MathArray | Matrix; R: MathArray | Matrix };
|
502
|
+
|
503
|
+
/**
|
504
|
+
* Transform a rationalizable expression in a rational fraction. If
|
505
|
+
* rational fraction is one variable polynomial then converts the
|
506
|
+
* numerator and denominator in canonical form, with decreasing
|
507
|
+
* exponents, returning the coefficients of numerator.
|
508
|
+
* @param expr The expression to check if is a polynomial expression
|
509
|
+
* @param optional scope of expression or true for already evaluated
|
510
|
+
* rational expression at input
|
511
|
+
* @param detailed optional True if return an object, false if return
|
512
|
+
* expression node (default)
|
513
|
+
* @returns The rational polynomial of expr
|
514
|
+
*/
|
515
|
+
rationalize(
|
516
|
+
expr: MathNode | string,
|
517
|
+
optional?: object | boolean,
|
518
|
+
detailed?: true
|
519
|
+
): { expression: MathNode | string; variables: string[]; coefficients: MathType[] };
|
520
|
+
rationalize(expr: MathNode | string, optional?: object | boolean, detailed?: false): MathNode;
|
521
|
+
|
522
|
+
/**
|
523
|
+
* Simplify an expression tree.
|
524
|
+
* @param expr The expression to be simplified
|
525
|
+
* @param [rules] (optional) A list of rules are applied to an expression, repeating
|
526
|
+
* over the list until no further changes are made. It’s possible to
|
527
|
+
* pass a custom set of rules to the function as second argument. A rule
|
528
|
+
* can be specified as an object, string, or function.
|
529
|
+
* @param [scope] (optional) Scope to variables
|
530
|
+
* @param [options] (optional) An object with simplify options
|
531
|
+
* @returns Returns the simplified form of expr
|
532
|
+
*/
|
533
|
+
simplify(
|
534
|
+
expr: MathNode | string,
|
535
|
+
rules?: Array<{ l: string; r: string } | string | ((node: MathNode) => MathNode)>,
|
536
|
+
scope?: object,
|
537
|
+
options?: SimplifyOptions,
|
538
|
+
): MathNode;
|
539
|
+
simplify(expr: MathNode | string, scope?: object, options?: SimplifyOptions): MathNode;
|
540
|
+
|
541
|
+
/**
|
542
|
+
* Calculate the Sparse Matrix LU decomposition with full pivoting.
|
543
|
+
* Sparse Matrix A is decomposed in two matrices (L, U) and two
|
544
|
+
* permutation vectors (pinv, q) where P * A * Q = L * U
|
545
|
+
* @param A A two dimensional sparse matrix for which to get the LU
|
546
|
+
* decomposition.
|
547
|
+
* @param order The Symbolic Ordering and Analysis order: 0 - Natural
|
548
|
+
* ordering, no permutation vector q is returned 1 - Matrix must be
|
549
|
+
* square, symbolic ordering and analisis is performed on M = A + A' 2 -
|
550
|
+
* Symbolic ordering and analysis is performed on M = A' * A. Dense
|
551
|
+
* columns from A' are dropped, A recreated from A'. This is appropriate
|
552
|
+
* for LU factorization of non-symmetric matrices. 3 - Symbolic ordering
|
553
|
+
* and analysis is performed on M = A' * A. This is best used for LU
|
554
|
+
* factorization is matrix M has no dense rows. A dense row is a row
|
555
|
+
* with more than 10*sqr(columns) entries.
|
556
|
+
* @param threshold Partial pivoting threshold (1 for partial pivoting)
|
557
|
+
* @returns The lower triangular matrix, the upper triangular matrix and
|
558
|
+
* the permutation vectors.
|
559
|
+
*/
|
560
|
+
slu(A: Matrix, order: number, threshold: number): object;
|
561
|
+
|
562
|
+
/**
|
563
|
+
* Solves the linear equation system by backward substitution. Matrix
|
564
|
+
* must be an upper triangular matrix. U * x = b
|
565
|
+
* @param U A N x N matrix or array (U)
|
566
|
+
* @param b A column vector with the b values
|
567
|
+
* @returns A column vector with the linear system solution (x)
|
568
|
+
*/
|
569
|
+
usolve(U: Matrix | MathArray, b: Matrix | MathArray): Matrix | MathArray;
|
570
|
+
|
571
|
+
/*************************************************************************
|
572
|
+
* Arithmetic functions
|
573
|
+
************************************************************************/
|
574
|
+
|
575
|
+
/**
|
576
|
+
* Calculate the absolute value of a number. For matrices, the function
|
577
|
+
* is evaluated element wise.
|
578
|
+
* @param x A number or matrix for which to get the absolute value
|
579
|
+
* @returns Absolute value of x
|
580
|
+
*/
|
581
|
+
abs(x: number): number;
|
582
|
+
abs(x: BigNumber): BigNumber;
|
583
|
+
abs(x: Fraction): Fraction;
|
584
|
+
abs(x: Complex): Complex;
|
585
|
+
abs(x: MathArray): MathArray;
|
586
|
+
abs(x: Matrix): Matrix;
|
587
|
+
abs(x: Unit): Unit;
|
588
|
+
|
589
|
+
/**
|
590
|
+
* Add two values, x + y. For matrices, the function is evaluated
|
591
|
+
* element wise.
|
592
|
+
* @param x First value to add
|
593
|
+
* @param y Second value to add
|
594
|
+
* @returns Sum of x and y
|
595
|
+
*/
|
596
|
+
add(x: MathType, y: MathType): MathType;
|
597
|
+
|
598
|
+
/**
|
599
|
+
* Calculate the cubic root of a value. For matrices, the function is
|
600
|
+
* evaluated element wise.
|
601
|
+
* @param x Value for which to calculate the cubic root.
|
602
|
+
* @param allRoots Optional, false by default. Only applicable when x is
|
603
|
+
* a number or complex number. If true, all complex roots are returned,
|
604
|
+
* if false (default) the principal root is returned.
|
605
|
+
* @returns Returns the cubic root of x
|
606
|
+
*/
|
607
|
+
cbrt(x: number, allRoots?: boolean): number;
|
608
|
+
cbrt(x: BigNumber, allRoots?: boolean): BigNumber;
|
609
|
+
cbrt(x: Fraction, allRoots?: boolean): Fraction;
|
610
|
+
cbrt(x: Complex, allRoots?: boolean): Complex;
|
611
|
+
cbrt(x: MathArray, allRoots?: boolean): MathArray;
|
612
|
+
cbrt(x: Matrix, allRoots?: boolean): Matrix;
|
613
|
+
cbrt(x: Unit, allRoots?: boolean): Unit;
|
614
|
+
|
615
|
+
/**
|
616
|
+
* Round a value towards plus infinity If x is complex, both real and
|
617
|
+
* imaginary part are rounded towards plus infinity. For matrices, the
|
618
|
+
* function is evaluated element wise.
|
619
|
+
* @param x Number to be rounded
|
620
|
+
* @returns Rounded value
|
621
|
+
*/
|
622
|
+
ceil(x: number): number;
|
623
|
+
ceil(x: BigNumber): BigNumber;
|
624
|
+
ceil(x: Fraction): Fraction;
|
625
|
+
ceil(x: Complex): Complex;
|
626
|
+
ceil(x: MathArray): MathArray;
|
627
|
+
ceil(x: Matrix): Matrix;
|
628
|
+
ceil(x: Unit): Unit;
|
629
|
+
|
630
|
+
/**
|
631
|
+
* Compute the cube of a value, x * x * x. For matrices, the function is
|
632
|
+
* evaluated element wise.
|
633
|
+
* @param x Number for which to calculate the cube
|
634
|
+
* @returns Cube of x
|
635
|
+
*/
|
636
|
+
cube(x: number): number;
|
637
|
+
cube(x: BigNumber): BigNumber;
|
638
|
+
cube(x: Fraction): Fraction;
|
639
|
+
cube(x: Complex): Complex;
|
640
|
+
cube(x: MathArray): MathArray;
|
641
|
+
cube(x: Matrix): Matrix;
|
642
|
+
cube(x: Unit): Unit;
|
643
|
+
|
644
|
+
/**
|
645
|
+
* Divide two values, x / y. To divide matrices, x is multiplied with
|
646
|
+
* the inverse of y: x * inv(y).
|
647
|
+
* @param x Numerator
|
648
|
+
* @param y Denominator
|
649
|
+
* @returns Quotient, x / y
|
650
|
+
*/
|
651
|
+
divide(x: Unit, y: Unit): Unit | number;
|
652
|
+
divide(x: number, y: number): number;
|
653
|
+
divide(x: MathType, y: MathType): MathType;
|
654
|
+
|
655
|
+
/**
|
656
|
+
* Divide two matrices element wise. The function accepts both matrices
|
657
|
+
* and scalar values.
|
658
|
+
* @param x Numerator
|
659
|
+
* @param y Denominator
|
660
|
+
* @returns Quotient, x ./ y
|
661
|
+
*/
|
662
|
+
dotDivide(x: MathType, y: MathType): MathType;
|
663
|
+
|
664
|
+
/**
|
665
|
+
* Multiply two matrices element wise. The function accepts both
|
666
|
+
* matrices and scalar values.
|
667
|
+
* @param x Left hand value
|
668
|
+
* @param y Right hand value
|
669
|
+
* @returns Multiplication of x and y
|
670
|
+
*/
|
671
|
+
dotMultiply(x: MathType, y: MathType): MathType;
|
672
|
+
|
673
|
+
/**
|
674
|
+
* Calculates the power of x to y element wise.
|
675
|
+
* @param x The base
|
676
|
+
* @param y The exponent
|
677
|
+
* @returns The value of x to the power y
|
678
|
+
*/
|
679
|
+
dotPow(x: MathType, y: MathType): MathType;
|
680
|
+
|
681
|
+
/**
|
682
|
+
* Calculate the exponent of a value. For matrices, the function is
|
683
|
+
* evaluated element wise.
|
684
|
+
* @param x A number or matrix to exponentiate
|
685
|
+
* @returns Exponent of x
|
686
|
+
*/
|
687
|
+
exp(x: number): number;
|
688
|
+
exp(x: BigNumber): BigNumber;
|
689
|
+
exp(x: Complex): Complex;
|
690
|
+
exp(x: MathArray): MathArray;
|
691
|
+
exp(x: Matrix): Matrix;
|
692
|
+
|
693
|
+
/**
|
694
|
+
* Calculate the value of subtracting 1 from the exponential value. For
|
695
|
+
* matrices, the function is evaluated element wise.
|
696
|
+
* @param x A number or matrix to apply expm1
|
697
|
+
* @returns Exponent of x
|
698
|
+
*/
|
699
|
+
expm1(x: number): number;
|
700
|
+
expm1(x: BigNumber): BigNumber;
|
701
|
+
expm1(x: Complex): Complex;
|
702
|
+
expm1(x: MathArray): MathArray;
|
703
|
+
expm1(x: Matrix): Matrix;
|
704
|
+
|
705
|
+
/**
|
706
|
+
* Round a value towards zero. For matrices, the function is evaluated
|
707
|
+
* element wise.
|
708
|
+
* @param x Number to be rounded
|
709
|
+
* @returns Rounded value
|
710
|
+
*/
|
711
|
+
fix(x: number): number;
|
712
|
+
fix(x: BigNumber): BigNumber;
|
713
|
+
fix(x: Fraction): Fraction;
|
714
|
+
fix(x: Complex): Complex;
|
715
|
+
fix(x: MathArray): MathArray;
|
716
|
+
fix(x: Matrix): Matrix;
|
717
|
+
|
718
|
+
/**
|
719
|
+
* Round a value towards minus infinity. For matrices, the function is
|
720
|
+
* evaluated element wise.
|
721
|
+
* @param Number to be rounded
|
722
|
+
* @returns Rounded value
|
723
|
+
*/
|
724
|
+
floor(x: number): number;
|
725
|
+
floor(x: BigNumber): BigNumber;
|
726
|
+
floor(x: Fraction): Fraction;
|
727
|
+
floor(x: Complex): Complex;
|
728
|
+
floor(x: MathArray): MathArray;
|
729
|
+
floor(x: Matrix): Matrix;
|
730
|
+
|
731
|
+
/**
|
732
|
+
* Round a value towards minus infinity. For matrices, the function is
|
733
|
+
* evaluated element wise.
|
734
|
+
* @param x Number to be rounded
|
735
|
+
* @param n Number of decimals Default value: 0.
|
736
|
+
* @returns Rounded value
|
737
|
+
*/
|
738
|
+
floor(
|
739
|
+
x: number | BigNumber | Fraction | Complex | MathArray | Matrix,
|
740
|
+
n: number | BigNumber | MathArray
|
741
|
+
): number | BigNumber | Fraction | Complex | MathArray | Matrix;
|
742
|
+
|
743
|
+
/**
|
744
|
+
* Calculate the greatest common divisor for two or more values or
|
745
|
+
* arrays. For matrices, the function is evaluated element wise.
|
746
|
+
* @param args Two or more integer numbers
|
747
|
+
* @returns The greatest common divisor
|
748
|
+
*/
|
749
|
+
gcd(...args: number[]): number;
|
750
|
+
gcd(...args: BigNumber[]): BigNumber;
|
751
|
+
gcd(...args: Fraction[]): Fraction;
|
752
|
+
gcd(...args: MathArray[]): MathArray;
|
753
|
+
gcd(...args: Matrix[]): Matrix;
|
754
|
+
|
755
|
+
/**
|
756
|
+
* Calculate the hypotenusa of a list with values. The hypotenusa is
|
757
|
+
* defined as: hypot(a, b, c, ...) = sqrt(a^2 + b^2 + c^2 + ...) For
|
758
|
+
* matrix input, the hypotenusa is calculated for all values in the
|
759
|
+
* matrix.
|
760
|
+
* @param args A list with numeric values or an Array or Matrix. Matrix
|
761
|
+
* and Array input is flattened and returns a single number for the
|
762
|
+
* whole matrix.
|
763
|
+
* @returns Returns the hypothenuse of the input values.
|
764
|
+
*/
|
765
|
+
hypot(...args: number[]): number;
|
766
|
+
hypot(...args: BigNumber[]): BigNumber;
|
767
|
+
|
768
|
+
/**
|
769
|
+
* Calculate the least common multiple for two or more values or arrays.
|
770
|
+
* lcm is defined as: lcm(a, b) = abs(a * b) / gcd(a, b) For matrices,
|
771
|
+
* the function is evaluated element wise.
|
772
|
+
* @param a An integer number
|
773
|
+
* @param b An integer number
|
774
|
+
* @returns The least common multiple
|
775
|
+
*/
|
776
|
+
lcm(a: number, b: number): number;
|
777
|
+
lcm(a: BigNumber, b: BigNumber): BigNumber;
|
778
|
+
lcm(a: MathArray, b: MathArray): MathArray;
|
779
|
+
lcm(a: Matrix, b: Matrix): Matrix;
|
780
|
+
|
781
|
+
/**
|
782
|
+
* Calculate the logarithm of a value. For matrices, the function is
|
783
|
+
* evaluated element wise.
|
784
|
+
* @param x Value for which to calculate the logarithm.
|
785
|
+
* @param base Optional base for the logarithm. If not provided, the
|
786
|
+
* natural logarithm of x is calculated. Default value: e.
|
787
|
+
* @returns Returns the logarithm of x
|
788
|
+
*/
|
789
|
+
log<T extends number | BigNumber | Complex | MathArray | Matrix>(x: T, base?: number | BigNumber | Complex): NoLiteralType<T>;
|
790
|
+
|
791
|
+
/**
|
792
|
+
* Calculate the 10-base of a value. This is the same as calculating
|
793
|
+
* log(x, 10). For matrices, the function is evaluated element wise.
|
794
|
+
* @param x Value for which to calculate the logarithm.
|
795
|
+
* @returns Returns the 10-base logarithm of x
|
796
|
+
*/
|
797
|
+
log10(x: number): number;
|
798
|
+
log10(x: BigNumber): BigNumber;
|
799
|
+
log10(x: Complex): Complex;
|
800
|
+
log10(x: MathArray): MathArray;
|
801
|
+
log10(x: Matrix): Matrix;
|
802
|
+
|
803
|
+
/**
|
804
|
+
* Calculate the logarithm of a value+1. For matrices, the function is
|
805
|
+
* evaluated element wise.
|
806
|
+
* @param x Value for which to calculate the logarithm.
|
807
|
+
* @returns Returns the logarithm of x+1
|
808
|
+
*/
|
809
|
+
log1p(x: number, base?: number | BigNumber | Complex): number;
|
810
|
+
log1p(x: BigNumber, base?: number | BigNumber | Complex): BigNumber;
|
811
|
+
log1p(x: Complex, base?: number | BigNumber | Complex): Complex;
|
812
|
+
log1p(x: MathArray, base?: number | BigNumber | Complex): MathArray;
|
813
|
+
log1p(x: Matrix, base?: number | BigNumber | Complex): Matrix;
|
814
|
+
|
815
|
+
/**
|
816
|
+
* Calculate the 2-base of a value. This is the same as calculating
|
817
|
+
* log(x, 2). For matrices, the function is evaluated element wise.
|
818
|
+
* @param x Value for which to calculate the logarithm.
|
819
|
+
* @returns Returns the 2-base logarithm of x
|
820
|
+
*/
|
821
|
+
log2(x: number): number;
|
822
|
+
log2(x: BigNumber): BigNumber;
|
823
|
+
log2(x: Complex): Complex;
|
824
|
+
log2(x: MathArray): MathArray;
|
825
|
+
log2(x: Matrix): Matrix;
|
826
|
+
|
827
|
+
/**
|
828
|
+
* Calculates the modulus, the remainder of an integer division. For
|
829
|
+
* matrices, the function is evaluated element wise. The modulus is
|
830
|
+
* defined as: x - y * floor(x / y)
|
831
|
+
* @see http://en.wikipedia.org/wiki/Modulo_operation.
|
832
|
+
* @param x Dividend
|
833
|
+
* @param y Divisor
|
834
|
+
* @returns Returns the remainder of x divided by y
|
835
|
+
*/
|
836
|
+
mod<T extends number | BigNumber | Fraction | MathArray | Matrix>(
|
837
|
+
x: T,
|
838
|
+
y: number | BigNumber | Fraction | MathArray | Matrix
|
839
|
+
): NoLiteralType<T>;
|
840
|
+
|
841
|
+
/**
|
842
|
+
* Multiply two values, x * y. The result is squeezed. For matrices, the
|
843
|
+
* matrix product is calculated.
|
844
|
+
* @param x The first value to multiply
|
845
|
+
* @param y The second value to multiply
|
846
|
+
* @returns Multiplication of x and y
|
847
|
+
*/
|
848
|
+
multiply<T extends Matrix | MathArray>(x: T, y: MathType): T;
|
849
|
+
multiply(x: Unit, y: Unit): Unit;
|
850
|
+
multiply(x: number, y: number): number;
|
851
|
+
multiply(x: MathType, y: MathType): MathType;
|
852
|
+
|
853
|
+
/**
|
854
|
+
* Calculate the norm of a number, vector or matrix. The second
|
855
|
+
* parameter p is optional. If not provided, it defaults to 2.
|
856
|
+
* @param x Value for which to calculate the norm
|
857
|
+
* @param p Vector space. Supported numbers include Infinity and
|
858
|
+
* -Infinity. Supported strings are: 'inf', '-inf', and 'fro' (The
|
859
|
+
* Frobenius norm) Default value: 2.
|
860
|
+
* @returns the p-norm
|
861
|
+
*/
|
862
|
+
norm(x: number | BigNumber | Complex | MathArray | Matrix, p?: number | BigNumber | string): number | BigNumber;
|
863
|
+
|
864
|
+
/**
|
865
|
+
* Calculate the nth root of a value. The principal nth root of a
|
866
|
+
* positive real number A, is the positive real solution of the equation
|
867
|
+
* x^root = A For matrices, the function is evaluated element wise.
|
868
|
+
* @param a Value for which to calculate the nth root
|
869
|
+
* @param root The root. Default value: 2.
|
870
|
+
* @return The nth root of a
|
871
|
+
*/
|
872
|
+
nthRoot(a: number | BigNumber | MathArray | Matrix | Complex, root?: number | BigNumber): number | Complex | MathArray | Matrix;
|
873
|
+
|
874
|
+
/**
|
875
|
+
* Calculates the power of x to y, x ^ y. Matrix exponentiation is
|
876
|
+
* supported for square matrices x, and positive integer exponents y.
|
877
|
+
* @param x The base
|
878
|
+
* @param y The exponent
|
879
|
+
* @returns x to the power y
|
880
|
+
*/
|
881
|
+
pow(x: MathType, y: number | BigNumber | Complex): MathType;
|
882
|
+
|
883
|
+
/**
|
884
|
+
* Round a value towards the nearest integer. For matrices, the function
|
885
|
+
* is evaluated element wise.
|
886
|
+
* @param x Number to be rounded
|
887
|
+
* @param n Number of decimals Default value: 0.
|
888
|
+
* @returns Rounded value of x
|
889
|
+
*/
|
890
|
+
round<T extends number | BigNumber | Fraction | Complex | MathArray | Matrix>(
|
891
|
+
x: T,
|
892
|
+
n?: number | BigNumber | MathArray
|
893
|
+
): NoLiteralType<T>;
|
894
|
+
|
895
|
+
/**
|
896
|
+
* Compute the sign of a value. The sign of a value x is: 1 when x > 1
|
897
|
+
* -1 when x < 0 0 when x == 0 For matrices, the function is evaluated
|
898
|
+
* element wise.
|
899
|
+
* @param x The number for which to determine the sign
|
900
|
+
* @returns The sign of x
|
901
|
+
*/
|
902
|
+
sign(x: number): number;
|
903
|
+
sign(x: BigNumber): BigNumber;
|
904
|
+
sign(x: Fraction): Fraction;
|
905
|
+
sign(x: Complex): Complex;
|
906
|
+
sign(x: MathArray): MathArray;
|
907
|
+
sign(x: Matrix): Matrix;
|
908
|
+
sign(x: Unit): Unit;
|
909
|
+
|
910
|
+
/**
|
911
|
+
* Calculate the square root of a value. For matrices, the function is
|
912
|
+
* evaluated element wise.
|
913
|
+
* @param x Value for which to calculate the square root
|
914
|
+
* @returns Returns the square root of x
|
915
|
+
*/
|
916
|
+
sqrt(x: number): number;
|
917
|
+
sqrt(x: BigNumber): BigNumber;
|
918
|
+
sqrt(x: Complex): Complex;
|
919
|
+
sqrt(x: MathArray): MathArray;
|
920
|
+
sqrt(x: Matrix): Matrix;
|
921
|
+
sqrt(x: Unit): Unit;
|
922
|
+
|
923
|
+
/**
|
924
|
+
* Compute the square of a value, x * x. For matrices, the function is
|
925
|
+
* evaluated element wise.
|
926
|
+
* @param x Number for which to calculate the square
|
927
|
+
* @returns Squared value
|
928
|
+
*/
|
929
|
+
square(x: number): number;
|
930
|
+
square(x: BigNumber): BigNumber;
|
931
|
+
square(x: Fraction): Fraction;
|
932
|
+
square(x: Complex): Complex;
|
933
|
+
square(x: MathArray): MathArray;
|
934
|
+
square(x: Matrix): Matrix;
|
935
|
+
square(x: Unit): Unit;
|
936
|
+
|
937
|
+
/**
|
938
|
+
* Subtract two values, x - y. For matrices, the function is evaluated
|
939
|
+
* element wise.
|
940
|
+
* @param x Initial value
|
941
|
+
* @param y Value to subtract from x
|
942
|
+
* @returns Subtraction of x and y
|
943
|
+
*/
|
944
|
+
subtract(x: MathType, y: MathType): MathType;
|
945
|
+
|
946
|
+
/**
|
947
|
+
* Inverse the sign of a value, apply a unary minus operation. For
|
948
|
+
* matrices, the function is evaluated element wise. Boolean values and
|
949
|
+
* strings will be converted to a number. For complex numbers, both real
|
950
|
+
* and complex value are inverted.
|
951
|
+
* @param x Number to be inverted
|
952
|
+
* @returns Retursn the value with inverted sign
|
953
|
+
*/
|
954
|
+
unaryMinus(x: number): number;
|
955
|
+
unaryMinus(x: BigNumber): BigNumber;
|
956
|
+
unaryMinus(x: Fraction): Fraction;
|
957
|
+
unaryMinus(x: Complex): Complex;
|
958
|
+
unaryMinus(x: MathArray): MathArray;
|
959
|
+
unaryMinus(x: Matrix): Matrix;
|
960
|
+
unaryMinus(x: Unit): Unit;
|
961
|
+
|
962
|
+
/**
|
963
|
+
* Unary plus operation. Boolean values and strings will be converted to
|
964
|
+
* a number, numeric values will be returned as is. For matrices, the
|
965
|
+
* function is evaluated element wise.
|
966
|
+
* @param x Input value
|
967
|
+
* @returns Returns the input value when numeric, converts to a number
|
968
|
+
* when input is non-numeric.
|
969
|
+
*/
|
970
|
+
unaryPlus(x: number): number;
|
971
|
+
unaryPlus(x: BigNumber): BigNumber;
|
972
|
+
unaryPlus(x: Fraction): Fraction;
|
973
|
+
unaryPlus(x: string): string;
|
974
|
+
unaryPlus(x: Complex): Complex;
|
975
|
+
unaryPlus(x: MathArray): MathArray;
|
976
|
+
unaryPlus(x: Matrix): Matrix;
|
977
|
+
unaryPlus(x: Unit): Unit;
|
978
|
+
|
979
|
+
/**
|
980
|
+
* Calculate the extended greatest common divisor for two values. See
|
981
|
+
* http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm.
|
982
|
+
* @param a An integer number
|
983
|
+
* @param b An integer number
|
984
|
+
* @returns Returns an array containing 3 integers [div, m, n] where div
|
985
|
+
* = gcd(a, b) and a*m + b*n = div
|
986
|
+
*/
|
987
|
+
xgcd(a: number | BigNumber, b: number | BigNumber): MathArray;
|
988
|
+
|
989
|
+
/*************************************************************************
|
990
|
+
* Bitwise functions
|
991
|
+
************************************************************************/
|
992
|
+
|
993
|
+
/**
|
994
|
+
* Bitwise AND two values, x & y. For matrices, the function is
|
995
|
+
* evaluated element wise.
|
996
|
+
* @param x First value to and
|
997
|
+
* @param y Second value to and
|
998
|
+
* @returns AND of x and y
|
999
|
+
*/
|
1000
|
+
bitAnd<T extends number | BigNumber | MathArray | Matrix>(x: T, y: number | BigNumber | MathArray | Matrix): NoLiteralType<T>;
|
1001
|
+
|
1002
|
+
/**
|
1003
|
+
* Bitwise NOT value, ~x. For matrices, the function is evaluated
|
1004
|
+
* element wise. For units, the function is evaluated on the best prefix
|
1005
|
+
* base.
|
1006
|
+
* @param x Value to not
|
1007
|
+
* @returns NOT of x
|
1008
|
+
*/
|
1009
|
+
bitNot(x: number): number;
|
1010
|
+
bitNot(x: BigNumber): BigNumber;
|
1011
|
+
bitNot(x: MathArray): MathArray;
|
1012
|
+
bitNot(x: Matrix): Matrix;
|
1013
|
+
|
1014
|
+
/**
|
1015
|
+
* Bitwise OR two values, x | y. For matrices, the function is evaluated
|
1016
|
+
* element wise. For units, the function is evaluated on the lowest
|
1017
|
+
* print base.
|
1018
|
+
* @param x First value to or
|
1019
|
+
* @param y Second value to or
|
1020
|
+
* @returns OR of x and y
|
1021
|
+
*/
|
1022
|
+
bitOr(x: number, y: number): number;
|
1023
|
+
bitOr(x: BigNumber, y: BigNumber): BigNumber;
|
1024
|
+
bitOr(x: MathArray, y: MathArray): MathArray;
|
1025
|
+
bitOr(x: Matrix, y: Matrix): Matrix;
|
1026
|
+
|
1027
|
+
/**
|
1028
|
+
* Bitwise XOR two values, x ^ y. For matrices, the function is
|
1029
|
+
* evaluated element wise.
|
1030
|
+
* @param x First value to xor
|
1031
|
+
* @param y Second value to xor
|
1032
|
+
* @returns XOR of x and y
|
1033
|
+
*/
|
1034
|
+
bitXor<T extends number | BigNumber | MathArray | Matrix>(x: T, y: number | BigNumber | MathArray | Matrix): NoLiteralType<T>;
|
1035
|
+
|
1036
|
+
/**
|
1037
|
+
* Bitwise left logical shift of a value x by y number of bits, x << y.
|
1038
|
+
* For matrices, the function is evaluated element wise. For units, the
|
1039
|
+
* function is evaluated on the best prefix base.
|
1040
|
+
* @param x Value to be shifted
|
1041
|
+
* @param y Amount of shifts
|
1042
|
+
* @returns x shifted left y times
|
1043
|
+
*/
|
1044
|
+
leftShift<T extends number | BigNumber | MathArray | Matrix>(x: T, y: number | BigNumber): NoLiteralType<T>;
|
1045
|
+
|
1046
|
+
/**
|
1047
|
+
* Bitwise right arithmetic shift of a value x by y number of bits, x >>
|
1048
|
+
* y. For matrices, the function is evaluated element wise. For units,
|
1049
|
+
* the function is evaluated on the best prefix base.
|
1050
|
+
* @param x Value to be shifted
|
1051
|
+
* @param y Amount of shifts
|
1052
|
+
* @returns x sign-filled shifted right y times
|
1053
|
+
*/
|
1054
|
+
rightArithShift<T extends number | BigNumber | MathArray | Matrix>(x: T, y: number | BigNumber): NoLiteralType<T>;
|
1055
|
+
|
1056
|
+
/**
|
1057
|
+
* Bitwise right logical shift of value x by y number of bits, x >>> y.
|
1058
|
+
* For matrices, the function is evaluated element wise. For units, the
|
1059
|
+
* function is evaluated on the best prefix base.
|
1060
|
+
* @param x Value to be shifted
|
1061
|
+
* @param y Amount of shifts
|
1062
|
+
* @returns x zero-filled shifted right y times
|
1063
|
+
*/
|
1064
|
+
rightLogShift<T extends number | MathArray | Matrix>(x: T, y: number): NoLiteralType<T>;
|
1065
|
+
|
1066
|
+
/*************************************************************************
|
1067
|
+
* Combinatorics functions
|
1068
|
+
************************************************************************/
|
1069
|
+
|
1070
|
+
/**
|
1071
|
+
* The Bell Numbers count the number of partitions of a set. A partition
|
1072
|
+
* is a pairwise disjoint subset of S whose union is S. bellNumbers only
|
1073
|
+
* takes integer arguments. The following condition must be enforced: n
|
1074
|
+
* >= 0
|
1075
|
+
* @param n Total number of objects in the set
|
1076
|
+
* @returns B(n)
|
1077
|
+
*/
|
1078
|
+
bellNumbers(n: number): number;
|
1079
|
+
bellNumbers(n: BigNumber): BigNumber;
|
1080
|
+
|
1081
|
+
/**
|
1082
|
+
* The Catalan Numbers enumerate combinatorial structures of many
|
1083
|
+
* different types. catalan only takes integer arguments. The following
|
1084
|
+
* condition must be enforced: n >= 0
|
1085
|
+
* @param n nth Catalan number
|
1086
|
+
* @returns Cn(n)
|
1087
|
+
*/
|
1088
|
+
catalan(n: number): number;
|
1089
|
+
catalan(n: BigNumber): BigNumber;
|
1090
|
+
|
1091
|
+
/**
|
1092
|
+
* The composition counts of n into k parts. Composition only takes
|
1093
|
+
* integer arguments. The following condition must be enforced: k <= n.
|
1094
|
+
* @param n Total number of objects in the set
|
1095
|
+
* @param k Number of objects in the subset
|
1096
|
+
* @returns Returns the composition counts of n into k parts.
|
1097
|
+
*/
|
1098
|
+
composition<T extends number | BigNumber>(n: T, k: number | BigNumber): NoLiteralType<T>;
|
1099
|
+
|
1100
|
+
/**
|
1101
|
+
* The Stirling numbers of the second kind, counts the number of ways to
|
1102
|
+
* partition a set of n labelled objects into k nonempty unlabelled
|
1103
|
+
* subsets. stirlingS2 only takes integer arguments. The following
|
1104
|
+
* condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) =
|
1105
|
+
* 1
|
1106
|
+
* @param n Total number of objects in the set
|
1107
|
+
* @param k Number of objects in the subset
|
1108
|
+
* @returns S(n,k)
|
1109
|
+
*/
|
1110
|
+
stirlingS2<T extends number | BigNumber>(n: T, k: number | BigNumber): NoLiteralType<T>;
|
1111
|
+
|
1112
|
+
/*************************************************************************
|
1113
|
+
* Complex functions
|
1114
|
+
************************************************************************/
|
1115
|
+
|
1116
|
+
/**
|
1117
|
+
* Compute the argument of a complex value. For a complex number a + bi,
|
1118
|
+
* the argument is computed as atan2(b, a). For matrices, the function
|
1119
|
+
* is evaluated element wise.
|
1120
|
+
* @param x A complex number or array with complex numbers
|
1121
|
+
* @returns The argument of x
|
1122
|
+
*/
|
1123
|
+
arg(x: number | Complex): number;
|
1124
|
+
arg(x: BigNumber | Complex): BigNumber;
|
1125
|
+
arg(x: MathArray): MathArray;
|
1126
|
+
arg(x: Matrix): Matrix;
|
1127
|
+
|
1128
|
+
/**
|
1129
|
+
* Compute the complex conjugate of a complex value. If x = a+bi, the
|
1130
|
+
* complex conjugate of x is a - bi. For matrices, the function is
|
1131
|
+
* evaluated element wise.
|
1132
|
+
* @param x A complex number or array with complex numbers
|
1133
|
+
* @returns The complex conjugate of x
|
1134
|
+
*/
|
1135
|
+
conj<T extends number | BigNumber | Complex | MathArray | Matrix>(x: T): NoLiteralType<T>;
|
1136
|
+
|
1137
|
+
/**
|
1138
|
+
* Get the imaginary part of a complex number. For a complex number a +
|
1139
|
+
* bi, the function returns b. For matrices, the function is evaluated
|
1140
|
+
* element wise.
|
1141
|
+
* @param x A complex number or array with complex numbers
|
1142
|
+
* @returns The imaginary part of x
|
1143
|
+
*/
|
1144
|
+
im(x: number | BigNumber | Complex | MathArray | Matrix): number | BigNumber | MathArray | Matrix;
|
1145
|
+
|
1146
|
+
/**
|
1147
|
+
* Get the real part of a complex number. For a complex number a + bi,
|
1148
|
+
* the function returns a. For matrices, the function is evaluated
|
1149
|
+
* element wise.
|
1150
|
+
* @param x A complex number or array of complex numbers
|
1151
|
+
* @returns The real part of x
|
1152
|
+
*/
|
1153
|
+
re(x: number | BigNumber | Complex | MathArray | Matrix): number | BigNumber | MathArray | Matrix;
|
1154
|
+
|
1155
|
+
/*************************************************************************
|
1156
|
+
* Geometry functions
|
1157
|
+
************************************************************************/
|
1158
|
+
|
1159
|
+
/**
|
1160
|
+
* Calculates: The eucledian distance between two points in 2 and 3
|
1161
|
+
* dimensional spaces. Distance between point and a line in 2 and 3
|
1162
|
+
* dimensional spaces. Pairwise distance between a set of 2D or 3D
|
1163
|
+
* points NOTE: When substituting coefficients of a line(a, b and c),
|
1164
|
+
* use ax + by + c = 0 instead of ax + by = c For parametric equation of
|
1165
|
+
* a 3D line, x0, y0, z0, a, b, c are from: (x−x0, y−y0, z−z0) = t(a, b,
|
1166
|
+
* c)
|
1167
|
+
* @param x Coordinates of the first point
|
1168
|
+
* @param y Coordinates of the second point
|
1169
|
+
* @returns Returns the distance from two/three points
|
1170
|
+
*/
|
1171
|
+
distance(x: MathArray | Matrix | object, y: MathArray | Matrix | object): number | BigNumber;
|
1172
|
+
|
1173
|
+
/**
|
1174
|
+
* Calculates the point of intersection of two lines in two or three
|
1175
|
+
* dimensions and of a line and a plane in three dimensions. The inputs
|
1176
|
+
* are in the form of arrays or 1 dimensional matrices. The line
|
1177
|
+
* intersection functions return null if the lines do not meet. Note:
|
1178
|
+
* Fill the plane coefficients as x + y + z = c and not as x + y + z + c
|
1179
|
+
* = 0.
|
1180
|
+
* @param w Co-ordinates of first end-point of first line
|
1181
|
+
* @param x Co-ordinates of second end-point of first line
|
1182
|
+
* @param y Co-ordinates of first end-point of second line OR
|
1183
|
+
* Coefficients of the plane's equation
|
1184
|
+
* @param z Co-ordinates of second end-point of second line OR null if
|
1185
|
+
* the calculation is for line and plane
|
1186
|
+
* @returns Returns the point of intersection of lines/lines-planes
|
1187
|
+
*/
|
1188
|
+
intersect(w: MathArray | Matrix, x: MathArray | Matrix, y: MathArray | Matrix, z: MathArray | Matrix): MathArray;
|
1189
|
+
|
1190
|
+
/*************************************************************************
|
1191
|
+
* Logical functions
|
1192
|
+
************************************************************************/
|
1193
|
+
|
1194
|
+
/**
|
1195
|
+
* Logical and. Test whether two values are both defined with a
|
1196
|
+
* nonzero/nonempty value. For matrices, the function is evaluated
|
1197
|
+
* element wise.
|
1198
|
+
* @param x First value to and
|
1199
|
+
* @param y Second value to and
|
1200
|
+
* @returns Returns true when both inputs are defined with a
|
1201
|
+
* nonzero/nonempty value.
|
1202
|
+
*/
|
1203
|
+
and(
|
1204
|
+
x: number | BigNumber | Complex | Unit | MathArray | Matrix,
|
1205
|
+
y: number | BigNumber | Complex | Unit | MathArray | Matrix
|
1206
|
+
): boolean | MathArray | Matrix;
|
1207
|
+
|
1208
|
+
/**
|
1209
|
+
* Logical not. Flips boolean value of a given parameter. For matrices,
|
1210
|
+
* the function is evaluated element wise.
|
1211
|
+
* @param x First value to not
|
1212
|
+
* @returns Returns true when input is a zero or empty value.
|
1213
|
+
*/
|
1214
|
+
not(x: number | BigNumber | Complex | Unit | MathArray | Matrix): boolean | MathArray | Matrix;
|
1215
|
+
|
1216
|
+
/**
|
1217
|
+
* Logical or. Test if at least one value is defined with a
|
1218
|
+
* nonzero/nonempty value. For matrices, the function is evaluated
|
1219
|
+
* element wise.
|
1220
|
+
* @param x First value to or
|
1221
|
+
* @param y Second value to or
|
1222
|
+
* @returns Returns true when one of the inputs is defined with a
|
1223
|
+
* nonzero/nonempty value.
|
1224
|
+
*/
|
1225
|
+
or(
|
1226
|
+
x: number | BigNumber | Complex | Unit | MathArray | Matrix,
|
1227
|
+
y: number | BigNumber | Complex | Unit | MathArray | Matrix
|
1228
|
+
): boolean | MathArray | Matrix;
|
1229
|
+
|
1230
|
+
/**
|
1231
|
+
* Logical xor. Test whether one and only one value is defined with a
|
1232
|
+
* nonzero/nonempty value. For matrices, the function is evaluated
|
1233
|
+
* element wise.
|
1234
|
+
* @param x First value to xor
|
1235
|
+
* @param y Second value to xor
|
1236
|
+
* @returns Returns true when one and only one input is defined with a
|
1237
|
+
* nonzero/nonempty value.
|
1238
|
+
*/
|
1239
|
+
xor(
|
1240
|
+
x: number | BigNumber | Complex | Unit | MathArray | Matrix,
|
1241
|
+
y: number | BigNumber | Complex | Unit | MathArray | Matrix
|
1242
|
+
): boolean | MathArray | Matrix;
|
1243
|
+
|
1244
|
+
/*************************************************************************
|
1245
|
+
* Matrix functions
|
1246
|
+
************************************************************************/
|
1247
|
+
|
1248
|
+
/**
|
1249
|
+
* Concatenate two or more matrices. dim: number is a zero-based
|
1250
|
+
* dimension over which to concatenate the matrices. By default the last
|
1251
|
+
* dimension of the matrices.
|
1252
|
+
* @param args Two or more matrices
|
1253
|
+
* @returns Concatenated matrix
|
1254
|
+
*/
|
1255
|
+
concat(...args: Array<MathArray | Matrix | number | BigNumber>): MathArray | Matrix;
|
1256
|
+
|
1257
|
+
/**
|
1258
|
+
* Calculate the cross product for two vectors in three dimensional
|
1259
|
+
* space. The cross product of A = [a1, a2, a3] and B =[b1, b2, b3] is
|
1260
|
+
* defined as: cross(A, B) = [ a2 * b3 - a3 * b2, a3 * b1 - a1 * b3, a1
|
1261
|
+
* * b2 - a2 * b1 ]
|
1262
|
+
* @param x First vector
|
1263
|
+
* @param y Second vector
|
1264
|
+
* @returns Returns the cross product of x and y
|
1265
|
+
*/
|
1266
|
+
cross(x: MathArray | Matrix, y: MathArray | Matrix): Matrix | MathArray;
|
1267
|
+
|
1268
|
+
/**
|
1269
|
+
* Calculate the determinant of a matrix.
|
1270
|
+
* @param x A Matrix
|
1271
|
+
* @returns the determinant of x
|
1272
|
+
*/
|
1273
|
+
det(x: MathArray | Matrix): number;
|
1274
|
+
|
1275
|
+
/**
|
1276
|
+
* Create a diagonal matrix or retrieve the diagonal of a matrix. When x
|
1277
|
+
* is a vector, a matrix with vector x on the diagonal will be returned.
|
1278
|
+
* When x is a two dimensional matrix, the matrixes kth diagonal will be
|
1279
|
+
* returned as vector. When k is positive, the values are placed on the
|
1280
|
+
* super diagonal. When k is negative, the values are placed on the sub
|
1281
|
+
* diagonal.
|
1282
|
+
* @param X A two dimensional matrix or a vector
|
1283
|
+
* @param k The diagonal where the vector will be filled in or
|
1284
|
+
* retrieved. Default value: 0.
|
1285
|
+
* @param format The matrix storage format. Default value: 'dense'.
|
1286
|
+
* @returns Diagonal matrix from input vector, or diagonal from input
|
1287
|
+
* matrix
|
1288
|
+
*/
|
1289
|
+
diag(X: MathArray | Matrix, format?: string): Matrix;
|
1290
|
+
diag(X: MathArray | Matrix, k: number | BigNumber, format?: string): Matrix | MathArray;
|
1291
|
+
|
1292
|
+
/**
|
1293
|
+
* Calculate the dot product of two vectors. The dot product of A = [a1,
|
1294
|
+
* a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as: dot(A,
|
1295
|
+
* B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn
|
1296
|
+
* @param x First vector
|
1297
|
+
* @param y Second vector
|
1298
|
+
* @returns Returns the dot product of x and y
|
1299
|
+
*/
|
1300
|
+
dot(x: MathArray | Matrix, y: MathArray | Matrix): number;
|
1301
|
+
|
1302
|
+
/**
|
1303
|
+
* Compute eigenvalues and eigenvectors of a matrix.
|
1304
|
+
* The eigenvalues are sorted by their absolute value, ascending.
|
1305
|
+
* An eigenvalue with multiplicity k will be listed k times.
|
1306
|
+
* The eigenvectors are returned as columns of a matrix – the eigenvector
|
1307
|
+
* that belongs to the j-th eigenvalue in the list (eg. values[j]) is the
|
1308
|
+
* j-th column (eg. column(vectors, j)). If the algorithm fails to converge,
|
1309
|
+
* it will throw an error – in that case, however, you may still find useful
|
1310
|
+
* information in err.values and err.vectors
|
1311
|
+
* @param x Matrix to be diagonalized
|
1312
|
+
* @param prec Precision, default value: 1e-15
|
1313
|
+
* @returns Object containing an array of eigenvalues and a matrix with eigenvectors as columns.
|
1314
|
+
*/
|
1315
|
+
eigs(x: MathArray | Matrix, prec?:number|BigNumber): {values: MathArray | Matrix, vectors: MathArray | Matrix}
|
1316
|
+
|
1317
|
+
/**
|
1318
|
+
* Compute the matrix exponential, expm(A) = e^A. The matrix must be
|
1319
|
+
* square. Not to be confused with exp(a), which performs element-wise
|
1320
|
+
* exponentiation. The exponential is calculated using the Padé
|
1321
|
+
* approximant with scaling and squaring; see “Nineteen Dubious Ways to
|
1322
|
+
* Compute the Exponential of a Matrix,” by Moler and Van Loan.
|
1323
|
+
* @param x A square matrix
|
1324
|
+
* @returns The exponential of x
|
1325
|
+
*/
|
1326
|
+
expm(x: Matrix): Matrix;
|
1327
|
+
|
1328
|
+
/**
|
1329
|
+
* Create a 2-dimensional identity matrix with size m x n or n x n. The
|
1330
|
+
* matrix has ones on the diagonal and zeros elsewhere.
|
1331
|
+
* @param size The size for the matrix
|
1332
|
+
* @param format The Matrix storage format
|
1333
|
+
* @returns A matrix with ones on the diagonal
|
1334
|
+
*/
|
1335
|
+
identity(size: number | number[] | Matrix | MathArray, format?: string): Matrix | MathArray | number;
|
1336
|
+
/**
|
1337
|
+
* @param m The x dimension for the matrix
|
1338
|
+
* @param n The y dimension for the matrix
|
1339
|
+
* @param format The Matrix storage format
|
1340
|
+
* @returns A matrix with ones on the diagonal
|
1341
|
+
*/
|
1342
|
+
identity(m: number, n: number, format?: string): Matrix | MathArray | number;
|
1343
|
+
|
1344
|
+
/**
|
1345
|
+
* Filter the items in an array or one dimensional matrix.
|
1346
|
+
* @param x A one dimensional matrix or array to filter
|
1347
|
+
* @param test A function or regular expression to test items. All
|
1348
|
+
* entries for which test returns true are returned. When test is a
|
1349
|
+
* function, it is invoked with three parameters: the value of the
|
1350
|
+
* element, the index of the element, and the matrix/array being
|
1351
|
+
* traversed. The function must return a boolean.
|
1352
|
+
*/
|
1353
|
+
filter(
|
1354
|
+
x: Matrix | MathArray | string[],
|
1355
|
+
test: ((value: any, index: any, matrix: Matrix | MathArray | string[]) => boolean) | RegExp
|
1356
|
+
): Matrix | MathArray;
|
1357
|
+
|
1358
|
+
/**
|
1359
|
+
* Flatten a multi dimensional matrix into a single dimensional matrix.
|
1360
|
+
* @param x Matrix to be flattened
|
1361
|
+
* @returns Returns the flattened matrix
|
1362
|
+
*/
|
1363
|
+
flatten<T extends MathArray | Matrix>(x: T): T;
|
1364
|
+
|
1365
|
+
/**
|
1366
|
+
* Iterate over all elements of a matrix/array, and executes the given
|
1367
|
+
* callback function.
|
1368
|
+
* @param x The matrix to iterate on.
|
1369
|
+
* @param callback The callback function is invoked with three
|
1370
|
+
* parameters: the value of the element, the index of the element, and
|
1371
|
+
* the Matrix/array being traversed.
|
1372
|
+
*/
|
1373
|
+
forEach<T extends Matrix | MathArray>(x: T, callback: (value: any, index: any, matrix: T) => void): void;
|
1374
|
+
|
1375
|
+
/**
|
1376
|
+
* Calculate the inverse of a square matrix.
|
1377
|
+
* @param x Matrix to be inversed
|
1378
|
+
* @returns The inverse of x
|
1379
|
+
*/
|
1380
|
+
inv<T extends number | Complex | MathArray | Matrix>(x: T): NoLiteralType<T>;
|
1381
|
+
|
1382
|
+
/**
|
1383
|
+
* Calculate the kronecker product of two matrices or vectors
|
1384
|
+
* @param x First vector
|
1385
|
+
* @param y Second vector
|
1386
|
+
* @returns Returns the kronecker product of x and y
|
1387
|
+
*/
|
1388
|
+
kron(x: Matrix | MathArray, y: Matrix | MathArray): Matrix;
|
1389
|
+
|
1390
|
+
/**
|
1391
|
+
* Iterate over all elements of a matrix/array, and executes the given
|
1392
|
+
* callback function.
|
1393
|
+
* @param x The matrix to iterate on.
|
1394
|
+
* @param callback The callback function is invoked with three
|
1395
|
+
* parameters: the value of the element, the index of the element, and
|
1396
|
+
* the Matrix/array being traversed.
|
1397
|
+
* @returns Transformed map of x
|
1398
|
+
*/
|
1399
|
+
map<T extends Matrix | MathArray>(x: T, callback: (value: any, index: any, matrix: T) => MathType | string): T;
|
1400
|
+
|
1401
|
+
/**
|
1402
|
+
* Create a matrix filled with ones. The created matrix can have one or
|
1403
|
+
* multiple dimensions.
|
1404
|
+
* @param size The size of each dimension of the matrix
|
1405
|
+
* @param format The matrix storage format
|
1406
|
+
* @returns A matrix filled with ones
|
1407
|
+
*/
|
1408
|
+
ones(size: number | number[], format?: string): MathArray | Matrix;
|
1409
|
+
/**
|
1410
|
+
* @param m The x dimension of the matrix
|
1411
|
+
* @param n The y dimension of the amtrix
|
1412
|
+
* @param format The matrix storage format
|
1413
|
+
* @returns A matrix filled with ones
|
1414
|
+
*/
|
1415
|
+
ones(m: number, n: number, format?: string): MathArray | Matrix;
|
1416
|
+
|
1417
|
+
/**
|
1418
|
+
* Partition-based selection of an array or 1D matrix. Will find the kth
|
1419
|
+
* smallest value, and mutates the input array. Uses Quickselect.
|
1420
|
+
* @param x A one dimensional matrix or array to sort
|
1421
|
+
* @param k The kth smallest value to be retrieved; zero-based index
|
1422
|
+
* @param compare An optional comparator function. The function is
|
1423
|
+
* called as compare(a, b), and must return 1 when a > b, -1 when a < b,
|
1424
|
+
* and 0 when a == b. Default value: 'asc'.
|
1425
|
+
* @returns Returns the kth lowest value.
|
1426
|
+
*/
|
1427
|
+
partitionSelect(x: MathArray | Matrix, k: number, compare?: 'asc' | 'desc' | ((a: any, b: any) => number)): any;
|
1428
|
+
|
1429
|
+
/**
|
1430
|
+
* Create an array from a range. By default, the range end is excluded.
|
1431
|
+
* This can be customized by providing an extra parameter includeEnd.
|
1432
|
+
* @param str A string 'start:end' or 'start:step:end'
|
1433
|
+
* @param start Start of the range
|
1434
|
+
* @param end End of the range, excluded by default, included when
|
1435
|
+
* parameter includeEnd=true
|
1436
|
+
* @param step Step size. Default value is 1.
|
1437
|
+
* @param includeEnd: Option to specify whether to include the end or
|
1438
|
+
* not. False by default
|
1439
|
+
* @returns Parameters describing the ranges start, end, and optional
|
1440
|
+
* step.
|
1441
|
+
*/
|
1442
|
+
range(str: string, includeEnd?: boolean): Matrix;
|
1443
|
+
range(start: number | BigNumber, end: number | BigNumber, includeEnd?: boolean): Matrix;
|
1444
|
+
range(start: number | BigNumber, end: number | BigNumber, step: number | BigNumber, includeEnd?: boolean): Matrix;
|
1445
|
+
|
1446
|
+
/**
|
1447
|
+
* Reshape a multi dimensional array to fit the specified dimensions
|
1448
|
+
* @param x Matrix to be reshaped
|
1449
|
+
* @param sizes One dimensional array with integral sizes for each
|
1450
|
+
* dimension
|
1451
|
+
* @returns A reshaped clone of matrix x
|
1452
|
+
*/
|
1453
|
+
reshape<T extends MathArray | Matrix>(x: T, sizes: number[]): T;
|
1454
|
+
|
1455
|
+
/**
|
1456
|
+
* Resize a matrix
|
1457
|
+
* @param x Matrix to be resized
|
1458
|
+
* @param size One dimensional array with numbers
|
1459
|
+
* @param defaultValue Zero by default, except in case of a string, in
|
1460
|
+
* that case defaultValue = ' ' Default value: 0.
|
1461
|
+
* @returns A resized clone of matrix x
|
1462
|
+
*/
|
1463
|
+
resize<T extends MathArray | Matrix>(x: T, size: MathArray | Matrix, defaultValue?: number | string): T;
|
1464
|
+
|
1465
|
+
/**
|
1466
|
+
* Return a row from a Matrix.
|
1467
|
+
* @param value An array or matrix
|
1468
|
+
* @param row The index of the row
|
1469
|
+
* @returns The retrieved row
|
1470
|
+
*/
|
1471
|
+
row<T extends MathArray | Matrix>(
|
1472
|
+
value: T,
|
1473
|
+
row: number
|
1474
|
+
): T;
|
1475
|
+
|
1476
|
+
/**
|
1477
|
+
* Return a column from a Matrix.
|
1478
|
+
* @param value An array or matrix
|
1479
|
+
* @param column The index of the column
|
1480
|
+
* @returns The retrieved column
|
1481
|
+
*/
|
1482
|
+
column<T extends MathArray | Matrix>(
|
1483
|
+
value: T,
|
1484
|
+
column: number
|
1485
|
+
): T;
|
1486
|
+
|
1487
|
+
/**
|
1488
|
+
* Calculate the size of a matrix or scalar.
|
1489
|
+
* @param A matrix
|
1490
|
+
* @returns A vector with the size of x
|
1491
|
+
*/
|
1492
|
+
size(x: boolean | number | Complex | Unit | string | MathArray | Matrix): MathArray | Matrix;
|
1493
|
+
|
1494
|
+
/**
|
1495
|
+
* Sort the items in a matrix
|
1496
|
+
* @param x A one dimensional matrix or array to sort
|
1497
|
+
* @param compare An optional _comparator function or name. The function
|
1498
|
+
* is called as compare(a, b), and must return 1 when a > b, -1 when a <
|
1499
|
+
* b, and 0 when a == b. Default value: ‘asc’
|
1500
|
+
* @returns Returns the sorted matrix
|
1501
|
+
*/
|
1502
|
+
sort<T extends Matrix | MathArray>(x: T, compare: ((a: any, b: any) => number) | 'asc' | 'desc' | 'natural'): T;
|
1503
|
+
|
1504
|
+
/**
|
1505
|
+
* Calculate the principal square root of a square matrix. The principal
|
1506
|
+
* square root matrix X of another matrix A is such that X * X = A.
|
1507
|
+
* @param A The square matrix A
|
1508
|
+
* @returns The principal square root of matrix A
|
1509
|
+
*/
|
1510
|
+
sqrtm<T extends MathArray | Matrix>(A: T): T;
|
1511
|
+
|
1512
|
+
/**
|
1513
|
+
* Squeeze a matrix, remove inner and outer singleton dimensions from a
|
1514
|
+
* matrix.
|
1515
|
+
* @param x Matrix to be squeezed
|
1516
|
+
* @returns Squeezed matrix
|
1517
|
+
*/
|
1518
|
+
squeeze<T extends MathArray | Matrix>(x: T): T;
|
1519
|
+
|
1520
|
+
/**
|
1521
|
+
* Get or set a subset of a matrix or string.
|
1522
|
+
* @param value An array, matrix, or string
|
1523
|
+
* @param index An index containing ranges for each dimension
|
1524
|
+
* @param replacement An array, matrix, or scalar. If provided, the
|
1525
|
+
* subset is replaced with replacement. If not provided, the subset is
|
1526
|
+
* returned
|
1527
|
+
* @param defaultValue Default value, filled in on new entries when the
|
1528
|
+
* matrix is resized. If not provided, math.matrix elements will be left
|
1529
|
+
* undefined. Default value: undefined.
|
1530
|
+
* @returns Either the retrieved subset or the updated matrix
|
1531
|
+
*/
|
1532
|
+
subset<T extends MathArray | Matrix | string>(value: T, index: Index, replacement?: any, defaultValue?: any): T;
|
1533
|
+
|
1534
|
+
/**
|
1535
|
+
* Calculate the trace of a matrix: the sum of the elements on the main
|
1536
|
+
* diagonal of a square matrix.
|
1537
|
+
* @param x A matrix
|
1538
|
+
* @returns The trace of x
|
1539
|
+
*/
|
1540
|
+
trace(x: MathArray | Matrix): number;
|
1541
|
+
|
1542
|
+
/**
|
1543
|
+
* Transpose a matrix. All values of the matrix are reflected over its
|
1544
|
+
* main diagonal. Only two dimensional matrices are supported.
|
1545
|
+
* @param x Matrix to be transposed
|
1546
|
+
* @returns The transposed matrix
|
1547
|
+
*/
|
1548
|
+
transpose<T extends MathArray | Matrix>(x: T): T;
|
1549
|
+
|
1550
|
+
/**
|
1551
|
+
* Create a matrix filled with zeros. The created matrix can have one or
|
1552
|
+
* multiple dimensions.
|
1553
|
+
* @param size The size of each dimension of the matrix
|
1554
|
+
* @param format The matrix storage format
|
1555
|
+
* @returns A matrix filled with zeros
|
1556
|
+
*/
|
1557
|
+
zeros(size: number | number[], format?: string): MathArray | Matrix;
|
1558
|
+
/**
|
1559
|
+
* @param m The x dimension of the matrix
|
1560
|
+
* @param n The y dimension of the matrix
|
1561
|
+
* @param format The matrix storage format
|
1562
|
+
* @returns A matrix filled with zeros
|
1563
|
+
*/
|
1564
|
+
zeros(m: number, n: number, format?: string): MathArray | Matrix;
|
1565
|
+
|
1566
|
+
/*************************************************************************
|
1567
|
+
* Probability functions
|
1568
|
+
************************************************************************/
|
1569
|
+
|
1570
|
+
/**
|
1571
|
+
* Compute the number of ways of picking k unordered outcomes from n
|
1572
|
+
* possibilities. Combinations only takes integer arguments. The
|
1573
|
+
* following condition must be enforced: k <= n.
|
1574
|
+
* @param n Total number of objects in the set
|
1575
|
+
* @param k Number of objects in the subset
|
1576
|
+
* @returns Number of possible combinations
|
1577
|
+
*/
|
1578
|
+
combinations<T extends number | BigNumber>(n: T, k: number | BigNumber): NoLiteralType<T>;
|
1579
|
+
|
1580
|
+
/**
|
1581
|
+
* Compute the factorial of a value Factorial only supports an integer
|
1582
|
+
* value as argument. For matrices, the function is evaluated element
|
1583
|
+
* wise.
|
1584
|
+
* @param n An integer number
|
1585
|
+
* @returns The factorial of n
|
1586
|
+
*/
|
1587
|
+
factorial<T extends number | BigNumber | MathArray | Matrix>(n: T): NoLiteralType<T>;
|
1588
|
+
|
1589
|
+
/**
|
1590
|
+
* Compute the gamma function of a value using Lanczos approximation for
|
1591
|
+
* small values, and an extended Stirling approximation for large
|
1592
|
+
* values. For matrices, the function is evaluated element wise.
|
1593
|
+
* @param n A real or complex number
|
1594
|
+
* @returns The gamma of n
|
1595
|
+
*/
|
1596
|
+
gamma(n: number | MathArray | Matrix): number | MathArray | Matrix;
|
1597
|
+
|
1598
|
+
/**
|
1599
|
+
* Calculate the Kullback-Leibler (KL) divergence between two
|
1600
|
+
* distributions
|
1601
|
+
* @param q First vector
|
1602
|
+
* @param p Second vector
|
1603
|
+
* @returns Returns disance between q and p
|
1604
|
+
*/
|
1605
|
+
kldivergence(q: MathArray | Matrix, p: MathArray | Matrix): number;
|
1606
|
+
|
1607
|
+
/**
|
1608
|
+
* Multinomial Coefficients compute the number of ways of picking a1,
|
1609
|
+
* a2, ..., ai unordered outcomes from n possibilities. multinomial
|
1610
|
+
* takes one array of integers as an argument. The following condition
|
1611
|
+
* must be enforced: every ai <= 0
|
1612
|
+
* @param a Integer number of objects in the subset
|
1613
|
+
* @returns multinomial coefficent
|
1614
|
+
*/
|
1615
|
+
multinomial<T extends number | BigNumber>(a: T[]): NoLiteralType<T>;
|
1616
|
+
|
1617
|
+
/**
|
1618
|
+
* Compute the number of ways of obtaining an ordered subset of k
|
1619
|
+
* elements from a set of n elements. Permutations only takes integer
|
1620
|
+
* arguments. The following condition must be enforced: k <= n.
|
1621
|
+
* @param n The number of objects in total
|
1622
|
+
* @param k The number of objects in the subset
|
1623
|
+
* @returns The number of permutations
|
1624
|
+
*/
|
1625
|
+
permutations<T extends number | BigNumber>(n: T, k?: number | BigNumber): NoLiteralType<T>;
|
1626
|
+
|
1627
|
+
/**
|
1628
|
+
* Random pick a value from a one dimensional array. Array element is
|
1629
|
+
* picked using a random function with uniform distribution.
|
1630
|
+
* @param array A one dimensional array
|
1631
|
+
* @param number An int or float
|
1632
|
+
* @param weights An array of ints or floats
|
1633
|
+
* @returns Returns a single random value from array when number is 1 or
|
1634
|
+
* undefined. Returns an array with the configured number of elements
|
1635
|
+
* when number is > 1.
|
1636
|
+
*/
|
1637
|
+
pickRandom(array: number[], number?: number, weights?: number[]): number | number[];
|
1638
|
+
|
1639
|
+
/**
|
1640
|
+
* Return a random number larger or equal to min and smaller than max
|
1641
|
+
* using a uniform distribution.
|
1642
|
+
* @param size If provided, an array or matrix with given size and
|
1643
|
+
* filled with random values is returned
|
1644
|
+
* @param min Minimum boundary for the random value, included
|
1645
|
+
* @param max Maximum boundary for the random value, excluded
|
1646
|
+
* @returns A random number
|
1647
|
+
*/
|
1648
|
+
random(min?: number, max?: number): number;
|
1649
|
+
random<T extends MathArray | Matrix>(size: T, min?: number, max?: number): T;
|
1650
|
+
|
1651
|
+
/**
|
1652
|
+
* Return a random integer number larger or equal to min and smaller
|
1653
|
+
* than max using a uniform distribution.
|
1654
|
+
* @param size If provided, an array or matrix with given size and
|
1655
|
+
* filled with random values is returned
|
1656
|
+
* @param min Minimum boundary for the random value, included
|
1657
|
+
* @param max Maximum boundary for the random value, excluded
|
1658
|
+
* @returns A random number
|
1659
|
+
*/
|
1660
|
+
randomInt(min: number, max?: number): number;
|
1661
|
+
randomInt<T extends MathArray | Matrix>(size: T, min?: number, max?: number): T;
|
1662
|
+
|
1663
|
+
/*************************************************************************
|
1664
|
+
* Relational functions
|
1665
|
+
************************************************************************/
|
1666
|
+
|
1667
|
+
/**
|
1668
|
+
* Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x
|
1669
|
+
* == y. x and y are considered equal when the relative difference
|
1670
|
+
* between x and y is smaller than the configured epsilon. The function
|
1671
|
+
* cannot be used to compare values smaller than approximately 2.22e-16.
|
1672
|
+
* For matrices, the function is evaluated element wise.
|
1673
|
+
* @param x First value to compare
|
1674
|
+
* @param y Second value to compare
|
1675
|
+
* @returns Returns the result of the comparison: 1 when x > y, -1 when
|
1676
|
+
* x < y, and 0 when x == y.
|
1677
|
+
*/
|
1678
|
+
compare(x: MathType | string, y: MathType | string): number | BigNumber | Fraction | MathArray | Matrix;
|
1679
|
+
|
1680
|
+
/**
|
1681
|
+
* Compare two values of any type in a deterministic, natural way. For
|
1682
|
+
* numeric values, the function works the same as math.compare. For
|
1683
|
+
* types of values that can’t be compared mathematically, the function
|
1684
|
+
* compares in a natural way.
|
1685
|
+
* @param x First value to compare
|
1686
|
+
* @param y Second value to compare
|
1687
|
+
* @returns Returns the result of the comparison: 1 when x > y, -1 when
|
1688
|
+
* x < y, and 0 when x == y.
|
1689
|
+
*/
|
1690
|
+
compareNatural(x: any, y: any): number;
|
1691
|
+
|
1692
|
+
/**
|
1693
|
+
* Compare two strings lexically. Comparison is case sensitive. Returns
|
1694
|
+
* 1 when x > y, -1 when x < y, and 0 when x == y. For matrices, the
|
1695
|
+
* function is evaluated element wise.
|
1696
|
+
* @param x First string to compare
|
1697
|
+
* @param y Second string to compare
|
1698
|
+
* @returns Returns the result of the comparison: 1 when x > y, -1 when
|
1699
|
+
* x < y, and 0 when x == y.
|
1700
|
+
*/
|
1701
|
+
compareText(x: string | MathArray | Matrix, y: string | MathArray | Matrix): number | MathArray | Matrix;
|
1702
|
+
|
1703
|
+
/**
|
1704
|
+
* Test element wise whether two matrices are equal. The function
|
1705
|
+
* accepts both matrices and scalar values.
|
1706
|
+
* @param x First matrix to compare
|
1707
|
+
* @param y Second amtrix to compare
|
1708
|
+
* @returns Returns true when the input matrices have the same size and
|
1709
|
+
* each of their elements is equal.
|
1710
|
+
*/
|
1711
|
+
deepEqual(x: MathType, y: MathType): number | BigNumber | Fraction | Complex | Unit | MathArray | Matrix;
|
1712
|
+
|
1713
|
+
/**
|
1714
|
+
* Test whether two values are equal.
|
1715
|
+
*
|
1716
|
+
* The function tests whether the relative difference between x and y is
|
1717
|
+
* smaller than the configured epsilon. The function cannot be used to
|
1718
|
+
* compare values smaller than approximately 2.22e-16. For matrices, the
|
1719
|
+
* function is evaluated element wise. In case of complex numbers, x.re
|
1720
|
+
* must equal y.re, and x.im must equal y.im. Values null and undefined
|
1721
|
+
* are compared strictly, thus null is only equal to null and nothing
|
1722
|
+
* else, and undefined is only equal to undefined and nothing else.
|
1723
|
+
* @param x First value to compare
|
1724
|
+
* @param y Second value to compare
|
1725
|
+
* @returns Returns true when the compared values are equal, else
|
1726
|
+
* returns false
|
1727
|
+
*/
|
1728
|
+
equal(x: MathType | string, y: MathType | string): boolean | MathArray | Matrix;
|
1729
|
+
|
1730
|
+
/**
|
1731
|
+
* Check equality of two strings. Comparison is case sensitive. For
|
1732
|
+
* matrices, the function is evaluated element wise.
|
1733
|
+
* @param x First string to compare
|
1734
|
+
* @param y Second string to compare
|
1735
|
+
* @returns Returns true if the values are equal, and false if not.
|
1736
|
+
*/
|
1737
|
+
equalText(x: string | MathArray | Matrix, y: string | MathArray | Matrix): number | MathArray | Matrix;
|
1738
|
+
|
1739
|
+
/**
|
1740
|
+
* Test whether value x is larger than y. The function returns true when
|
1741
|
+
* x is larger than y and the relative difference between x and y is
|
1742
|
+
* larger than the configured epsilon. The function cannot be used to
|
1743
|
+
* compare values smaller than approximately 2.22e-16. For matrices, the
|
1744
|
+
* function is evaluated element wise.
|
1745
|
+
* @param x First value to compare
|
1746
|
+
* @param y Second value to vcompare
|
1747
|
+
* @returns Returns true when x is larger than y, else returns false
|
1748
|
+
*/
|
1749
|
+
larger(x: MathType | string, y: MathType | string): boolean | MathArray | Matrix;
|
1750
|
+
|
1751
|
+
/**
|
1752
|
+
* Test whether value x is larger or equal to y. The function returns
|
1753
|
+
* true when x is larger than y or the relative difference between x and
|
1754
|
+
* y is smaller than the configured epsilon. The function cannot be used
|
1755
|
+
* to compare values smaller than approximately 2.22e-16. For matrices,
|
1756
|
+
* the function is evaluated element wise.
|
1757
|
+
* @param x First value to compare
|
1758
|
+
* @param y Second value to vcompare
|
1759
|
+
* @returns Returns true when x is larger than or equal to y, else
|
1760
|
+
* returns false
|
1761
|
+
*/
|
1762
|
+
largerEq(x: MathType | string, y: MathType | string): boolean | MathArray | Matrix;
|
1763
|
+
|
1764
|
+
/**
|
1765
|
+
* Test whether value x is smaller than y. The function returns true
|
1766
|
+
* when x is smaller than y and the relative difference between x and y
|
1767
|
+
* is smaller than the configured epsilon. The function cannot be used
|
1768
|
+
* to compare values smaller than approximately 2.22e-16. For matrices,
|
1769
|
+
* the function is evaluated element wise.
|
1770
|
+
* @param x First value to compare
|
1771
|
+
* @param y Second value to vcompare
|
1772
|
+
* @returns Returns true when x is smaller than y, else returns false
|
1773
|
+
*/
|
1774
|
+
smaller(x: MathType | string, y: MathType | string): boolean | MathArray | Matrix;
|
1775
|
+
|
1776
|
+
/**
|
1777
|
+
* Test whether value x is smaller or equal to y. The function returns
|
1778
|
+
* true when x is smaller than y or the relative difference between x
|
1779
|
+
* and y is smaller than the configured epsilon. The function cannot be
|
1780
|
+
* used to compare values smaller than approximately 2.22e-16. For
|
1781
|
+
* matrices, the function is evaluated element wise.
|
1782
|
+
* @param x First value to compare
|
1783
|
+
* @param y Second value to vcompare
|
1784
|
+
* @returns Returns true when x is smaller than or equal to y, else
|
1785
|
+
* returns false
|
1786
|
+
*/
|
1787
|
+
smallerEq(x: MathType | string, y: MathType | string): boolean | MathArray | Matrix;
|
1788
|
+
|
1789
|
+
/**
|
1790
|
+
* Test whether two values are unequal. The function tests whether the
|
1791
|
+
* relative difference between x and y is larger than the configured
|
1792
|
+
* epsilon. The function cannot be used to compare values smaller than
|
1793
|
+
* approximately 2.22e-16. For matrices, the function is evaluated
|
1794
|
+
* element wise. In case of complex numbers, x.re must unequal y.re, or
|
1795
|
+
* x.im must unequal y.im. Values null and undefined are compared
|
1796
|
+
* strictly, thus null is unequal with everything except null, and
|
1797
|
+
* undefined is unequal with everything except undefined.
|
1798
|
+
* @param x First value to compare
|
1799
|
+
* @param y Second value to vcompare
|
1800
|
+
* @returns Returns true when the compared values are unequal, else
|
1801
|
+
* returns false
|
1802
|
+
*/
|
1803
|
+
unequal(x: MathType | string, y: MathType | string): boolean | MathArray | Matrix;
|
1804
|
+
|
1805
|
+
/*************************************************************************
|
1806
|
+
* Set functions
|
1807
|
+
************************************************************************/
|
1808
|
+
|
1809
|
+
/**
|
1810
|
+
* Create the cartesian product of two (multi)sets. Multi-dimension
|
1811
|
+
* arrays will be converted to single-dimension arrays before the
|
1812
|
+
* operation.
|
1813
|
+
* @param a1 A (multi)set
|
1814
|
+
* @param a2 A (multi)set
|
1815
|
+
* @returns The cartesian product of two (multi)sets
|
1816
|
+
*/
|
1817
|
+
setCartesian<T extends MathArray | Matrix>(a1: T, a2: MathArray | Matrix): T;
|
1818
|
+
|
1819
|
+
/**
|
1820
|
+
* Create the difference of two (multi)sets: every element of set1, that
|
1821
|
+
* is not the element of set2. Multi-dimension arrays will be converted
|
1822
|
+
* to single-dimension arrays before the operation
|
1823
|
+
* @param a1 A (multi)set
|
1824
|
+
* @param a2 A (multi)set
|
1825
|
+
* @returns The difference of two (multi)sets
|
1826
|
+
*/
|
1827
|
+
setDifference<T extends MathArray | Matrix>(a1: T, a2: MathArray | Matrix): T;
|
1828
|
+
|
1829
|
+
/**
|
1830
|
+
* Collect the distinct elements of a multiset. A multi-dimension array
|
1831
|
+
* will be converted to a single-dimension array before the operation.
|
1832
|
+
* @param a A multiset
|
1833
|
+
* @returns A set containing the distinct elements of the multiset
|
1834
|
+
*/
|
1835
|
+
setDistinct<T extends MathArray | Matrix>(a: T): T;
|
1836
|
+
|
1837
|
+
/**
|
1838
|
+
* Create the intersection of two (multi)sets. Multi-dimension arrays
|
1839
|
+
* will be converted to single-dimension arrays before the operation.
|
1840
|
+
* @param a1 A (multi)set
|
1841
|
+
* @param a2 A (multi)set
|
1842
|
+
* @returns The intersection of two (multi)sets
|
1843
|
+
*/
|
1844
|
+
setIntersect<T extends MathArray | Matrix>(a1: T, a2: MathArray | Matrix): T;
|
1845
|
+
|
1846
|
+
/**
|
1847
|
+
* Check whether a (multi)set is a subset of another (multi)set. (Every
|
1848
|
+
* element of set1 is the element of set2.) Multi-dimension arrays will
|
1849
|
+
* be converted to single-dimension arrays before the operation.
|
1850
|
+
* @param a1 A (multi)set
|
1851
|
+
* @param a2 A (multi)set
|
1852
|
+
* @returns True if a1 is subset of a2, else false
|
1853
|
+
*/
|
1854
|
+
setIsSubset(a1: MathArray | Matrix, a2: MathArray | Matrix): boolean;
|
1855
|
+
|
1856
|
+
/**
|
1857
|
+
* Count the multiplicity of an element in a multiset. A multi-dimension
|
1858
|
+
* array will be converted to a single-dimension array before the
|
1859
|
+
* operation.
|
1860
|
+
* @param e An element in the multiset
|
1861
|
+
* @param a A multiset
|
1862
|
+
* @returns The number of how many times the multiset contains the
|
1863
|
+
* element
|
1864
|
+
*/
|
1865
|
+
setMultiplicity(e: number | BigNumber | Fraction | Complex, a: MathArray | Matrix): number;
|
1866
|
+
|
1867
|
+
/**
|
1868
|
+
* Create the powerset of a (multi)set. (The powerset contains very
|
1869
|
+
* possible subsets of a (multi)set.) A multi-dimension array will be
|
1870
|
+
* converted to a single-dimension array before the operation.
|
1871
|
+
* @param a A multiset
|
1872
|
+
* @returns The powerset of the (multi)set
|
1873
|
+
*/
|
1874
|
+
setPowerset<T extends MathArray | Matrix>(a: T): T;
|
1875
|
+
|
1876
|
+
/**
|
1877
|
+
* Count the number of elements of a (multi)set. When a second parameter
|
1878
|
+
* is ‘true’, count only the unique values. A multi-dimension array will
|
1879
|
+
* be converted to a single-dimension array before the operation.
|
1880
|
+
* @param a A multiset
|
1881
|
+
* @returns The number of elements of the (multi)set
|
1882
|
+
*/
|
1883
|
+
setSize(a: MathArray | Matrix): number;
|
1884
|
+
|
1885
|
+
/**
|
1886
|
+
* Create the symmetric difference of two (multi)sets. Multi-dimension
|
1887
|
+
* arrays will be converted to single-dimension arrays before the
|
1888
|
+
* operation.
|
1889
|
+
* @param a1 A (multi)set
|
1890
|
+
* @param a2 A (multi)set
|
1891
|
+
* @returns The symmetric difference of two (multi)sets
|
1892
|
+
*/
|
1893
|
+
setSymDifference<T extends MathArray | Matrix>(a1: T, a2: MathArray | Matrix): T;
|
1894
|
+
|
1895
|
+
/**
|
1896
|
+
* Create the union of two (multi)sets. Multi-dimension arrays will be
|
1897
|
+
* converted to single-dimension arrays before the operation.
|
1898
|
+
* @param a1 A (multi)set
|
1899
|
+
* @param a2 A (multi)set
|
1900
|
+
* @returns The union of two (multi)sets
|
1901
|
+
*/
|
1902
|
+
setUnion<T extends MathArray | Matrix>(a1: T, a2: MathArray | Matrix): T;
|
1903
|
+
|
1904
|
+
/*************************************************************************
|
1905
|
+
* Special functions
|
1906
|
+
************************************************************************/
|
1907
|
+
|
1908
|
+
/**
|
1909
|
+
* Compute the erf function of a value using a rational Chebyshev
|
1910
|
+
* approximations for different intervals of x.
|
1911
|
+
* @param x A real number
|
1912
|
+
* @returns The erf of x
|
1913
|
+
*/
|
1914
|
+
erf<T extends number | MathArray | Matrix>(x: T): NoLiteralType<T>;
|
1915
|
+
|
1916
|
+
/*************************************************************************
|
1917
|
+
* Statistics functions
|
1918
|
+
************************************************************************/
|
1919
|
+
|
1920
|
+
/**
|
1921
|
+
* Compute the median absolute deviation of a matrix or a list with
|
1922
|
+
* values. The median absolute deviation is defined as the median of the
|
1923
|
+
* absolute deviations from the median.
|
1924
|
+
* @param array A single matrix or multiple scalar values.
|
1925
|
+
* @returns The median absolute deviation
|
1926
|
+
*/
|
1927
|
+
mad(array: MathArray | Matrix): any;
|
1928
|
+
|
1929
|
+
/**
|
1930
|
+
* Compute the maximum value of a matrix or a list with values. In case
|
1931
|
+
* of a multi dimensional array, the maximum of the flattened array will
|
1932
|
+
* be calculated. When dim is provided, the maximum over the selected
|
1933
|
+
* dimension will be calculated. Parameter dim is zero-based.
|
1934
|
+
* @param args A single matrix or multiple scalar values
|
1935
|
+
* @returns The maximum value
|
1936
|
+
*/
|
1937
|
+
max(...args: MathType[]): any;
|
1938
|
+
/**
|
1939
|
+
* @param A A single matrix
|
1940
|
+
* @param dim The maximum over the selected dimension
|
1941
|
+
* @returns The maximum value
|
1942
|
+
*/
|
1943
|
+
max(A: MathArray | Matrix, dim?: number): any;
|
1944
|
+
|
1945
|
+
/**
|
1946
|
+
* Compute the mean value of matrix or a list with values. In case of a
|
1947
|
+
* multi dimensional array, the mean of the flattened array will be
|
1948
|
+
* calculated. When dim is provided, the maximum over the selected
|
1949
|
+
* dimension will be calculated. Parameter dim is zero-based.
|
1950
|
+
* @param args A single matrix or multiple scalar values
|
1951
|
+
* @returns The mean of all values
|
1952
|
+
*/
|
1953
|
+
mean(...args: MathType[]): any;
|
1954
|
+
/**
|
1955
|
+
* @param A A single matrix
|
1956
|
+
* @param dim The mean over the selected dimension
|
1957
|
+
* @returns The mean of all values
|
1958
|
+
*/
|
1959
|
+
mean(A: MathArray | Matrix, dim?: number): any;
|
1960
|
+
|
1961
|
+
/**
|
1962
|
+
* Compute the median of a matrix or a list with values. The values are
|
1963
|
+
* sorted and the middle value is returned. In case of an even number of
|
1964
|
+
* values, the average of the two middle values is returned. Supported
|
1965
|
+
* types of values are: Number, BigNumber, Unit In case of a (multi
|
1966
|
+
* dimensional) array or matrix, the median of all elements will be
|
1967
|
+
* calculated.
|
1968
|
+
* @param args A single matrix or or multiple scalar values
|
1969
|
+
* @returns The median
|
1970
|
+
*/
|
1971
|
+
median(...args: MathType[]): any;
|
1972
|
+
|
1973
|
+
/**
|
1974
|
+
* Compute the maximum value of a matrix or a list of values. In case of
|
1975
|
+
* a multi dimensional array, the maximum of the flattened array will be
|
1976
|
+
* calculated. When dim is provided, the maximum over the selected
|
1977
|
+
* dimension will be calculated. Parameter dim is zero-based.
|
1978
|
+
* @param args A single matrix or or multiple scalar values
|
1979
|
+
* @returns The minimum value
|
1980
|
+
*/
|
1981
|
+
min(...args: MathType[]): any;
|
1982
|
+
/**
|
1983
|
+
* @param A A single matrix
|
1984
|
+
* @param dim The minimum over the selected dimension
|
1985
|
+
* @returns The minimum value
|
1986
|
+
*/
|
1987
|
+
min(A: MathArray | Matrix, dim?: number): any;
|
1988
|
+
|
1989
|
+
/**
|
1990
|
+
* Computes the mode of a set of numbers or a list with values(numbers
|
1991
|
+
* or characters). If there are more than one modes, it returns a list
|
1992
|
+
* of those values.
|
1993
|
+
* @param args A single matrix
|
1994
|
+
* @returns The mode of all values
|
1995
|
+
*/
|
1996
|
+
mode(...args: MathType[]): any;
|
1997
|
+
|
1998
|
+
/**
|
1999
|
+
* Compute the product of a matrix or a list with values. In case of a
|
2000
|
+
* (multi dimensional) array or matrix, the sum of all elements will be
|
2001
|
+
* calculated.
|
2002
|
+
* @param args A single matrix or multiple scalar values
|
2003
|
+
* @returns The product of all values
|
2004
|
+
*/
|
2005
|
+
prod(...args: MathType[]): any;
|
2006
|
+
|
2007
|
+
/**
|
2008
|
+
* Compute the prob order quantile of a matrix or a list with values.
|
2009
|
+
* The sequence is sorted and the middle value is returned. Supported
|
2010
|
+
* types of sequence values are: Number, BigNumber, Unit Supported types
|
2011
|
+
* of probability are: Number, BigNumber In case of a (multi
|
2012
|
+
* dimensional) array or matrix, the prob order quantile of all elements
|
2013
|
+
* will be calculated.
|
2014
|
+
* @param A A single matrix or array
|
2015
|
+
* @param probOrN prob is the order of the quantile, while N is the
|
2016
|
+
* amount of evenly distributed steps of probabilities; only one of
|
2017
|
+
* these options can be provided
|
2018
|
+
* @param sorted =false is data sorted in ascending order
|
2019
|
+
* @returns Quantile(s)
|
2020
|
+
*/
|
2021
|
+
quantileSeq(A: MathArray | Matrix, prob: number | BigNumber | MathArray, sorted?: boolean): number | BigNumber | Unit | MathArray;
|
2022
|
+
|
2023
|
+
/**
|
2024
|
+
* Compute the standard deviation of a matrix or a list with values. The
|
2025
|
+
* standard deviations is defined as the square root of the variance:
|
2026
|
+
* std(A) = sqrt(variance(A)). In case of a (multi dimensional) array or
|
2027
|
+
* matrix, the standard deviation over all elements will be calculated.
|
2028
|
+
* Optionally, the type of normalization can be specified as second
|
2029
|
+
* parameter. The parameter normalization can be one of the following
|
2030
|
+
* values: 'unbiased' (default) The sum of squared errors is divided by
|
2031
|
+
* (n - 1) 'uncorrected' The sum of squared errors is divided by n
|
2032
|
+
* 'biased' The sum of squared errors is divided by (n + 1)
|
2033
|
+
* @param array A single matrix or multiple scalar values
|
2034
|
+
* @param normalization Determines how to normalize the variance. Choose
|
2035
|
+
* ‘unbiased’ (default), ‘uncorrected’, or ‘biased’. Default value:
|
2036
|
+
* ‘unbiased’.
|
2037
|
+
* @returns The standard deviation
|
2038
|
+
*/
|
2039
|
+
std(array: MathArray | Matrix, normalization?: 'unbiased' | 'uncorrected' | 'biased' | 'unbiased'): number;
|
2040
|
+
|
2041
|
+
/**
|
2042
|
+
* Compute the sum of a matrix or a list with values. In case of a
|
2043
|
+
* (multi dimensional) array or matrix, the sum of all elements will be
|
2044
|
+
* calculated.
|
2045
|
+
* @param args A single matrix or multiple scalar values
|
2046
|
+
* @returns The sum of all values
|
2047
|
+
*/
|
2048
|
+
sum(...args: Array<number | BigNumber | Fraction>): any;
|
2049
|
+
/**
|
2050
|
+
* @param array A single matrix
|
2051
|
+
* @returns The sum of all values
|
2052
|
+
*/
|
2053
|
+
sum(array: MathArray | Matrix): any;
|
2054
|
+
|
2055
|
+
/**
|
2056
|
+
* Compute the variance of a matrix or a list with values. In case of a
|
2057
|
+
* (multi dimensional) array or matrix, the variance over all elements
|
2058
|
+
* will be calculated. Optionally, the type of normalization can be
|
2059
|
+
* specified as second parameter. The parameter normalization can be one
|
2060
|
+
* of the following values: 'unbiased' (default) The sum of squared
|
2061
|
+
* errors is divided by (n - 1) 'uncorrected' The sum of squared errors
|
2062
|
+
* is divided by n 'biased' The sum of squared errors is divided by (n +
|
2063
|
+
* 1) Note that older browser may not like the variable name var. In
|
2064
|
+
* that case, the function can be called as math['var'](...) instead of
|
2065
|
+
* math.variance(...).
|
2066
|
+
* @param args A single matrix or multiple scalar values
|
2067
|
+
* @returns The variance
|
2068
|
+
*/
|
2069
|
+
variance(...args: Array<number | BigNumber | Fraction>): any;
|
2070
|
+
/**
|
2071
|
+
* @param array A single matrix
|
2072
|
+
* @param normalization normalization Determines how to normalize the
|
2073
|
+
* variance. Choose ‘unbiased’ (default), ‘uncorrected’, or ‘biased’.
|
2074
|
+
* Default value: ‘unbiased’.
|
2075
|
+
* @returns The variance
|
2076
|
+
*/
|
2077
|
+
variance(array: MathArray | Matrix, normalization?: 'unbiased' | 'uncorrected' | 'biased' | 'unbiased'): any;
|
2078
|
+
|
2079
|
+
/*************************************************************************
|
2080
|
+
* String functions
|
2081
|
+
************************************************************************/
|
2082
|
+
|
2083
|
+
/**
|
2084
|
+
* Format a value of any type into a string.
|
2085
|
+
* @param value The value to be formatted
|
2086
|
+
* @param options An object with formatting options.
|
2087
|
+
* @param callback A custom formatting function, invoked for all numeric
|
2088
|
+
* elements in value, for example all elements of a matrix, or the real
|
2089
|
+
* and imaginary parts of a complex number. This callback can be used to
|
2090
|
+
* override the built-in numeric notation with any type of formatting.
|
2091
|
+
* Function callback is called with value as parameter and must return a
|
2092
|
+
* string.
|
2093
|
+
* @see http://mathjs.org/docs/reference/functions/format.html
|
2094
|
+
* @returns The formatted value
|
2095
|
+
*/
|
2096
|
+
format(value: any, options?: FormatOptions | number | ((item: any) => string), callback?: (value: any) => string): string;
|
2097
|
+
|
2098
|
+
/**
|
2099
|
+
* Interpolate values into a string template.
|
2100
|
+
* @param template A string containing variable placeholders.
|
2101
|
+
* @param values An object containing variables which will be filled in
|
2102
|
+
* in the template.
|
2103
|
+
* @param precision Number of digits to format numbers. If not provided,
|
2104
|
+
* the value will not be rounded.
|
2105
|
+
* @param options Formatting options, or the number of digits to format
|
2106
|
+
* numbers. See function math.format for a description of all options.
|
2107
|
+
* @returns Interpolated string
|
2108
|
+
*/
|
2109
|
+
print(template: string, values: any, precision?: number, options?: number | object): void;
|
2110
|
+
|
2111
|
+
/*************************************************************************
|
2112
|
+
* Trigonometry functions
|
2113
|
+
************************************************************************/
|
2114
|
+
|
2115
|
+
/**
|
2116
|
+
* Calculate the inverse cosine of a value. For matrices, the function
|
2117
|
+
* is evaluated element wise.
|
2118
|
+
* @param x Function input
|
2119
|
+
* @returns The arc cosine of x
|
2120
|
+
*/
|
2121
|
+
acos(x: number): number;
|
2122
|
+
acos(x: BigNumber): BigNumber;
|
2123
|
+
acos(x: Complex): Complex;
|
2124
|
+
acos(x: MathArray): MathArray;
|
2125
|
+
acos(x: Matrix): Matrix;
|
2126
|
+
|
2127
|
+
/**
|
2128
|
+
* Calculate the hyperbolic arccos of a value, defined as acosh(x) =
|
2129
|
+
* ln(sqrt(x^2 - 1) + x). For matrices, the function is evaluated
|
2130
|
+
* element wise.
|
2131
|
+
* @param x Function input
|
2132
|
+
* @returns The hyperbolic arccosine of x
|
2133
|
+
*/
|
2134
|
+
acosh(x: number): number;
|
2135
|
+
acosh(x: BigNumber): BigNumber;
|
2136
|
+
acosh(x: Complex): Complex;
|
2137
|
+
acosh(x: MathArray): MathArray;
|
2138
|
+
acosh(x: Matrix): Matrix;
|
2139
|
+
|
2140
|
+
/**
|
2141
|
+
* Calculate the inverse cotangent of a value. For matrices, the
|
2142
|
+
* function is evaluated element wise.
|
2143
|
+
* @param x Function input
|
2144
|
+
* @returns The arc cotangent of x
|
2145
|
+
*/
|
2146
|
+
acot(x: number): number;
|
2147
|
+
acot(x: BigNumber): BigNumber;
|
2148
|
+
acot(x: MathArray): MathArray;
|
2149
|
+
acot(x: Matrix): Matrix;
|
2150
|
+
|
2151
|
+
/**
|
2152
|
+
* Calculate the hyperbolic arccotangent of a value, defined as acoth(x)
|
2153
|
+
* = (ln((x+1)/x) + ln(x/(x-1))) / 2. For matrices, the function is
|
2154
|
+
* evaluated element wise.
|
2155
|
+
* @param x Function input
|
2156
|
+
* @returns The hyperbolic arccotangent of x
|
2157
|
+
*/
|
2158
|
+
acoth(x: number): number;
|
2159
|
+
acoth(x: BigNumber): BigNumber;
|
2160
|
+
acoth(x: MathArray): MathArray;
|
2161
|
+
acoth(x: Matrix): Matrix;
|
2162
|
+
|
2163
|
+
/**
|
2164
|
+
* Calculate the inverse cosecant of a value. For matrices, the function
|
2165
|
+
* is evaluated element wise.
|
2166
|
+
* @param x Function input
|
2167
|
+
* @returns The arc cosecant of x
|
2168
|
+
*/
|
2169
|
+
acsc(x: number): number;
|
2170
|
+
acsc(x: BigNumber): BigNumber;
|
2171
|
+
acsc(x: MathArray): MathArray;
|
2172
|
+
acsc(x: Matrix): Matrix;
|
2173
|
+
|
2174
|
+
/**
|
2175
|
+
* Calculate the hyperbolic arccosecant of a value, defined as acsch(x)
|
2176
|
+
* = ln(1/x + sqrt(1/x^2 + 1)). For matrices, the function is evaluated
|
2177
|
+
* element wise.
|
2178
|
+
* @param x Function input
|
2179
|
+
* @returns The hyperbolic arccosecant of x
|
2180
|
+
*/
|
2181
|
+
acsch(x: number): number;
|
2182
|
+
acsch(x: BigNumber): BigNumber;
|
2183
|
+
acsch(x: MathArray): MathArray;
|
2184
|
+
acsch(x: Matrix): Matrix;
|
2185
|
+
|
2186
|
+
/**
|
2187
|
+
* Calculate the inverse secant of a value. For matrices, the function
|
2188
|
+
* is evaluated element wise.
|
2189
|
+
* @param x Function input
|
2190
|
+
* @returns The arc secant of x
|
2191
|
+
*/
|
2192
|
+
asec(x: number): number;
|
2193
|
+
asec(x: BigNumber): BigNumber;
|
2194
|
+
asec(x: MathArray): MathArray;
|
2195
|
+
asec(x: Matrix): Matrix;
|
2196
|
+
|
2197
|
+
/**
|
2198
|
+
* Calculate the hyperbolic arcsecant of a value, defined as asech(x) =
|
2199
|
+
* ln(sqrt(1/x^2 - 1) + 1/x). For matrices, the function is evaluated
|
2200
|
+
* element wise.
|
2201
|
+
* @param x Function input
|
2202
|
+
* @returns The hyperbolic arcsecant of x
|
2203
|
+
*/
|
2204
|
+
asech(x: number): number;
|
2205
|
+
asech(x: BigNumber): BigNumber;
|
2206
|
+
asech(x: MathArray): MathArray;
|
2207
|
+
asech(x: Matrix): Matrix;
|
2208
|
+
|
2209
|
+
/**
|
2210
|
+
* Calculate the inverse sine of a value. For matrices, the function is
|
2211
|
+
* evaluated element wise.
|
2212
|
+
* @param x Function input
|
2213
|
+
* @returns The arc sine of x
|
2214
|
+
*/
|
2215
|
+
asin(x: number): number;
|
2216
|
+
asin(x: BigNumber): BigNumber;
|
2217
|
+
asin(x: Complex): Complex;
|
2218
|
+
asin(x: MathArray): MathArray;
|
2219
|
+
asin(x: Matrix): Matrix;
|
2220
|
+
|
2221
|
+
/**
|
2222
|
+
* Calculate the hyperbolic arcsine of a value, defined as asinh(x) =
|
2223
|
+
* ln(x + sqrt(x^2 + 1)). For matrices, the function is evaluated
|
2224
|
+
* element wise.
|
2225
|
+
* @param x Function input
|
2226
|
+
* @returns The hyperbolic arcsine of x
|
2227
|
+
*/
|
2228
|
+
asinh(x: number): number;
|
2229
|
+
asinh(x: BigNumber): BigNumber;
|
2230
|
+
asinh(x: MathArray): MathArray;
|
2231
|
+
asinh(x: Matrix): Matrix;
|
2232
|
+
|
2233
|
+
/**
|
2234
|
+
* Calculate the inverse tangent of a value. For matrices, the function
|
2235
|
+
* is evaluated element wise.
|
2236
|
+
* @param x Function input
|
2237
|
+
* @returns The arc tangent of x
|
2238
|
+
*/
|
2239
|
+
atan(x: number): number;
|
2240
|
+
atan(x: BigNumber): BigNumber;
|
2241
|
+
atan(x: MathArray): MathArray;
|
2242
|
+
atan(x: Matrix): Matrix;
|
2243
|
+
|
2244
|
+
/**
|
2245
|
+
* Calculate the inverse tangent function with two arguments, y/x. By
|
2246
|
+
* providing two arguments, the right quadrant of the computed angle can
|
2247
|
+
* be determined. For matrices, the function is evaluated element wise.
|
2248
|
+
* @param x Function input
|
2249
|
+
* @returns Four quadrant inverse tangent
|
2250
|
+
*/
|
2251
|
+
atan2(y: number, x: number): number;
|
2252
|
+
atan2(y: MathArray | Matrix, x: MathArray | Matrix): MathArray | Matrix;
|
2253
|
+
|
2254
|
+
/**
|
2255
|
+
* Calculate the hyperbolic arctangent of a value, defined as atanh(x) =
|
2256
|
+
* ln((1 + x)/(1 - x)) / 2. For matrices, the function is evaluated
|
2257
|
+
* element wise.
|
2258
|
+
* @param x Function input
|
2259
|
+
* @returns The hyperbolic arctangent of x
|
2260
|
+
*/
|
2261
|
+
atanh(x: number): number;
|
2262
|
+
atanh(x: BigNumber): BigNumber;
|
2263
|
+
atanh(x: MathArray): MathArray;
|
2264
|
+
atanh(x: Matrix): Matrix;
|
2265
|
+
|
2266
|
+
/**
|
2267
|
+
* Calculate the cosine of a value. For matrices, the function is
|
2268
|
+
* evaluated element wise.
|
2269
|
+
* @param x Function input
|
2270
|
+
* @returns The cosine of x
|
2271
|
+
*/
|
2272
|
+
cos(x: number | Unit): number;
|
2273
|
+
cos(x: BigNumber): BigNumber;
|
2274
|
+
cos(x: Complex): Complex;
|
2275
|
+
cos(x: MathArray): MathArray;
|
2276
|
+
cos(x: Matrix): Matrix;
|
2277
|
+
|
2278
|
+
/**
|
2279
|
+
* Calculate the hyperbolic cosine of a value, defined as cosh(x) = 1/2
|
2280
|
+
* * (exp(x) + exp(-x)). For matrices, the function is evaluated element
|
2281
|
+
* wise.
|
2282
|
+
* @param x Function input
|
2283
|
+
* @returns The hyperbolic cosine of x
|
2284
|
+
*/
|
2285
|
+
cosh(x: number | Unit): number;
|
2286
|
+
cosh(x: BigNumber): BigNumber;
|
2287
|
+
cosh(x: Complex): Complex;
|
2288
|
+
cosh(x: MathArray): MathArray;
|
2289
|
+
cosh(x: Matrix): Matrix;
|
2290
|
+
|
2291
|
+
/**
|
2292
|
+
* Calculate the cotangent of a value. cot(x) is defined as 1 / tan(x).
|
2293
|
+
* For matrices, the function is evaluated element wise.
|
2294
|
+
* @param x Function input
|
2295
|
+
* @returns The cotangent of x
|
2296
|
+
*/
|
2297
|
+
cot(x: number | Unit): number;
|
2298
|
+
cot(x: Complex): Complex;
|
2299
|
+
cot(x: MathArray): MathArray;
|
2300
|
+
cot(x: Matrix): Matrix;
|
2301
|
+
|
2302
|
+
/**
|
2303
|
+
* Calculate the hyperbolic cotangent of a value, defined as coth(x) = 1
|
2304
|
+
* / tanh(x). For matrices, the function is evaluated element wise.
|
2305
|
+
* @param x Function input
|
2306
|
+
* @returns The hyperbolic cotangent of x
|
2307
|
+
*/
|
2308
|
+
coth(x: number | Unit): number;
|
2309
|
+
coth(x: Complex): Complex;
|
2310
|
+
coth(x: MathArray): MathArray;
|
2311
|
+
coth(x: Matrix): Matrix;
|
2312
|
+
|
2313
|
+
/**
|
2314
|
+
* Calculate the cosecant of a value, defined as csc(x) = 1/sin(x). For
|
2315
|
+
* matrices, the function is evaluated element wise.
|
2316
|
+
* @param x Function input
|
2317
|
+
* @returns The cosecant hof x
|
2318
|
+
*/
|
2319
|
+
csc(x: number | Unit): number;
|
2320
|
+
csc(x: Complex): Complex;
|
2321
|
+
csc(x: MathArray): MathArray;
|
2322
|
+
csc(x: Matrix): Matrix;
|
2323
|
+
|
2324
|
+
/**
|
2325
|
+
* Calculate the hyperbolic cosecant of a value, defined as csch(x) = 1
|
2326
|
+
* / sinh(x). For matrices, the function is evaluated element wise.
|
2327
|
+
* @param x Function input
|
2328
|
+
* @returns The hyperbolic cosecant of x
|
2329
|
+
*/
|
2330
|
+
csch(x: number | Unit): number;
|
2331
|
+
csch(x: Complex): Complex;
|
2332
|
+
csch(x: MathArray): MathArray;
|
2333
|
+
csch(x: Matrix): Matrix;
|
2334
|
+
|
2335
|
+
/**
|
2336
|
+
* Calculate the secant of a value, defined as sec(x) = 1/cos(x). For
|
2337
|
+
* matrices, the function is evaluated element wise.
|
2338
|
+
* @param x Function input
|
2339
|
+
* @returns The secant of x
|
2340
|
+
*/
|
2341
|
+
sec(x: number | Unit): number;
|
2342
|
+
sec(x: Complex): Complex;
|
2343
|
+
sec(x: MathArray): MathArray;
|
2344
|
+
sec(x: Matrix): Matrix;
|
2345
|
+
|
2346
|
+
/**
|
2347
|
+
* Calculate the hyperbolic secant of a value, defined as sech(x) = 1 /
|
2348
|
+
* cosh(x). For matrices, the function is evaluated element wise.
|
2349
|
+
* @param x Function input
|
2350
|
+
* @returns The hyperbolic secant of x
|
2351
|
+
*/
|
2352
|
+
sech(x: number | Unit): number;
|
2353
|
+
sech(x: Complex): Complex;
|
2354
|
+
sech(x: MathArray): MathArray;
|
2355
|
+
sech(x: Matrix): Matrix;
|
2356
|
+
|
2357
|
+
/**
|
2358
|
+
* Calculate the sine of a value. For matrices, the function is
|
2359
|
+
* evaluated element wise.
|
2360
|
+
* @param x Function input
|
2361
|
+
* @returns The sine of x
|
2362
|
+
*/
|
2363
|
+
sin(x: number | Unit): number;
|
2364
|
+
sin(x: BigNumber): BigNumber;
|
2365
|
+
sin(x: Complex): Complex;
|
2366
|
+
sin(x: MathArray): MathArray;
|
2367
|
+
sin(x: Matrix): Matrix;
|
2368
|
+
|
2369
|
+
/**
|
2370
|
+
* Calculate the hyperbolic sine of a value, defined as sinh(x) = 1/2 *
|
2371
|
+
* (exp(x) - exp(-x)). For matrices, the function is evaluated element
|
2372
|
+
* wise.
|
2373
|
+
* @param x Function input
|
2374
|
+
* @returns The hyperbolic sine of x
|
2375
|
+
*/
|
2376
|
+
sinh(x: number | Unit): number;
|
2377
|
+
sinh(x: BigNumber): BigNumber;
|
2378
|
+
sinh(x: Complex): Complex;
|
2379
|
+
sinh(x: MathArray): MathArray;
|
2380
|
+
sinh(x: Matrix): Matrix;
|
2381
|
+
|
2382
|
+
/**
|
2383
|
+
* Calculate the tangent of a value. tan(x) is equal to sin(x) / cos(x).
|
2384
|
+
* For matrices, the function is evaluated element wise.
|
2385
|
+
* @param x Function input
|
2386
|
+
* @returns The tangent of x
|
2387
|
+
*/
|
2388
|
+
tan(x: number | Unit): number;
|
2389
|
+
tan(x: BigNumber): BigNumber;
|
2390
|
+
tan(x: Complex): Complex;
|
2391
|
+
tan(x: MathArray): MathArray;
|
2392
|
+
tan(x: Matrix): Matrix;
|
2393
|
+
|
2394
|
+
/**
|
2395
|
+
* Calculate the hyperbolic tangent of a value, defined as tanh(x) =
|
2396
|
+
* (exp(2 * x) - 1) / (exp(2 * x) + 1). For matrices, the function is
|
2397
|
+
* evaluated element wise.
|
2398
|
+
* @param x Function input
|
2399
|
+
* @returns The hyperbolic tangent of x
|
2400
|
+
*/
|
2401
|
+
tanh(x: number | Unit): number;
|
2402
|
+
tanh(x: BigNumber): BigNumber;
|
2403
|
+
tanh(x: Complex): Complex;
|
2404
|
+
tanh(x: MathArray): MathArray;
|
2405
|
+
tanh(x: Matrix): Matrix;
|
2406
|
+
|
2407
|
+
/*************************************************************************
|
2408
|
+
* Unit functions
|
2409
|
+
************************************************************************/
|
2410
|
+
|
2411
|
+
/**
|
2412
|
+
* Change the unit of a value. For matrices, the function is evaluated
|
2413
|
+
* element wise.
|
2414
|
+
* @param x The unit to be converted.
|
2415
|
+
* @param unit New unit. Can be a string like "cm" or a unit without
|
2416
|
+
* value.
|
2417
|
+
* @returns Value with changed, fixed unit
|
2418
|
+
*/
|
2419
|
+
to(x: Unit | MathArray | Matrix, unit: Unit | string): Unit | MathArray | Matrix;
|
2420
|
+
|
2421
|
+
/*************************************************************************
|
2422
|
+
* Utils functions
|
2423
|
+
************************************************************************/
|
2424
|
+
|
2425
|
+
/**
|
2426
|
+
* Clone an object.
|
2427
|
+
* @param x Object to be cloned
|
2428
|
+
* @returns A clone of object x
|
2429
|
+
*/
|
2430
|
+
clone(x: any): any;
|
2431
|
+
|
2432
|
+
/**
|
2433
|
+
* Test whether a value is an integer number. The function supports
|
2434
|
+
* number, BigNumber, and Fraction. The function is evaluated
|
2435
|
+
* element-wise in case of Array or Matrix input.
|
2436
|
+
* @param x Value to be tested
|
2437
|
+
* @returns Returns true when x contains a numeric, integer value.
|
2438
|
+
* Throws an error in case of an unknown data type.
|
2439
|
+
*/
|
2440
|
+
isInteger(x: number | BigNumber | Fraction | MathArray | Matrix): boolean;
|
2441
|
+
|
2442
|
+
/**
|
2443
|
+
* Test whether a value is NaN (not a number). The function supports
|
2444
|
+
* types number, BigNumber, Fraction, Unit and Complex. The function is
|
2445
|
+
* evaluated element-wise in case of Array or Matrix input.
|
2446
|
+
* @param x Value to be tested
|
2447
|
+
* @returns Returns true when x is NaN. Throws an error in case of an
|
2448
|
+
* unknown data type.
|
2449
|
+
*/
|
2450
|
+
isNaN(x: number | BigNumber | Fraction | MathArray | Matrix | Unit): boolean;
|
2451
|
+
|
2452
|
+
/**
|
2453
|
+
* Test whether a value is negative: smaller than zero. The function
|
2454
|
+
* supports types number, BigNumber, Fraction, and Unit. The function is
|
2455
|
+
* evaluated element-wise in case of Array or Matrix input.
|
2456
|
+
* @param x Value to be tested
|
2457
|
+
* @returns Returns true when x is larger than zero. Throws an error in
|
2458
|
+
* case of an unknown data type.
|
2459
|
+
*/
|
2460
|
+
isNegative(x: number | BigNumber | Fraction | MathArray | Matrix | Unit): boolean;
|
2461
|
+
|
2462
|
+
/**
|
2463
|
+
* Test whether a value is an numeric value. The function is evaluated
|
2464
|
+
* element-wise in case of Array or Matrix input.
|
2465
|
+
* @param x Value to be tested
|
2466
|
+
* @returns Returns true when x is a number, BigNumber, Fraction, or
|
2467
|
+
* boolean. Returns false for other types. Throws an error in case of
|
2468
|
+
* unknown types.
|
2469
|
+
*/
|
2470
|
+
isNumeric(x: any): x is number | BigNumber | Fraction | boolean;
|
2471
|
+
|
2472
|
+
/**
|
2473
|
+
* Test whether a value is positive: larger than zero. The function
|
2474
|
+
* supports types number, BigNumber, Fraction, and Unit. The function is
|
2475
|
+
* evaluated element-wise in case of Array or Matrix input.
|
2476
|
+
* @param x Value to be tested
|
2477
|
+
* @returns Returns true when x is larger than zero. Throws an error in
|
2478
|
+
* case of an unknown data type.
|
2479
|
+
*/
|
2480
|
+
isPositive(x: number | BigNumber | Fraction | MathArray | Matrix | Unit): boolean;
|
2481
|
+
|
2482
|
+
/**
|
2483
|
+
* Test whether a value is prime: has no divisors other than itself and
|
2484
|
+
* one. The function supports type number, bignumber. The function is
|
2485
|
+
* evaluated element-wise in case of Array or Matrix input.
|
2486
|
+
* @param x Value to be tested
|
2487
|
+
* @returns Returns true when x is larger than zero. Throws an error in
|
2488
|
+
* case of an unknown data type.
|
2489
|
+
*/
|
2490
|
+
isPrime(x: number | BigNumber | MathArray | Matrix): boolean;
|
2491
|
+
|
2492
|
+
/**
|
2493
|
+
* Test whether a value is zero. The function can check for zero for
|
2494
|
+
* types number, BigNumber, Fraction, Complex, and Unit. The function is
|
2495
|
+
* evaluated element-wise in case of Array or Matrix input.
|
2496
|
+
* @param x Value to be tested
|
2497
|
+
* @returns Returns true when x is zero. Throws an error in case of an
|
2498
|
+
* unknown data type.
|
2499
|
+
*/
|
2500
|
+
isZero(x: number | BigNumber | Fraction | MathArray | Matrix | Unit | Complex): boolean;
|
2501
|
+
|
2502
|
+
/**
|
2503
|
+
* Determine the type of a variable.
|
2504
|
+
* @param x The variable for which to test the type
|
2505
|
+
* @returns Returns the name of the type. Primitive types are lower
|
2506
|
+
* case, non-primitive types are upper-camel-case. For example ‘number’,
|
2507
|
+
* ‘string’, ‘Array’, ‘Date’.
|
2508
|
+
*/
|
2509
|
+
typeOf(x: any): string;
|
2510
|
+
|
2511
|
+
/**
|
2512
|
+
* Import functions from an object or a module
|
2513
|
+
* To avoid errors when using one of the imported functions extend module like this:
|
2514
|
+
*
|
2515
|
+
* @example
|
2516
|
+
* // imported_math_functions.ts
|
2517
|
+
* declare module 'mathjs' {
|
2518
|
+
* interface MathJsStatic {
|
2519
|
+
* hello(a: number): number;
|
2520
|
+
* }
|
2521
|
+
* }
|
2522
|
+
*
|
2523
|
+
* @param object An object with functions to be imported.
|
2524
|
+
* @param options An object with import options.
|
2525
|
+
*/
|
2526
|
+
import(object: ImportObject | ImportObject[], options: ImportOptions): void;
|
2527
|
+
}
|
2528
|
+
|
2529
|
+
/*************************************************************************
|
2530
|
+
* Factory and Dependencies
|
2531
|
+
************************************************************************/
|
2532
|
+
interface FactoryDependencies {
|
2533
|
+
create: (factories: FactoryFunctionMap, config?: ConfigOptions) => Partial<MathJsStatic>;
|
2534
|
+
factory: <T>(
|
2535
|
+
name: string,
|
2536
|
+
dependencies: MathJsFunctionName[],
|
2537
|
+
create: (injected: Partial<MathJsStatic>) => T,
|
2538
|
+
meta?: any
|
2539
|
+
) => FactoryFunction<T>;
|
2540
|
+
all: FactoryFunctionMap;
|
2541
|
+
|
2542
|
+
typedDependencies: FactoryFunctionMap;
|
2543
|
+
ResultSetDependencies: FactoryFunctionMap;
|
2544
|
+
BigNumberDependencies: FactoryFunctionMap;
|
2545
|
+
ComplexDependencies: FactoryFunctionMap;
|
2546
|
+
FractionDependencies: FactoryFunctionMap;
|
2547
|
+
RangeDependencies: FactoryFunctionMap;
|
2548
|
+
MatrixDependencies: FactoryFunctionMap;
|
2549
|
+
DenseMatrixDependencies: FactoryFunctionMap;
|
2550
|
+
cloneDependencies: FactoryFunctionMap;
|
2551
|
+
isIntegerDependencies: FactoryFunctionMap;
|
2552
|
+
isNegativeDependencies: FactoryFunctionMap;
|
2553
|
+
isNumericDependencies: FactoryFunctionMap;
|
2554
|
+
hasNumericValueDependencies: FactoryFunctionMap;
|
2555
|
+
isPositiveDependencies: FactoryFunctionMap;
|
2556
|
+
isZeroDependencies: FactoryFunctionMap;
|
2557
|
+
isNaNDependencies: FactoryFunctionMap;
|
2558
|
+
typeOfDependencies: FactoryFunctionMap;
|
2559
|
+
typeofDependencies: FactoryFunctionMap;
|
2560
|
+
equalScalarDependencies: FactoryFunctionMap;
|
2561
|
+
SparseMatrixDependencies: FactoryFunctionMap;
|
2562
|
+
numberDependencies: FactoryFunctionMap;
|
2563
|
+
stringDependencies: FactoryFunctionMap;
|
2564
|
+
booleanDependencies: FactoryFunctionMap;
|
2565
|
+
bignumberDependencies: FactoryFunctionMap;
|
2566
|
+
complexDependencies: FactoryFunctionMap;
|
2567
|
+
fractionDependencies: FactoryFunctionMap;
|
2568
|
+
matrixDependencies: FactoryFunctionMap;
|
2569
|
+
splitUnitDependencies: FactoryFunctionMap;
|
2570
|
+
unaryMinusDependencies: FactoryFunctionMap;
|
2571
|
+
unaryPlusDependencies: FactoryFunctionMap;
|
2572
|
+
absDependencies: FactoryFunctionMap;
|
2573
|
+
applyDependencies: FactoryFunctionMap;
|
2574
|
+
addScalarDependencies: FactoryFunctionMap;
|
2575
|
+
cbrtDependencies: FactoryFunctionMap;
|
2576
|
+
ceilDependencies: FactoryFunctionMap;
|
2577
|
+
cubeDependencies: FactoryFunctionMap;
|
2578
|
+
expDependencies: FactoryFunctionMap;
|
2579
|
+
expm1Dependencies: FactoryFunctionMap;
|
2580
|
+
fixDependencies: FactoryFunctionMap;
|
2581
|
+
floorDependencies: FactoryFunctionMap;
|
2582
|
+
gcdDependencies: FactoryFunctionMap;
|
2583
|
+
lcmDependencies: FactoryFunctionMap;
|
2584
|
+
log10Dependencies: FactoryFunctionMap;
|
2585
|
+
log2Dependencies: FactoryFunctionMap;
|
2586
|
+
modDependencies: FactoryFunctionMap;
|
2587
|
+
multiplyScalarDependencies: FactoryFunctionMap;
|
2588
|
+
multiplyDependencies: FactoryFunctionMap;
|
2589
|
+
nthRootDependencies: FactoryFunctionMap;
|
2590
|
+
signDependencies: FactoryFunctionMap;
|
2591
|
+
sqrtDependencies: FactoryFunctionMap;
|
2592
|
+
squareDependencies: FactoryFunctionMap;
|
2593
|
+
subtractDependencies: FactoryFunctionMap;
|
2594
|
+
xgcdDependencies: FactoryFunctionMap;
|
2595
|
+
dotMultiplyDependencies: FactoryFunctionMap;
|
2596
|
+
bitAndDependencies: FactoryFunctionMap;
|
2597
|
+
bitNotDependencies: FactoryFunctionMap;
|
2598
|
+
bitOrDependencies: FactoryFunctionMap;
|
2599
|
+
bitXorDependencies: FactoryFunctionMap;
|
2600
|
+
argDependencies: FactoryFunctionMap;
|
2601
|
+
conjDependencies: FactoryFunctionMap;
|
2602
|
+
imDependencies: FactoryFunctionMap;
|
2603
|
+
reDependencies: FactoryFunctionMap;
|
2604
|
+
notDependencies: FactoryFunctionMap;
|
2605
|
+
orDependencies: FactoryFunctionMap;
|
2606
|
+
xorDependencies: FactoryFunctionMap;
|
2607
|
+
concatDependencies: FactoryFunctionMap;
|
2608
|
+
columnDependencies: FactoryFunctionMap;
|
2609
|
+
crossDependencies: FactoryFunctionMap;
|
2610
|
+
diagDependencies: FactoryFunctionMap;
|
2611
|
+
eyeDependencies: FactoryFunctionMap;
|
2612
|
+
filterDependencies: FactoryFunctionMap;
|
2613
|
+
flattenDependencies: FactoryFunctionMap;
|
2614
|
+
forEachDependencies: FactoryFunctionMap;
|
2615
|
+
getMatrixDataTypeDependencies: FactoryFunctionMap;
|
2616
|
+
identityDependencies: FactoryFunctionMap;
|
2617
|
+
kronDependencies: FactoryFunctionMap;
|
2618
|
+
mapDependencies: FactoryFunctionMap;
|
2619
|
+
onesDependencies: FactoryFunctionMap;
|
2620
|
+
rangeDependencies: FactoryFunctionMap;
|
2621
|
+
reshapeDependencies: FactoryFunctionMap;
|
2622
|
+
resizeDependencies: FactoryFunctionMap;
|
2623
|
+
rowDependencies: FactoryFunctionMap;
|
2624
|
+
sizeDependencies: FactoryFunctionMap;
|
2625
|
+
squeezeDependencies: FactoryFunctionMap;
|
2626
|
+
subsetDependencies: FactoryFunctionMap;
|
2627
|
+
transposeDependencies: FactoryFunctionMap;
|
2628
|
+
ctransposeDependencies: FactoryFunctionMap;
|
2629
|
+
zerosDependencies: FactoryFunctionMap;
|
2630
|
+
erfDependencies: FactoryFunctionMap;
|
2631
|
+
modeDependencies: FactoryFunctionMap;
|
2632
|
+
prodDependencies: FactoryFunctionMap;
|
2633
|
+
formatDependencies: FactoryFunctionMap;
|
2634
|
+
printDependencies: FactoryFunctionMap;
|
2635
|
+
toDependencies: FactoryFunctionMap;
|
2636
|
+
isPrimeDependencies: FactoryFunctionMap;
|
2637
|
+
numericDependencies: FactoryFunctionMap;
|
2638
|
+
divideScalarDependencies: FactoryFunctionMap;
|
2639
|
+
powDependencies: FactoryFunctionMap;
|
2640
|
+
roundDependencies: FactoryFunctionMap;
|
2641
|
+
logDependencies: FactoryFunctionMap;
|
2642
|
+
log1pDependencies: FactoryFunctionMap;
|
2643
|
+
nthRootsDependencies: FactoryFunctionMap;
|
2644
|
+
dotPowDependencies: FactoryFunctionMap;
|
2645
|
+
dotDivideDependencies: FactoryFunctionMap;
|
2646
|
+
lsolveDependencies: FactoryFunctionMap;
|
2647
|
+
usolveDependencies: FactoryFunctionMap;
|
2648
|
+
leftShiftDependencies: FactoryFunctionMap;
|
2649
|
+
rightArithShiftDependencies: FactoryFunctionMap;
|
2650
|
+
rightLogShiftDependencies: FactoryFunctionMap;
|
2651
|
+
andDependencies: FactoryFunctionMap;
|
2652
|
+
compareDependencies: FactoryFunctionMap;
|
2653
|
+
compareNaturalDependencies: FactoryFunctionMap;
|
2654
|
+
compareTextDependencies: FactoryFunctionMap;
|
2655
|
+
equalDependencies: FactoryFunctionMap;
|
2656
|
+
equalTextDependencies: FactoryFunctionMap;
|
2657
|
+
smallerDependencies: FactoryFunctionMap;
|
2658
|
+
smallerEqDependencies: FactoryFunctionMap;
|
2659
|
+
largerDependencies: FactoryFunctionMap;
|
2660
|
+
largerEqDependencies: FactoryFunctionMap;
|
2661
|
+
deepEqualDependencies: FactoryFunctionMap;
|
2662
|
+
unequalDependencies: FactoryFunctionMap;
|
2663
|
+
partitionSelectDependencies: FactoryFunctionMap;
|
2664
|
+
sortDependencies: FactoryFunctionMap;
|
2665
|
+
maxDependencies: FactoryFunctionMap;
|
2666
|
+
minDependencies: FactoryFunctionMap;
|
2667
|
+
ImmutableDenseMatrixDependencies: FactoryFunctionMap;
|
2668
|
+
IndexDependencies: FactoryFunctionMap;
|
2669
|
+
FibonacciHeapDependencies: FactoryFunctionMap;
|
2670
|
+
SpaDependencies: FactoryFunctionMap;
|
2671
|
+
UnitDependencies: FactoryFunctionMap;
|
2672
|
+
unitDependencies: FactoryFunctionMap;
|
2673
|
+
sparseDependencies: FactoryFunctionMap;
|
2674
|
+
createUnitDependencies: FactoryFunctionMap;
|
2675
|
+
acosDependencies: FactoryFunctionMap;
|
2676
|
+
acoshDependencies: FactoryFunctionMap;
|
2677
|
+
acotDependencies: FactoryFunctionMap;
|
2678
|
+
acothDependencies: FactoryFunctionMap;
|
2679
|
+
acscDependencies: FactoryFunctionMap;
|
2680
|
+
acschDependencies: FactoryFunctionMap;
|
2681
|
+
asecDependencies: FactoryFunctionMap;
|
2682
|
+
asechDependencies: FactoryFunctionMap;
|
2683
|
+
asinDependencies: FactoryFunctionMap;
|
2684
|
+
asinhDependencies: FactoryFunctionMap;
|
2685
|
+
atanDependencies: FactoryFunctionMap;
|
2686
|
+
atan2Dependencies: FactoryFunctionMap;
|
2687
|
+
atanhDependencies: FactoryFunctionMap;
|
2688
|
+
cosDependencies: FactoryFunctionMap;
|
2689
|
+
coshDependencies: FactoryFunctionMap;
|
2690
|
+
cotDependencies: FactoryFunctionMap;
|
2691
|
+
cothDependencies: FactoryFunctionMap;
|
2692
|
+
cscDependencies: FactoryFunctionMap;
|
2693
|
+
cschDependencies: FactoryFunctionMap;
|
2694
|
+
secDependencies: FactoryFunctionMap;
|
2695
|
+
sechDependencies: FactoryFunctionMap;
|
2696
|
+
sinDependencies: FactoryFunctionMap;
|
2697
|
+
sinhDependencies: FactoryFunctionMap;
|
2698
|
+
tanDependencies: FactoryFunctionMap;
|
2699
|
+
tanhDependencies: FactoryFunctionMap;
|
2700
|
+
setCartesianDependencies: FactoryFunctionMap;
|
2701
|
+
setDifferenceDependencies: FactoryFunctionMap;
|
2702
|
+
setDistinctDependencies: FactoryFunctionMap;
|
2703
|
+
setIntersectDependencies: FactoryFunctionMap;
|
2704
|
+
setIsSubsetDependencies: FactoryFunctionMap;
|
2705
|
+
setMultiplicityDependencies: FactoryFunctionMap;
|
2706
|
+
setPowersetDependencies: FactoryFunctionMap;
|
2707
|
+
setSizeDependencies: FactoryFunctionMap;
|
2708
|
+
setSymDifferenceDependencies: FactoryFunctionMap;
|
2709
|
+
setUnionDependencies: FactoryFunctionMap;
|
2710
|
+
addDependencies: FactoryFunctionMap;
|
2711
|
+
hypotDependencies: FactoryFunctionMap;
|
2712
|
+
normDependencies: FactoryFunctionMap;
|
2713
|
+
dotDependencies: FactoryFunctionMap;
|
2714
|
+
traceDependencies: FactoryFunctionMap;
|
2715
|
+
indexDependencies: FactoryFunctionMap;
|
2716
|
+
NodeDependencies: FactoryFunctionMap;
|
2717
|
+
AccessorNodeDependencies: FactoryFunctionMap;
|
2718
|
+
ArrayNodeDependencies: FactoryFunctionMap;
|
2719
|
+
AssignmentNodeDependencies: FactoryFunctionMap;
|
2720
|
+
BlockNodeDependencies: FactoryFunctionMap;
|
2721
|
+
ConditionalNodeDependencies: FactoryFunctionMap;
|
2722
|
+
ConstantNodeDependencies: FactoryFunctionMap;
|
2723
|
+
FunctionAssignmentNodeDependencies: FactoryFunctionMap;
|
2724
|
+
IndexNodeDependencies: FactoryFunctionMap;
|
2725
|
+
ObjectNodeDependencies: FactoryFunctionMap;
|
2726
|
+
OperatorNodeDependencies: FactoryFunctionMap;
|
2727
|
+
ParenthesisNodeDependencies: FactoryFunctionMap;
|
2728
|
+
RangeNodeDependencies: FactoryFunctionMap;
|
2729
|
+
RelationalNodeDependencies: FactoryFunctionMap;
|
2730
|
+
SymbolNodeDependencies: FactoryFunctionMap;
|
2731
|
+
FunctionNodeDependencies: FactoryFunctionMap;
|
2732
|
+
parseDependencies: FactoryFunctionMap;
|
2733
|
+
compileDependencies: FactoryFunctionMap;
|
2734
|
+
evaluateDependencies: FactoryFunctionMap;
|
2735
|
+
evalDependencies: FactoryFunctionMap;
|
2736
|
+
ParserDependencies: FactoryFunctionMap;
|
2737
|
+
parserDependencies: FactoryFunctionMap;
|
2738
|
+
lupDependencies: FactoryFunctionMap;
|
2739
|
+
qrDependencies: FactoryFunctionMap;
|
2740
|
+
sluDependencies: FactoryFunctionMap;
|
2741
|
+
lusolveDependencies: FactoryFunctionMap;
|
2742
|
+
HelpDependencies: FactoryFunctionMap;
|
2743
|
+
ChainDependencies: FactoryFunctionMap;
|
2744
|
+
helpDependencies: FactoryFunctionMap;
|
2745
|
+
chainDependencies: FactoryFunctionMap;
|
2746
|
+
detDependencies: FactoryFunctionMap;
|
2747
|
+
invDependencies: FactoryFunctionMap;
|
2748
|
+
expmDependencies: FactoryFunctionMap;
|
2749
|
+
sqrtmDependencies: FactoryFunctionMap;
|
2750
|
+
divideDependencies: FactoryFunctionMap;
|
2751
|
+
distanceDependencies: FactoryFunctionMap;
|
2752
|
+
intersectDependencies: FactoryFunctionMap;
|
2753
|
+
sumDependencies: FactoryFunctionMap;
|
2754
|
+
meanDependencies: FactoryFunctionMap;
|
2755
|
+
medianDependencies: FactoryFunctionMap;
|
2756
|
+
madDependencies: FactoryFunctionMap;
|
2757
|
+
varianceDependencies: FactoryFunctionMap;
|
2758
|
+
varDependencies: FactoryFunctionMap;
|
2759
|
+
quantileSeqDependencies: FactoryFunctionMap;
|
2760
|
+
stdDependencies: FactoryFunctionMap;
|
2761
|
+
combinationsDependencies: FactoryFunctionMap;
|
2762
|
+
gammaDependencies: FactoryFunctionMap;
|
2763
|
+
factorialDependencies: FactoryFunctionMap;
|
2764
|
+
kldivergenceDependencies: FactoryFunctionMap;
|
2765
|
+
multinomialDependencies: FactoryFunctionMap;
|
2766
|
+
permutationsDependencies: FactoryFunctionMap;
|
2767
|
+
pickRandomDependencies: FactoryFunctionMap;
|
2768
|
+
randomDependencies: FactoryFunctionMap;
|
2769
|
+
randomIntDependencies: FactoryFunctionMap;
|
2770
|
+
stirlingS2Dependencies: FactoryFunctionMap;
|
2771
|
+
bellNumbersDependencies: FactoryFunctionMap;
|
2772
|
+
catalanDependencies: FactoryFunctionMap;
|
2773
|
+
compositionDependencies: FactoryFunctionMap;
|
2774
|
+
simplifyDependencies: FactoryFunctionMap;
|
2775
|
+
derivativeDependencies: FactoryFunctionMap;
|
2776
|
+
rationalizeDependencies: FactoryFunctionMap;
|
2777
|
+
reviverDependencies: FactoryFunctionMap;
|
2778
|
+
eDependencies: FactoryFunctionMap;
|
2779
|
+
EDependencies: FactoryFunctionMap;
|
2780
|
+
falseDependencies: FactoryFunctionMap;
|
2781
|
+
iDependencies: FactoryFunctionMap;
|
2782
|
+
InfinityDependencies: FactoryFunctionMap;
|
2783
|
+
LN10Dependencies: FactoryFunctionMap;
|
2784
|
+
LN2Dependencies: FactoryFunctionMap;
|
2785
|
+
LOG10EDependencies: FactoryFunctionMap;
|
2786
|
+
LOG2EDependencies: FactoryFunctionMap;
|
2787
|
+
NaNDependencies: FactoryFunctionMap;
|
2788
|
+
nullDependencies: FactoryFunctionMap;
|
2789
|
+
phiDependencies: FactoryFunctionMap;
|
2790
|
+
piDependencies: FactoryFunctionMap;
|
2791
|
+
PIDependencies: FactoryFunctionMap;
|
2792
|
+
SQRT1_2Dependencies: FactoryFunctionMap;
|
2793
|
+
SQRT2Dependencies: FactoryFunctionMap;
|
2794
|
+
tauDependencies: FactoryFunctionMap;
|
2795
|
+
trueDependencies: FactoryFunctionMap;
|
2796
|
+
versionDependencies: FactoryFunctionMap;
|
2797
|
+
atomicMassDependencies: FactoryFunctionMap;
|
2798
|
+
avogadroDependencies: FactoryFunctionMap;
|
2799
|
+
bohrMagnetonDependencies: FactoryFunctionMap;
|
2800
|
+
bohrRadiusDependencies: FactoryFunctionMap;
|
2801
|
+
boltzmannDependencies: FactoryFunctionMap;
|
2802
|
+
classicalElectronRadiusDependencies: FactoryFunctionMap;
|
2803
|
+
conductanceQuantumDependencies: FactoryFunctionMap;
|
2804
|
+
coulombDependencies: FactoryFunctionMap;
|
2805
|
+
deuteronMassDependencies: FactoryFunctionMap;
|
2806
|
+
efimovFactorDependencies: FactoryFunctionMap;
|
2807
|
+
electricConstantDependencies: FactoryFunctionMap;
|
2808
|
+
electronMassDependencies: FactoryFunctionMap;
|
2809
|
+
elementaryChargeDependencies: FactoryFunctionMap;
|
2810
|
+
faradayDependencies: FactoryFunctionMap;
|
2811
|
+
fermiCouplingDependencies: FactoryFunctionMap;
|
2812
|
+
fineStructureDependencies: FactoryFunctionMap;
|
2813
|
+
firstRadiationDependencies: FactoryFunctionMap;
|
2814
|
+
gasConstantDependencies: FactoryFunctionMap;
|
2815
|
+
gravitationConstantDependencies: FactoryFunctionMap;
|
2816
|
+
gravityDependencies: FactoryFunctionMap;
|
2817
|
+
hartreeEnergyDependencies: FactoryFunctionMap;
|
2818
|
+
inverseConductanceQuantumDependencies: FactoryFunctionMap;
|
2819
|
+
klitzingDependencies: FactoryFunctionMap;
|
2820
|
+
loschmidtDependencies: FactoryFunctionMap;
|
2821
|
+
magneticConstantDependencies: FactoryFunctionMap;
|
2822
|
+
magneticFluxQuantumDependencies: FactoryFunctionMap;
|
2823
|
+
molarMassDependencies: FactoryFunctionMap;
|
2824
|
+
molarMassC12Dependencies: FactoryFunctionMap;
|
2825
|
+
molarPlanckConstantDependencies: FactoryFunctionMap;
|
2826
|
+
molarVolumeDependencies: FactoryFunctionMap;
|
2827
|
+
neutronMassDependencies: FactoryFunctionMap;
|
2828
|
+
nuclearMagnetonDependencies: FactoryFunctionMap;
|
2829
|
+
planckChargeDependencies: FactoryFunctionMap;
|
2830
|
+
planckConstantDependencies: FactoryFunctionMap;
|
2831
|
+
planckLengthDependencies: FactoryFunctionMap;
|
2832
|
+
planckMassDependencies: FactoryFunctionMap;
|
2833
|
+
planckTemperatureDependencies: FactoryFunctionMap;
|
2834
|
+
planckTimeDependencies: FactoryFunctionMap;
|
2835
|
+
protonMassDependencies: FactoryFunctionMap;
|
2836
|
+
quantumOfCirculationDependencies: FactoryFunctionMap;
|
2837
|
+
reducedPlanckConstantDependencies: FactoryFunctionMap;
|
2838
|
+
rydbergDependencies: FactoryFunctionMap;
|
2839
|
+
sackurTetrodeDependencies: FactoryFunctionMap;
|
2840
|
+
secondRadiationDependencies: FactoryFunctionMap;
|
2841
|
+
speedOfLightDependencies: FactoryFunctionMap;
|
2842
|
+
stefanBoltzmannDependencies: FactoryFunctionMap;
|
2843
|
+
thomsonCrossSectionDependencies: FactoryFunctionMap;
|
2844
|
+
vacuumImpedanceDependencies: FactoryFunctionMap;
|
2845
|
+
weakMixingAngleDependencies: FactoryFunctionMap;
|
2846
|
+
wienDisplacementDependencies: FactoryFunctionMap;
|
2847
|
+
applyTransformDependencies: FactoryFunctionMap;
|
2848
|
+
columnTransformDependencies: FactoryFunctionMap;
|
2849
|
+
filterTransformDependencies: FactoryFunctionMap;
|
2850
|
+
forEachTransformDependencies: FactoryFunctionMap;
|
2851
|
+
indexTransformDependencies: FactoryFunctionMap;
|
2852
|
+
mapTransformDependencies: FactoryFunctionMap;
|
2853
|
+
maxTransformDependencies: FactoryFunctionMap;
|
2854
|
+
meanTransformDependencies: FactoryFunctionMap;
|
2855
|
+
minTransformDependencies: FactoryFunctionMap;
|
2856
|
+
rangeTransformDependencies: FactoryFunctionMap;
|
2857
|
+
rowTransformDependencies: FactoryFunctionMap;
|
2858
|
+
subsetTransformDependencies: FactoryFunctionMap;
|
2859
|
+
concatTransformDependencies: FactoryFunctionMap;
|
2860
|
+
stdTransformDependencies: FactoryFunctionMap;
|
2861
|
+
sumTransformDependencies: FactoryFunctionMap;
|
2862
|
+
varianceTransformDependencies: FactoryFunctionMap;
|
2863
|
+
}
|
2864
|
+
|
2865
|
+
interface Matrix {
|
2866
|
+
type: string;
|
2867
|
+
storage(): string;
|
2868
|
+
datatype(): string;
|
2869
|
+
create(data: MathArray, datatype?: string): void;
|
2870
|
+
density(): number;
|
2871
|
+
subset(index: Index, replacement?: any, defaultValue?: any): Matrix;
|
2872
|
+
get(index: number[]): any;
|
2873
|
+
set(index: number[], value: any, defaultValue?: number | string): Matrix;
|
2874
|
+
resize(size: MathArray | Matrix, defaultValue?: number | string): Matrix;
|
2875
|
+
clone(): Matrix;
|
2876
|
+
size(): number[];
|
2877
|
+
map(callback: (a: any, b: number, c: Matrix) => any, skipZeros?: boolean): Matrix;
|
2878
|
+
forEach(callback: (a: any, b: number, c: Matrix) => void, skipZeros?: boolean): void;
|
2879
|
+
toArray(): MathArray;
|
2880
|
+
valueOf(): MathArray;
|
2881
|
+
format(options?: FormatOptions | number | ((value: any) => string)): string;
|
2882
|
+
toString(): string;
|
2883
|
+
toJSON(): any;
|
2884
|
+
diagonal(k?: number | BigNumber): any[];
|
2885
|
+
swapRows(i: number, j: number): Matrix;
|
2886
|
+
}
|
2887
|
+
|
2888
|
+
interface BigNumber extends Decimal {} // tslint:disable-line no-empty-interface
|
2889
|
+
|
2890
|
+
interface Fraction {
|
2891
|
+
s: number;
|
2892
|
+
n: number;
|
2893
|
+
d: number;
|
2894
|
+
}
|
2895
|
+
|
2896
|
+
interface Complex {
|
2897
|
+
re: number;
|
2898
|
+
im: number;
|
2899
|
+
clone(): Complex;
|
2900
|
+
equals(other: Complex): boolean;
|
2901
|
+
format(precision?: number): string;
|
2902
|
+
fromJSON(json: object): Complex;
|
2903
|
+
fromPolar(polar: object): Complex;
|
2904
|
+
fromPolar(r: number, phi: number): Complex;
|
2905
|
+
toJSON(): object;
|
2906
|
+
toPolar(): PolarCoordinates;
|
2907
|
+
toString(): string;
|
2908
|
+
compare(a: Complex, b: Complex): number;
|
2909
|
+
}
|
2910
|
+
|
2911
|
+
interface PolarCoordinates {
|
2912
|
+
r: number;
|
2913
|
+
phi: number;
|
2914
|
+
}
|
2915
|
+
|
2916
|
+
interface MathJSON {
|
2917
|
+
mathjs?: string;
|
2918
|
+
value: number;
|
2919
|
+
unit: string;
|
2920
|
+
fixPrefix?: boolean;
|
2921
|
+
}
|
2922
|
+
|
2923
|
+
interface Unit {
|
2924
|
+
valueOf(): string;
|
2925
|
+
clone(): Unit;
|
2926
|
+
hasBase(base: any): boolean;
|
2927
|
+
equalBase(unit: Unit): boolean;
|
2928
|
+
equals(unit: Unit): boolean;
|
2929
|
+
multiply(unit: Unit): Unit;
|
2930
|
+
divide(unit: Unit): Unit;
|
2931
|
+
pow(unit: Unit): Unit;
|
2932
|
+
abs(unit: Unit): Unit;
|
2933
|
+
to(unit: string): Unit;
|
2934
|
+
toNumber(unit: string): number;
|
2935
|
+
toNumeric(unit: string): number | Fraction | BigNumber;
|
2936
|
+
toSI(): Unit;
|
2937
|
+
toString(): string;
|
2938
|
+
toJSON(): MathJSON;
|
2939
|
+
formatUnits(): string;
|
2940
|
+
format(options: FormatOptions): string;
|
2941
|
+
splitUnit(parts: ReadonlyArray<string | Unit>): Unit[];
|
2942
|
+
}
|
2943
|
+
|
2944
|
+
interface CreateUnitOptions {
|
2945
|
+
prefixes?: 'none' | 'short' | 'long' | 'binary_short' | 'binary_long';
|
2946
|
+
aliases?: string[];
|
2947
|
+
offset?: number;
|
2948
|
+
override?: boolean;
|
2949
|
+
}
|
2950
|
+
|
2951
|
+
interface SimplifyOptions {
|
2952
|
+
/** A boolean which is `true` by default. */
|
2953
|
+
exactFractions?: boolean;
|
2954
|
+
/**
|
2955
|
+
* When `exactFractions` is true, a fraction will be returned only
|
2956
|
+
* when both numerator and denominator are smaller than `fractionsLimit`.
|
2957
|
+
* Default value is 10000.
|
2958
|
+
*/
|
2959
|
+
fractionsLimit?: number;
|
2960
|
+
}
|
2961
|
+
|
2962
|
+
interface UnitDefinition {
|
2963
|
+
definition?: string | Unit;
|
2964
|
+
prefixes?: string;
|
2965
|
+
offset?: number;
|
2966
|
+
aliases?: string[];
|
2967
|
+
}
|
2968
|
+
|
2969
|
+
interface Index {} // tslint:disable-line no-empty-interface
|
2970
|
+
|
2971
|
+
interface EvalFunction {
|
2972
|
+
evaluate(scope?: any): any;
|
2973
|
+
}
|
2974
|
+
|
2975
|
+
interface MathNode {
|
2976
|
+
isNode: boolean;
|
2977
|
+
isAccessorNode?: boolean;
|
2978
|
+
isArrayNode?: boolean;
|
2979
|
+
isAssignmentNode?: boolean;
|
2980
|
+
isBlockNode?: boolean;
|
2981
|
+
isConditionalnode?: boolean;
|
2982
|
+
isConstantNode?: boolean;
|
2983
|
+
isFunctionAssignmentNode?: boolean;
|
2984
|
+
isFunctionNode?: boolean;
|
2985
|
+
isIndexNode?: boolean;
|
2986
|
+
isObjectNode?: boolean;
|
2987
|
+
isOperatorNode?: boolean;
|
2988
|
+
isParenthesisNode?: boolean;
|
2989
|
+
isRangeNode?: boolean;
|
2990
|
+
isSymbolNode?: boolean;
|
2991
|
+
isUpdateNode?: boolean;
|
2992
|
+
comment?: string;
|
2993
|
+
content?: MathNode;
|
2994
|
+
op?: string;
|
2995
|
+
fn?: string;
|
2996
|
+
args?: MathNode[];
|
2997
|
+
type: string;
|
2998
|
+
name?: string;
|
2999
|
+
value?: any;
|
3000
|
+
|
3001
|
+
/**
|
3002
|
+
* Create a shallow clone of the node. The node itself is cloned, its
|
3003
|
+
* childs are not cloned.
|
3004
|
+
*/
|
3005
|
+
clone(): MathNode;
|
3006
|
+
/**
|
3007
|
+
* Create a deep clone of the node. Both the node as well as all its
|
3008
|
+
* childs are cloned recursively.
|
3009
|
+
*/
|
3010
|
+
cloneDeep(): MathNode;
|
3011
|
+
/**
|
3012
|
+
* Compile an expression into optimized JavaScript code. compile returns
|
3013
|
+
* an object with a function evaluate([scope]) to evaluate. Example:
|
3014
|
+
*/
|
3015
|
+
compile(): EvalFunction;
|
3016
|
+
/**
|
3017
|
+
* Compile and eval an expression, this is the equivalent of doing
|
3018
|
+
* node.compile().evaluate(scope). Example:
|
3019
|
+
*/
|
3020
|
+
evaluate(expr?: any): any;
|
3021
|
+
/**
|
3022
|
+
* Test whether this node equals an other node. Does a deep comparison
|
3023
|
+
* of the values of both nodes.
|
3024
|
+
*/
|
3025
|
+
equals(other: MathNode): boolean;
|
3026
|
+
/**
|
3027
|
+
*
|
3028
|
+
* Filter nodes in an expression tree. The callback function is called
|
3029
|
+
* as callback(node: MathNode, path: string, parent: MathNode) : boolean
|
3030
|
+
* for every node in the tree, and must return a boolean. The function
|
3031
|
+
* filter returns an array with nodes for which the test returned true.
|
3032
|
+
* Parameter path is a string containing a relative JSON Path.
|
3033
|
+
*
|
3034
|
+
* Example:
|
3035
|
+
*
|
3036
|
+
* ```
|
3037
|
+
* var node = math.parse('x^2 + x/4 + 3*y');
|
3038
|
+
* var filtered = node.filter(function (node) {
|
3039
|
+
* return node.isSymbolMathNode && node.name == 'x';
|
3040
|
+
* });
|
3041
|
+
* // returns an array with two entries: two SymbolMathNodes 'x'
|
3042
|
+
* ```
|
3043
|
+
*
|
3044
|
+
* The callback function is called as callback(node: MathNode, path:
|
3045
|
+
* string, parent: MathNode) : boolean for every node in the tree, and
|
3046
|
+
* must return a boolean. The function filter returns an array with
|
3047
|
+
* nodes for which the test returned true. Parameter path is a string
|
3048
|
+
* containing a relative JSON Path.
|
3049
|
+
* @return Returns an array with nodes for which test returned true
|
3050
|
+
*/
|
3051
|
+
filter(callback: (node: MathNode, path: string, parent: MathNode) => any): MathNode[];
|
3052
|
+
|
3053
|
+
/**
|
3054
|
+
* [forEach description]
|
3055
|
+
*/
|
3056
|
+
forEach(callback: (node: MathNode, path: string, parent: MathNode) => any): MathNode[];
|
3057
|
+
|
3058
|
+
/**
|
3059
|
+
* Transform a node. Creates a new MathNode having it’s child's be the
|
3060
|
+
* results of calling the provided callback function for each of the
|
3061
|
+
* child's of the original node. The callback function is called as
|
3062
|
+
* `callback(child: MathNode, path: string, parent: MathNode)` and must
|
3063
|
+
* return a MathNode. Parameter path is a string containing a relative
|
3064
|
+
* JSON Path.
|
3065
|
+
*
|
3066
|
+
*
|
3067
|
+
* See also transform, which is a recursive version of map.
|
3068
|
+
*/
|
3069
|
+
map(callback: (node: MathNode, path: string, parent: MathNode) => MathNode): MathNode;
|
3070
|
+
|
3071
|
+
/**
|
3072
|
+
* Get a HTML representation of the parsed expression.
|
3073
|
+
*/
|
3074
|
+
toHtml(options?: object): string;
|
3075
|
+
|
3076
|
+
/**
|
3077
|
+
* Get a string representation of the parsed expression. This is not
|
3078
|
+
* exactly the same as the original input.
|
3079
|
+
*/
|
3080
|
+
toString(options?: object): string;
|
3081
|
+
|
3082
|
+
/**
|
3083
|
+
* Get a LaTeX representation of the expression.
|
3084
|
+
*/
|
3085
|
+
toTex(options?: object): string;
|
3086
|
+
|
3087
|
+
/**
|
3088
|
+
* Recursively transform an expression tree via a transform function.
|
3089
|
+
* Similar to Array.map, but recursively executed on all nodes in the
|
3090
|
+
* expression tree. The callback function is a mapping function
|
3091
|
+
* accepting a node, and returning a replacement for the node or the
|
3092
|
+
* original node. Function callback is called as callback(node:
|
3093
|
+
* MathNode, path: string, parent: MathNode) for every node in the tree,
|
3094
|
+
* and must return a MathNode. Parameter path is a string containing a
|
3095
|
+
* relative JSON Path.
|
3096
|
+
*
|
3097
|
+
* For example, to replace all nodes of type SymbolMathNode having name
|
3098
|
+
* ‘x’ with a ConstantMathNode with value 3:
|
3099
|
+
* ```js
|
3100
|
+
* var node = math.parse('x^2 + 5*x');
|
3101
|
+
* var transformed = node.transform(function (node, path, parent) {
|
3102
|
+
* if (node.SymbolMathNode && node.name == 'x') {
|
3103
|
+
* return new math.expression.node.ConstantMathNode(3);
|
3104
|
+
* }
|
3105
|
+
* else {
|
3106
|
+
* return node;
|
3107
|
+
* }
|
3108
|
+
* });
|
3109
|
+
* transformed.toString(); // returns '(3 ^ 2) + (5 * 3)'
|
3110
|
+
* ```
|
3111
|
+
*/
|
3112
|
+
transform(callback: (node: MathNode, path: string, parent: MathNode) => MathNode): MathNode;
|
3113
|
+
|
3114
|
+
/**
|
3115
|
+
* `traverse(callback)`
|
3116
|
+
*
|
3117
|
+
* Recursively traverse all nodes in a node tree. Executes given
|
3118
|
+
* callback for this node and each of its child nodes. Similar to
|
3119
|
+
* Array.forEach, except recursive. The callback function is a mapping
|
3120
|
+
* function accepting a node, and returning a replacement for the node
|
3121
|
+
* or the original node. Function callback is called as callback(node:
|
3122
|
+
* MathNode, path: string, parent: MathNode) for every node in the tree.
|
3123
|
+
* Parameter path is a string containing a relative JSON Path. Example:
|
3124
|
+
*
|
3125
|
+
* ```
|
3126
|
+
* var node = math.parse('3 * x + 2');
|
3127
|
+
* node.traverse(function (node, path, parent) {
|
3128
|
+
* switch (node.type) {
|
3129
|
+
* case 'OperatorMathNode': console.log(node.type, node.op); break;
|
3130
|
+
* case 'ConstantMathNode': console.log(node.type, node.value); break;
|
3131
|
+
* case 'SymbolMathNode': console.log(node.type, node.name); break;
|
3132
|
+
* default: console.log(node.type);
|
3133
|
+
* }
|
3134
|
+
* });
|
3135
|
+
* // outputs:
|
3136
|
+
* // OperatorMathNode +
|
3137
|
+
* // OperatorMathNode *
|
3138
|
+
* // ConstantMathNode 3
|
3139
|
+
* // SymbolMathNode x
|
3140
|
+
* // ConstantMathNode 2
|
3141
|
+
* ```
|
3142
|
+
*/
|
3143
|
+
traverse(callback: (node: MathNode, path: string, parent: MathNode) => void): any;
|
3144
|
+
}
|
3145
|
+
|
3146
|
+
interface Parser {
|
3147
|
+
evaluate(expr: string): any;
|
3148
|
+
get(variable: string): any;
|
3149
|
+
getAll(): { [key: string]: any };
|
3150
|
+
set: (variable: string, value: any) => void;
|
3151
|
+
clear: () => void;
|
3152
|
+
}
|
3153
|
+
|
3154
|
+
interface Distribution {
|
3155
|
+
random(size: any, min?: any, max?: any): any;
|
3156
|
+
randomInt(min: any, max?: any): any;
|
3157
|
+
pickRandom(array: any): any;
|
3158
|
+
}
|
3159
|
+
|
3160
|
+
interface FormatOptions {
|
3161
|
+
/**
|
3162
|
+
* Number notation. Choose from: 'fixed' Always use regular number
|
3163
|
+
* notation. For example '123.40' and '14000000' 'exponential' Always
|
3164
|
+
* use exponential notation. For example '1.234e+2' and '1.4e+7' 'auto'
|
3165
|
+
* (default) Regular number notation for numbers having an absolute
|
3166
|
+
* value between lower and upper bounds, and uses exponential notation
|
3167
|
+
* elsewhere. Lower bound is included, upper bound is excluded. For
|
3168
|
+
* example '123.4' and '1.4e7'.
|
3169
|
+
*/
|
3170
|
+
notation?: 'fixed' | 'exponential' | 'engineering' | 'auto';
|
3171
|
+
|
3172
|
+
/**
|
3173
|
+
* A number between 0 and 16 to round the digits of the number. In case
|
3174
|
+
* of notations 'exponential' and 'auto', precision defines the total
|
3175
|
+
* number of significant digits returned and is undefined by default. In
|
3176
|
+
* case of notation 'fixed', precision defines the number of significant
|
3177
|
+
* digits after the decimal point, and is 0 by default.
|
3178
|
+
*/
|
3179
|
+
precision?: number;
|
3180
|
+
|
3181
|
+
/**
|
3182
|
+
* Exponent determining the lower boundary for formatting a value with
|
3183
|
+
* an exponent when notation='auto. Default value is -3.
|
3184
|
+
*/
|
3185
|
+
lowerExp?: number;
|
3186
|
+
|
3187
|
+
/**
|
3188
|
+
* Exponent determining the upper boundary for formatting a value with
|
3189
|
+
* an exponent when notation='auto. Default value is 5.
|
3190
|
+
*/
|
3191
|
+
upperExp?: number;
|
3192
|
+
|
3193
|
+
/**
|
3194
|
+
* Available values: 'ratio' (default) or 'decimal'. For example
|
3195
|
+
* format(fraction(1, 3)) will output '1/3' when 'ratio' is configured,
|
3196
|
+
* and will output 0.(3) when 'decimal' is configured.
|
3197
|
+
*/
|
3198
|
+
fraction?: string;
|
3199
|
+
}
|
3200
|
+
|
3201
|
+
interface Help {
|
3202
|
+
toString(): string;
|
3203
|
+
toJSON(): string;
|
3204
|
+
}
|
3205
|
+
|
3206
|
+
interface ConfigOptions {
|
3207
|
+
epsilon?: number;
|
3208
|
+
matrix?: string;
|
3209
|
+
number?: string;
|
3210
|
+
precision?: number;
|
3211
|
+
parenthesis?: string;
|
3212
|
+
randomSeed?: string;
|
3213
|
+
}
|
3214
|
+
|
3215
|
+
interface MathJsJson {
|
3216
|
+
/**
|
3217
|
+
* Returns reviver function that can be used as reviver in JSON.parse function.
|
3218
|
+
*/
|
3219
|
+
reviver(): (key: any, value: any) => any;
|
3220
|
+
}
|
3221
|
+
|
3222
|
+
interface MathJsChain {
|
3223
|
+
done(): any;
|
3224
|
+
|
3225
|
+
/*************************************************************************
|
3226
|
+
* Construction functions
|
3227
|
+
************************************************************************/
|
3228
|
+
|
3229
|
+
/**
|
3230
|
+
* Create a BigNumber, which can store numbers with arbitrary precision.
|
3231
|
+
* When a matrix is provided, all elements will be converted to
|
3232
|
+
* BigNumber.
|
3233
|
+
*/
|
3234
|
+
bignumber(): MathJsChain;
|
3235
|
+
|
3236
|
+
/**
|
3237
|
+
* Create a boolean or convert a string or number to a boolean. In case
|
3238
|
+
* of a number, true is returned for non-zero numbers, and false in case
|
3239
|
+
* of zero. Strings can be 'true' or 'false', or can contain a number.
|
3240
|
+
* When value is a matrix, all elements will be converted to boolean.
|
3241
|
+
*/
|
3242
|
+
boolean(): MathJsChain;
|
3243
|
+
|
3244
|
+
/**
|
3245
|
+
* Create a complex value or convert a value to a complex value.
|
3246
|
+
* @param im Argument specifying the imaginary part of the complex
|
3247
|
+
* number
|
3248
|
+
*/
|
3249
|
+
complex(im?: number): MathJsChain;
|
3250
|
+
|
3251
|
+
/**
|
3252
|
+
* Create a user-defined unit and register it with the Unit type.
|
3253
|
+
* @param definition Definition of the unit in terms of existing units.
|
3254
|
+
* For example, ‘0.514444444 m / s’.
|
3255
|
+
* @param options (optional) An object containing any of the following
|
3256
|
+
* properties:</br>- prefixes {string} “none”, “short”, “long”,
|
3257
|
+
* “binary_short”, or “binary_long”. The default is “none”.</br>-
|
3258
|
+
* aliases {Array} Array of strings. Example: [‘knots’, ‘kt’,
|
3259
|
+
* ‘kts’]</br>- offset {Numeric} An offset to apply when converting from
|
3260
|
+
* the unit. For example, the offset for celsius is 273.15. Default is
|
3261
|
+
* 0.
|
3262
|
+
*/
|
3263
|
+
createUnit(definition?: string | UnitDefinition, options?: CreateUnitOptions): MathJsChain;
|
3264
|
+
/**
|
3265
|
+
* Create a user-defined unit and register it with the Unit type.
|
3266
|
+
* @param options (optional) An object containing any of the following
|
3267
|
+
* properties:</br>- prefixes {string} “none”, “short”, “long”,
|
3268
|
+
* “binary_short”, or “binary_long”. The default is “none”.</br>-
|
3269
|
+
* aliases {Array} Array of strings. Example: [‘knots’, ‘kt’,
|
3270
|
+
* ‘kts’]</br>- offset {Numeric} An offset to apply when converting from
|
3271
|
+
* the unit. For example, the offset for celsius is 273.15. Default is
|
3272
|
+
* 0.
|
3273
|
+
*/
|
3274
|
+
createUnit(options?: CreateUnitOptions): MathJsChain;
|
3275
|
+
|
3276
|
+
/**
|
3277
|
+
* Create a fraction convert a value to a fraction.
|
3278
|
+
* @param denominator Argument specifying the denominator of the
|
3279
|
+
* fraction
|
3280
|
+
*/
|
3281
|
+
fraction(denominator?: number | string | MathArray | Matrix): MathJsChain;
|
3282
|
+
|
3283
|
+
/**
|
3284
|
+
* Create an index. An Index can store ranges having start, step, and
|
3285
|
+
* end for multiple dimensions. Matrix.get, Matrix.set, and math.subset
|
3286
|
+
* accept an Index as input.
|
3287
|
+
*/
|
3288
|
+
index(): MathJsChain;
|
3289
|
+
|
3290
|
+
/**
|
3291
|
+
* Create a Matrix. The function creates a new math.type.Matrix object
|
3292
|
+
* from an Array. A Matrix has utility functions to manipulate the data
|
3293
|
+
* in the matrix, like getting the size and getting or setting values in
|
3294
|
+
* the matrix. Supported storage formats are 'dense' and 'sparse'.
|
3295
|
+
*/
|
3296
|
+
matrix(format?: 'sparse' | 'dense', dataType?: string): MathJsChain;
|
3297
|
+
|
3298
|
+
/**
|
3299
|
+
* Create a number or convert a string, boolean, or unit to a number.
|
3300
|
+
* When value is a matrix, all elements will be converted to number.
|
3301
|
+
* @param valuelessUnit A valueless unit, used to convert a unit to a
|
3302
|
+
* number
|
3303
|
+
*/
|
3304
|
+
number(valuelessUnit?: Unit | string): MathJsChain;
|
3305
|
+
|
3306
|
+
/**
|
3307
|
+
* Create a Sparse Matrix. The function creates a new math.type.Matrix
|
3308
|
+
* object from an Array. A Matrix has utility functions to manipulate
|
3309
|
+
* the data in the matrix, like getting the size and getting or setting
|
3310
|
+
* values in the matrix.
|
3311
|
+
* @param dataType Sparse Matrix data type
|
3312
|
+
*/
|
3313
|
+
sparse(dataType?: string): MathJsChain;
|
3314
|
+
|
3315
|
+
/**
|
3316
|
+
* Split a unit in an array of units whose sum is equal to the original
|
3317
|
+
* unit.
|
3318
|
+
* @param parts An array of strings or valueless units
|
3319
|
+
*/
|
3320
|
+
splitUnit(parts: Unit[]): MathJsChain;
|
3321
|
+
|
3322
|
+
/**
|
3323
|
+
* Create a string or convert any object into a string. Elements of
|
3324
|
+
* Arrays and Matrices are processed element wise.
|
3325
|
+
*/
|
3326
|
+
string(): MathJsChain;
|
3327
|
+
|
3328
|
+
/**
|
3329
|
+
* Create a unit. Depending on the passed arguments, the function will
|
3330
|
+
* create and return a new math.type.Unit object. When a matrix is
|
3331
|
+
* provided, all elements will be converted to units.
|
3332
|
+
* @param unit The unit to be created
|
3333
|
+
*/
|
3334
|
+
unit(unit?: string): MathJsChain;
|
3335
|
+
|
3336
|
+
/*************************************************************************
|
3337
|
+
* Expression functions
|
3338
|
+
************************************************************************/
|
3339
|
+
|
3340
|
+
/**
|
3341
|
+
* Parse and compile an expression. Returns a an object with a function
|
3342
|
+
* evaluate([scope]) to evaluate the compiled expression.
|
3343
|
+
*/
|
3344
|
+
compile(): MathJsChain;
|
3345
|
+
|
3346
|
+
/**
|
3347
|
+
* Evaluate an expression.
|
3348
|
+
* @param scope Scope to read/write variables
|
3349
|
+
*/
|
3350
|
+
evaluate(scope?: object): MathJsChain;
|
3351
|
+
|
3352
|
+
/**
|
3353
|
+
* Retrieve help on a function or data type. Help files are retrieved
|
3354
|
+
* from the documentation in math.expression.docs.
|
3355
|
+
*/
|
3356
|
+
help(): MathJsChain;
|
3357
|
+
|
3358
|
+
/**
|
3359
|
+
* Parse an expression. Returns a node tree, which can be evaluated by
|
3360
|
+
* invoking node.evaluate();
|
3361
|
+
* @param options Available options: nodes - a set of custome nodes
|
3362
|
+
*/
|
3363
|
+
parse(options?: any): MathJsChain;
|
3364
|
+
/**
|
3365
|
+
* @param options Available options: nodes - a set of custome nodes
|
3366
|
+
*/
|
3367
|
+
parse(options?: any): MathJsChain;
|
3368
|
+
|
3369
|
+
/**
|
3370
|
+
* Create a parser. The function creates a new math.expression.Parser
|
3371
|
+
* object.
|
3372
|
+
*/
|
3373
|
+
parser(): MathJsChain;
|
3374
|
+
|
3375
|
+
/*************************************************************************
|
3376
|
+
* Algebra functions
|
3377
|
+
************************************************************************/
|
3378
|
+
/**
|
3379
|
+
* @param variable The variable over which to differentiate
|
3380
|
+
* @param options There is one option available, simplify, which is true
|
3381
|
+
* by default. When false, output will not be simplified.
|
3382
|
+
*/
|
3383
|
+
derivative(variable: MathNode | string, options?: { simplify: boolean }): MathJsChain;
|
3384
|
+
|
3385
|
+
/**
|
3386
|
+
* Solves the linear equation system by forwards substitution. Matrix
|
3387
|
+
* must be a lower triangular matrix.
|
3388
|
+
* @param b A column vector with the b values
|
3389
|
+
*/
|
3390
|
+
lsolve(b: Matrix | MathArray): MathJsChain;
|
3391
|
+
|
3392
|
+
/**
|
3393
|
+
* Calculate the Matrix LU decomposition with partial pivoting. Matrix A
|
3394
|
+
* is decomposed in two matrices (L, U) and a row permutation vector p
|
3395
|
+
* where A[p,:] = L * U
|
3396
|
+
*/
|
3397
|
+
lup(): MathJsChain;
|
3398
|
+
|
3399
|
+
/**
|
3400
|
+
* Solves the linear system A * x = b where A is an [n x n] matrix and b
|
3401
|
+
* is a [n] column vector.
|
3402
|
+
* @param b Column Vector
|
3403
|
+
* @param order The Symbolic Ordering and Analysis order, see slu for
|
3404
|
+
* details. Matrix must be a SparseMatrix
|
3405
|
+
* @param threshold Partial pivoting threshold (1 for partial pivoting),
|
3406
|
+
* see slu for details. Matrix must be a SparseMatrix.
|
3407
|
+
*/
|
3408
|
+
lusolve(b: Matrix | MathArray, order?: number, threshold?: number): MathJsChain;
|
3409
|
+
|
3410
|
+
/**
|
3411
|
+
* Calculate the Matrix QR decomposition. Matrix A is decomposed in two
|
3412
|
+
* matrices (Q, R) where Q is an orthogonal matrix and R is an upper
|
3413
|
+
* triangular matrix.
|
3414
|
+
*/
|
3415
|
+
qr(): MathJsChain;
|
3416
|
+
|
3417
|
+
/**
|
3418
|
+
* Transform a rationalizable expression in a rational fraction. If
|
3419
|
+
* rational fraction is one variable polynomial then converts the
|
3420
|
+
* numerator and denominator in canonical form, with decreasing
|
3421
|
+
* exponents, returning the coefficients of numerator.
|
3422
|
+
* @param optional scope of expression or true for already evaluated
|
3423
|
+
* rational expression at input
|
3424
|
+
* @param detailed optional True if return an object, false if return
|
3425
|
+
* expression node (default)
|
3426
|
+
*/
|
3427
|
+
rationalize(optional?: object | boolean, detailed?: boolean): MathJsChain;
|
3428
|
+
|
3429
|
+
/**
|
3430
|
+
* Simplify an expression tree.
|
3431
|
+
* @param rules A list of rules are applied to an expression, repeating
|
3432
|
+
* over the list until no further changes are made. It’s possible to
|
3433
|
+
* pass a custom set of rules to the function as second argument. A rule
|
3434
|
+
* can be specified as an object, string, or function.
|
3435
|
+
* @param scope Scope to variables
|
3436
|
+
*/
|
3437
|
+
simplify(rules?: Array<{ l: string; r: string } | string | ((node: MathNode) => MathNode)>, scope?: object): MathJsChain;
|
3438
|
+
|
3439
|
+
/**
|
3440
|
+
* Calculate the Sparse Matrix LU decomposition with full pivoting.
|
3441
|
+
* Sparse Matrix A is decomposed in two matrices (L, U) and two
|
3442
|
+
* permutation vectors (pinv, q) where P * A * Q = L * U
|
3443
|
+
* @param order The Symbolic Ordering and Analysis order: 0 - Natural
|
3444
|
+
* ordering, no permutation vector q is returned 1 - Matrix must be
|
3445
|
+
* square, symbolic ordering and analisis is performed on M = A + A' 2 -
|
3446
|
+
* Symbolic ordering and analysis is performed on M = A' * A. Dense
|
3447
|
+
* columns from A' are dropped, A recreated from A'. This is appropriate
|
3448
|
+
* for LU factorization of non-symmetric matrices. 3 - Symbolic ordering
|
3449
|
+
* and analysis is performed on M = A' * A. This is best used for LU
|
3450
|
+
* factorization is matrix M has no dense rows. A dense row is a row
|
3451
|
+
* with more than 10*sqr(columns) entries.
|
3452
|
+
* @param threshold Partial pivoting threshold (1 for partial pivoting)
|
3453
|
+
*/
|
3454
|
+
slu(order: number, threshold: number): MathJsChain;
|
3455
|
+
|
3456
|
+
/**
|
3457
|
+
* Solves the linear equation system by backward substitution. Matrix
|
3458
|
+
* must be an upper triangular matrix. U * x = b
|
3459
|
+
* @param b A column vector with the b values
|
3460
|
+
*/
|
3461
|
+
usolve(b: Matrix | MathArray): MathJsChain;
|
3462
|
+
|
3463
|
+
/*************************************************************************
|
3464
|
+
* Arithmetic functions
|
3465
|
+
************************************************************************/
|
3466
|
+
|
3467
|
+
/**
|
3468
|
+
* Calculate the absolute value of a number. For matrices, the function
|
3469
|
+
* is evaluated element wise.
|
3470
|
+
*/
|
3471
|
+
abs(): MathJsChain;
|
3472
|
+
|
3473
|
+
/**
|
3474
|
+
* Add two values, x + y. For matrices, the function is evaluated
|
3475
|
+
* element wise.
|
3476
|
+
* @param y Second value to add
|
3477
|
+
*/
|
3478
|
+
add(y: MathType): MathJsChain;
|
3479
|
+
|
3480
|
+
/**
|
3481
|
+
* Calculate the cubic root of a value. For matrices, the function is
|
3482
|
+
* evaluated element wise.
|
3483
|
+
* @param allRoots Optional, false by default. Only applicable when x is
|
3484
|
+
* a number or complex number. If true, all complex roots are returned,
|
3485
|
+
* if false (default) the principal root is returned.
|
3486
|
+
*/
|
3487
|
+
cbrt(allRoots?: boolean): MathJsChain;
|
3488
|
+
|
3489
|
+
/**
|
3490
|
+
* Round a value towards plus infinity If x is complex, both real and
|
3491
|
+
* imaginary part are rounded towards plus infinity. For matrices, the
|
3492
|
+
* function is evaluated element wise.
|
3493
|
+
*/
|
3494
|
+
ceil(): MathJsChain;
|
3495
|
+
|
3496
|
+
/**
|
3497
|
+
* Compute the cube of a value, x * x * x. For matrices, the function is
|
3498
|
+
* evaluated element wise.
|
3499
|
+
*/
|
3500
|
+
cube(): MathJsChain;
|
3501
|
+
|
3502
|
+
/**
|
3503
|
+
* Divide two values, x / y. To divide matrices, x is multiplied with
|
3504
|
+
* the inverse of y: x * inv(y).
|
3505
|
+
* @param y Denominator
|
3506
|
+
*/
|
3507
|
+
divide(y: MathType): MathJsChain;
|
3508
|
+
|
3509
|
+
/**
|
3510
|
+
* Divide two matrices element wise. The function accepts both matrices
|
3511
|
+
* and scalar values.
|
3512
|
+
* @param y Denominator
|
3513
|
+
*/
|
3514
|
+
dotDivide(y: MathType): MathJsChain;
|
3515
|
+
|
3516
|
+
/**
|
3517
|
+
* Multiply two matrices element wise. The function accepts both
|
3518
|
+
* matrices and scalar values.
|
3519
|
+
* @param y Right hand value
|
3520
|
+
*/
|
3521
|
+
dotMultiply(y: MathType): MathJsChain;
|
3522
|
+
|
3523
|
+
/**
|
3524
|
+
* Calculates the power of x to y element wise.
|
3525
|
+
* @param y The exponent
|
3526
|
+
*/
|
3527
|
+
dotPow(y: MathType): MathJsChain;
|
3528
|
+
|
3529
|
+
/**
|
3530
|
+
* Calculate the exponent of a value. For matrices, the function is
|
3531
|
+
* evaluated element wise.
|
3532
|
+
*/
|
3533
|
+
exp(): MathJsChain;
|
3534
|
+
|
3535
|
+
/**
|
3536
|
+
* Calculate the value of subtracting 1 from the exponential value. For
|
3537
|
+
* matrices, the function is evaluated element wise.
|
3538
|
+
*/
|
3539
|
+
expm1(): MathJsChain;
|
3540
|
+
|
3541
|
+
/**
|
3542
|
+
* Round a value towards zero. For matrices, the function is evaluated
|
3543
|
+
* element wise.
|
3544
|
+
*/
|
3545
|
+
fix(): MathJsChain;
|
3546
|
+
|
3547
|
+
/**
|
3548
|
+
* Round a value towards minus infinity. For matrices, the function is
|
3549
|
+
* evaluated element wise.
|
3550
|
+
*/
|
3551
|
+
floor(): MathJsChain;
|
3552
|
+
|
3553
|
+
/**
|
3554
|
+
* Calculate the greatest common divisor for two or more values or
|
3555
|
+
* arrays. For matrices, the function is evaluated element wise.
|
3556
|
+
*/
|
3557
|
+
gcd(): MathJsChain;
|
3558
|
+
|
3559
|
+
/**
|
3560
|
+
* Calculate the hypotenusa of a list with values. The hypotenusa is
|
3561
|
+
* defined as: hypot(a, b, c, ...) = sqrt(a^2 + b^2 + c^2 + ...) For
|
3562
|
+
* matrix input, the hypotenusa is calculated for all values in the
|
3563
|
+
* matrix.
|
3564
|
+
*/
|
3565
|
+
hypot(): MathJsChain;
|
3566
|
+
|
3567
|
+
/**
|
3568
|
+
* Calculate the least common multiple for two or more values or arrays.
|
3569
|
+
* lcm is defined as: lcm(a, b) = abs(a * b) / gcd(a, b) For matrices,
|
3570
|
+
* the function is evaluated element wise.
|
3571
|
+
* @param b An integer number
|
3572
|
+
*/
|
3573
|
+
lcm(b: number | BigNumber | MathArray | Matrix): MathJsChain;
|
3574
|
+
|
3575
|
+
/**
|
3576
|
+
* Calculate the logarithm of a value. For matrices, the function is
|
3577
|
+
* evaluated element wise.
|
3578
|
+
* @param base Optional base for the logarithm. If not provided, the
|
3579
|
+
* natural logarithm of x is calculated. Default value: e.
|
3580
|
+
*/
|
3581
|
+
log(base?: number | BigNumber | Complex): MathJsChain;
|
3582
|
+
|
3583
|
+
/**
|
3584
|
+
* Calculate the 10-base of a value. This is the same as calculating
|
3585
|
+
* log(x, 10). For matrices, the function is evaluated element wise.
|
3586
|
+
*/
|
3587
|
+
log10(): MathJsChain;
|
3588
|
+
|
3589
|
+
/**
|
3590
|
+
* Calculate the logarithm of a value+1. For matrices, the function is
|
3591
|
+
* evaluated element wise.
|
3592
|
+
*/
|
3593
|
+
log1p(base?: number | BigNumber | Complex): MathJsChain;
|
3594
|
+
/**
|
3595
|
+
* Calculate the 2-base of a value. This is the same as calculating
|
3596
|
+
* log(x, 2). For matrices, the function is evaluated element wise.
|
3597
|
+
*/
|
3598
|
+
log2(): MathJsChain;
|
3599
|
+
/**
|
3600
|
+
* Calculates the modulus, the remainder of an integer division. For
|
3601
|
+
* matrices, the function is evaluated element wise. The modulus is
|
3602
|
+
* defined as: x - y * floor(x / y)
|
3603
|
+
* @see http://en.wikipedia.org/wiki/Modulo_operation.
|
3604
|
+
* @param y Divisor
|
3605
|
+
*/
|
3606
|
+
mod(y: number | BigNumber | Fraction | MathArray | Matrix): MathJsChain;
|
3607
|
+
|
3608
|
+
/**
|
3609
|
+
* Multiply two values, x * y. The result is squeezed. For matrices, the
|
3610
|
+
* matrix product is calculated.
|
3611
|
+
* @param y The second value to multiply
|
3612
|
+
*/
|
3613
|
+
multiply(y: MathType): MathJsChain;
|
3614
|
+
|
3615
|
+
/**
|
3616
|
+
* Calculate the norm of a number, vector or matrix. The second
|
3617
|
+
* parameter p is optional. If not provided, it defaults to 2.
|
3618
|
+
* @param p Vector space. Supported numbers include Infinity and
|
3619
|
+
* -Infinity. Supported strings are: 'inf', '-inf', and 'fro' (The
|
3620
|
+
* Frobenius norm) Default value: 2.
|
3621
|
+
*/
|
3622
|
+
norm(p?: number | BigNumber | string): MathJsChain;
|
3623
|
+
|
3624
|
+
/**
|
3625
|
+
* Calculate the nth root of a value. The principal nth root of a
|
3626
|
+
* positive real number A, is the positive real solution of the equation
|
3627
|
+
* x^root = A For matrices, the function is evaluated element wise.
|
3628
|
+
* @param root The root. Default value: 2.
|
3629
|
+
*/
|
3630
|
+
nthRoot(root?: number | BigNumber): MathJsChain;
|
3631
|
+
|
3632
|
+
/**
|
3633
|
+
* Calculates the power of x to y, x ^ y. Matrix exponentiation is
|
3634
|
+
* supported for square matrices x, and positive integer exponents y.
|
3635
|
+
* @param y The exponent
|
3636
|
+
*/
|
3637
|
+
pow(y: number | BigNumber): MathJsChain;
|
3638
|
+
|
3639
|
+
/**
|
3640
|
+
* Round a value towards the nearest integer. For matrices, the function
|
3641
|
+
* is evaluated element wise.
|
3642
|
+
* @param n Number of decimals Default value: 0.
|
3643
|
+
*/
|
3644
|
+
round(n?: number | BigNumber | MathArray): MathJsChain;
|
3645
|
+
|
3646
|
+
/**
|
3647
|
+
* Compute the sign of a value. The sign of a value x is: 1 when x > 1
|
3648
|
+
* -1 when x < 0 0 when x == 0 For matrices, the function is evaluated
|
3649
|
+
* element wise.
|
3650
|
+
* @param x The number for which to determine the sign
|
3651
|
+
* @returns The sign of x
|
3652
|
+
*/
|
3653
|
+
sign(x: number | BigNumber): MathJsChain;
|
3654
|
+
|
3655
|
+
/**
|
3656
|
+
* Calculate the square root of a value. For matrices, the function is
|
3657
|
+
* evaluated element wise.
|
3658
|
+
*/
|
3659
|
+
sqrt(): MathJsChain;
|
3660
|
+
|
3661
|
+
/**
|
3662
|
+
* Compute the square of a value, x * x. For matrices, the function is
|
3663
|
+
* evaluated element wise.
|
3664
|
+
*/
|
3665
|
+
square(): MathJsChain;
|
3666
|
+
|
3667
|
+
/**
|
3668
|
+
* Subtract two values, x - y. For matrices, the function is evaluated
|
3669
|
+
* element wise.
|
3670
|
+
* @param y Value to subtract from x
|
3671
|
+
*/
|
3672
|
+
subtract(y: MathType): MathJsChain;
|
3673
|
+
|
3674
|
+
/**
|
3675
|
+
* Inverse the sign of a value, apply a unary minus operation. For
|
3676
|
+
* matrices, the function is evaluated element wise. Boolean values and
|
3677
|
+
* strings will be converted to a number. For complex numbers, both real
|
3678
|
+
* and complex value are inverted.
|
3679
|
+
*/
|
3680
|
+
unaryMinus(): MathJsChain;
|
3681
|
+
|
3682
|
+
/**
|
3683
|
+
* Unary plus operation. Boolean values and strings will be converted to
|
3684
|
+
* a number, numeric values will be returned as is. For matrices, the
|
3685
|
+
* function is evaluated element wise.
|
3686
|
+
*/
|
3687
|
+
unaryPlus(): MathJsChain;
|
3688
|
+
|
3689
|
+
/**
|
3690
|
+
* Calculate the extended greatest common divisor for two values. See
|
3691
|
+
* http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm.
|
3692
|
+
* @param b An integer number
|
3693
|
+
*/
|
3694
|
+
xgcd(b: number | BigNumber): MathJsChain;
|
3695
|
+
|
3696
|
+
/*************************************************************************
|
3697
|
+
* Bitwise functions
|
3698
|
+
************************************************************************/
|
3699
|
+
|
3700
|
+
/**
|
3701
|
+
* Bitwise AND two values, x & y. For matrices, the function is
|
3702
|
+
* evaluated element wise.
|
3703
|
+
* @param y Second value to and
|
3704
|
+
*/
|
3705
|
+
bitAnd(y: number | BigNumber | MathArray | Matrix): MathJsChain;
|
3706
|
+
|
3707
|
+
/**
|
3708
|
+
* Bitwise NOT value, ~x. For matrices, the function is evaluated
|
3709
|
+
* element wise. For units, the function is evaluated on the best prefix
|
3710
|
+
* base.
|
3711
|
+
*/
|
3712
|
+
bitNot(): MathJsChain;
|
3713
|
+
|
3714
|
+
/**
|
3715
|
+
* Bitwise OR two values, x | y. For matrices, the function is evaluated
|
3716
|
+
* element wise. For units, the function is evaluated on the lowest
|
3717
|
+
* print base.
|
3718
|
+
* @param y Second value to or
|
3719
|
+
*/
|
3720
|
+
bitOr(y: number | BigNumber | MathArray | Matrix): MathJsChain;
|
3721
|
+
|
3722
|
+
/**
|
3723
|
+
* Bitwise XOR two values, x ^ y. For matrices, the function is
|
3724
|
+
* evaluated element wise.
|
3725
|
+
* @param y Second value to xor
|
3726
|
+
*/
|
3727
|
+
bitXor(y: number | BigNumber | MathArray | Matrix): MathJsChain;
|
3728
|
+
|
3729
|
+
/**
|
3730
|
+
* Bitwise left logical shift of a value x by y number of bits, x << y.
|
3731
|
+
* For matrices, the function is evaluated element wise. For units, the
|
3732
|
+
* function is evaluated on the best prefix base.
|
3733
|
+
* @param y Amount of shifts
|
3734
|
+
*/
|
3735
|
+
leftShift(y: number | BigNumber): MathJsChain;
|
3736
|
+
|
3737
|
+
/**
|
3738
|
+
* Bitwise right arithmetic shift of a value x by y number of bits, x >>
|
3739
|
+
* y. For matrices, the function is evaluated element wise. For units,
|
3740
|
+
* the function is evaluated on the best prefix base.
|
3741
|
+
* @param y Amount of shifts
|
3742
|
+
*/
|
3743
|
+
rightArithShift(y: number | BigNumber): MathJsChain;
|
3744
|
+
|
3745
|
+
/**
|
3746
|
+
* Bitwise right logical shift of value x by y number of bits, x >>> y.
|
3747
|
+
* For matrices, the function is evaluated element wise. For units, the
|
3748
|
+
* function is evaluated on the best prefix base.
|
3749
|
+
* @param y Amount of shifts
|
3750
|
+
*/
|
3751
|
+
rightLogShift(y: number): MathJsChain;
|
3752
|
+
|
3753
|
+
/*************************************************************************
|
3754
|
+
* Combinatorics functions
|
3755
|
+
************************************************************************/
|
3756
|
+
|
3757
|
+
/**
|
3758
|
+
* The Bell Numbers count the number of partitions of a set. A partition
|
3759
|
+
* is a pairwise disjoint subset of S whose union is S. bellNumbers only
|
3760
|
+
* takes integer arguments. The following condition must be enforced: n
|
3761
|
+
* >= 0
|
3762
|
+
*/
|
3763
|
+
bellNumbers(): MathJsChain;
|
3764
|
+
|
3765
|
+
/**
|
3766
|
+
* The Catalan Numbers enumerate combinatorial structures of many
|
3767
|
+
* different types. catalan only takes integer arguments. The following
|
3768
|
+
* condition must be enforced: n >= 0
|
3769
|
+
*/
|
3770
|
+
catalan(): MathJsChain;
|
3771
|
+
|
3772
|
+
/**
|
3773
|
+
* The composition counts of n into k parts. Composition only takes
|
3774
|
+
* integer arguments. The following condition must be enforced: k <= n.
|
3775
|
+
* @param k Number of objects in the subset
|
3776
|
+
*/
|
3777
|
+
composition(k: number | BigNumber): MathJsChain;
|
3778
|
+
|
3779
|
+
/**
|
3780
|
+
* The Stirling numbers of the second kind, counts the number of ways to
|
3781
|
+
* partition a set of n labelled objects into k nonempty unlabelled
|
3782
|
+
* subsets. stirlingS2 only takes integer arguments. The following
|
3783
|
+
* condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) =
|
3784
|
+
* 1
|
3785
|
+
* @param k Number of objects in the subset
|
3786
|
+
*/
|
3787
|
+
stirlingS2(k: number | BigNumber): MathJsChain;
|
3788
|
+
|
3789
|
+
/*************************************************************************
|
3790
|
+
* Complex functions
|
3791
|
+
************************************************************************/
|
3792
|
+
|
3793
|
+
/**
|
3794
|
+
* Compute the argument of a complex value. For a complex number a + bi,
|
3795
|
+
* the argument is computed as atan2(b, a). For matrices, the function
|
3796
|
+
* is evaluated element wise.
|
3797
|
+
*/
|
3798
|
+
arg(): MathJsChain;
|
3799
|
+
|
3800
|
+
/**
|
3801
|
+
* Compute the complex conjugate of a complex value. If x = a+bi, the
|
3802
|
+
* complex conjugate of x is a - bi. For matrices, the function is
|
3803
|
+
* evaluated element wise.
|
3804
|
+
*/
|
3805
|
+
conj(): MathJsChain;
|
3806
|
+
|
3807
|
+
/**
|
3808
|
+
* Get the imaginary part of a complex number. For a complex number a +
|
3809
|
+
* bi, the function returns b. For matrices, the function is evaluated
|
3810
|
+
* element wise.
|
3811
|
+
*/
|
3812
|
+
im(): MathJsChain;
|
3813
|
+
|
3814
|
+
/**
|
3815
|
+
* Get the real part of a complex number. For a complex number a + bi,
|
3816
|
+
* the function returns a. For matrices, the function is evaluated
|
3817
|
+
* element wise.
|
3818
|
+
*/
|
3819
|
+
re(): MathJsChain;
|
3820
|
+
|
3821
|
+
/*************************************************************************
|
3822
|
+
* Geometry functions
|
3823
|
+
************************************************************************/
|
3824
|
+
|
3825
|
+
/**
|
3826
|
+
* Calculates: The eucledian distance between two points in 2 and 3
|
3827
|
+
* dimensional spaces. Distance between point and a line in 2 and 3
|
3828
|
+
* dimensional spaces. Pairwise distance between a set of 2D or 3D
|
3829
|
+
* points NOTE: When substituting coefficients of a line(a, b and c),
|
3830
|
+
* use ax + by + c = 0 instead of ax + by = c For parametric equation of
|
3831
|
+
* a 3D line, x0, y0, z0, a, b, c are from: (x−x0, y−y0, z−z0) = t(a, b,
|
3832
|
+
* c)
|
3833
|
+
* @param y Coordinates of the second point
|
3834
|
+
*/
|
3835
|
+
distance(y: MathArray | Matrix | object): MathJsChain;
|
3836
|
+
|
3837
|
+
/**
|
3838
|
+
* Calculates the point of intersection of two lines in two or three
|
3839
|
+
* dimensions and of a line and a plane in three dimensions. The inputs
|
3840
|
+
* are in the form of arrays or 1 dimensional matrices. The line
|
3841
|
+
* intersection functions return null if the lines do not meet. Note:
|
3842
|
+
* Fill the plane coefficients as x + y + z = c and not as x + y + z + c
|
3843
|
+
* = 0.
|
3844
|
+
* @param x Co-ordinates of second end-point of first line
|
3845
|
+
* @param y Co-ordinates of first end-point of second line OR
|
3846
|
+
* Coefficients of the plane's equation
|
3847
|
+
* @param z Co-ordinates of second end-point of second line OR null if
|
3848
|
+
* the calculation is for line and plane
|
3849
|
+
*/
|
3850
|
+
intersect(x: MathArray | Matrix, y: MathArray | Matrix, z: MathArray | Matrix): MathJsChain;
|
3851
|
+
|
3852
|
+
/*************************************************************************
|
3853
|
+
* Logical functions
|
3854
|
+
************************************************************************/
|
3855
|
+
|
3856
|
+
/**
|
3857
|
+
* Logical and. Test whether two values are both defined with a
|
3858
|
+
* nonzero/nonempty value. For matrices, the function is evaluated
|
3859
|
+
* element wise.
|
3860
|
+
* @param y Second value to and
|
3861
|
+
*/
|
3862
|
+
and(y: number | BigNumber | Complex | Unit | MathArray | Matrix): MathJsChain;
|
3863
|
+
|
3864
|
+
/**
|
3865
|
+
* Logical not. Flips boolean value of a given parameter. For matrices,
|
3866
|
+
* the function is evaluated element wise.
|
3867
|
+
*/
|
3868
|
+
not(): MathJsChain;
|
3869
|
+
|
3870
|
+
/**
|
3871
|
+
* Logical or. Test if at least one value is defined with a
|
3872
|
+
* nonzero/nonempty value. For matrices, the function is evaluated
|
3873
|
+
* element wise.
|
3874
|
+
* @param y Second value to or
|
3875
|
+
*/
|
3876
|
+
or(y: number | BigNumber | Complex | Unit | MathArray | Matrix): MathJsChain;
|
3877
|
+
|
3878
|
+
/**
|
3879
|
+
* Logical xor. Test whether one and only one value is defined with a
|
3880
|
+
* nonzero/nonempty value. For matrices, the function is evaluated
|
3881
|
+
* element wise.
|
3882
|
+
* @param y Second value to xor
|
3883
|
+
*/
|
3884
|
+
xor(y: number | BigNumber | Complex | Unit | MathArray | Matrix): MathJsChain;
|
3885
|
+
|
3886
|
+
/*************************************************************************
|
3887
|
+
* Matrix functions
|
3888
|
+
************************************************************************/
|
3889
|
+
|
3890
|
+
/**
|
3891
|
+
* Concatenate two or more matrices. dim: number is a zero-based
|
3892
|
+
* dimension over which to concatenate the matrices. By default the last
|
3893
|
+
* dimension of the matrices.
|
3894
|
+
*/
|
3895
|
+
concat(): MathJsChain;
|
3896
|
+
|
3897
|
+
/**
|
3898
|
+
* Calculate the cross product for two vectors in three dimensional
|
3899
|
+
* space. The cross product of A = [a1, a2, a3] and B =[b1, b2, b3] is
|
3900
|
+
* defined as: cross(A, B) = [ a2 * b3 - a3 * b2, a3 * b1 - a1 * b3, a1
|
3901
|
+
* * b2 - a2 * b1 ]
|
3902
|
+
* @param y Second vector
|
3903
|
+
*/
|
3904
|
+
cross(y: MathArray | Matrix): MathJsChain;
|
3905
|
+
|
3906
|
+
/**
|
3907
|
+
* Calculate the determinant of a matrix.
|
3908
|
+
*/
|
3909
|
+
det(): MathJsChain;
|
3910
|
+
|
3911
|
+
/**
|
3912
|
+
* Create a diagonal matrix or retrieve the diagonal of a matrix. When x
|
3913
|
+
* is a vector, a matrix with vector x on the diagonal will be returned.
|
3914
|
+
* When x is a two dimensional matrix, the matrixes kth diagonal will be
|
3915
|
+
* returned as vector. When k is positive, the values are placed on the
|
3916
|
+
* super diagonal. When k is negative, the values are placed on the sub
|
3917
|
+
* diagonal.
|
3918
|
+
* @param k The diagonal where the vector will be filled in or
|
3919
|
+
* retrieved. Default value: 0.
|
3920
|
+
* @param format The matrix storage format. Default value: 'dense'.
|
3921
|
+
*/
|
3922
|
+
diag(format?: string): MathJsChain;
|
3923
|
+
diag(k: number | BigNumber, format?: string): MathJsChain;
|
3924
|
+
|
3925
|
+
/**
|
3926
|
+
* Calculate the dot product of two vectors. The dot product of A = [a1,
|
3927
|
+
* a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as: dot(A,
|
3928
|
+
* B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn
|
3929
|
+
* @param y Second vector
|
3930
|
+
*/
|
3931
|
+
dot(y: MathArray | Matrix): MathJsChain;
|
3932
|
+
|
3933
|
+
/**
|
3934
|
+
* Compute the matrix exponential, expm(A) = e^A. The matrix must be
|
3935
|
+
* square. Not to be confused with exp(a), which performs element-wise
|
3936
|
+
* exponentiation. The exponential is calculated using the Padé
|
3937
|
+
* approximant with scaling and squaring; see “Nineteen Dubious Ways to
|
3938
|
+
* Compute the Exponential of a Matrix,” by Moler and Van Loan.
|
3939
|
+
*/
|
3940
|
+
expm(): MathJsChain;
|
3941
|
+
|
3942
|
+
/**
|
3943
|
+
* Create a 2-dimensional identity matrix with size m x n or n x n. The
|
3944
|
+
* matrix has ones on the diagonal and zeros elsewhere.
|
3945
|
+
* @param format The Matrix storage format
|
3946
|
+
*/
|
3947
|
+
identity(format?: string): MathJsChain;
|
3948
|
+
/**
|
3949
|
+
* @param n The y dimension for the matrix
|
3950
|
+
* @param format The Matrix storage format
|
3951
|
+
*/
|
3952
|
+
identity(n: number, format?: string): MathJsChain;
|
3953
|
+
|
3954
|
+
/**
|
3955
|
+
* Filter the items in an array or one dimensional matrix.
|
3956
|
+
*/
|
3957
|
+
filter(test: ((value: any, index: any, matrix: Matrix | MathArray) => boolean) | RegExp): MathJsChain;
|
3958
|
+
|
3959
|
+
/**
|
3960
|
+
* Flatten a multi dimensional matrix into a single dimensional matrix.
|
3961
|
+
*/
|
3962
|
+
flatten(): MathJsChain;
|
3963
|
+
|
3964
|
+
/**
|
3965
|
+
* Iterate over all elements of a matrix/array, and executes the given
|
3966
|
+
* callback function.
|
3967
|
+
*/
|
3968
|
+
forEach(callback: (value: any, index: any, matrix: Matrix | MathArray) => void): MathJsChain;
|
3969
|
+
|
3970
|
+
/**
|
3971
|
+
* Calculate the inverse of a square matrix.
|
3972
|
+
*/
|
3973
|
+
inv(): MathJsChain;
|
3974
|
+
|
3975
|
+
/**
|
3976
|
+
* Calculate the kronecker product of two matrices or vectors
|
3977
|
+
* @param y Second vector
|
3978
|
+
*/
|
3979
|
+
kron(y: Matrix | MathArray): MathJsChain;
|
3980
|
+
|
3981
|
+
/**
|
3982
|
+
* Iterate over all elements of a matrix/array, and executes the given
|
3983
|
+
* callback function.
|
3984
|
+
* @param callback The callback function is invoked with three
|
3985
|
+
* parameters: the value of the element, the index of the element, and
|
3986
|
+
* the Matrix/array being traversed.
|
3987
|
+
*/
|
3988
|
+
map(callback: (value: any, index: any, matrix: Matrix | MathArray) => Matrix | MathArray): MathJsChain;
|
3989
|
+
|
3990
|
+
/**
|
3991
|
+
* Create a matrix filled with ones. The created matrix can have one or
|
3992
|
+
* multiple dimensions.
|
3993
|
+
* @param format The matrix storage format
|
3994
|
+
*/
|
3995
|
+
ones(format?: string): MathJsChain;
|
3996
|
+
/**
|
3997
|
+
* @param format The matrix storage format
|
3998
|
+
*/
|
3999
|
+
ones(n: number, format?: string): MathJsChain;
|
4000
|
+
/**
|
4001
|
+
* Partition-based selection of an array or 1D matrix. Will find the kth
|
4002
|
+
* smallest value, and mutates the input array. Uses Quickselect.
|
4003
|
+
* @param k The kth smallest value to be retrieved; zero-based index
|
4004
|
+
* @param compare An optional comparator function. The function is
|
4005
|
+
* called as compare(a, b), and must return 1 when a > b, -1 when a < b,
|
4006
|
+
* and 0 when a == b. Default value: 'asc'.
|
4007
|
+
*/
|
4008
|
+
partitionSelect(k: number, compare?: 'asc' | 'desc' | ((a: any, b: any) => number)): MathJsChain;
|
4009
|
+
|
4010
|
+
/**
|
4011
|
+
* Create an array from a range. By default, the range end is excluded.
|
4012
|
+
* This can be customized by providing an extra parameter includeEnd.
|
4013
|
+
* @param end End of the range, excluded by default, included when
|
4014
|
+
* parameter includeEnd=true
|
4015
|
+
* @param step Step size. Default value is 1.
|
4016
|
+
* @param includeEnd: Option to specify whether to include the end or
|
4017
|
+
* not. False by default
|
4018
|
+
*/
|
4019
|
+
range(includeEnd?: boolean): Matrix;
|
4020
|
+
range(end: number | BigNumber, includeEnd?: boolean): MathJsChain;
|
4021
|
+
range(end: number | BigNumber, step: number | BigNumber, includeEnd?: boolean): MathJsChain;
|
4022
|
+
|
4023
|
+
/**
|
4024
|
+
* Reshape a multi dimensional array to fit the specified dimensions
|
4025
|
+
* @param sizes One dimensional array with integral sizes for each
|
4026
|
+
* dimension
|
4027
|
+
*/
|
4028
|
+
reshape(sizes: number[]): MathJsChain;
|
4029
|
+
|
4030
|
+
/**
|
4031
|
+
* Resize a matrix
|
4032
|
+
* @param size One dimensional array with numbers
|
4033
|
+
* @param defaultValue Zero by default, except in case of a string, in
|
4034
|
+
* that case defaultValue = ' ' Default value: 0.
|
4035
|
+
*/
|
4036
|
+
resize(size: MathArray | Matrix, defaultValue?: number | string): MathJsChain;
|
4037
|
+
|
4038
|
+
/**
|
4039
|
+
* Calculate the size of a matrix or scalar.
|
4040
|
+
*/
|
4041
|
+
size(): MathJsChain;
|
4042
|
+
|
4043
|
+
/**
|
4044
|
+
* Sort the items in a matrix
|
4045
|
+
* @param compare An optional _comparator function or name. The function
|
4046
|
+
* is called as compare(a, b), and must return 1 when a > b, -1 when a <
|
4047
|
+
* b, and 0 when a == b. Default value: ‘asc’
|
4048
|
+
*/
|
4049
|
+
sort(compare: ((a: any, b: any) => number) | 'asc' | 'desc' | 'natural'): MathJsChain;
|
4050
|
+
|
4051
|
+
/**
|
4052
|
+
* Calculate the principal square root of a square matrix. The principal
|
4053
|
+
* square root matrix X of another matrix A is such that X * X = A.
|
4054
|
+
*/
|
4055
|
+
sqrtm(): MathJsChain;
|
4056
|
+
|
4057
|
+
/**
|
4058
|
+
* Squeeze a matrix, remove inner and outer singleton dimensions from a
|
4059
|
+
* matrix.
|
4060
|
+
*/
|
4061
|
+
squeeze(): MathJsChain;
|
4062
|
+
|
4063
|
+
/**
|
4064
|
+
* Get or set a subset of a matrix or string.
|
4065
|
+
* @param index An index containing ranges for each dimension
|
4066
|
+
* @param replacement An array, matrix, or scalar. If provided, the
|
4067
|
+
* subset is replaced with replacement. If not provided, the subset is
|
4068
|
+
* returned
|
4069
|
+
* @param defaultValue Default value, filled in on new entries when the
|
4070
|
+
* matrix is resized. If not provided, math.matrix elements will be left
|
4071
|
+
* undefined. Default value: undefined.
|
4072
|
+
*/
|
4073
|
+
subset(index: Index, replacement?: any, defaultValue?: any): MathJsChain;
|
4074
|
+
|
4075
|
+
/**
|
4076
|
+
* Calculate the trace of a matrix: the sum of the elements on the main
|
4077
|
+
* diagonal of a square matrix.
|
4078
|
+
*/
|
4079
|
+
trace(): MathJsChain;
|
4080
|
+
|
4081
|
+
/**
|
4082
|
+
* Transpose a matrix. All values of the matrix are reflected over its
|
4083
|
+
* main diagonal. Only two dimensional matrices are supported.
|
4084
|
+
*/
|
4085
|
+
transpose(): MathJsChain;
|
4086
|
+
|
4087
|
+
/**
|
4088
|
+
* Create a matrix filled with zeros. The created matrix can have one or
|
4089
|
+
* multiple dimensions.
|
4090
|
+
* @param format The matrix storage format
|
4091
|
+
* @returns A matrix filled with zeros
|
4092
|
+
*/
|
4093
|
+
zeros(format?: string): MathJsChain;
|
4094
|
+
/**
|
4095
|
+
* @param n The y dimension of the matrix
|
4096
|
+
* @param format The matrix storage format
|
4097
|
+
*/
|
4098
|
+
zeros(n: number, format?: string): MathJsChain;
|
4099
|
+
|
4100
|
+
/*************************************************************************
|
4101
|
+
* Probability functions
|
4102
|
+
************************************************************************/
|
4103
|
+
|
4104
|
+
/**
|
4105
|
+
* Compute the number of ways of picking k unordered outcomes from n
|
4106
|
+
* possibilities. Combinations only takes integer arguments. The
|
4107
|
+
* following condition must be enforced: k <= n.
|
4108
|
+
* @param k Number of objects in the subset
|
4109
|
+
*/
|
4110
|
+
combinations(k: number | BigNumber): MathJsChain;
|
4111
|
+
|
4112
|
+
/**
|
4113
|
+
* Compute the factorial of a value Factorial only supports an integer
|
4114
|
+
* value as argument. For matrices, the function is evaluated element
|
4115
|
+
* wise.
|
4116
|
+
*/
|
4117
|
+
factorial(): MathJsChain;
|
4118
|
+
|
4119
|
+
/**
|
4120
|
+
* Compute the gamma function of a value using Lanczos approximation for
|
4121
|
+
* small values, and an extended Stirling approximation for large
|
4122
|
+
* values. For matrices, the function is evaluated element wise.
|
4123
|
+
*/
|
4124
|
+
gamma(): MathJsChain;
|
4125
|
+
|
4126
|
+
/**
|
4127
|
+
* Calculate the Kullback-Leibler (KL) divergence between two
|
4128
|
+
* distributions
|
4129
|
+
* @param p Second vector
|
4130
|
+
*/
|
4131
|
+
kldivergence(p: MathArray | Matrix): MathJsChain;
|
4132
|
+
|
4133
|
+
/**
|
4134
|
+
* Multinomial Coefficients compute the number of ways of picking a1,
|
4135
|
+
* a2, ..., ai unordered outcomes from n possibilities. multinomial
|
4136
|
+
* takes one array of integers as an argument. The following condition
|
4137
|
+
* must be enforced: every ai <= 0
|
4138
|
+
*/
|
4139
|
+
multinomial(): MathJsChain;
|
4140
|
+
|
4141
|
+
/**
|
4142
|
+
* Compute the number of ways of obtaining an ordered subset of k
|
4143
|
+
* elements from a set of n elements. Permutations only takes integer
|
4144
|
+
* arguments. The following condition must be enforced: k <= n.
|
4145
|
+
* @param k The number of objects in the subset
|
4146
|
+
*/
|
4147
|
+
permutations(k?: number | BigNumber): MathJsChain;
|
4148
|
+
|
4149
|
+
/**
|
4150
|
+
* Random pick a value from a one dimensional array. Array element is
|
4151
|
+
* picked using a random function with uniform distribution.
|
4152
|
+
* @param number An int or float
|
4153
|
+
* @param weights An array of ints or floats
|
4154
|
+
*/
|
4155
|
+
pickRandom(number?: number, weights?: number[]): MathJsChain;
|
4156
|
+
|
4157
|
+
/**
|
4158
|
+
* Return a random number larger or equal to min and smaller than max
|
4159
|
+
* using a uniform distribution.
|
4160
|
+
* @param min Minimum boundary for the random value, included
|
4161
|
+
* @param max Maximum boundary for the random value, excluded
|
4162
|
+
*/
|
4163
|
+
random(max?: number): MathJsChain;
|
4164
|
+
// tslint:disable-next-line unified-signatures
|
4165
|
+
random(min: number, max: number): MathJsChain;
|
4166
|
+
|
4167
|
+
/**
|
4168
|
+
* Return a random integer number larger or equal to min and smaller
|
4169
|
+
* than max using a uniform distribution.
|
4170
|
+
* @param min Minimum boundary for the random value, included
|
4171
|
+
* @param max Maximum boundary for the random value, excluded
|
4172
|
+
*/
|
4173
|
+
randomInt(max?: number): MathJsChain;
|
4174
|
+
// tslint:disable-next-line unified-signatures
|
4175
|
+
randomInt(min: number, max: number): MathJsChain;
|
4176
|
+
|
4177
|
+
/*************************************************************************
|
4178
|
+
* Relational functions
|
4179
|
+
************************************************************************/
|
4180
|
+
|
4181
|
+
/**
|
4182
|
+
* Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x
|
4183
|
+
* == y. x and y are considered equal when the relative difference
|
4184
|
+
* between x and y is smaller than the configured epsilon. The function
|
4185
|
+
* cannot be used to compare values smaller than approximately 2.22e-16.
|
4186
|
+
* For matrices, the function is evaluated element wise.
|
4187
|
+
* @param y Second value to compare
|
4188
|
+
*/
|
4189
|
+
compare(y: MathType | string): MathJsChain;
|
4190
|
+
|
4191
|
+
/**
|
4192
|
+
* Compare two values of any type in a deterministic, natural way. For
|
4193
|
+
* numeric values, the function works the same as math.compare. For
|
4194
|
+
* types of values that can’t be compared mathematically, the function
|
4195
|
+
* compares in a natural way.
|
4196
|
+
* @param y Second value to compare
|
4197
|
+
*/
|
4198
|
+
compareNatural(y: any): MathJsChain;
|
4199
|
+
|
4200
|
+
/**
|
4201
|
+
* Compare two strings lexically. Comparison is case sensitive. Returns
|
4202
|
+
* 1 when x > y, -1 when x < y, and 0 when x == y. For matrices, the
|
4203
|
+
* function is evaluated element wise.
|
4204
|
+
* @param y Second string to compare
|
4205
|
+
*/
|
4206
|
+
compareText(y: string | MathArray | Matrix): MathJsChain;
|
4207
|
+
|
4208
|
+
/**
|
4209
|
+
* Test element wise whether two matrices are equal. The function
|
4210
|
+
* accepts both matrices and scalar values.
|
4211
|
+
* @param y Second amtrix to compare
|
4212
|
+
*/
|
4213
|
+
deepEqual(y: MathType): MathJsChain;
|
4214
|
+
|
4215
|
+
/**
|
4216
|
+
* Test whether two values are equal.
|
4217
|
+
*
|
4218
|
+
* The function tests whether the relative difference between x and y is
|
4219
|
+
* smaller than the configured epsilon. The function cannot be used to
|
4220
|
+
* compare values smaller than approximately 2.22e-16. For matrices, the
|
4221
|
+
* function is evaluated element wise. In case of complex numbers, x.re
|
4222
|
+
* must equal y.re, and x.im must equal y.im. Values null and undefined
|
4223
|
+
* are compared strictly, thus null is only equal to null and nothing
|
4224
|
+
* else, and undefined is only equal to undefined and nothing else.
|
4225
|
+
* @param y Second value to compare
|
4226
|
+
*/
|
4227
|
+
equal(y: MathType | string): MathJsChain;
|
4228
|
+
|
4229
|
+
/**
|
4230
|
+
* Check equality of two strings. Comparison is case sensitive. For
|
4231
|
+
* matrices, the function is evaluated element wise.
|
4232
|
+
* @param y Second string to compare
|
4233
|
+
*/
|
4234
|
+
equalText(y: string | MathArray | Matrix): MathJsChain;
|
4235
|
+
|
4236
|
+
/**
|
4237
|
+
* Test whether value x is larger than y. The function returns true when
|
4238
|
+
* x is larger than y and the relative difference between x and y is
|
4239
|
+
* larger than the configured epsilon. The function cannot be used to
|
4240
|
+
* compare values smaller than approximately 2.22e-16. For matrices, the
|
4241
|
+
* function is evaluated element wise.
|
4242
|
+
* @param y Second value to compare
|
4243
|
+
*/
|
4244
|
+
larger(y: MathType | string): MathJsChain;
|
4245
|
+
|
4246
|
+
/**
|
4247
|
+
* Test whether value x is larger or equal to y. The function returns
|
4248
|
+
* true when x is larger than y or the relative difference between x and
|
4249
|
+
* y is smaller than the configured epsilon. The function cannot be used
|
4250
|
+
* to compare values smaller than approximately 2.22e-16. For matrices,
|
4251
|
+
* the function is evaluated element wise.
|
4252
|
+
* @param y Second value to vcompare
|
4253
|
+
*/
|
4254
|
+
largerEq(y: MathType | string): MathJsChain;
|
4255
|
+
|
4256
|
+
/**
|
4257
|
+
* Test whether value x is smaller than y. The function returns true
|
4258
|
+
* when x is smaller than y and the relative difference between x and y
|
4259
|
+
* is smaller than the configured epsilon. The function cannot be used
|
4260
|
+
* to compare values smaller than approximately 2.22e-16. For matrices,
|
4261
|
+
* the function is evaluated element wise.
|
4262
|
+
* @param y Second value to vcompare
|
4263
|
+
*/
|
4264
|
+
smaller(y: MathType | string): MathJsChain;
|
4265
|
+
|
4266
|
+
/**
|
4267
|
+
* Test whether value x is smaller or equal to y. The function returns
|
4268
|
+
* true when x is smaller than y or the relative difference between x
|
4269
|
+
* and y is smaller than the configured epsilon. The function cannot be
|
4270
|
+
* used to compare values smaller than approximately 2.22e-16. For
|
4271
|
+
* matrices, the function is evaluated element wise.
|
4272
|
+
* @param y Second value to compare
|
4273
|
+
*/
|
4274
|
+
smallerEq(y: MathType | string): MathJsChain;
|
4275
|
+
|
4276
|
+
/**
|
4277
|
+
* Test whether two values are unequal. The function tests whether the
|
4278
|
+
* relative difference between x and y is larger than the configured
|
4279
|
+
* epsilon. The function cannot be used to compare values smaller than
|
4280
|
+
* approximately 2.22e-16. For matrices, the function is evaluated
|
4281
|
+
* element wise. In case of complex numbers, x.re must unequal y.re, or
|
4282
|
+
* x.im must unequal y.im. Values null and undefined are compared
|
4283
|
+
* strictly, thus null is unequal with everything except null, and
|
4284
|
+
* undefined is unequal with everything except undefined.
|
4285
|
+
* @param y Second value to vcompare
|
4286
|
+
*/
|
4287
|
+
unequal(y: MathType | string): MathJsChain;
|
4288
|
+
|
4289
|
+
/*************************************************************************
|
4290
|
+
* Set functions
|
4291
|
+
************************************************************************/
|
4292
|
+
|
4293
|
+
/**
|
4294
|
+
* Create the cartesian product of two (multi)sets. Multi-dimension
|
4295
|
+
* arrays will be converted to single-dimension arrays before the
|
4296
|
+
* operation.
|
4297
|
+
* @param a2 A (multi)set
|
4298
|
+
*/
|
4299
|
+
setCartesian(a2: MathArray | Matrix): MathJsChain;
|
4300
|
+
|
4301
|
+
/**
|
4302
|
+
* Create the difference of two (multi)sets: every element of set1, that
|
4303
|
+
* is not the element of set2. Multi-dimension arrays will be converted
|
4304
|
+
* to single-dimension arrays before the operation
|
4305
|
+
* @param a2 A (multi)set
|
4306
|
+
*/
|
4307
|
+
setDifference(a2: MathArray | Matrix): MathJsChain;
|
4308
|
+
|
4309
|
+
/**
|
4310
|
+
* Collect the distinct elements of a multiset. A multi-dimension array
|
4311
|
+
* will be converted to a single-dimension array before the operation.
|
4312
|
+
*/
|
4313
|
+
setDistinct(): MathJsChain;
|
4314
|
+
|
4315
|
+
/**
|
4316
|
+
* Create the intersection of two (multi)sets. Multi-dimension arrays
|
4317
|
+
* will be converted to single-dimension arrays before the operation.
|
4318
|
+
* @param a2 A (multi)set
|
4319
|
+
*/
|
4320
|
+
setIntersect(a2: MathArray | Matrix): MathJsChain;
|
4321
|
+
|
4322
|
+
/**
|
4323
|
+
* Check whether a (multi)set is a subset of another (multi)set. (Every
|
4324
|
+
* element of set1 is the element of set2.) Multi-dimension arrays will
|
4325
|
+
* be converted to single-dimension arrays before the operation.
|
4326
|
+
* @param a2 A (multi)set
|
4327
|
+
*/
|
4328
|
+
setIsSubset(a2: MathArray | Matrix): MathJsChain;
|
4329
|
+
|
4330
|
+
/**
|
4331
|
+
* Count the multiplicity of an element in a multiset. A multi-dimension
|
4332
|
+
* array will be converted to a single-dimension array before the
|
4333
|
+
* operation.
|
4334
|
+
* @param a A multiset
|
4335
|
+
*/
|
4336
|
+
setMultiplicity(a: MathArray | Matrix): MathJsChain;
|
4337
|
+
|
4338
|
+
/**
|
4339
|
+
* Create the powerset of a (multi)set. (The powerset contains very
|
4340
|
+
* possible subsets of a (multi)set.) A multi-dimension array will be
|
4341
|
+
* converted to a single-dimension array before the operation.
|
4342
|
+
*/
|
4343
|
+
setPowerset(): MathJsChain;
|
4344
|
+
|
4345
|
+
/**
|
4346
|
+
* Count the number of elements of a (multi)set. When a second parameter
|
4347
|
+
* is ‘true’, count only the unique values. A multi-dimension array will
|
4348
|
+
* be converted to a single-dimension array before the operation.
|
4349
|
+
*/
|
4350
|
+
setSize(): MathJsChain;
|
4351
|
+
|
4352
|
+
/**
|
4353
|
+
* Create the symmetric difference of two (multi)sets. Multi-dimension
|
4354
|
+
* arrays will be converted to single-dimension arrays before the
|
4355
|
+
* operation.
|
4356
|
+
* @param a2 A (multi)set
|
4357
|
+
*/
|
4358
|
+
setSymDifference(a2: MathArray | Matrix): MathJsChain;
|
4359
|
+
|
4360
|
+
/**
|
4361
|
+
* Create the union of two (multi)sets. Multi-dimension arrays will be
|
4362
|
+
* converted to single-dimension arrays before the operation.
|
4363
|
+
* @param a2 A (multi)set
|
4364
|
+
*/
|
4365
|
+
setUnion(a2: MathArray | Matrix): MathJsChain;
|
4366
|
+
|
4367
|
+
/*************************************************************************
|
4368
|
+
* Special functions
|
4369
|
+
************************************************************************/
|
4370
|
+
|
4371
|
+
/**
|
4372
|
+
* Compute the erf function of a value using a rational Chebyshev
|
4373
|
+
* approximations for different intervals of x.
|
4374
|
+
*/
|
4375
|
+
erf(): MathJsChain;
|
4376
|
+
|
4377
|
+
/*************************************************************************
|
4378
|
+
* Statistics functions
|
4379
|
+
************************************************************************/
|
4380
|
+
|
4381
|
+
/**
|
4382
|
+
* Compute the median absolute deviation of a matrix or a list with
|
4383
|
+
* values. The median absolute deviation is defined as the median of the
|
4384
|
+
* absolute deviations from the median.
|
4385
|
+
*/
|
4386
|
+
mad(): MathJsChain;
|
4387
|
+
|
4388
|
+
/**
|
4389
|
+
* Compute the maximum value of a matrix or a list with values. In case
|
4390
|
+
* of a multi dimensional array, the maximum of the flattened array will
|
4391
|
+
* be calculated. When dim is provided, the maximum over the selected
|
4392
|
+
* dimension will be calculated. Parameter dim is zero-based.
|
4393
|
+
* @param dim The maximum over the selected dimension
|
4394
|
+
*/
|
4395
|
+
max(dim?: number): MathJsChain;
|
4396
|
+
|
4397
|
+
/**
|
4398
|
+
* Compute the mean value of matrix or a list with values. In case of a
|
4399
|
+
* multi dimensional array, the mean of the flattened array will be
|
4400
|
+
* calculated. When dim is provided, the maximum over the selected
|
4401
|
+
* dimension will be calculated. Parameter dim is zero-based.
|
4402
|
+
* @param dim The mean over the selected dimension
|
4403
|
+
*/
|
4404
|
+
mean(dim?: number): MathJsChain;
|
4405
|
+
|
4406
|
+
/**
|
4407
|
+
* Compute the median of a matrix or a list with values. The values are
|
4408
|
+
* sorted and the middle value is returned. In case of an even number of
|
4409
|
+
* values, the average of the two middle values is returned. Supported
|
4410
|
+
* types of values are: Number, BigNumber, Unit In case of a (multi
|
4411
|
+
* dimensional) array or matrix, the median of all elements will be
|
4412
|
+
* calculated.
|
4413
|
+
*/
|
4414
|
+
median(): MathJsChain;
|
4415
|
+
|
4416
|
+
/**
|
4417
|
+
* Compute the maximum value of a matrix or a list of values. In case of
|
4418
|
+
* a multi dimensional array, the maximum of the flattened array will be
|
4419
|
+
* calculated. When dim is provided, the maximum over the selected
|
4420
|
+
* dimension will be calculated. Parameter dim is zero-based.
|
4421
|
+
* @param dim The minimum over the selected dimension
|
4422
|
+
*/
|
4423
|
+
min(dim?: number): MathJsChain;
|
4424
|
+
|
4425
|
+
/**
|
4426
|
+
* Computes the mode of a set of numbers or a list with values(numbers
|
4427
|
+
* or characters). If there are more than one modes, it returns a list
|
4428
|
+
* of those values.
|
4429
|
+
*/
|
4430
|
+
mode(): MathJsChain;
|
4431
|
+
|
4432
|
+
/**
|
4433
|
+
* Compute the product of a matrix or a list with values. In case of a
|
4434
|
+
* (multi dimensional) array or matrix, the sum of all elements will be
|
4435
|
+
* calculated.
|
4436
|
+
*/
|
4437
|
+
prod(): MathJsChain;
|
4438
|
+
|
4439
|
+
/**
|
4440
|
+
* Compute the prob order quantile of a matrix or a list with values.
|
4441
|
+
* The sequence is sorted and the middle value is returned. Supported
|
4442
|
+
* types of sequence values are: Number, BigNumber, Unit Supported types
|
4443
|
+
* of probability are: Number, BigNumber In case of a (multi
|
4444
|
+
* dimensional) array or matrix, the prob order quantile of all elements
|
4445
|
+
* will be calculated.
|
4446
|
+
* @param probOrN prob is the order of the quantile, while N is the
|
4447
|
+
* amount of evenly distributed steps of probabilities; only one of
|
4448
|
+
* these options can be provided
|
4449
|
+
* @param sorted =false is data sorted in ascending order
|
4450
|
+
*/
|
4451
|
+
quantileSeq(prob: number | BigNumber | MathArray, sorted?: boolean): MathJsChain;
|
4452
|
+
|
4453
|
+
/**
|
4454
|
+
* Compute the standard deviation of a matrix or a list with values. The
|
4455
|
+
* standard deviations is defined as the square root of the variance:
|
4456
|
+
* std(A) = sqrt(variance(A)). In case of a (multi dimensional) array or
|
4457
|
+
* matrix, the standard deviation over all elements will be calculated.
|
4458
|
+
* Optionally, the type of normalization can be specified as second
|
4459
|
+
* parameter. The parameter normalization can be one of the following
|
4460
|
+
* values: 'unbiased' (default) The sum of squared errors is divided by
|
4461
|
+
* (n - 1) 'uncorrected' The sum of squared errors is divided by n
|
4462
|
+
* 'biased' The sum of squared errors is divided by (n + 1)
|
4463
|
+
* @param array A single matrix or multiple scalar values
|
4464
|
+
* @param normalization Determines how to normalize the variance. Choose
|
4465
|
+
* ‘unbiased’ (default), ‘uncorrected’, or ‘biased’. Default value:
|
4466
|
+
* ‘unbiased’.
|
4467
|
+
* @returns The standard deviation
|
4468
|
+
*/
|
4469
|
+
std(normalization?: 'unbiased' | 'uncorrected' | 'biased' | 'unbiased'): MathJsChain;
|
4470
|
+
|
4471
|
+
/**
|
4472
|
+
* Compute the sum of a matrix or a list with values. In case of a
|
4473
|
+
* (multi dimensional) array or matrix, the sum of all elements will be
|
4474
|
+
* calculated.
|
4475
|
+
*/
|
4476
|
+
sum(): MathJsChain;
|
4477
|
+
|
4478
|
+
/**
|
4479
|
+
* Compute the variance of a matrix or a list with values. In case of a
|
4480
|
+
* (multi dimensional) array or matrix, the variance over all elements
|
4481
|
+
* will be calculated. Optionally, the type of normalization can be
|
4482
|
+
* specified as second parameter. The parameter normalization can be one
|
4483
|
+
* of the following values: 'unbiased' (default) The sum of squared
|
4484
|
+
* errors is divided by (n - 1) 'uncorrected' The sum of squared errors
|
4485
|
+
* is divided by n 'biased' The sum of squared errors is divided by (n +
|
4486
|
+
* 1) Note that older browser may not like the variable name var. In
|
4487
|
+
* that case, the function can be called as math['var'](...) instead of
|
4488
|
+
* math.variance(...).
|
4489
|
+
* @param normalization normalization Determines how to normalize the
|
4490
|
+
* variance. Choose ‘unbiased’ (default), ‘uncorrected’, or ‘biased’.
|
4491
|
+
* Default value: ‘unbiased’.
|
4492
|
+
* @returns The variance
|
4493
|
+
*/
|
4494
|
+
variance(normalization?: 'unbiased' | 'uncorrected' | 'biased' | 'unbiased'): MathJsChain;
|
4495
|
+
|
4496
|
+
/*************************************************************************
|
4497
|
+
* String functions
|
4498
|
+
************************************************************************/
|
4499
|
+
|
4500
|
+
/**
|
4501
|
+
* Format a value of any type into a string.
|
4502
|
+
* @param options An object with formatting options.
|
4503
|
+
* @param callback A custom formatting function, invoked for all numeric
|
4504
|
+
* elements in value, for example all elements of a matrix, or the real
|
4505
|
+
* and imaginary parts of a complex number. This callback can be used to
|
4506
|
+
* override the built-in numeric notation with any type of formatting.
|
4507
|
+
* Function callback is called with value as parameter and must return a
|
4508
|
+
* string.
|
4509
|
+
* @see http://mathjs.org/docs/reference/functions/format.html
|
4510
|
+
*/
|
4511
|
+
format(value: any, options?: FormatOptions | number | ((item: any) => string), callback?: (value: any) => string): MathJsChain;
|
4512
|
+
|
4513
|
+
/**
|
4514
|
+
* Interpolate values into a string template.
|
4515
|
+
* @param values An object containing variables which will be filled in
|
4516
|
+
* in the template.
|
4517
|
+
* @param precision Number of digits to format numbers. If not provided,
|
4518
|
+
* the value will not be rounded.
|
4519
|
+
* @param options Formatting options, or the number of digits to format
|
4520
|
+
* numbers. See function math.format for a description of all options.
|
4521
|
+
*/
|
4522
|
+
print(values: any, precision?: number, options?: number | object): MathJsChain;
|
4523
|
+
|
4524
|
+
/*************************************************************************
|
4525
|
+
* Trigonometry functions
|
4526
|
+
************************************************************************/
|
4527
|
+
|
4528
|
+
/**
|
4529
|
+
* Calculate the inverse cosine of a value. For matrices, the function
|
4530
|
+
* is evaluated element wise.
|
4531
|
+
*/
|
4532
|
+
acos(): MathJsChain;
|
4533
|
+
|
4534
|
+
/**
|
4535
|
+
* Calculate the hyperbolic arccos of a value, defined as acosh(x) =
|
4536
|
+
* ln(sqrt(x^2 - 1) + x). For matrices, the function is evaluated
|
4537
|
+
* element wise.
|
4538
|
+
*/
|
4539
|
+
acosh(): MathJsChain;
|
4540
|
+
|
4541
|
+
/**
|
4542
|
+
* Calculate the inverse cotangent of a value. For matrices, the
|
4543
|
+
* function is evaluated element wise.
|
4544
|
+
*/
|
4545
|
+
acot(): MathJsChain;
|
4546
|
+
|
4547
|
+
/**
|
4548
|
+
* Calculate the hyperbolic arccotangent of a value, defined as acoth(x)
|
4549
|
+
* = (ln((x+1)/x) + ln(x/(x-1))) / 2. For matrices, the function is
|
4550
|
+
* evaluated element wise.
|
4551
|
+
*/
|
4552
|
+
acoth(): MathJsChain;
|
4553
|
+
|
4554
|
+
/**
|
4555
|
+
* Calculate the inverse cosecant of a value. For matrices, the function
|
4556
|
+
* is evaluated element wise.
|
4557
|
+
*/
|
4558
|
+
acsc(): MathJsChain;
|
4559
|
+
|
4560
|
+
/**
|
4561
|
+
* Calculate the hyperbolic arccosecant of a value, defined as acsch(x)
|
4562
|
+
* = ln(1/x + sqrt(1/x^2 + 1)). For matrices, the function is evaluated
|
4563
|
+
* element wise.
|
4564
|
+
*/
|
4565
|
+
acsch(): MathJsChain;
|
4566
|
+
|
4567
|
+
/**
|
4568
|
+
* Calculate the inverse secant of a value. For matrices, the function
|
4569
|
+
* is evaluated element wise.
|
4570
|
+
*/
|
4571
|
+
asec(): MathJsChain;
|
4572
|
+
|
4573
|
+
/**
|
4574
|
+
* Calculate the hyperbolic arcsecant of a value, defined as asech(x) =
|
4575
|
+
* ln(sqrt(1/x^2 - 1) + 1/x). For matrices, the function is evaluated
|
4576
|
+
* element wise.
|
4577
|
+
*/
|
4578
|
+
asech(): MathJsChain;
|
4579
|
+
|
4580
|
+
/**
|
4581
|
+
* Calculate the inverse sine of a value. For matrices, the function is
|
4582
|
+
* evaluated element wise.
|
4583
|
+
*/
|
4584
|
+
asin(): MathJsChain;
|
4585
|
+
|
4586
|
+
/**
|
4587
|
+
* Calculate the hyperbolic arcsine of a value, defined as asinh(x) =
|
4588
|
+
* ln(x + sqrt(x^2 + 1)). For matrices, the function is evaluated
|
4589
|
+
* element wise.
|
4590
|
+
*/
|
4591
|
+
asinh(): MathJsChain;
|
4592
|
+
|
4593
|
+
/**
|
4594
|
+
* Calculate the inverse tangent of a value. For matrices, the function
|
4595
|
+
* is evaluated element wise.
|
4596
|
+
*/
|
4597
|
+
atan(): MathJsChain;
|
4598
|
+
|
4599
|
+
/**
|
4600
|
+
* Calculate the inverse tangent function with two arguments, y/x. By
|
4601
|
+
* providing two arguments, the right quadrant of the computed angle can
|
4602
|
+
* be determined. For matrices, the function is evaluated element wise.
|
4603
|
+
*/
|
4604
|
+
atan2(): MathJsChain;
|
4605
|
+
|
4606
|
+
/**
|
4607
|
+
* Calculate the hyperbolic arctangent of a value, defined as atanh(x) =
|
4608
|
+
* ln((1 + x)/(1 - x)) / 2. For matrices, the function is evaluated
|
4609
|
+
* element wise.
|
4610
|
+
*/
|
4611
|
+
atanh(): MathJsChain;
|
4612
|
+
|
4613
|
+
/**
|
4614
|
+
* Calculate the cosine of a value. For matrices, the function is
|
4615
|
+
* evaluated element wise.
|
4616
|
+
*/
|
4617
|
+
cos(): MathJsChain;
|
4618
|
+
|
4619
|
+
/**
|
4620
|
+
* Calculate the hyperbolic cosine of a value, defined as cosh(x) = 1/2
|
4621
|
+
* * (exp(x) + exp(-x)). For matrices, the function is evaluated element
|
4622
|
+
* wise.
|
4623
|
+
*/
|
4624
|
+
cosh(): MathJsChain;
|
4625
|
+
|
4626
|
+
/**
|
4627
|
+
* Calculate the cotangent of a value. cot(x) is defined as 1 / tan(x).
|
4628
|
+
* For matrices, the function is evaluated element wise.
|
4629
|
+
*/
|
4630
|
+
cot(): MathJsChain;
|
4631
|
+
|
4632
|
+
/**
|
4633
|
+
* Calculate the hyperbolic cotangent of a value, defined as coth(x) = 1
|
4634
|
+
* / tanh(x). For matrices, the function is evaluated element wise.
|
4635
|
+
*/
|
4636
|
+
coth(): MathJsChain;
|
4637
|
+
|
4638
|
+
/**
|
4639
|
+
* Calculate the cosecant of a value, defined as csc(x) = 1/sin(x). For
|
4640
|
+
* matrices, the function is evaluated element wise.
|
4641
|
+
*/
|
4642
|
+
csc(): MathJsChain;
|
4643
|
+
|
4644
|
+
/**
|
4645
|
+
* Calculate the hyperbolic cosecant of a value, defined as csch(x) = 1
|
4646
|
+
* / sinh(x). For matrices, the function is evaluated element wise.
|
4647
|
+
*/
|
4648
|
+
csch(): MathJsChain;
|
4649
|
+
|
4650
|
+
/**
|
4651
|
+
* Calculate the secant of a value, defined as sec(x) = 1/cos(x). For
|
4652
|
+
* matrices, the function is evaluated element wise.
|
4653
|
+
*/
|
4654
|
+
sec(): MathJsChain;
|
4655
|
+
|
4656
|
+
/**
|
4657
|
+
* Calculate the hyperbolic secant of a value, defined as sech(x) = 1 /
|
4658
|
+
* cosh(x). For matrices, the function is evaluated element wise.
|
4659
|
+
*/
|
4660
|
+
sech(): MathJsChain;
|
4661
|
+
|
4662
|
+
/**
|
4663
|
+
* Calculate the sine of a value. For matrices, the function is
|
4664
|
+
* evaluated element wise.
|
4665
|
+
*/
|
4666
|
+
sin(): MathJsChain;
|
4667
|
+
|
4668
|
+
/**
|
4669
|
+
* Calculate the hyperbolic sine of a value, defined as sinh(x) = 1/2 *
|
4670
|
+
* (exp(x) - exp(-x)). For matrices, the function is evaluated element
|
4671
|
+
* wise.
|
4672
|
+
*/
|
4673
|
+
sinh(): MathJsChain;
|
4674
|
+
|
4675
|
+
/**
|
4676
|
+
* Calculate the tangent of a value. tan(x) is equal to sin(x) / cos(x).
|
4677
|
+
* For matrices, the function is evaluated element wise.
|
4678
|
+
*/
|
4679
|
+
tan(): MathJsChain;
|
4680
|
+
|
4681
|
+
/**
|
4682
|
+
* Calculate the hyperbolic tangent of a value, defined as tanh(x) =
|
4683
|
+
* (exp(2 * x) - 1) / (exp(2 * x) + 1). For matrices, the function is
|
4684
|
+
* evaluated element wise.
|
4685
|
+
*/
|
4686
|
+
tanh(): MathJsChain;
|
4687
|
+
|
4688
|
+
/*************************************************************************
|
4689
|
+
* Unit functions
|
4690
|
+
************************************************************************/
|
4691
|
+
|
4692
|
+
/**
|
4693
|
+
* Change the unit of a value. For matrices, the function is evaluated
|
4694
|
+
* element wise.
|
4695
|
+
* @param unit New unit. Can be a string like "cm" or a unit without
|
4696
|
+
* value.
|
4697
|
+
*/
|
4698
|
+
to(unit: Unit | string): MathJsChain;
|
4699
|
+
|
4700
|
+
/*************************************************************************
|
4701
|
+
* Utils functions
|
4702
|
+
************************************************************************/
|
4703
|
+
|
4704
|
+
/**
|
4705
|
+
* Clone an object.
|
4706
|
+
*/
|
4707
|
+
clone(): MathJsChain;
|
4708
|
+
|
4709
|
+
/**
|
4710
|
+
* Test whether a value is an integer number. The function supports
|
4711
|
+
* number, BigNumber, and Fraction. The function is evaluated
|
4712
|
+
* element-wise in case of Array or Matrix input.
|
4713
|
+
*/
|
4714
|
+
isInteger(): MathJsChain;
|
4715
|
+
|
4716
|
+
/**
|
4717
|
+
* Test whether a value is NaN (not a number). The function supports
|
4718
|
+
* types number, BigNumber, Fraction, Unit and Complex. The function is
|
4719
|
+
* evaluated element-wise in case of Array or Matrix input.
|
4720
|
+
*/
|
4721
|
+
isNaN(): MathJsChain;
|
4722
|
+
|
4723
|
+
/**
|
4724
|
+
* Test whether a value is negative: smaller than zero. The function
|
4725
|
+
* supports types number, BigNumber, Fraction, and Unit. The function is
|
4726
|
+
* evaluated element-wise in case of Array or Matrix input.
|
4727
|
+
*/
|
4728
|
+
isNegative(): MathJsChain;
|
4729
|
+
|
4730
|
+
/**
|
4731
|
+
* Test whether a value is an numeric value. The function is evaluated
|
4732
|
+
* element-wise in case of Array or Matrix input.
|
4733
|
+
*/
|
4734
|
+
isNumeric(): MathJsChain;
|
4735
|
+
|
4736
|
+
/**
|
4737
|
+
* Test whether a value is positive: larger than zero. The function
|
4738
|
+
* supports types number, BigNumber, Fraction, and Unit. The function is
|
4739
|
+
* evaluated element-wise in case of Array or Matrix input.
|
4740
|
+
*/
|
4741
|
+
isPositive(): MathJsChain;
|
4742
|
+
|
4743
|
+
/**
|
4744
|
+
* Test whether a value is prime: has no divisors other than itself and
|
4745
|
+
* one. The function supports type number, bignumber. The function is
|
4746
|
+
* evaluated element-wise in case of Array or Matrix input.
|
4747
|
+
*/
|
4748
|
+
isPrime(): MathJsChain;
|
4749
|
+
|
4750
|
+
/**
|
4751
|
+
* Test whether a value is zero. The function can check for zero for
|
4752
|
+
* types number, BigNumber, Fraction, Complex, and Unit. The function is
|
4753
|
+
* evaluated element-wise in case of Array or Matrix input.
|
4754
|
+
*/
|
4755
|
+
isZero(): MathJsChain;
|
4756
|
+
|
4757
|
+
/**
|
4758
|
+
* Determine the type of a variable.
|
4759
|
+
*/
|
4760
|
+
typeOf(): MathJsChain;
|
4761
|
+
}
|
4762
|
+
|
4763
|
+
interface ImportOptions {
|
4764
|
+
override?: boolean;
|
4765
|
+
silent?: boolean;
|
4766
|
+
wrap?: boolean;
|
4767
|
+
}
|
4768
|
+
|
4769
|
+
interface ImportObject {
|
4770
|
+
[key: string]: any;
|
4771
|
+
}
|
4772
|
+
}
|