mathjs 9.5.1 → 10.0.2
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 +37 -0
- package/bin/cli.js +0 -0
- package/docs/reference/constants.md +1 -1
- package/docs/reference/functions/parser.md +4 -4
- package/examples/expressions.js +1 -1
- package/lib/browser/math.js +6 -6
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/constants.js +1 -1
- package/lib/cjs/core/function/config.js +1 -1
- package/lib/cjs/core/function/import.js +2 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesIntersect.generated.js +6 -0
- package/lib/cjs/entry/dependenciesAny.generated.js +999 -999
- package/lib/cjs/entry/dependenciesNumber.generated.js +581 -581
- package/lib/cjs/entry/impureFunctionsAny.generated.js +314 -313
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +223 -222
- package/lib/cjs/entry/mainAny.js +8 -8
- package/lib/cjs/entry/mainNumber.js +8 -8
- package/lib/cjs/entry/pureFunctionsAny.generated.js +1102 -1100
- package/lib/cjs/entry/pureFunctionsNumber.generated.js +375 -375
- package/lib/cjs/entry/typeChecks.js +12 -12
- package/lib/cjs/expression/Parser.js +1 -1
- package/lib/cjs/expression/function/parser.js +4 -4
- package/lib/cjs/expression/operators.js +1 -1
- package/lib/cjs/factoriesAny.js +660 -660
- package/lib/cjs/factoriesNumber.js +268 -237
- package/lib/cjs/function/algebra/simplify.js +3 -0
- package/lib/cjs/function/arithmetic/round.js +2 -2
- package/lib/cjs/function/geometry/intersect.js +12 -13
- package/lib/cjs/function/probability/gamma.js +28 -30
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/plain/bignumber/arithmetic.js +2 -2
- package/lib/cjs/plain/number/arithmetic.js +10 -10
- package/lib/cjs/plain/number/constants.js +1 -1
- package/lib/cjs/plain/number/logical.js +1 -1
- package/lib/cjs/plain/number/probability.js +2 -1
- package/lib/cjs/plain/number/trigonometry.js +1 -1
- package/lib/cjs/plain/number/utils.js +1 -1
- package/lib/cjs/type/matrix/SparseMatrix.js +19 -15
- package/lib/cjs/type/unit/Unit.js +2 -2
- package/lib/cjs/type/unit/physicalConstants.js +1 -1
- package/lib/cjs/utils/array.js +14 -14
- package/lib/cjs/utils/bignumber/bitwise.js +1 -1
- package/lib/cjs/utils/customs.js +5 -5
- package/lib/cjs/utils/factory.js +3 -3
- package/lib/cjs/utils/function.js +1 -1
- package/lib/cjs/utils/is.js +23 -23
- package/lib/cjs/utils/latex.js +2 -1
- package/lib/cjs/utils/map.js +3 -3
- package/lib/cjs/utils/noop.js +1 -1
- package/lib/cjs/utils/number.js +11 -7
- package/lib/cjs/utils/object.js +8 -8
- package/lib/cjs/utils/snapshot.js +3 -3
- package/lib/cjs/utils/string.js +2 -2
- package/lib/cjs/version.js +1 -1
- package/lib/esm/core/function/import.js +2 -1
- package/lib/esm/entry/dependenciesAny/dependenciesIntersect.generated.js +4 -0
- package/lib/esm/entry/dependenciesAny.generated.js +270 -270
- package/lib/esm/entry/dependenciesNumber.generated.js +163 -163
- package/lib/esm/entry/impureFunctionsAny.generated.js +301 -301
- package/lib/esm/entry/impureFunctionsNumber.generated.js +211 -211
- package/lib/esm/entry/pureFunctionsAny.generated.js +818 -816
- package/lib/esm/entry/pureFunctionsNumber.generated.js +234 -234
- package/lib/esm/expression/Parser.js +1 -1
- package/lib/esm/expression/function/parser.js +4 -4
- package/lib/esm/function/algebra/simplify.js +3 -0
- package/lib/esm/function/arithmetic/round.js +2 -2
- package/lib/esm/function/geometry/intersect.js +12 -12
- package/lib/esm/function/probability/gamma.js +28 -30
- package/lib/esm/type/matrix/SparseMatrix.js +19 -15
- package/lib/esm/type/unit/Unit.js +2 -2
- package/lib/esm/utils/number.js +1 -1
- package/lib/esm/utils/snapshot.js +2 -2
- package/lib/esm/version.js +1 -1
- package/package.json +17 -17
- package/types/index.d.ts +47 -47
@@ -37,7 +37,7 @@ export var createParserClass = /* #__PURE__ */factory(name, dependencies, _ref =
|
|
37
37
|
* // define variables and functions
|
38
38
|
* parser.evaluate('x = 7 / 2') // 3.5
|
39
39
|
* parser.evaluate('x + 3') // 6.5
|
40
|
-
* parser.evaluate('
|
40
|
+
* parser.evaluate('f(x, y) = x^y') // f(x, y)
|
41
41
|
* parser.evaluate('f(2, 3)') // 8
|
42
42
|
*
|
43
43
|
* // get and set variables and functions
|
@@ -25,10 +25,10 @@ export var createParser = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
25
25
|
* const d = parser.evaluate('cos(45 deg)') // 0.7071067811865476
|
26
26
|
*
|
27
27
|
* // define variables and functions
|
28
|
-
* parser.evaluate('x = 7 / 2')
|
29
|
-
* parser.evaluate('x + 3')
|
30
|
-
* parser.evaluate('
|
31
|
-
* parser.evaluate('f(2, 3)')
|
28
|
+
* parser.evaluate('x = 7 / 2') // 3.5
|
29
|
+
* parser.evaluate('x + 3') // 6.5
|
30
|
+
* parser.evaluate('f(x, y) = x^y') // f(x, y)
|
31
|
+
* parser.evaluate('f(2, 3)') // 8
|
32
32
|
*
|
33
33
|
* // get and set variables and functions
|
34
34
|
* const x = parser.get('x') // 7
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
2
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
4
4
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
6
6
|
|
7
7
|
import { factory } from '../../utils/factory.js';
|
8
8
|
import { deepMap } from '../../utils/collection.js';
|
@@ -1,7 +1,6 @@
|
|
1
|
-
import { isBigNumber } from '../../utils/is.js';
|
2
1
|
import { factory } from '../../utils/factory.js';
|
3
2
|
var name = 'intersect';
|
4
|
-
var dependencies = ['typed', 'config', 'abs', 'add', 'addScalar', 'matrix', 'multiply', 'multiplyScalar', 'divideScalar', 'subtract', 'smaller', 'equalScalar', 'flatten'];
|
3
|
+
var dependencies = ['typed', 'config', 'abs', 'add', 'addScalar', 'matrix', 'multiply', 'multiplyScalar', 'divideScalar', 'subtract', 'smaller', 'equalScalar', 'flatten', 'isZero', 'isNumeric'];
|
5
4
|
export var createIntersect = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
5
|
var {
|
7
6
|
typed,
|
@@ -16,7 +15,9 @@ export var createIntersect = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
16
15
|
subtract,
|
17
16
|
smaller,
|
18
17
|
equalScalar,
|
19
|
-
flatten
|
18
|
+
flatten,
|
19
|
+
isZero,
|
20
|
+
isNumeric
|
20
21
|
} = _ref;
|
21
22
|
|
22
23
|
/**
|
@@ -142,21 +143,16 @@ export var createIntersect = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
142
143
|
return arr;
|
143
144
|
}
|
144
145
|
|
145
|
-
function _isNumeric(a) {
|
146
|
-
// intersect supports numbers and bignumbers
|
147
|
-
return typeof a === 'number' || isBigNumber(a);
|
148
|
-
}
|
149
|
-
|
150
146
|
function _2d(x) {
|
151
|
-
return x.length === 2 &&
|
147
|
+
return x.length === 2 && isNumeric(x[0]) && isNumeric(x[1]);
|
152
148
|
}
|
153
149
|
|
154
150
|
function _3d(x) {
|
155
|
-
return x.length === 3 &&
|
151
|
+
return x.length === 3 && isNumeric(x[0]) && isNumeric(x[1]) && isNumeric(x[2]);
|
156
152
|
}
|
157
153
|
|
158
154
|
function _4d(x) {
|
159
|
-
return x.length === 4 &&
|
155
|
+
return x.length === 4 && isNumeric(x[0]) && isNumeric(x[1]) && isNumeric(x[2]) && isNumeric(x[3]);
|
160
156
|
}
|
161
157
|
|
162
158
|
function _intersect2d(p1a, p1b, p2a, p2b) {
|
@@ -165,6 +161,7 @@ export var createIntersect = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
165
161
|
var d1 = subtract(o1, p1b);
|
166
162
|
var d2 = subtract(o2, p2b);
|
167
163
|
var det = subtract(multiplyScalar(d1[0], d2[1]), multiplyScalar(d2[0], d1[1]));
|
164
|
+
if (isZero(det)) return null;
|
168
165
|
|
169
166
|
if (smaller(abs(det), config.epsilon)) {
|
170
167
|
return null;
|
@@ -197,7 +194,10 @@ export var createIntersect = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
197
194
|
|
198
195
|
var d2121 = _intersect3dHelper(x2, x1, x2, x1, y2, y1, y2, y1, z2, z1, z2, z1);
|
199
196
|
|
200
|
-
var
|
197
|
+
var numerator = subtract(multiplyScalar(d1343, d4321), multiplyScalar(d1321, d4343));
|
198
|
+
var denominator = subtract(multiplyScalar(d2121, d4343), multiplyScalar(d4321, d4321));
|
199
|
+
if (isZero(denominator)) return null;
|
200
|
+
var ta = divideScalar(numerator, denominator);
|
201
201
|
var tb = divideScalar(addScalar(d1343, multiplyScalar(ta, d4321)), d4343);
|
202
202
|
var pax = addScalar(x1, multiplyScalar(ta, subtract(x2, x1)));
|
203
203
|
var pay = addScalar(y1, multiplyScalar(ta, subtract(y2, y1)));
|
@@ -41,44 +41,42 @@ export var createGamma = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
41
41
|
Complex: function Complex(n) {
|
42
42
|
if (n.im === 0) {
|
43
43
|
return this(n.re);
|
44
|
-
}
|
44
|
+
} // Lanczos approximation doesn't work well with real part lower than 0.5
|
45
|
+
// So reflection formula is required
|
46
|
+
|
47
|
+
|
48
|
+
if (n.re < 0.5) {
|
49
|
+
// Euler's reflection formula
|
50
|
+
// gamma(1-z) * gamma(z) = PI / sin(PI * z)
|
51
|
+
// real part of Z should not be integer [sin(PI) == 0 -> 1/0 - undefined]
|
52
|
+
// thanks to imperfect sin implementation sin(PI * n) != 0
|
53
|
+
// we can safely use it anyway
|
54
|
+
var _t = new _Complex(1 - n.re, -n.im);
|
55
|
+
|
56
|
+
var r = new _Complex(Math.PI * n.re, Math.PI * n.im);
|
57
|
+
return new _Complex(Math.PI).div(r.sin()).div(this(_t));
|
58
|
+
} // Lanczos approximation
|
59
|
+
// z -= 1
|
60
|
+
|
45
61
|
|
46
|
-
n = new _Complex(n.re - 1, n.im);
|
47
|
-
|
62
|
+
n = new _Complex(n.re - 1, n.im); // x = gammaPval[0]
|
63
|
+
|
64
|
+
var x = new _Complex(gammaP[0], 0); // for (i, gammaPval) in enumerate(gammaP):
|
48
65
|
|
49
66
|
for (var i = 1; i < gammaP.length; ++i) {
|
50
|
-
|
67
|
+
// x += gammaPval / (z + i)
|
68
|
+
var gammaPval = new _Complex(gammaP[i], 0);
|
69
|
+
x = x.add(gammaPval.div(n.add(i)));
|
70
|
+
} // t = z + gammaG + 0.5
|
51
71
|
|
52
|
-
var den = real * real + n.im * n.im;
|
53
72
|
|
54
|
-
|
55
|
-
x.re += gammaP[i] * real / den;
|
56
|
-
x.im += -(gammaP[i] * n.im) / den;
|
57
|
-
} else {
|
58
|
-
x.re = gammaP[i] < 0 ? -Infinity : Infinity;
|
59
|
-
}
|
60
|
-
}
|
73
|
+
var t = new _Complex(n.re + gammaG + 0.5, n.im); // y = sqrt(2 * pi) * t ** (z + 0.5) * exp(-t) * x
|
61
74
|
|
62
|
-
var t = new _Complex(n.re + gammaG + 0.5, n.im);
|
63
75
|
var twoPiSqrt = Math.sqrt(2 * Math.PI);
|
64
|
-
n.
|
65
|
-
var
|
66
|
-
|
67
|
-
if (result.im === 0) {
|
68
|
-
// sqrt(2*PI)*result
|
69
|
-
result.re *= twoPiSqrt;
|
70
|
-
} else if (result.re === 0) {
|
71
|
-
result.im *= twoPiSqrt;
|
72
|
-
} else {
|
73
|
-
result.re *= twoPiSqrt;
|
74
|
-
result.im *= twoPiSqrt;
|
75
|
-
}
|
76
|
-
|
77
|
-
var r = Math.exp(-t.re); // exp(-t)
|
76
|
+
var tpow = t.pow(n.add(0.5));
|
77
|
+
var expt = t.neg().exp(); // y = [x] * [sqrt(2 * pi)] * [t ** (z + 0.5)] * [exp(-t)]
|
78
78
|
|
79
|
-
|
80
|
-
t.im = r * Math.sin(-t.im);
|
81
|
-
return multiplyScalar(multiplyScalar(result, t), x);
|
79
|
+
return x.mul(twoPiSqrt).mul(tpow).mul(expt);
|
82
80
|
},
|
83
81
|
BigNumber: function BigNumber(n) {
|
84
82
|
if (n.isInteger()) {
|
@@ -417,23 +417,27 @@ export var createSparseMatrixClass = /* #__PURE__ */factory(name, dependencies,
|
|
417
417
|
|
418
418
|
if (!deepStrictEqual(iSize, sSize)) {
|
419
419
|
throw new DimensionError(iSize, sSize, '>');
|
420
|
-
} //
|
420
|
+
} // insert the sub matrix
|
421
421
|
|
422
422
|
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
423
|
+
if (iSize.length === 1) {
|
424
|
+
// if the replacement index only has 1 dimension, go trough each one and set its value
|
425
|
+
var range = index.dimension(0);
|
426
|
+
range.forEach(function (dataIndex, subIndex) {
|
427
|
+
validateIndex(dataIndex);
|
428
|
+
matrix.set([dataIndex, 0], submatrix[subIndex[0]], defaultValue);
|
429
|
+
});
|
430
|
+
} else {
|
431
|
+
// if the replacement index has 2 dimensions, go through each one and set the value in the correct index
|
432
|
+
var firstDimensionRange = index.dimension(0);
|
433
|
+
var secondDimensionRange = index.dimension(1);
|
434
|
+
firstDimensionRange.forEach(function (firstDataIndex, firstSubIndex) {
|
435
|
+
validateIndex(firstDataIndex);
|
436
|
+
secondDimensionRange.forEach(function (secondDataIndex, secondSubIndex) {
|
437
|
+
validateIndex(secondDataIndex);
|
438
|
+
matrix.set([firstDataIndex, secondDataIndex], submatrix[firstSubIndex[0]][secondSubIndex[0]], defaultValue);
|
439
|
+
});
|
440
|
+
});
|
437
441
|
}
|
438
442
|
}
|
439
443
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
3
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
5
5
|
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
7
7
|
|
8
8
|
import { isComplex, isUnit, typeOf } from '../../utils/is.js';
|
9
9
|
import { factory } from '../../utils/factory.js';
|
package/lib/esm/utils/number.js
CHANGED
@@ -318,7 +318,7 @@ export function format(value, options) {
|
|
318
318
|
|
319
319
|
export function splitNumber(value) {
|
320
320
|
// parse the input value
|
321
|
-
var match = String(value).toLowerCase().match(/^
|
321
|
+
var match = String(value).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);
|
322
322
|
|
323
323
|
if (!match) {
|
324
324
|
throw new SyntaxError('Invalid number ' + value);
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
3
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
5
5
|
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
7
7
|
|
8
8
|
/**
|
9
9
|
* This file contains helper methods to create expected snapshot structures
|
package/lib/esm/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export var version = '
|
1
|
+
export var version = '10.0.2'; // Note: This file is automatically generated when building math.js.
|
2
2
|
// Changes made in this file will be overwritten.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mathjs",
|
3
|
-
"version": "
|
3
|
+
"version": "10.0.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,39 +25,39 @@
|
|
25
25
|
"unit"
|
26
26
|
],
|
27
27
|
"dependencies": {
|
28
|
-
"@babel/runtime": "^7.
|
28
|
+
"@babel/runtime": "^7.16.5",
|
29
29
|
"complex.js": "^2.0.15",
|
30
30
|
"decimal.js": "^10.3.1",
|
31
31
|
"escape-latex": "^1.2.0",
|
32
|
-
"fraction.js": "^4.1.
|
32
|
+
"fraction.js": "^4.1.2",
|
33
33
|
"javascript-natural-sort": "^0.7.1",
|
34
34
|
"seedrandom": "^3.0.5",
|
35
35
|
"tiny-emitter": "^2.1.0",
|
36
36
|
"typed-function": "^2.0.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.
|
44
|
-
"babel-loader": "8.2.
|
39
|
+
"@babel/core": "7.16.5",
|
40
|
+
"@babel/plugin-transform-object-assign": "7.16.5",
|
41
|
+
"@babel/plugin-transform-runtime": "7.16.5",
|
42
|
+
"@babel/preset-env": "7.16.5",
|
43
|
+
"@babel/register": "7.16.5",
|
44
|
+
"babel-loader": "8.2.3",
|
45
45
|
"benchmark": "2.1.4",
|
46
46
|
"codecov": "3.8.3",
|
47
|
-
"core-js": "3.
|
47
|
+
"core-js": "3.20.1",
|
48
48
|
"del": "6.0.0",
|
49
|
-
"dtslint": "4.1
|
49
|
+
"dtslint": "4.2.1",
|
50
50
|
"expr-eval": "2.0.2",
|
51
51
|
"fancy-log": "1.3.3",
|
52
|
-
"glob": "7.
|
52
|
+
"glob": "7.2.0",
|
53
53
|
"gulp": "4.0.2",
|
54
54
|
"gulp-babel": "8.0.0",
|
55
55
|
"handlebars": "4.7.7",
|
56
56
|
"istanbul": "0.4.5",
|
57
|
-
"jsep": "1.0
|
58
|
-
"karma": "6.3.
|
57
|
+
"jsep": "1.2.0",
|
58
|
+
"karma": "6.3.9",
|
59
59
|
"karma-browserstack-launcher": "1.6.0",
|
60
|
-
"karma-firefox-launcher": "2.1.
|
60
|
+
"karma-firefox-launcher": "2.1.2",
|
61
61
|
"karma-mocha": "2.0.1",
|
62
62
|
"karma-mocha-reporter": "2.2.5",
|
63
63
|
"karma-webpack": "4.0.2",
|
@@ -72,9 +72,9 @@
|
|
72
72
|
"numericjs": "1.2.6",
|
73
73
|
"nyc": "15.1.0",
|
74
74
|
"pad-right": "0.2.2",
|
75
|
-
"standard": "16.0.
|
75
|
+
"standard": "16.0.4",
|
76
76
|
"sylvester": "0.0.21",
|
77
|
-
"typescript": "4.4
|
77
|
+
"typescript": "4.5.4",
|
78
78
|
"webpack": "4.46.0",
|
79
79
|
"zeros": "1.0.0"
|
80
80
|
},
|
package/types/index.d.ts
CHANGED
@@ -5,10 +5,10 @@ export as namespace math;
|
|
5
5
|
export = math;
|
6
6
|
|
7
7
|
type NoLiteralType<T> =
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
T extends number ? number :
|
9
|
+
T extends string ? string :
|
10
|
+
T extends boolean ? boolean :
|
11
|
+
T;
|
12
12
|
|
13
13
|
declare namespace math {
|
14
14
|
type MathArray = number[] | number[][];
|
@@ -273,7 +273,7 @@ declare namespace math {
|
|
273
273
|
interface OperatorNodeCtor {
|
274
274
|
new(op: string, fn: string, args: MathNode[], implicit?: boolean): OperatorNode;
|
275
275
|
}
|
276
|
-
|
276
|
+
|
277
277
|
interface ParenthesisNode extends MathNodeCommon {
|
278
278
|
type: 'ParenthesisNode';
|
279
279
|
isParenthesisNode: true;
|
@@ -314,8 +314,8 @@ declare namespace math {
|
|
314
314
|
}
|
315
315
|
|
316
316
|
type MathNode = AccessorNode | ArrayNode | AssignmentNode | BlockNode | ConditionalNode | ConstantNode |
|
317
|
-
|
318
|
-
|
317
|
+
FunctionAssignmentNode | FunctionNode | IndexNode | ObjectNode | OperatorNode | ParenthesisNode | RangeNode |
|
318
|
+
RelationalNode | SymbolNode;
|
319
319
|
|
320
320
|
|
321
321
|
type MathJsFunctionName = keyof MathJsStatic;
|
@@ -489,8 +489,8 @@ declare namespace math {
|
|
489
489
|
* @returns Returns a fraction
|
490
490
|
*/
|
491
491
|
fraction(
|
492
|
-
|
493
|
-
|
492
|
+
numerator: number | string | MathArray | Matrix,
|
493
|
+
denominator?: number | string | MathArray | Matrix
|
494
494
|
): Fraction | MathArray | Matrix;
|
495
495
|
|
496
496
|
/**
|
@@ -693,11 +693,11 @@ declare namespace math {
|
|
693
693
|
* @returns The rational polynomial of expr
|
694
694
|
*/
|
695
695
|
rationalize(
|
696
|
-
|
697
|
-
|
698
|
-
|
696
|
+
expr: MathNode | string,
|
697
|
+
optional?: object | boolean,
|
698
|
+
detailed?: true
|
699
699
|
): { expression: MathNode | string; variables: string[]; coefficients: MathType[] };
|
700
|
-
|
700
|
+
|
701
701
|
|
702
702
|
/**
|
703
703
|
* Simplify an expression tree.
|
@@ -903,17 +903,17 @@ declare namespace math {
|
|
903
903
|
floor(x: MathArray): MathArray;
|
904
904
|
floor(x: Matrix): Matrix;
|
905
905
|
|
906
|
-
|
906
|
+
/**
|
907
907
|
* Round a value towards minus infinity. For matrices, the function is
|
908
908
|
* evaluated element wise.
|
909
909
|
* @param x Number to be rounded
|
910
910
|
* @param n Number of decimals Default value: 0.
|
911
911
|
* @returns Rounded value
|
912
912
|
*/
|
913
|
-
|
913
|
+
floor(
|
914
914
|
x: number | BigNumber | Fraction | Complex | MathArray | Matrix,
|
915
915
|
n: number | BigNumber | MathArray
|
916
|
-
|
916
|
+
): number | BigNumber | Fraction | Complex | MathArray | Matrix;
|
917
917
|
|
918
918
|
/**
|
919
919
|
* Calculate the greatest common divisor for two or more values or
|
@@ -1009,8 +1009,8 @@ declare namespace math {
|
|
1009
1009
|
* @returns Returns the remainder of x divided by y
|
1010
1010
|
*/
|
1011
1011
|
mod<T extends number | BigNumber | Fraction | MathArray | Matrix>(
|
1012
|
-
|
1013
|
-
|
1012
|
+
x: T,
|
1013
|
+
y: number | BigNumber | Fraction | MathArray | Matrix
|
1014
1014
|
): NoLiteralType<T>;
|
1015
1015
|
|
1016
1016
|
/**
|
@@ -1063,8 +1063,8 @@ declare namespace math {
|
|
1063
1063
|
* @returns Rounded value of x
|
1064
1064
|
*/
|
1065
1065
|
round<T extends number | BigNumber | Fraction | Complex | MathArray | Matrix>(
|
1066
|
-
|
1067
|
-
|
1066
|
+
x: T,
|
1067
|
+
n?: number | BigNumber | MathArray
|
1068
1068
|
): NoLiteralType<T>;
|
1069
1069
|
|
1070
1070
|
/**
|
@@ -1378,8 +1378,8 @@ declare namespace math {
|
|
1378
1378
|
* nonzero/nonempty value.
|
1379
1379
|
*/
|
1380
1380
|
and(
|
1381
|
-
|
1382
|
-
|
1381
|
+
x: number | BigNumber | Complex | Unit | MathArray | Matrix,
|
1382
|
+
y: number | BigNumber | Complex | Unit | MathArray | Matrix
|
1383
1383
|
): boolean | MathArray | Matrix;
|
1384
1384
|
|
1385
1385
|
/**
|
@@ -1400,8 +1400,8 @@ declare namespace math {
|
|
1400
1400
|
* nonzero/nonempty value.
|
1401
1401
|
*/
|
1402
1402
|
or(
|
1403
|
-
|
1404
|
-
|
1403
|
+
x: number | BigNumber | Complex | Unit | MathArray | Matrix,
|
1404
|
+
y: number | BigNumber | Complex | Unit | MathArray | Matrix
|
1405
1405
|
): boolean | MathArray | Matrix;
|
1406
1406
|
|
1407
1407
|
/**
|
@@ -1414,8 +1414,8 @@ declare namespace math {
|
|
1414
1414
|
* nonzero/nonempty value.
|
1415
1415
|
*/
|
1416
1416
|
xor(
|
1417
|
-
|
1418
|
-
|
1417
|
+
x: number | BigNumber | Complex | Unit | MathArray | Matrix,
|
1418
|
+
y: number | BigNumber | Complex | Unit | MathArray | Matrix
|
1419
1419
|
): boolean | MathArray | Matrix;
|
1420
1420
|
|
1421
1421
|
/*************************************************************************
|
@@ -1432,7 +1432,7 @@ declare namespace math {
|
|
1432
1432
|
* array or 1-d matrix as an input and return a number.
|
1433
1433
|
* @returns The residual matrix with the function applied over some dimension.
|
1434
1434
|
*/
|
1435
|
-
|
1435
|
+
apply<T extends MathArray | Matrix>(array: T, dim: number, callback: (array: MathArray | Matrix) => number): T
|
1436
1436
|
|
1437
1437
|
|
1438
1438
|
/**
|
@@ -1502,7 +1502,7 @@ declare namespace math {
|
|
1502
1502
|
* @param prec Precision, default value: 1e-15
|
1503
1503
|
* @returns Object containing an array of eigenvalues and a matrix with eigenvectors as columns.
|
1504
1504
|
*/
|
1505
|
-
|
1505
|
+
eigs(x: MathArray | Matrix, prec?:number|BigNumber): {values: MathArray | Matrix, vectors: MathArray | Matrix}
|
1506
1506
|
|
1507
1507
|
/**
|
1508
1508
|
* Compute the matrix exponential, expm(A) = e^A. The matrix must be
|
@@ -1541,8 +1541,8 @@ declare namespace math {
|
|
1541
1541
|
* traversed. The function must return a boolean.
|
1542
1542
|
*/
|
1543
1543
|
filter(
|
1544
|
-
|
1545
|
-
|
1544
|
+
x: Matrix | MathArray | string[],
|
1545
|
+
test: ((value: any, index: any, matrix: Matrix | MathArray | string[]) => boolean) | RegExp
|
1546
1546
|
): Matrix | MathArray;
|
1547
1547
|
|
1548
1548
|
/**
|
@@ -2619,7 +2619,7 @@ declare namespace math {
|
|
2619
2619
|
*/
|
2620
2620
|
clone(x: any): any;
|
2621
2621
|
|
2622
|
-
|
2622
|
+
/**
|
2623
2623
|
* Test whether a value is an numeric value. In case of a string,
|
2624
2624
|
* true is returned if the string contains a numeric value.
|
2625
2625
|
* @param x Value to be tested
|
@@ -2627,7 +2627,7 @@ declare namespace math {
|
|
2627
2627
|
* Returns false for other types.
|
2628
2628
|
* Throws an error in case of unknown types.
|
2629
2629
|
*/
|
2630
|
-
|
2630
|
+
hasNumericValue(x: any ): boolean| boolean[];
|
2631
2631
|
|
2632
2632
|
/**
|
2633
2633
|
* Test whether a value is an integer number. The function supports
|
@@ -2732,10 +2732,10 @@ declare namespace math {
|
|
2732
2732
|
interface FactoryDependencies {
|
2733
2733
|
create: (factories: FactoryFunctionMap, config?: ConfigOptions) => MathJsStatic;
|
2734
2734
|
factory: <T>(
|
2735
|
-
|
2736
|
-
|
2737
|
-
|
2738
|
-
|
2735
|
+
name: string,
|
2736
|
+
dependencies: MathJsFunctionName[],
|
2737
|
+
create: (injected: Partial<MathJsStatic>) => T,
|
2738
|
+
meta?: any
|
2739
2739
|
) => FactoryFunction<T>;
|
2740
2740
|
all: FactoryFunctionMap;
|
2741
2741
|
|
@@ -3164,15 +3164,15 @@ declare namespace math {
|
|
3164
3164
|
|
3165
3165
|
interface Simplify {
|
3166
3166
|
(
|
3167
|
-
|
3168
|
-
|
3169
|
-
|
3170
|
-
|
3167
|
+
expr: MathNode | string,
|
3168
|
+
rules?: SimplifyRule[],
|
3169
|
+
scope?: object,
|
3170
|
+
options?: SimplifyOptions,
|
3171
3171
|
): MathNode;
|
3172
3172
|
(
|
3173
|
-
|
3174
|
-
|
3175
|
-
|
3173
|
+
expr: MathNode | string,
|
3174
|
+
scope?: object,
|
3175
|
+
options?: SimplifyOptions,
|
3176
3176
|
): MathNode;
|
3177
3177
|
|
3178
3178
|
rules: SimplifyRule[];
|
@@ -3197,8 +3197,8 @@ declare namespace math {
|
|
3197
3197
|
isNode: true;
|
3198
3198
|
comment: string;
|
3199
3199
|
type: 'AccessorNode' | 'ArrayNode' | 'AssignmentNode' | 'BlockNode' | 'ConditionalNode' | 'ConstantNode' |
|
3200
|
-
|
3201
|
-
|
3200
|
+
'FunctionAssignmentNode' | 'FunctionNode' | 'IndexNode' | 'ObjectNode' | 'OperatorNode' | 'ParenthesisNode' |
|
3201
|
+
'RangeNode' | 'RelationalNode' | 'SymbolNode';
|
3202
3202
|
|
3203
3203
|
isUpdateNode?: boolean;
|
3204
3204
|
|
@@ -3275,7 +3275,7 @@ declare namespace math {
|
|
3275
3275
|
/**
|
3276
3276
|
* Get a HTML representation of the parsed expression.
|
3277
3277
|
*/
|
3278
|
-
|
3278
|
+
toHTML(options?: object): string;
|
3279
3279
|
|
3280
3280
|
/**
|
3281
3281
|
* Get a string representation of the parsed expression. This is not
|
@@ -3690,7 +3690,7 @@ declare namespace math {
|
|
3690
3690
|
* array or 1-d matrix as an input and return a number.
|
3691
3691
|
* @returns The residual matrix with the function applied over some dimension.
|
3692
3692
|
*/
|
3693
|
-
|
3693
|
+
apply(dim: number, callback: (array: Array<MathType> | Matrix) => number): MathJsChain;
|
3694
3694
|
|
3695
3695
|
/**
|
3696
3696
|
* Calculate the cubic root of a value. For matrices, the function is
|