mathjs 11.8.0 → 11.8.2
Sign up to get free protection for your applications and to get access to all the features.
- package/HISTORY.md +25 -1
- package/lib/browser/math.js +1 -1
- package/lib/browser/math.js.LICENSE.txt +2 -2
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesDistance.generated.js +2 -2
- package/lib/cjs/entry/pureFunctionsAny.generated.js +2 -2
- package/lib/cjs/expression/Parser.js +1 -1
- package/lib/cjs/expression/function/parser.js +1 -1
- package/lib/cjs/expression/transform/filter.transform.js +4 -13
- package/lib/cjs/expression/transform/forEach.transform.js +3 -12
- package/lib/cjs/expression/transform/map.transform.js +4 -13
- package/lib/cjs/function/algebra/derivative.js +2 -2
- package/lib/cjs/function/algebra/leafCount.js +1 -1
- package/lib/cjs/function/algebra/polynomialRoot.js +1 -1
- package/lib/cjs/function/algebra/rationalize.js +4 -4
- package/lib/cjs/function/algebra/resolve.js +1 -1
- package/lib/cjs/function/algebra/simplify.js +7 -7
- package/lib/cjs/function/algebra/simplifyConstant.js +2 -2
- package/lib/cjs/function/algebra/simplifyCore.js +2 -2
- package/lib/cjs/function/algebra/symbolicEqual.js +8 -8
- package/lib/cjs/function/geometry/distance.js +21 -17
- package/lib/cjs/function/matrix/filter.js +2 -11
- package/lib/cjs/function/matrix/forEach.js +3 -12
- package/lib/cjs/function/matrix/map.js +6 -38
- package/lib/cjs/function/matrix/sqrtm.js +1 -1
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/type/bignumber/function/bignumber.js +7 -0
- package/lib/cjs/type/fraction/function/fraction.js +8 -1
- package/lib/cjs/type/number.js +7 -3
- package/lib/cjs/type/unit/function/splitUnit.js +1 -1
- package/lib/cjs/utils/applyCallback.js +73 -0
- package/lib/cjs/utils/bignumber/formatter.js +4 -3
- package/lib/cjs/version.js +1 -1
- package/lib/esm/entry/dependenciesAny/dependenciesDistance.generated.js +2 -2
- package/lib/esm/entry/pureFunctionsAny.generated.js +2 -2
- package/lib/esm/expression/Parser.js +1 -1
- package/lib/esm/expression/function/parser.js +1 -1
- package/lib/esm/expression/transform/filter.transform.js +4 -13
- package/lib/esm/expression/transform/forEach.transform.js +3 -12
- package/lib/esm/expression/transform/map.transform.js +4 -13
- package/lib/esm/function/algebra/derivative.js +2 -2
- package/lib/esm/function/algebra/leafCount.js +1 -1
- package/lib/esm/function/algebra/polynomialRoot.js +1 -1
- package/lib/esm/function/algebra/rationalize.js +4 -4
- package/lib/esm/function/algebra/resolve.js +1 -1
- package/lib/esm/function/algebra/simplify.js +7 -7
- package/lib/esm/function/algebra/simplifyConstant.js +2 -2
- package/lib/esm/function/algebra/simplifyCore.js +2 -2
- package/lib/esm/function/algebra/symbolicEqual.js +8 -8
- package/lib/esm/function/geometry/distance.js +21 -17
- package/lib/esm/function/matrix/filter.js +2 -11
- package/lib/esm/function/matrix/forEach.js +3 -12
- package/lib/esm/function/matrix/map.js +6 -38
- package/lib/esm/function/matrix/sqrtm.js +1 -1
- package/lib/esm/type/bignumber/function/bignumber.js +5 -0
- package/lib/esm/type/fraction/function/fraction.js +6 -1
- package/lib/esm/type/number.js +5 -3
- package/lib/esm/type/unit/function/splitUnit.js +1 -1
- package/lib/esm/utils/applyCallback.js +67 -0
- package/lib/esm/utils/bignumber/formatter.js +4 -3
- package/lib/esm/version.js +1 -1
- package/package.json +19 -19
- package/types/index.d.ts +149 -50
@@ -63,6 +63,11 @@ export var createBignumber = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
63
63
|
// we assume a BigNumber is immutable
|
64
64
|
return x;
|
65
65
|
},
|
66
|
+
Unit: typed.referToSelf(self => x => {
|
67
|
+
var clone = x.clone();
|
68
|
+
clone.value = self(x.value);
|
69
|
+
return clone;
|
70
|
+
}),
|
66
71
|
Fraction: function Fraction(x) {
|
67
72
|
return new BigNumber(x.n).div(x.d).times(x.s);
|
68
73
|
},
|
@@ -39,7 +39,7 @@ export var createFraction = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
39
39
|
*
|
40
40
|
* bignumber, number, string, unit
|
41
41
|
*
|
42
|
-
* @param {number | string | Fraction | BigNumber | Array | Matrix} [args]
|
42
|
+
* @param {number | string | Fraction | BigNumber | Unit | Array | Matrix} [args]
|
43
43
|
* Arguments specifying the value, or numerator and denominator of
|
44
44
|
* the fraction
|
45
45
|
* @return {Fraction | Array | Matrix} Returns a fraction
|
@@ -67,6 +67,11 @@ export var createFraction = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
67
67
|
return x; // fractions are immutable
|
68
68
|
},
|
69
69
|
|
70
|
+
Unit: typed.referToSelf(self => x => {
|
71
|
+
var clone = x.clone();
|
72
|
+
clone.value = self(x.value);
|
73
|
+
return clone;
|
74
|
+
}),
|
70
75
|
Object: function Object(x) {
|
71
76
|
return new Fraction(x);
|
72
77
|
},
|
package/lib/esm/type/number.js
CHANGED
@@ -121,9 +121,11 @@ export var createNumber = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
121
121
|
Fraction: function Fraction(x) {
|
122
122
|
return x.valueOf();
|
123
123
|
},
|
124
|
-
Unit:
|
125
|
-
|
126
|
-
|
124
|
+
Unit: typed.referToSelf(self => x => {
|
125
|
+
var clone = x.clone();
|
126
|
+
clone.value = self(x.value);
|
127
|
+
return clone;
|
128
|
+
}),
|
127
129
|
null: function _null(x) {
|
128
130
|
return 0;
|
129
131
|
},
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import typed from 'typed-function';
|
2
|
+
import { typeOf as _typeOf } from './is.js';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Invoke a callback for functions like map and filter with a matching number of arguments
|
6
|
+
* @param {function} callback
|
7
|
+
* @param {any} value
|
8
|
+
* @param {number | number[]} index
|
9
|
+
* @param {Array} array
|
10
|
+
* @param {string} mappingFnName The name of the function that is invoking these callbacks, for example "map" or "filter"
|
11
|
+
* @returns {*}
|
12
|
+
*/
|
13
|
+
export function applyCallback(callback, value, index, array, mappingFnName) {
|
14
|
+
if (typed.isTypedFunction(callback)) {
|
15
|
+
// invoke the typed callback function with the matching number of arguments only
|
16
|
+
|
17
|
+
var args3 = [value, index, array];
|
18
|
+
var signature3 = typed.resolve(callback, args3);
|
19
|
+
if (signature3) {
|
20
|
+
return tryWithArgs(signature3.implementation, args3);
|
21
|
+
}
|
22
|
+
var args2 = [value, index];
|
23
|
+
var signature2 = typed.resolve(callback, args2);
|
24
|
+
if (signature2) {
|
25
|
+
return tryWithArgs(signature2.implementation, args2);
|
26
|
+
}
|
27
|
+
var args1 = [value];
|
28
|
+
var signature1 = typed.resolve(callback, args1);
|
29
|
+
if (signature1) {
|
30
|
+
return tryWithArgs(signature1.implementation, args1);
|
31
|
+
}
|
32
|
+
|
33
|
+
// fallback (will throw an exception)
|
34
|
+
return tryWithArgs(callback, args3);
|
35
|
+
} else {
|
36
|
+
// A regular JavaScript function
|
37
|
+
return callback(value, index, array);
|
38
|
+
}
|
39
|
+
|
40
|
+
/**
|
41
|
+
* @param {function} signature The selected signature of the typed-function
|
42
|
+
* @param {Array} args List with arguments to apply to the selected signature
|
43
|
+
* @returns {*} Returns the return value of the invoked signature
|
44
|
+
* @throws {TypeError} Throws an error when no matching signature was found
|
45
|
+
*/
|
46
|
+
function tryWithArgs(signature, args) {
|
47
|
+
try {
|
48
|
+
return signature.apply(signature, args);
|
49
|
+
} catch (err) {
|
50
|
+
var _err$data;
|
51
|
+
// Enrich the error message so the user understands that it took place inside the callback function
|
52
|
+
if (err instanceof TypeError && ((_err$data = err.data) === null || _err$data === void 0 ? void 0 : _err$data.category) === 'wrongType') {
|
53
|
+
var argsDesc = [];
|
54
|
+
argsDesc.push("value: ".concat(_typeOf(value)));
|
55
|
+
if (args.length >= 2) {
|
56
|
+
argsDesc.push("index: ".concat(_typeOf(index)));
|
57
|
+
}
|
58
|
+
if (args.length >= 3) {
|
59
|
+
argsDesc.push("array: ".concat(_typeOf(array)));
|
60
|
+
}
|
61
|
+
throw new TypeError("Function ".concat(mappingFnName, " cannot apply callback arguments ") + "".concat(callback.name, "(").concat(argsDesc.join(', '), ") at index ").concat(JSON.stringify(index)));
|
62
|
+
} else {
|
63
|
+
throw new TypeError("Function ".concat(mappingFnName, " cannot apply callback arguments ") + "to function ".concat(callback.name, ": ").concat(err.message));
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
@@ -146,7 +146,7 @@ export function format(value, options) {
|
|
146
146
|
// determine precision from options
|
147
147
|
if (typeof options === 'number') {
|
148
148
|
precision = options;
|
149
|
-
} else if (options.precision) {
|
149
|
+
} else if (options.precision !== undefined) {
|
150
150
|
precision = options.precision;
|
151
151
|
}
|
152
152
|
if (options.wordSize) {
|
@@ -207,7 +207,7 @@ export function format(value, options) {
|
|
207
207
|
|
208
208
|
/**
|
209
209
|
* Format a BigNumber in engineering notation. Like '1.23e+6', '2.3e+0', '3.500e-3'
|
210
|
-
* @param {BigNumber
|
210
|
+
* @param {BigNumber} value
|
211
211
|
* @param {number} [precision] Optional number of significant figures to return.
|
212
212
|
*/
|
213
213
|
export function toEngineering(value, precision) {
|
@@ -219,7 +219,8 @@ export function toEngineering(value, precision) {
|
|
219
219
|
var valueWithoutExp = value.mul(Math.pow(10, -newExp));
|
220
220
|
var valueStr = valueWithoutExp.toPrecision(precision);
|
221
221
|
if (valueStr.indexOf('e') !== -1) {
|
222
|
-
|
222
|
+
var BigNumber = value.constructor;
|
223
|
+
valueStr = new BigNumber(valueStr).toFixed();
|
223
224
|
}
|
224
225
|
return valueStr + 'e' + (e >= 0 ? '+' : '') + newExp.toString();
|
225
226
|
}
|
package/lib/esm/version.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mathjs",
|
3
|
-
"version": "11.8.
|
3
|
+
"version": "11.8.2",
|
4
4
|
"description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
|
5
5
|
"author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
|
6
6
|
"homepage": "https://mathjs.org",
|
@@ -25,7 +25,7 @@
|
|
25
25
|
"unit"
|
26
26
|
],
|
27
27
|
"dependencies": {
|
28
|
-
"@babel/runtime": "^7.
|
28
|
+
"@babel/runtime": "^7.22.5",
|
29
29
|
"complex.js": "^2.1.1",
|
30
30
|
"decimal.js": "^10.4.3",
|
31
31
|
"escape-latex": "^1.2.0",
|
@@ -36,32 +36,32 @@
|
|
36
36
|
"typed-function": "^4.1.0"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
|
-
"@babel/core": "7.
|
40
|
-
"@babel/plugin-transform-object-assign": "7.
|
41
|
-
"@babel/plugin-transform-runtime": "7.
|
42
|
-
"@babel/preset-env": "7.
|
43
|
-
"@babel/register": "7.
|
39
|
+
"@babel/core": "7.22.5",
|
40
|
+
"@babel/plugin-transform-object-assign": "7.22.5",
|
41
|
+
"@babel/plugin-transform-runtime": "7.22.5",
|
42
|
+
"@babel/preset-env": "7.22.5",
|
43
|
+
"@babel/register": "7.22.5",
|
44
44
|
"@types/assert": "1.5.6",
|
45
45
|
"@types/mocha": "10.0.1",
|
46
|
-
"@typescript-eslint/eslint-plugin": "5.
|
47
|
-
"@typescript-eslint/parser": "5.
|
46
|
+
"@typescript-eslint/eslint-plugin": "5.60.0",
|
47
|
+
"@typescript-eslint/parser": "5.60.0",
|
48
48
|
"assert": "2.0.0",
|
49
49
|
"babel-loader": "9.1.2",
|
50
50
|
"benchmark": "2.1.4",
|
51
|
-
"c8": "
|
51
|
+
"c8": "8.0.0",
|
52
52
|
"codecov": "3.8.3",
|
53
|
-
"core-js": "3.
|
53
|
+
"core-js": "3.31.0",
|
54
54
|
"del": "6.1.1",
|
55
55
|
"dtslint": "4.2.1",
|
56
|
-
"eslint": "8.
|
56
|
+
"eslint": "8.43.0",
|
57
57
|
"eslint-config-prettier": "8.8.0",
|
58
|
-
"eslint-config-standard": "17.
|
58
|
+
"eslint-config-standard": "17.1.0",
|
59
59
|
"eslint-plugin-import": "2.27.5",
|
60
60
|
"eslint-plugin-mocha": "10.1.0",
|
61
|
-
"eslint-plugin-n": "
|
61
|
+
"eslint-plugin-n": "16.0.0",
|
62
62
|
"eslint-plugin-prettier": "4.2.1",
|
63
63
|
"eslint-plugin-promise": "6.1.1",
|
64
|
-
"expect-type": "0.
|
64
|
+
"expect-type": "0.16.0",
|
65
65
|
"expr-eval": "2.0.2",
|
66
66
|
"fancy-log": "2.0.0",
|
67
67
|
"glob": "8.1.0",
|
@@ -69,7 +69,7 @@
|
|
69
69
|
"gulp-babel": "8.0.0",
|
70
70
|
"handlebars": "4.7.7",
|
71
71
|
"jsep": "1.3.8",
|
72
|
-
"karma": "6.4.
|
72
|
+
"karma": "6.4.2",
|
73
73
|
"karma-browserstack-launcher": "1.6.0",
|
74
74
|
"karma-firefox-launcher": "2.1.2",
|
75
75
|
"karma-mocha": "2.0.1",
|
@@ -85,12 +85,12 @@
|
|
85
85
|
"ndarray-pack": "1.2.1",
|
86
86
|
"numericjs": "1.2.6",
|
87
87
|
"pad-right": "0.2.2",
|
88
|
-
"prettier": "2.8.
|
88
|
+
"prettier": "2.8.8",
|
89
89
|
"process": "0.11.10",
|
90
90
|
"sylvester": "0.0.21",
|
91
91
|
"ts-node": "10.9.1",
|
92
|
-
"typescript": "5.
|
93
|
-
"webpack": "5.
|
92
|
+
"typescript": "5.1.3",
|
93
|
+
"webpack": "5.87.0",
|
94
94
|
"zeros": "1.0.0"
|
95
95
|
},
|
96
96
|
"type": "module",
|
package/types/index.d.ts
CHANGED
@@ -13,10 +13,12 @@ type NoLiteralType<T> = T extends number
|
|
13
13
|
: T
|
14
14
|
|
15
15
|
declare namespace math {
|
16
|
+
// TODO: introduce generics for MathCollection, MathMatrix, and MathArray
|
16
17
|
type MathNumericType = number | BigNumber | Fraction | Complex
|
17
|
-
type
|
18
|
+
type MathScalarType = MathNumericType | Unit
|
19
|
+
type MathArray = MathNumericType[] | MathNumericType[][] // TODO: MathArray can also contain Unit
|
18
20
|
type MathCollection = MathArray | Matrix
|
19
|
-
type MathType =
|
21
|
+
type MathType = MathScalarType | MathCollection
|
20
22
|
type MathExpression = string | string[] | MathCollection
|
21
23
|
|
22
24
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -1581,12 +1583,14 @@ declare namespace math {
|
|
1581
1583
|
* a 3D line, x0, y0, z0, a, b, c are from: (x−x0, y−y0, z−z0) = t(a, b,
|
1582
1584
|
* c)
|
1583
1585
|
* @param x Coordinates of the first point
|
1584
|
-
* @param y Coordinates of the second point
|
1586
|
+
* @param y Coordinates of the second point OR coefficients of a line in 3D OR first end-point of a line if the calculation is for distance between point and a line in 2D
|
1587
|
+
* @param z Coordinates of second end-point of a line if the calculation is for distance between point and a line in 2D
|
1585
1588
|
* @returns Returns the distance from two/three points
|
1586
1589
|
*/
|
1587
1590
|
distance(
|
1588
1591
|
x: MathCollection | object,
|
1589
|
-
y: MathCollection | object
|
1592
|
+
y: MathCollection | object,
|
1593
|
+
z?: MathCollection | object
|
1590
1594
|
): number | BigNumber
|
1591
1595
|
|
1592
1596
|
/**
|
@@ -2593,36 +2597,60 @@ declare namespace math {
|
|
2593
2597
|
* of a multi dimensional array, the maximum of the flattened array will
|
2594
2598
|
* be calculated. When dim is provided, the maximum over the selected
|
2595
2599
|
* dimension will be calculated. Parameter dim is zero-based.
|
2596
|
-
* @param args
|
2600
|
+
* @param args Multiple scalar values
|
2597
2601
|
* @returns The maximum value
|
2598
2602
|
*/
|
2599
|
-
|
2600
|
-
|
2603
|
+
max<T extends MathScalarType>(...args: T[]): T
|
2604
|
+
/**
|
2605
|
+
* @param args Multiple scalar values
|
2606
|
+
* @returns The maximum value
|
2607
|
+
*/
|
2608
|
+
max(...args: MathScalarType[]): MathScalarType
|
2601
2609
|
/**
|
2602
2610
|
* @param A A single matrix
|
2603
|
-
* @param
|
2611
|
+
* @param dimension The maximum over the selected dimension
|
2604
2612
|
* @returns The maximum value
|
2605
2613
|
*/
|
2606
|
-
|
2607
|
-
|
2614
|
+
max<T extends MathScalarType>(
|
2615
|
+
A: T[] | T[][],
|
2616
|
+
dimension?: number | BigNumber
|
2617
|
+
): T
|
2618
|
+
/**
|
2619
|
+
* @param A A single matrix
|
2620
|
+
* @param dimension The maximum over the selected dimension
|
2621
|
+
* @returns The maximum value
|
2622
|
+
*/
|
2623
|
+
max(A: MathCollection, dimension?: number | BigNumber): MathScalarType
|
2608
2624
|
|
2609
2625
|
/**
|
2610
2626
|
* Compute the mean value of matrix or a list with values. In case of a
|
2611
2627
|
* multi dimensional array, the mean of the flattened array will be
|
2612
2628
|
* calculated. When dim is provided, the maximum over the selected
|
2613
2629
|
* dimension will be calculated. Parameter dim is zero-based.
|
2614
|
-
* @param args
|
2630
|
+
* @param args Multiple scalar values
|
2615
2631
|
* @returns The mean of all values
|
2616
2632
|
*/
|
2617
|
-
|
2618
|
-
|
2633
|
+
mean<T extends MathScalarType>(...args: T[]): T
|
2634
|
+
/**
|
2635
|
+
* @param args Multiple scalar values
|
2636
|
+
* @returns The mean value
|
2637
|
+
*/
|
2638
|
+
mean(...args: MathScalarType[]): MathScalarType
|
2619
2639
|
/**
|
2620
2640
|
* @param A A single matrix
|
2621
|
-
* @param
|
2622
|
-
* @returns The mean
|
2641
|
+
* @param dimension The mean over the selected dimension
|
2642
|
+
* @returns The mean value
|
2623
2643
|
*/
|
2624
|
-
|
2625
|
-
|
2644
|
+
mean<T extends MathScalarType>(
|
2645
|
+
A: T[] | T[][],
|
2646
|
+
dimension?: number | BigNumber
|
2647
|
+
): T
|
2648
|
+
/**
|
2649
|
+
* @param A A single matrix
|
2650
|
+
* @param dimension The mean over the selected dimension
|
2651
|
+
* @returns The mean value
|
2652
|
+
*/
|
2653
|
+
mean(A: MathCollection, dimension?: number | BigNumber): MathScalarType
|
2626
2654
|
|
2627
2655
|
/**
|
2628
2656
|
* Compute the median of a matrix or a list with values. The values are
|
@@ -2631,49 +2659,103 @@ declare namespace math {
|
|
2631
2659
|
* types of values are: Number, BigNumber, Unit In case of a (multi
|
2632
2660
|
* dimensional) array or matrix, the median of all elements will be
|
2633
2661
|
* calculated.
|
2634
|
-
* @param args
|
2635
|
-
* @returns The median
|
2662
|
+
* @param args Multiple scalar values
|
2663
|
+
* @returns The median value
|
2636
2664
|
*/
|
2637
|
-
|
2638
|
-
|
2665
|
+
median<T extends MathScalarType>(...args: T[]): T
|
2666
|
+
/**
|
2667
|
+
* @param args Multiple scalar values
|
2668
|
+
* @returns The median value
|
2669
|
+
*/
|
2670
|
+
median(...args: MathScalarType[]): MathScalarType
|
2671
|
+
/**
|
2672
|
+
* @param A A single matrix
|
2673
|
+
* @returns The median value
|
2674
|
+
*/
|
2675
|
+
median<T extends MathScalarType>(A: T[] | T[][]): T
|
2676
|
+
/**
|
2677
|
+
* @param A A single matrix
|
2678
|
+
* @returns The median value
|
2679
|
+
*/
|
2680
|
+
median(A: MathCollection): MathScalarType
|
2639
2681
|
|
2640
2682
|
/**
|
2641
2683
|
* Compute the minimum value of a matrix or a list of values. In case of
|
2642
|
-
* a multi dimensional array, the
|
2643
|
-
* calculated. When dim is provided, the
|
2684
|
+
* a multi dimensional array, the minimum of the flattened array will be
|
2685
|
+
* calculated. When dim is provided, the minimum over the selected
|
2644
2686
|
* dimension will be calculated. Parameter dim is zero-based.
|
2645
|
-
* @param args
|
2687
|
+
* @param args multiple scalar values
|
2646
2688
|
* @returns The minimum value
|
2647
2689
|
*/
|
2648
|
-
|
2649
|
-
|
2690
|
+
min<T extends MathScalarType>(...args: T[]): T
|
2691
|
+
/**
|
2692
|
+
* @param args Multiple scalar values
|
2693
|
+
* @returns The minimum value
|
2694
|
+
*/
|
2695
|
+
min(...args: MathScalarType[]): MathScalarType
|
2650
2696
|
/**
|
2651
2697
|
* @param A A single matrix
|
2652
|
-
* @param
|
2698
|
+
* @param dimension The minimum over the selected dimension
|
2653
2699
|
* @returns The minimum value
|
2654
2700
|
*/
|
2655
|
-
|
2656
|
-
|
2701
|
+
min<T extends MathScalarType>(
|
2702
|
+
A: T[] | T[][],
|
2703
|
+
dimension?: number | BigNumber
|
2704
|
+
): T
|
2705
|
+
/**
|
2706
|
+
* @param A A single matrix
|
2707
|
+
* @param dimension The minimum over the selected dimension
|
2708
|
+
* @returns The minimum value
|
2709
|
+
*/
|
2710
|
+
min(A: MathCollection, dimension?: number | BigNumber): MathScalarType
|
2657
2711
|
|
2658
2712
|
/**
|
2659
2713
|
* Computes the mode of a set of numbers or a list with values(numbers
|
2660
2714
|
* or characters). If there are more than one modes, it returns a list
|
2661
2715
|
* of those values.
|
2662
|
-
* @param args
|
2716
|
+
* @param args Multiple scalar values
|
2663
2717
|
* @returns The mode of all values
|
2664
2718
|
*/
|
2665
|
-
|
2666
|
-
|
2719
|
+
mode<T extends MathScalarType>(...args: T[]): T
|
2720
|
+
/**
|
2721
|
+
* @param args Multiple scalar values
|
2722
|
+
* @returns The mode of all values
|
2723
|
+
*/
|
2724
|
+
mode(...args: MathScalarType[]): MathScalarType
|
2725
|
+
/**
|
2726
|
+
* @param A A single matrix
|
2727
|
+
* @returns The median value
|
2728
|
+
*/
|
2729
|
+
mode<T extends MathScalarType>(A: T[] | T[][]): T
|
2730
|
+
/**
|
2731
|
+
* @param A A single matrix
|
2732
|
+
* @returns The mode of all values
|
2733
|
+
*/
|
2734
|
+
mode(A: MathCollection): MathScalarType
|
2667
2735
|
|
2668
2736
|
/**
|
2669
2737
|
* Compute the product of a matrix or a list with values. In case of a
|
2670
2738
|
* (multi dimensional) array or matrix, the sum of all elements will be
|
2671
2739
|
* calculated.
|
2672
|
-
* @param args
|
2740
|
+
* @param args Multiple scalar values
|
2673
2741
|
* @returns The product of all values
|
2674
2742
|
*/
|
2675
|
-
|
2676
|
-
|
2743
|
+
prod<T extends MathScalarType>(...args: T[]): T
|
2744
|
+
/**
|
2745
|
+
* @param args Multiple scalar values
|
2746
|
+
* @returns The product of all values
|
2747
|
+
*/
|
2748
|
+
prod(...args: MathScalarType[]): MathScalarType
|
2749
|
+
/**
|
2750
|
+
* @param A A single matrix
|
2751
|
+
* @returns The product of all values
|
2752
|
+
*/
|
2753
|
+
prod<T extends MathScalarType>(A: T[] | T[][]): T
|
2754
|
+
/**
|
2755
|
+
* @param A A single matrix
|
2756
|
+
* @returns The product of all values
|
2757
|
+
*/
|
2758
|
+
prod(A: MathCollection): MathScalarType
|
2677
2759
|
|
2678
2760
|
/**
|
2679
2761
|
* Compute the prob order quantile of a matrix or a list with values.
|
@@ -2705,10 +2787,15 @@ declare namespace math {
|
|
2705
2787
|
* values: 'unbiased' (default) The sum of squared errors is divided by
|
2706
2788
|
* (n - 1) 'uncorrected' The sum of squared errors is divided by n
|
2707
2789
|
* 'biased' The sum of squared errors is divided by (n + 1)
|
2708
|
-
* @param
|
2709
|
-
* @returns The standard deviation
|
2790
|
+
* @param args variadic argument of number to calculate standard deviation
|
2791
|
+
* @returns The standard deviation
|
2710
2792
|
*/
|
2711
|
-
std(...
|
2793
|
+
std<T extends MathScalarType>(...args: T[]): T
|
2794
|
+
/**
|
2795
|
+
* @param args Multiple scalar values
|
2796
|
+
* @returns The standard deviation
|
2797
|
+
*/
|
2798
|
+
std(...args: MathScalarType[]): MathScalarType
|
2712
2799
|
/**
|
2713
2800
|
* Compute the standard deviation of a matrix or a list with values. The
|
2714
2801
|
* standard deviations is defined as the square root of the variance:
|
@@ -2730,7 +2817,7 @@ declare namespace math {
|
|
2730
2817
|
array: MathCollection,
|
2731
2818
|
dimension?: number,
|
2732
2819
|
normalization?: 'unbiased' | 'uncorrected' | 'biased'
|
2733
|
-
):
|
2820
|
+
): MathNumericType[]
|
2734
2821
|
/**
|
2735
2822
|
* Compute the standard deviation of a matrix or a list with values. The
|
2736
2823
|
* standard deviations is defined as the square root of the variance:
|
@@ -2750,7 +2837,7 @@ declare namespace math {
|
|
2750
2837
|
std(
|
2751
2838
|
array: MathCollection,
|
2752
2839
|
normalization: 'unbiased' | 'uncorrected' | 'biased'
|
2753
|
-
):
|
2840
|
+
): MathNumericType
|
2754
2841
|
|
2755
2842
|
/**
|
2756
2843
|
* Compute the sum of a matrix or a list with values. In case of a
|
@@ -2759,14 +2846,27 @@ declare namespace math {
|
|
2759
2846
|
* @param args A single matrix or multiple scalar values
|
2760
2847
|
* @returns The sum of all values
|
2761
2848
|
*/
|
2762
|
-
|
2763
|
-
sum(...args: Array<number | BigNumber | Fraction>): any
|
2849
|
+
sum<T extends MathScalarType>(...args: T[]): T
|
2764
2850
|
/**
|
2765
|
-
* @param
|
2851
|
+
* @param args Multiple scalar values
|
2766
2852
|
* @returns The sum of all values
|
2767
2853
|
*/
|
2768
|
-
|
2769
|
-
|
2854
|
+
sum(...args: MathScalarType[]): MathScalarType
|
2855
|
+
/**
|
2856
|
+
* @param A A single matrix
|
2857
|
+
* @param dimension The sum over the selected dimension
|
2858
|
+
* @returns The sum of all values
|
2859
|
+
*/
|
2860
|
+
sum<T extends MathScalarType>(
|
2861
|
+
A: T[] | T[][],
|
2862
|
+
dimension?: number | BigNumber
|
2863
|
+
): T
|
2864
|
+
/**
|
2865
|
+
* @param A A single matrix
|
2866
|
+
* @param dimension The sum over the selected dimension
|
2867
|
+
* @returns The sum of all values
|
2868
|
+
*/
|
2869
|
+
sum(A: MathCollection, dimension?: number | BigNumber): MathScalarType
|
2770
2870
|
|
2771
2871
|
/**
|
2772
2872
|
* Count the number of elements of a matrix, array or string.
|
@@ -2804,8 +2904,7 @@ declare namespace math {
|
|
2804
2904
|
* @param args A single matrix or multiple scalar values
|
2805
2905
|
* @returns The variance
|
2806
2906
|
*/
|
2807
|
-
variance(...args:
|
2808
|
-
|
2907
|
+
variance(...args: MathNumericType[]): MathNumericType
|
2809
2908
|
/**
|
2810
2909
|
* Compute the variance of a matrix or a list with values. In case of a
|
2811
2910
|
* (multi dimensional) array or matrix, the variance over all elements
|
@@ -2828,7 +2927,7 @@ declare namespace math {
|
|
2828
2927
|
array: MathCollection,
|
2829
2928
|
dimension?: number,
|
2830
2929
|
normalization?: 'unbiased' | 'uncorrected' | 'biased'
|
2831
|
-
):
|
2930
|
+
): MathNumericType[]
|
2832
2931
|
/**
|
2833
2932
|
* @param array A single matrix
|
2834
2933
|
* @param normalization normalization Determines how to normalize the
|
@@ -2839,7 +2938,7 @@ declare namespace math {
|
|
2839
2938
|
variance(
|
2840
2939
|
array: MathCollection,
|
2841
2940
|
normalization: 'unbiased' | 'uncorrected' | 'biased'
|
2842
|
-
):
|
2941
|
+
): MathNumericType
|
2843
2942
|
|
2844
2943
|
/*************************************************************************
|
2845
2944
|
* String functions
|
@@ -3781,7 +3880,7 @@ declare namespace math {
|
|
3781
3880
|
equalBase(unit: Unit): boolean
|
3782
3881
|
equals(unit: Unit): boolean
|
3783
3882
|
multiply(unit: Unit): Unit
|
3784
|
-
divide(unit: Unit): Unit
|
3883
|
+
divide(unit: Unit): Unit | number
|
3785
3884
|
pow(unit: Unit): Unit
|
3786
3885
|
abs(unit: Unit): Unit
|
3787
3886
|
to(unit: string): Unit
|