mathjs 12.1.0 → 12.2.1
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 +13 -0
- 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/core/function/import.js +0 -1
- package/lib/cjs/core/function/typed.js +0 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesAndTransform.generated.js +29 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesBitAndTransform.generated.js +29 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesBitOrTransform.generated.js +25 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesOrTransform.generated.js +25 -0
- package/lib/cjs/entry/dependenciesAny.generated.js +28 -0
- package/lib/cjs/entry/impureFunctionsAny.generated.js +33 -1
- package/lib/cjs/entry/pureFunctionsAny.generated.js +7 -7
- package/lib/cjs/expression/embeddedDocs/function/matrix/eigs.js +1 -1
- package/lib/cjs/expression/function/help.js +0 -1
- package/lib/cjs/expression/node/AccessorNode.js +2 -2
- package/lib/cjs/expression/node/ArrayNode.js +2 -2
- package/lib/cjs/expression/node/AssignmentNode.js +2 -2
- package/lib/cjs/expression/node/BlockNode.js +2 -2
- package/lib/cjs/expression/node/ConditionalNode.js +2 -2
- package/lib/cjs/expression/node/ConstantNode.js +2 -2
- package/lib/cjs/expression/node/FunctionAssignmentNode.js +2 -2
- package/lib/cjs/expression/node/FunctionNode.js +6 -6
- package/lib/cjs/expression/node/IndexNode.js +2 -2
- package/lib/cjs/expression/node/Node.js +18 -5
- package/lib/cjs/expression/node/ObjectNode.js +2 -2
- package/lib/cjs/expression/node/OperatorNode.js +10 -3
- package/lib/cjs/expression/node/ParenthesisNode.js +2 -2
- package/lib/cjs/expression/node/RangeNode.js +2 -2
- package/lib/cjs/expression/node/RelationalNode.js +2 -2
- package/lib/cjs/expression/node/SymbolNode.js +2 -2
- package/lib/cjs/expression/operators.js +0 -2
- package/lib/cjs/expression/parse.js +0 -3
- package/lib/cjs/expression/transform/and.transform.js +39 -0
- package/lib/cjs/expression/transform/bitAnd.transform.js +44 -0
- package/lib/cjs/expression/transform/bitOr.transform.js +45 -0
- package/lib/cjs/expression/transform/forEach.transform.js +0 -1
- package/lib/cjs/expression/transform/or.transform.js +37 -0
- package/lib/cjs/factoriesAny.js +29 -1
- package/lib/cjs/factoriesNumber.js +1 -0
- package/lib/cjs/function/algebra/derivative.js +0 -1
- package/lib/cjs/function/algebra/rationalize.js +0 -2
- package/lib/cjs/function/algebra/simplify.js +0 -1
- package/lib/cjs/function/algebra/simplifyConstant.js +0 -1
- package/lib/cjs/function/algebra/simplifyCore.js +0 -2
- package/lib/cjs/function/arithmetic/cube.js +0 -2
- package/lib/cjs/function/arithmetic/nthRoots.js +0 -1
- package/lib/cjs/function/arithmetic/unaryPlus.js +0 -3
- package/lib/cjs/function/matrix/det.js +0 -1
- package/lib/cjs/function/matrix/diff.js +0 -2
- package/lib/cjs/function/matrix/matrixFromColumns.js +0 -1
- package/lib/cjs/function/matrix/matrixFromRows.js +0 -1
- package/lib/cjs/function/matrix/partitionSelect.js +0 -1
- package/lib/cjs/function/matrix/resize.js +0 -1
- package/lib/cjs/function/matrix/transpose.js +0 -1
- package/lib/cjs/function/probability/pickRandom.js +0 -1
- package/lib/cjs/function/statistics/median.js +0 -1
- package/lib/cjs/function/statistics/prod.js +0 -1
- package/lib/cjs/function/utils/isNegative.js +0 -1
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/plain/number/arithmetic.js +0 -1
- package/lib/cjs/plain/number/probability.js +0 -2
- package/lib/cjs/type/complex/function/complex.js +0 -1
- package/lib/cjs/type/fraction/function/fraction.js +0 -1
- package/lib/cjs/type/unit/Unit.js +0 -2
- package/lib/cjs/type/unit/function/unit.js +0 -2
- package/lib/cjs/utils/is.js +0 -1
- package/lib/cjs/utils/latex.js +0 -2
- package/lib/cjs/version.js +1 -1
- package/lib/esm/core/function/import.js +0 -1
- package/lib/esm/core/function/typed.js +0 -1
- package/lib/esm/entry/dependenciesAny/dependenciesAndTransform.generated.js +22 -0
- package/lib/esm/entry/dependenciesAny/dependenciesBitAndTransform.generated.js +22 -0
- package/lib/esm/entry/dependenciesAny/dependenciesBitOrTransform.generated.js +18 -0
- package/lib/esm/entry/dependenciesAny/dependenciesOrTransform.generated.js +18 -0
- package/lib/esm/entry/dependenciesAny.generated.js +4 -0
- package/lib/esm/entry/impureFunctionsAny.generated.js +35 -3
- package/lib/esm/entry/pureFunctionsAny.generated.js +8 -8
- package/lib/esm/expression/embeddedDocs/function/matrix/eigs.js +1 -1
- package/lib/esm/expression/function/help.js +0 -1
- package/lib/esm/expression/node/AccessorNode.js +1 -1
- package/lib/esm/expression/node/ArrayNode.js +1 -1
- package/lib/esm/expression/node/AssignmentNode.js +1 -1
- package/lib/esm/expression/node/BlockNode.js +1 -1
- package/lib/esm/expression/node/ConditionalNode.js +1 -1
- package/lib/esm/expression/node/ConstantNode.js +1 -1
- package/lib/esm/expression/node/FunctionAssignmentNode.js +1 -1
- package/lib/esm/expression/node/FunctionNode.js +5 -5
- package/lib/esm/expression/node/IndexNode.js +1 -1
- package/lib/esm/expression/node/Node.js +15 -4
- package/lib/esm/expression/node/ObjectNode.js +1 -1
- package/lib/esm/expression/node/OperatorNode.js +9 -2
- package/lib/esm/expression/node/ParenthesisNode.js +1 -1
- package/lib/esm/expression/node/RangeNode.js +1 -2
- package/lib/esm/expression/node/RelationalNode.js +1 -1
- package/lib/esm/expression/node/SymbolNode.js +1 -1
- package/lib/esm/expression/operators.js +0 -2
- package/lib/esm/expression/parse.js +0 -3
- package/lib/esm/expression/transform/and.transform.js +35 -0
- package/lib/esm/expression/transform/bitAnd.transform.js +40 -0
- package/lib/esm/expression/transform/bitOr.transform.js +41 -0
- package/lib/esm/expression/transform/forEach.transform.js +0 -1
- package/lib/esm/expression/transform/or.transform.js +33 -0
- package/lib/esm/factoriesAny.js +5 -1
- package/lib/esm/function/algebra/derivative.js +0 -1
- package/lib/esm/function/algebra/rationalize.js +0 -2
- package/lib/esm/function/algebra/simplify.js +0 -1
- package/lib/esm/function/algebra/simplifyConstant.js +0 -1
- package/lib/esm/function/algebra/simplifyCore.js +0 -2
- package/lib/esm/function/arithmetic/cube.js +0 -2
- package/lib/esm/function/arithmetic/nthRoots.js +0 -1
- package/lib/esm/function/arithmetic/unaryPlus.js +0 -3
- package/lib/esm/function/matrix/det.js +0 -1
- package/lib/esm/function/matrix/diff.js +0 -2
- package/lib/esm/function/matrix/matrixFromColumns.js +0 -1
- package/lib/esm/function/matrix/matrixFromRows.js +0 -1
- package/lib/esm/function/matrix/partitionSelect.js +0 -1
- package/lib/esm/function/matrix/resize.js +0 -1
- package/lib/esm/function/matrix/transpose.js +0 -1
- package/lib/esm/function/probability/pickRandom.js +0 -1
- package/lib/esm/function/statistics/median.js +0 -1
- package/lib/esm/function/statistics/prod.js +0 -1
- package/lib/esm/function/utils/isNegative.js +0 -1
- package/lib/esm/plain/number/arithmetic.js +0 -1
- package/lib/esm/plain/number/probability.js +0 -2
- package/lib/esm/type/complex/function/complex.js +0 -1
- package/lib/esm/type/fraction/function/fraction.js +0 -1
- package/lib/esm/type/unit/Unit.js +0 -2
- package/lib/esm/type/unit/function/unit.js +0 -2
- package/lib/esm/utils/is.js +0 -1
- package/lib/esm/utils/latex.js +0 -2
- package/lib/esm/version.js +1 -1
- package/package.json +18 -18
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createBitAnd } from '../../function/bitwise/bitAnd.js';
|
|
2
|
+
import { factory } from '../../utils/factory.js';
|
|
3
|
+
import { isCollection } from '../../utils/is.js';
|
|
4
|
+
var name = 'bitAnd';
|
|
5
|
+
var dependencies = ['typed', 'matrix', 'zeros', 'add', 'equalScalar', 'not', 'concat'];
|
|
6
|
+
export var createBitAndTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
7
|
+
var {
|
|
8
|
+
typed,
|
|
9
|
+
matrix,
|
|
10
|
+
equalScalar,
|
|
11
|
+
zeros,
|
|
12
|
+
not,
|
|
13
|
+
concat
|
|
14
|
+
} = _ref;
|
|
15
|
+
var bitAnd = createBitAnd({
|
|
16
|
+
typed,
|
|
17
|
+
matrix,
|
|
18
|
+
equalScalar,
|
|
19
|
+
zeros,
|
|
20
|
+
not,
|
|
21
|
+
concat
|
|
22
|
+
});
|
|
23
|
+
function bitAndTransform(args, math, scope) {
|
|
24
|
+
var condition1 = args[0].compile().evaluate(scope);
|
|
25
|
+
if (!isCollection(condition1)) {
|
|
26
|
+
if (isNaN(condition1)) {
|
|
27
|
+
return NaN;
|
|
28
|
+
}
|
|
29
|
+
if (condition1 === 0 || condition1 === false) {
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
var condition2 = args[1].compile().evaluate(scope);
|
|
34
|
+
return bitAnd(condition1, condition2);
|
|
35
|
+
}
|
|
36
|
+
bitAndTransform.rawArgs = true;
|
|
37
|
+
return bitAndTransform;
|
|
38
|
+
}, {
|
|
39
|
+
isTransformFunction: true
|
|
40
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createBitOr } from '../../function/bitwise/bitOr.js';
|
|
2
|
+
import { factory } from '../../utils/factory.js';
|
|
3
|
+
import { isCollection } from '../../utils/is.js';
|
|
4
|
+
var name = 'bitOr';
|
|
5
|
+
var dependencies = ['typed', 'matrix', 'equalScalar', 'DenseMatrix', 'concat'];
|
|
6
|
+
export var createBitOrTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
7
|
+
var {
|
|
8
|
+
typed,
|
|
9
|
+
matrix,
|
|
10
|
+
equalScalar,
|
|
11
|
+
DenseMatrix,
|
|
12
|
+
concat
|
|
13
|
+
} = _ref;
|
|
14
|
+
var bitOr = createBitOr({
|
|
15
|
+
typed,
|
|
16
|
+
matrix,
|
|
17
|
+
equalScalar,
|
|
18
|
+
DenseMatrix,
|
|
19
|
+
concat
|
|
20
|
+
});
|
|
21
|
+
function bitOrTransform(args, math, scope) {
|
|
22
|
+
var condition1 = args[0].compile().evaluate(scope);
|
|
23
|
+
if (!isCollection(condition1)) {
|
|
24
|
+
if (isNaN(condition1)) {
|
|
25
|
+
return NaN;
|
|
26
|
+
}
|
|
27
|
+
if (condition1 === -1) {
|
|
28
|
+
return -1;
|
|
29
|
+
}
|
|
30
|
+
if (condition1 === true) {
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
var condition2 = args[1].compile().evaluate(scope);
|
|
35
|
+
return bitOr(condition1, condition2);
|
|
36
|
+
}
|
|
37
|
+
bitOrTransform.rawArgs = true;
|
|
38
|
+
return bitOrTransform;
|
|
39
|
+
}, {
|
|
40
|
+
isTransformFunction: true
|
|
41
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createOr } from '../../function/logical/or.js';
|
|
2
|
+
import { factory } from '../../utils/factory.js';
|
|
3
|
+
import { isCollection } from '../../utils/is.js';
|
|
4
|
+
var name = 'or';
|
|
5
|
+
var dependencies = ['typed', 'matrix', 'equalScalar', 'DenseMatrix', 'concat'];
|
|
6
|
+
export var createOrTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
7
|
+
var {
|
|
8
|
+
typed,
|
|
9
|
+
matrix,
|
|
10
|
+
equalScalar,
|
|
11
|
+
DenseMatrix,
|
|
12
|
+
concat
|
|
13
|
+
} = _ref;
|
|
14
|
+
var or = createOr({
|
|
15
|
+
typed,
|
|
16
|
+
matrix,
|
|
17
|
+
equalScalar,
|
|
18
|
+
DenseMatrix,
|
|
19
|
+
concat
|
|
20
|
+
});
|
|
21
|
+
function orTransform(args, math, scope) {
|
|
22
|
+
var condition1 = args[0].compile().evaluate(scope);
|
|
23
|
+
if (!isCollection(condition1) && or(condition1, false)) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
var condition2 = args[1].compile().evaluate(scope);
|
|
27
|
+
return or(condition1, condition2);
|
|
28
|
+
}
|
|
29
|
+
orTransform.rawArgs = true;
|
|
30
|
+
return orTransform;
|
|
31
|
+
}, {
|
|
32
|
+
isTransformFunction: true
|
|
33
|
+
});
|
package/lib/esm/factoriesAny.js
CHANGED
|
@@ -289,4 +289,8 @@ export { createSumTransform } from './expression/transform/sum.transform.js';
|
|
|
289
289
|
export { createQuantileSeqTransform } from './expression/transform/quantileSeq.transform.js';
|
|
290
290
|
export { createCumSumTransform } from './expression/transform/cumsum.transform.js';
|
|
291
291
|
export { createVarianceTransform } from './expression/transform/variance.transform.js';
|
|
292
|
-
export { createPrintTransform } from './expression/transform/print.transform.js';
|
|
292
|
+
export { createPrintTransform } from './expression/transform/print.transform.js';
|
|
293
|
+
export { createAndTransform } from './expression/transform/and.transform.js';
|
|
294
|
+
export { createOrTransform } from './expression/transform/or.transform.js';
|
|
295
|
+
export { createBitAndTransform } from './expression/transform/bitAnd.transform.js';
|
|
296
|
+
export { createBitOrTransform } from './expression/transform/bitOr.transform.js';
|
|
@@ -118,7 +118,6 @@ export var createRationalize = /* #__PURE__ */factory(name, dependencies, _ref =
|
|
|
118
118
|
if (s === sBefore) {
|
|
119
119
|
break; // No changes : end of the loop
|
|
120
120
|
}
|
|
121
|
-
|
|
122
121
|
redoInic = true;
|
|
123
122
|
sBefore = s;
|
|
124
123
|
}
|
|
@@ -541,7 +540,6 @@ export var createRationalize = /* #__PURE__ */factory(name, dependencies, _ref =
|
|
|
541
540
|
r: '(n1^(n2*n3))'
|
|
542
541
|
} // Power to Power
|
|
543
542
|
];
|
|
544
|
-
|
|
545
543
|
return setRules;
|
|
546
544
|
} // End rulesRationalize
|
|
547
545
|
|
|
@@ -899,7 +899,6 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
899
899
|
// const after = res.toString({parenthesis: 'all'})
|
|
900
900
|
// console.log('Simplified ' + before + ' to ' + after)
|
|
901
901
|
}
|
|
902
|
-
|
|
903
902
|
if (rule.repeat && res !== node) {
|
|
904
903
|
res = applyRule(res, rule, context);
|
|
905
904
|
}
|
|
@@ -100,7 +100,6 @@ export var createSimplifyConstant = /* #__PURE__ */factory(name, dependencies, _
|
|
|
100
100
|
}
|
|
101
101
|
return new ConstantNode(n); // old parameters: (n.toString(), 'number')
|
|
102
102
|
},
|
|
103
|
-
|
|
104
103
|
Complex: function Complex(s) {
|
|
105
104
|
throw new Error('Cannot convert Complex number to Node');
|
|
106
105
|
},
|
|
@@ -153,7 +153,6 @@ export var createSimplifyCore = /* #__PURE__ */factory(name, dependencies, _ref
|
|
|
153
153
|
node = new OperatorNode('-', 'subtract', [a0.args[1], a0.args[0]]);
|
|
154
154
|
finish = false; // continue to process the new binary node
|
|
155
155
|
}
|
|
156
|
-
|
|
157
156
|
if (a0.isUnary() && a0.op === '-') {
|
|
158
157
|
return a0.args[0];
|
|
159
158
|
}
|
|
@@ -206,7 +205,6 @@ export var createSimplifyCore = /* #__PURE__ */factory(name, dependencies, _ref
|
|
|
206
205
|
return new OperatorNode(node.op, node.fn, [a1, _a], node.implicit); // constants on left
|
|
207
206
|
}
|
|
208
207
|
}
|
|
209
|
-
|
|
210
208
|
return new OperatorNode(node.op, node.fn, [_a, a1], node.implicit);
|
|
211
209
|
}
|
|
212
210
|
if (node.op === '/') {
|
|
@@ -36,14 +36,12 @@ export var createCube = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
36
36
|
Complex: function Complex(x) {
|
|
37
37
|
return x.mul(x).mul(x); // Is faster than pow(x, 3)
|
|
38
38
|
},
|
|
39
|
-
|
|
40
39
|
BigNumber: function BigNumber(x) {
|
|
41
40
|
return x.times(x).times(x);
|
|
42
41
|
},
|
|
43
42
|
Fraction: function Fraction(x) {
|
|
44
43
|
return x.pow(3); // Is faster than mul()mul()mul()
|
|
45
44
|
},
|
|
46
|
-
|
|
47
45
|
Unit: function Unit(x) {
|
|
48
46
|
return x.pow(3);
|
|
49
47
|
}
|
|
@@ -38,15 +38,12 @@ export var createUnaryPlus = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
38
38
|
Complex: function Complex(x) {
|
|
39
39
|
return x; // complex numbers are immutable
|
|
40
40
|
},
|
|
41
|
-
|
|
42
41
|
BigNumber: function BigNumber(x) {
|
|
43
42
|
return x; // bignumbers are immutable
|
|
44
43
|
},
|
|
45
|
-
|
|
46
44
|
Fraction: function Fraction(x) {
|
|
47
45
|
return x; // fractions are immutable
|
|
48
46
|
},
|
|
49
|
-
|
|
50
47
|
Unit: function Unit(x) {
|
|
51
48
|
return x.clone();
|
|
52
49
|
},
|
|
@@ -126,7 +126,6 @@ export var createDet = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
126
126
|
}
|
|
127
127
|
if (_k === rows) return matrix[k_][k]; // some zero of the type
|
|
128
128
|
}
|
|
129
|
-
|
|
130
129
|
var piv = matrix[k_][k];
|
|
131
130
|
var piv_ = k === 0 ? 1 : matrix[rowIndices[k - 1]][k - 1];
|
|
132
131
|
for (var i = k + 1; i < rows; i++) {
|
|
@@ -89,7 +89,6 @@ export var createDiff = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
89
89
|
if (isMatrix(arr)) {
|
|
90
90
|
arr = arr.toArray(); // Makes sure arrays like [ matrix([0, 1]), matrix([1, 0]) ] are processed properly
|
|
91
91
|
}
|
|
92
|
-
|
|
93
92
|
if (!Array.isArray(arr)) {
|
|
94
93
|
throw RangeError('Array/Matrix does not have that many dimensions');
|
|
95
94
|
}
|
|
@@ -140,7 +139,6 @@ export var createDiff = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
140
139
|
if (!obj1IsArray && !obj2IsArray) {
|
|
141
140
|
return subtract(obj2, obj1); // Difference is (second - first) NOT (first - second)
|
|
142
141
|
}
|
|
143
|
-
|
|
144
142
|
throw TypeError('Cannot calculate difference between 1 array and 1 non-array');
|
|
145
143
|
}
|
|
146
144
|
|
|
@@ -40,7 +40,6 @@ export var createMatrixFromColumns = /* #__PURE__ */factory(name, dependencies,
|
|
|
40
40
|
|
|
41
41
|
// TODO implement this properly for SparseMatrix
|
|
42
42
|
});
|
|
43
|
-
|
|
44
43
|
function _createArray(arr) {
|
|
45
44
|
if (arr.length === 0) throw new TypeError('At least one column is needed to construct a matrix.');
|
|
46
45
|
var N = checkVectorTypeAndReturnLength(arr[0]);
|
|
@@ -40,7 +40,6 @@ export var createMatrixFromRows = /* #__PURE__ */factory(name, dependencies, _re
|
|
|
40
40
|
|
|
41
41
|
// TODO implement this properly for SparseMatrix
|
|
42
42
|
});
|
|
43
|
-
|
|
44
43
|
function _createArray(arr) {
|
|
45
44
|
if (arr.length === 0) throw new TypeError('At least one row is needed to construct a matrix.');
|
|
46
45
|
var N = checkVectorTypeAndReturnLength(arr[0]);
|
|
@@ -111,7 +111,6 @@ export var createPickRandom = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
111
111
|
if (weights) {
|
|
112
112
|
weights = weights.valueOf(); // get Array
|
|
113
113
|
}
|
|
114
|
-
|
|
115
114
|
if (elementWise === true) {
|
|
116
115
|
possibles = flatten(possibles);
|
|
117
116
|
weights = flatten(weights);
|
|
@@ -97,7 +97,6 @@ export var createMedian = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
97
97
|
throw new Error('median(A, dim) is not yet supported');
|
|
98
98
|
// return reduce(arguments[0], arguments[1], ...)
|
|
99
99
|
},
|
|
100
|
-
|
|
101
100
|
// median(a, b, c, d, ...)
|
|
102
101
|
'...': function _(args) {
|
|
103
102
|
if (containsCollections(args)) {
|
|
@@ -44,7 +44,6 @@ export var createProd = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
44
44
|
throw new Error('prod(A, dim) is not yet supported');
|
|
45
45
|
// return reduce(arguments[0], arguments[1], math.prod)
|
|
46
46
|
},
|
|
47
|
-
|
|
48
47
|
// prod(a, b, c, d, ...)
|
|
49
48
|
'...': function _(args) {
|
|
50
49
|
return _prod(args);
|
|
@@ -44,7 +44,6 @@ export var createIsNegative = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
44
44
|
Fraction: function Fraction(x) {
|
|
45
45
|
return x.s < 0; // It's enough to decide on the sign
|
|
46
46
|
},
|
|
47
|
-
|
|
48
47
|
Unit: typed.referToSelf(self => x => typed.find(self, x.valueType())(x.value)),
|
|
49
48
|
'Array | Matrix': typed.referToSelf(self => x => deepMap(x, self))
|
|
50
49
|
});
|
|
@@ -11,7 +11,6 @@ export function gammaNumber(n) {
|
|
|
11
11
|
if (n > 171) {
|
|
12
12
|
return Infinity; // Will overflow
|
|
13
13
|
}
|
|
14
|
-
|
|
15
14
|
return product(1, n - 1);
|
|
16
15
|
}
|
|
17
16
|
if (n < 0.5) {
|
|
@@ -20,7 +19,6 @@ export function gammaNumber(n) {
|
|
|
20
19
|
if (n >= 171.35) {
|
|
21
20
|
return Infinity; // will overflow
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
if (n > 85.0) {
|
|
25
23
|
// Extended Stirling Approx
|
|
26
24
|
var twoN = n * n;
|
|
@@ -66,7 +66,6 @@ export var createFraction = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
66
66
|
Fraction: function Fraction(x) {
|
|
67
67
|
return x; // fractions are immutable
|
|
68
68
|
},
|
|
69
|
-
|
|
70
69
|
Unit: typed.referToSelf(self => x => {
|
|
71
70
|
var clone = x.clone();
|
|
72
71
|
clone.value = self(x.value);
|
|
@@ -1068,7 +1068,6 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
1068
1068
|
if (simp.value && isComplex(simp.value)) {
|
|
1069
1069
|
str = '(' + str + ')'; // Surround complex values with ( ) to enable better parsing
|
|
1070
1070
|
}
|
|
1071
|
-
|
|
1072
1071
|
if (unitStr.length > 0 && str.length > 0) {
|
|
1073
1072
|
str += ' ';
|
|
1074
1073
|
}
|
|
@@ -3514,7 +3513,6 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
3514
3513
|
if (x !== null && x !== void 0 && x.isFraction) return new _BigNumber(x.n).div(x.d).times(x.s);
|
|
3515
3514
|
return new _BigNumber(x + ''); // stringify to prevent constructor error
|
|
3516
3515
|
},
|
|
3517
|
-
|
|
3518
3516
|
Fraction: function Fraction(x) {
|
|
3519
3517
|
return new _Fraction(x);
|
|
3520
3518
|
},
|
|
@@ -44,12 +44,10 @@ export var createUnitFunction = /* #__PURE__ */factory(name, dependencies, _ref
|
|
|
44
44
|
if (Unit.isValuelessUnit(x)) {
|
|
45
45
|
return new Unit(null, x); // a pure unit
|
|
46
46
|
}
|
|
47
|
-
|
|
48
47
|
return Unit.parse(x, {
|
|
49
48
|
allowNoUnits: true
|
|
50
49
|
}); // a unit with value, like '5cm'
|
|
51
50
|
},
|
|
52
|
-
|
|
53
51
|
'number | BigNumber | Fraction | Complex, string | Unit': function numberBigNumberFractionComplexStringUnit(value, unit) {
|
|
54
52
|
return new Unit(value, unit);
|
|
55
53
|
},
|
package/lib/esm/utils/is.js
CHANGED
package/lib/esm/utils/latex.js
CHANGED
|
@@ -175,7 +175,6 @@ export var latexFunctions = {
|
|
|
175
175
|
1: '\\left\\|${args[0]}\\right\\|',
|
|
176
176
|
2: undefined // use default template
|
|
177
177
|
},
|
|
178
|
-
|
|
179
178
|
nthRoot: {
|
|
180
179
|
2: '\\sqrt[${args[1]}]{${args[0]}}'
|
|
181
180
|
},
|
|
@@ -189,7 +188,6 @@ export var latexFunctions = {
|
|
|
189
188
|
1: '\\left\\lfloor${args[0]}\\right\\rceil',
|
|
190
189
|
2: undefined // use default template
|
|
191
190
|
},
|
|
192
|
-
|
|
193
191
|
sign: {
|
|
194
192
|
1: '\\mathrm{${name}}\\left(${args[0]}\\right)'
|
|
195
193
|
},
|
package/lib/esm/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mathjs",
|
|
3
|
-
"version": "12.1
|
|
3
|
+
"version": "12.2.1",
|
|
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.23.
|
|
28
|
+
"@babel/runtime": "^7.23.6",
|
|
29
29
|
"complex.js": "^2.1.1",
|
|
30
30
|
"decimal.js": "^10.4.3",
|
|
31
31
|
"escape-latex": "^1.2.0",
|
|
@@ -36,30 +36,30 @@
|
|
|
36
36
|
"typed-function": "^4.1.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@babel/core": "7.23.
|
|
39
|
+
"@babel/core": "7.23.6",
|
|
40
40
|
"@babel/plugin-transform-object-assign": "7.23.3",
|
|
41
|
-
"@babel/plugin-transform-runtime": "7.23.
|
|
42
|
-
"@babel/preset-env": "7.23.
|
|
41
|
+
"@babel/plugin-transform-runtime": "7.23.6",
|
|
42
|
+
"@babel/preset-env": "7.23.6",
|
|
43
43
|
"@babel/register": "7.22.15",
|
|
44
|
-
"@types/assert": "1.5.
|
|
45
|
-
"@types/mocha": "10.0.
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
47
|
-
"@typescript-eslint/parser": "6.
|
|
44
|
+
"@types/assert": "1.5.10",
|
|
45
|
+
"@types/mocha": "10.0.6",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "6.15.0",
|
|
47
|
+
"@typescript-eslint/parser": "6.15.0",
|
|
48
48
|
"assert": "2.1.0",
|
|
49
49
|
"babel-loader": "9.1.3",
|
|
50
50
|
"benchmark": "2.1.4",
|
|
51
51
|
"c8": "8.0.1",
|
|
52
52
|
"codecov": "3.8.3",
|
|
53
|
-
"core-js": "3.
|
|
53
|
+
"core-js": "3.34.0",
|
|
54
54
|
"del": "6.1.1",
|
|
55
55
|
"dtslint": "4.2.1",
|
|
56
|
-
"eslint": "8.
|
|
57
|
-
"eslint-config-prettier": "9.
|
|
56
|
+
"eslint": "8.56.0",
|
|
57
|
+
"eslint-config-prettier": "9.1.0",
|
|
58
58
|
"eslint-config-standard": "17.1.0",
|
|
59
|
-
"eslint-plugin-import": "2.29.
|
|
59
|
+
"eslint-plugin-import": "2.29.1",
|
|
60
60
|
"eslint-plugin-mocha": "10.2.0",
|
|
61
|
-
"eslint-plugin-n": "16.
|
|
62
|
-
"eslint-plugin-prettier": "5.0
|
|
61
|
+
"eslint-plugin-n": "16.5.0",
|
|
62
|
+
"eslint-plugin-prettier": "5.1.0",
|
|
63
63
|
"eslint-plugin-promise": "6.1.1",
|
|
64
64
|
"expect-type": "0.17.3",
|
|
65
65
|
"expr-eval": "2.0.2",
|
|
@@ -85,11 +85,11 @@
|
|
|
85
85
|
"ndarray-pack": "1.2.1",
|
|
86
86
|
"numericjs": "1.2.6",
|
|
87
87
|
"pad-right": "0.2.2",
|
|
88
|
-
"prettier": "3.1.
|
|
88
|
+
"prettier": "3.1.1",
|
|
89
89
|
"process": "0.11.10",
|
|
90
90
|
"sylvester": "0.0.21",
|
|
91
|
-
"ts-node": "10.9.
|
|
92
|
-
"typescript": "5.
|
|
91
|
+
"ts-node": "10.9.2",
|
|
92
|
+
"typescript": "5.3.3",
|
|
93
93
|
"webpack": "5.89.0",
|
|
94
94
|
"zeros": "1.0.0"
|
|
95
95
|
},
|