mathjs 13.2.2 → 14.0.0
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 +26 -0
- package/lib/browser/math.js +1 -1
- package/lib/browser/math.js.LICENSE.txt +2 -10
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/core/function/import.js +4 -1
- package/lib/cjs/core/function/typed.js +1 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesBitXor.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesDotDivide.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesDotPow.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesEqual.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesLarger.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesLargerEq.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesLog.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSimplify.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSmaller.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSmallerEq.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesUnequal.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesXor.generated.js +2 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesSimplify.generated.js +2 -0
- package/lib/cjs/entry/impureFunctionsAny.generated.js +1 -0
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +1 -0
- package/lib/cjs/entry/pureFunctionsAny.generated.js +11 -0
- package/lib/cjs/expression/embeddedDocs/function/arithmetic/ceil.js +2 -2
- package/lib/cjs/expression/embeddedDocs/function/arithmetic/fix.js +2 -2
- package/lib/cjs/expression/embeddedDocs/function/arithmetic/floor.js +2 -2
- package/lib/cjs/expression/parse.js +26 -36
- package/lib/cjs/function/algebra/simplify.js +4 -3
- package/lib/cjs/function/algebra/simplifyConstant.js +5 -11
- package/lib/cjs/function/arithmetic/ceil.js +21 -2
- package/lib/cjs/function/arithmetic/dotDivide.js +4 -3
- package/lib/cjs/function/arithmetic/dotPow.js +4 -3
- package/lib/cjs/function/arithmetic/fix.js +24 -5
- package/lib/cjs/function/arithmetic/floor.js +21 -2
- package/lib/cjs/function/arithmetic/log.js +12 -4
- package/lib/cjs/function/arithmetic/pow.js +2 -2
- package/lib/cjs/function/arithmetic/round.js +3 -5
- package/lib/cjs/function/arithmetic/sign.js +1 -1
- package/lib/cjs/function/bitwise/bitXor.js +4 -3
- package/lib/cjs/function/logical/xor.js +4 -3
- package/lib/cjs/function/matrix/filter.js +7 -0
- package/lib/cjs/function/matrix/forEach.js +7 -0
- package/lib/cjs/function/relational/equal.js +4 -3
- package/lib/cjs/function/relational/larger.js +4 -3
- package/lib/cjs/function/relational/largerEq.js +4 -3
- package/lib/cjs/function/relational/smaller.js +4 -3
- package/lib/cjs/function/relational/smallerEq.js +4 -3
- package/lib/cjs/function/relational/unequal.js +4 -3
- package/lib/cjs/function/utils/isInteger.js +1 -1
- package/lib/cjs/function/utils/isNegative.js +1 -1
- package/lib/cjs/function/utils/isPositive.js +1 -1
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/type/bignumber/function/bignumber.js +2 -2
- package/lib/cjs/type/fraction/Fraction.js +4 -4
- package/lib/cjs/type/fraction/function/fraction.js +3 -0
- package/lib/cjs/type/matrix/utils/matAlgo07xSSf.js +39 -43
- package/lib/cjs/type/unit/Unit.js +1 -1
- package/lib/cjs/utils/object.js +4 -0
- package/lib/cjs/utils/string.js +2 -2
- package/lib/cjs/version.js +1 -1
- package/lib/esm/core/function/import.js +4 -1
- package/lib/esm/core/function/typed.js +1 -1
- package/lib/esm/entry/dependenciesAny/dependenciesBitXor.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesDotDivide.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesDotPow.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesEqual.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesLarger.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesLargerEq.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesLog.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSimplify.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSmaller.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSmallerEq.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesUnequal.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesXor.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesSimplify.generated.js +2 -0
- package/lib/esm/entry/impureFunctionsAny.generated.js +1 -0
- package/lib/esm/entry/impureFunctionsNumber.generated.js +1 -0
- package/lib/esm/entry/pureFunctionsAny.generated.js +11 -0
- package/lib/esm/expression/embeddedDocs/function/arithmetic/ceil.js +2 -2
- package/lib/esm/expression/embeddedDocs/function/arithmetic/fix.js +2 -2
- package/lib/esm/expression/embeddedDocs/function/arithmetic/floor.js +2 -2
- package/lib/esm/expression/parse.js +26 -36
- package/lib/esm/function/algebra/simplify.js +4 -3
- package/lib/esm/function/algebra/simplifyConstant.js +5 -11
- package/lib/esm/function/arithmetic/ceil.js +21 -2
- package/lib/esm/function/arithmetic/dotDivide.js +4 -3
- package/lib/esm/function/arithmetic/dotPow.js +4 -3
- package/lib/esm/function/arithmetic/fix.js +24 -5
- package/lib/esm/function/arithmetic/floor.js +21 -2
- package/lib/esm/function/arithmetic/log.js +12 -4
- package/lib/esm/function/arithmetic/pow.js +2 -2
- package/lib/esm/function/arithmetic/round.js +3 -5
- package/lib/esm/function/arithmetic/sign.js +1 -1
- package/lib/esm/function/bitwise/bitXor.js +4 -3
- package/lib/esm/function/logical/xor.js +4 -3
- package/lib/esm/function/matrix/filter.js +7 -0
- package/lib/esm/function/matrix/forEach.js +7 -0
- package/lib/esm/function/relational/equal.js +4 -3
- package/lib/esm/function/relational/larger.js +4 -3
- package/lib/esm/function/relational/largerEq.js +4 -3
- package/lib/esm/function/relational/smaller.js +4 -3
- package/lib/esm/function/relational/smallerEq.js +4 -3
- package/lib/esm/function/relational/unequal.js +4 -3
- package/lib/esm/function/utils/isInteger.js +1 -1
- package/lib/esm/function/utils/isNegative.js +1 -1
- package/lib/esm/function/utils/isPositive.js +1 -1
- package/lib/esm/type/bignumber/function/bignumber.js +2 -2
- package/lib/esm/type/fraction/Fraction.js +4 -4
- package/lib/esm/type/fraction/function/fraction.js +3 -0
- package/lib/esm/type/matrix/utils/matAlgo07xSSf.js +39 -43
- package/lib/esm/type/unit/Unit.js +1 -1
- package/lib/esm/utils/object.js +4 -0
- package/lib/esm/utils/string.js +2 -2
- package/lib/esm/version.js +1 -1
- package/package.json +3 -3
- package/types/index.d.ts +115 -25
|
@@ -7,21 +7,22 @@ import { createMatAlgo12xSfs } from '../../type/matrix/utils/matAlgo12xSfs.js';
|
|
|
7
7
|
import { createMatrixAlgorithmSuite } from '../../type/matrix/utils/matrixAlgorithmSuite.js';
|
|
8
8
|
import { createCompareUnits } from './compareUnits.js';
|
|
9
9
|
var name = 'smaller';
|
|
10
|
-
var dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat'];
|
|
10
|
+
var dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
|
|
11
11
|
export var createSmaller = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
12
12
|
var {
|
|
13
13
|
typed,
|
|
14
14
|
config,
|
|
15
15
|
matrix,
|
|
16
16
|
DenseMatrix,
|
|
17
|
-
concat
|
|
17
|
+
concat,
|
|
18
|
+
SparseMatrix
|
|
18
19
|
} = _ref;
|
|
19
20
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
20
21
|
typed
|
|
21
22
|
});
|
|
22
23
|
var matAlgo07xSSf = createMatAlgo07xSSf({
|
|
23
24
|
typed,
|
|
24
|
-
|
|
25
|
+
SparseMatrix
|
|
25
26
|
});
|
|
26
27
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
27
28
|
typed,
|
|
@@ -7,21 +7,22 @@ import { createMatAlgo12xSfs } from '../../type/matrix/utils/matAlgo12xSfs.js';
|
|
|
7
7
|
import { createMatrixAlgorithmSuite } from '../../type/matrix/utils/matrixAlgorithmSuite.js';
|
|
8
8
|
import { createCompareUnits } from './compareUnits.js';
|
|
9
9
|
var name = 'smallerEq';
|
|
10
|
-
var dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat'];
|
|
10
|
+
var dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
|
|
11
11
|
export var createSmallerEq = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
12
12
|
var {
|
|
13
13
|
typed,
|
|
14
14
|
config,
|
|
15
15
|
matrix,
|
|
16
16
|
DenseMatrix,
|
|
17
|
-
concat
|
|
17
|
+
concat,
|
|
18
|
+
SparseMatrix
|
|
18
19
|
} = _ref;
|
|
19
20
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
20
21
|
typed
|
|
21
22
|
});
|
|
22
23
|
var matAlgo07xSSf = createMatAlgo07xSSf({
|
|
23
24
|
typed,
|
|
24
|
-
|
|
25
|
+
SparseMatrix
|
|
25
26
|
});
|
|
26
27
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
27
28
|
typed,
|
|
@@ -4,7 +4,7 @@ import { createMatAlgo07xSSf } from '../../type/matrix/utils/matAlgo07xSSf.js';
|
|
|
4
4
|
import { createMatAlgo12xSfs } from '../../type/matrix/utils/matAlgo12xSfs.js';
|
|
5
5
|
import { createMatrixAlgorithmSuite } from '../../type/matrix/utils/matrixAlgorithmSuite.js';
|
|
6
6
|
var name = 'unequal';
|
|
7
|
-
var dependencies = ['typed', 'config', 'equalScalar', 'matrix', 'DenseMatrix', 'concat'];
|
|
7
|
+
var dependencies = ['typed', 'config', 'equalScalar', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
|
|
8
8
|
export var createUnequal = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
9
9
|
var {
|
|
10
10
|
typed,
|
|
@@ -12,14 +12,15 @@ export var createUnequal = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
12
12
|
equalScalar,
|
|
13
13
|
matrix,
|
|
14
14
|
DenseMatrix,
|
|
15
|
-
concat
|
|
15
|
+
concat,
|
|
16
|
+
SparseMatrix
|
|
16
17
|
} = _ref;
|
|
17
18
|
var matAlgo03xDSf = createMatAlgo03xDSf({
|
|
18
19
|
typed
|
|
19
20
|
});
|
|
20
21
|
var matAlgo07xSSf = createMatAlgo07xSSf({
|
|
21
22
|
typed,
|
|
22
|
-
|
|
23
|
+
SparseMatrix
|
|
23
24
|
});
|
|
24
25
|
var matAlgo12xSfs = createMatAlgo12xSfs({
|
|
25
26
|
typed,
|
|
@@ -47,7 +47,7 @@ export var createIsInteger = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
47
47
|
return true;
|
|
48
48
|
},
|
|
49
49
|
Fraction: function Fraction(x) {
|
|
50
|
-
return x.d ===
|
|
50
|
+
return x.d === 1n;
|
|
51
51
|
},
|
|
52
52
|
'Array | Matrix': typed.referToSelf(self => x => deepMap(x, self))
|
|
53
53
|
});
|
|
@@ -43,7 +43,7 @@ export var createIsNegative = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
43
43
|
number: x => nearlyEqual(x, 0, config.relTol, config.absTol) ? false : isNegativeNumber(x),
|
|
44
44
|
BigNumber: x => bigNearlyEqual(x, new x.constructor(0), config.relTol, config.absTol) ? false : x.isNeg() && !x.isZero() && !x.isNaN(),
|
|
45
45
|
bigint: x => x < 0n,
|
|
46
|
-
Fraction: x => x.s <
|
|
46
|
+
Fraction: x => x.s < 0n,
|
|
47
47
|
// It's enough to decide on the sign
|
|
48
48
|
|
|
49
49
|
Unit: typed.referToSelf(self => x => typed.find(self, x.valueType())(x.value)),
|
|
@@ -45,7 +45,7 @@ export var createIsPositive = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
45
45
|
number: x => nearlyEqual(x, 0, config.relTol, config.absTol) ? false : isPositiveNumber(x),
|
|
46
46
|
BigNumber: x => bigNearlyEqual(x, new x.constructor(0), config.relTol, config.absTol) ? false : !x.isNeg() && !x.isZero() && !x.isNaN(),
|
|
47
47
|
bigint: x => x > 0n,
|
|
48
|
-
Fraction: x => x.s >
|
|
48
|
+
Fraction: x => x.s > 0n && x.n > 0n,
|
|
49
49
|
Unit: typed.referToSelf(self => x => typed.find(self, x.valueType())(x.value)),
|
|
50
50
|
'Array | Matrix': typed.referToSelf(self => x => deepMap(x, self))
|
|
51
51
|
});
|
|
@@ -72,9 +72,9 @@ export var createBignumber = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
72
72
|
return clone;
|
|
73
73
|
}),
|
|
74
74
|
Fraction: function Fraction(x) {
|
|
75
|
-
return new BigNumber(x.n).div(x.d).times(x.s);
|
|
75
|
+
return new BigNumber(String(x.n)).div(String(x.d)).times(String(x.s));
|
|
76
76
|
},
|
|
77
|
-
null: function _null(
|
|
77
|
+
null: function _null(_x) {
|
|
78
78
|
return new BigNumber(0);
|
|
79
79
|
},
|
|
80
80
|
'Array | Matrix': typed.referToSelf(self => x => deepMap(x, self))
|
|
@@ -16,20 +16,20 @@ export var createFractionClass = /* #__PURE__ */factory(name, dependencies, () =
|
|
|
16
16
|
/**
|
|
17
17
|
* Get a JSON representation of a Fraction containing type information
|
|
18
18
|
* @returns {Object} Returns a JSON object structured as:
|
|
19
|
-
* `{"mathjs": "Fraction", "n": 3, "d": 8}`
|
|
19
|
+
* `{"mathjs": "Fraction", "n": "3", "d": "8"}`
|
|
20
20
|
*/
|
|
21
21
|
Fraction.prototype.toJSON = function () {
|
|
22
22
|
return {
|
|
23
23
|
mathjs: 'Fraction',
|
|
24
|
-
n: this.s * this.n,
|
|
25
|
-
d: this.d
|
|
24
|
+
n: String(this.s * this.n),
|
|
25
|
+
d: String(this.d)
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Instantiate a Fraction from a JSON object
|
|
31
31
|
* @param {Object} json a JSON object structured as:
|
|
32
|
-
* `{"mathjs": "Fraction", "n": 3, "d": 8}`
|
|
32
|
+
* `{"mathjs": "Fraction", "n": "3", "d": "8"}`
|
|
33
33
|
* @return {BigNumber}
|
|
34
34
|
*/
|
|
35
35
|
Fraction.fromJSON = function (json) {
|
|
@@ -57,6 +57,9 @@ export var createFraction = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
57
57
|
'number, number': function number_number(numerator, denominator) {
|
|
58
58
|
return new Fraction(numerator, denominator);
|
|
59
59
|
},
|
|
60
|
+
'bigint, bigint': function bigint_bigint(numerator, denominator) {
|
|
61
|
+
return new Fraction(numerator, denominator);
|
|
62
|
+
},
|
|
60
63
|
null: function _null(x) {
|
|
61
64
|
return new Fraction(0);
|
|
62
65
|
},
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
import { factory } from '../../../utils/factory.js';
|
|
2
2
|
import { DimensionError } from '../../../error/DimensionError.js';
|
|
3
3
|
var name = 'matAlgo07xSSf';
|
|
4
|
-
var dependencies = ['typed', '
|
|
4
|
+
var dependencies = ['typed', 'SparseMatrix'];
|
|
5
5
|
export var createMatAlgo07xSSf = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
6
6
|
var {
|
|
7
7
|
typed,
|
|
8
|
-
|
|
8
|
+
SparseMatrix
|
|
9
9
|
} = _ref;
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
* Iterates over SparseMatrix A and SparseMatrix B items (zero and nonzero) and invokes the callback function f(Aij, Bij).
|
|
12
|
+
* Callback function invoked MxN times.
|
|
13
|
+
*
|
|
14
|
+
* C(i,j) = f(Aij, Bij)
|
|
15
|
+
*
|
|
16
|
+
* @param {Matrix} a The SparseMatrix instance (A)
|
|
17
|
+
* @param {Matrix} b The SparseMatrix instance (B)
|
|
18
|
+
* @param {Function} callback The f(Aij,Bij) operation to invoke
|
|
19
|
+
*
|
|
20
|
+
* @return {Matrix} SparseMatrix (C)
|
|
21
|
+
*
|
|
22
|
+
* see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294
|
|
23
|
+
*/
|
|
24
24
|
return function matAlgo07xSSf(a, b, callback) {
|
|
25
25
|
// sparse matrix arrays
|
|
26
26
|
var asize = a._size;
|
|
27
27
|
var adt = a._datatype || a._data === undefined ? a._datatype : a.getDataType();
|
|
28
|
-
// sparse matrix arrays
|
|
29
28
|
var bsize = b._size;
|
|
30
29
|
var bdt = b._datatype || b._data === undefined ? b._datatype : b.getDataType();
|
|
31
30
|
|
|
@@ -33,8 +32,6 @@ export var createMatAlgo07xSSf = /* #__PURE__ */factory(name, dependencies, _ref
|
|
|
33
32
|
if (asize.length !== bsize.length) {
|
|
34
33
|
throw new DimensionError(asize.length, bsize.length);
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
// check rows & columns
|
|
38
35
|
if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) {
|
|
39
36
|
throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')');
|
|
40
37
|
}
|
|
@@ -45,59 +42,58 @@ export var createMatAlgo07xSSf = /* #__PURE__ */factory(name, dependencies, _ref
|
|
|
45
42
|
|
|
46
43
|
// datatype
|
|
47
44
|
var dt;
|
|
48
|
-
// zero value
|
|
49
45
|
var zero = 0;
|
|
50
|
-
// callback signature to use
|
|
51
46
|
var cf = callback;
|
|
52
47
|
|
|
53
48
|
// process data types
|
|
54
49
|
if (typeof adt === 'string' && adt === bdt && adt !== 'mixed') {
|
|
55
|
-
// datatype
|
|
56
50
|
dt = adt;
|
|
57
|
-
// convert 0 to the same datatype
|
|
58
51
|
zero = typed.convert(0, dt);
|
|
59
|
-
// callback
|
|
60
52
|
cf = typed.find(callback, [dt, dt]);
|
|
61
53
|
}
|
|
62
54
|
|
|
63
|
-
//
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
//
|
|
67
|
-
var cdata = [];
|
|
68
|
-
// initialize c
|
|
69
|
-
for (i = 0; i < rows; i++) {
|
|
70
|
-
cdata[i] = [];
|
|
71
|
-
}
|
|
55
|
+
// result arrays for sparse format
|
|
56
|
+
var cvalues = [];
|
|
57
|
+
var cindex = [];
|
|
58
|
+
var cptr = new Array(columns + 1).fill(0); // Start with column pointer array
|
|
72
59
|
|
|
73
60
|
// workspaces
|
|
74
61
|
var xa = [];
|
|
75
62
|
var xb = [];
|
|
76
|
-
// marks indicating we have a value in x for a given column
|
|
77
63
|
var wa = [];
|
|
78
64
|
var wb = [];
|
|
79
65
|
|
|
80
66
|
// loop columns
|
|
81
|
-
for (j = 0; j < columns; j++) {
|
|
82
|
-
// columns mark
|
|
67
|
+
for (var j = 0; j < columns; j++) {
|
|
83
68
|
var mark = j + 1;
|
|
84
|
-
|
|
69
|
+
var nonZeroCount = 0;
|
|
85
70
|
_scatter(a, j, wa, xa, mark);
|
|
86
|
-
// scatter the values of B(:,j) into workspace
|
|
87
71
|
_scatter(b, j, wb, xb, mark);
|
|
72
|
+
|
|
88
73
|
// loop rows
|
|
89
|
-
for (i = 0; i < rows; i++) {
|
|
90
|
-
// matrix values @ i,j
|
|
74
|
+
for (var i = 0; i < rows; i++) {
|
|
91
75
|
var va = wa[i] === mark ? xa[i] : zero;
|
|
92
76
|
var vb = wb[i] === mark ? xb[i] : zero;
|
|
77
|
+
|
|
93
78
|
// invoke callback
|
|
94
|
-
|
|
79
|
+
var cij = cf(va, vb);
|
|
80
|
+
// Store all non zero and true values
|
|
81
|
+
if (cij !== 0 && cij !== false) {
|
|
82
|
+
cindex.push(i); // row index
|
|
83
|
+
cvalues.push(cij); // computed value
|
|
84
|
+
nonZeroCount++;
|
|
85
|
+
}
|
|
95
86
|
}
|
|
87
|
+
|
|
88
|
+
// Update column pointer with cumulative count of non-zero values
|
|
89
|
+
cptr[j + 1] = cptr[j] + nonZeroCount;
|
|
96
90
|
}
|
|
97
91
|
|
|
98
|
-
//
|
|
99
|
-
return new
|
|
100
|
-
|
|
92
|
+
// Return the result as a sparse matrix
|
|
93
|
+
return new SparseMatrix({
|
|
94
|
+
values: cvalues,
|
|
95
|
+
index: cindex,
|
|
96
|
+
ptr: cptr,
|
|
101
97
|
size: [rows, columns],
|
|
102
98
|
datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined
|
|
103
99
|
});
|
|
@@ -3533,7 +3533,7 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
3533
3533
|
*/
|
|
3534
3534
|
Unit.typeConverters = {
|
|
3535
3535
|
BigNumber: function BigNumber(x) {
|
|
3536
|
-
if (x !== null && x !== void 0 && x.isFraction) return new _BigNumber(x.n).div(x.d).times(x.s);
|
|
3536
|
+
if (x !== null && x !== void 0 && x.isFraction) return new _BigNumber(String(x.n)).div(String(x.d)).times(String(x.s));
|
|
3537
3537
|
return new _BigNumber(x + ''); // stringify to prevent constructor error
|
|
3538
3538
|
},
|
|
3539
3539
|
Fraction: function Fraction(x) {
|
package/lib/esm/utils/object.js
CHANGED
|
@@ -37,6 +37,10 @@ export function clone(x) {
|
|
|
37
37
|
if (isObject(x)) {
|
|
38
38
|
return mapObject(x, clone);
|
|
39
39
|
}
|
|
40
|
+
if (type === 'function') {
|
|
41
|
+
// we assume that the function is immutable
|
|
42
|
+
return x;
|
|
43
|
+
}
|
|
40
44
|
throw new TypeError("Cannot clone: unknown type of value (value: ".concat(x, ")"));
|
|
41
45
|
}
|
|
42
46
|
|
package/lib/esm/utils/string.js
CHANGED
|
@@ -71,7 +71,7 @@ function _format(value, options) {
|
|
|
71
71
|
if (looksLikeFraction(value)) {
|
|
72
72
|
if (!options || options.fraction !== 'decimal') {
|
|
73
73
|
// output as ratio, like '1/3'
|
|
74
|
-
return value.s * value.n
|
|
74
|
+
return "".concat(value.s * value.n, "/").concat(value.d);
|
|
75
75
|
} else {
|
|
76
76
|
// output as decimal, like '0.(3)'
|
|
77
77
|
return value.toString();
|
|
@@ -173,7 +173,7 @@ function formatArray(array, options) {
|
|
|
173
173
|
* @return {boolean}
|
|
174
174
|
*/
|
|
175
175
|
function looksLikeFraction(value) {
|
|
176
|
-
return value && typeof value === 'object' && typeof value.s === '
|
|
176
|
+
return value && typeof value === 'object' && typeof value.s === 'bigint' && typeof value.n === 'bigint' && typeof value.d === 'bigint' || false;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
/**
|
package/lib/esm/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mathjs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
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",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"complex.js": "^2.2.5",
|
|
30
30
|
"decimal.js": "^10.4.3",
|
|
31
31
|
"escape-latex": "^1.2.0",
|
|
32
|
-
"fraction.js": "^
|
|
32
|
+
"fraction.js": "^5.2.1",
|
|
33
33
|
"javascript-natural-sort": "^0.7.1",
|
|
34
34
|
"seedrandom": "^3.0.5",
|
|
35
35
|
"tiny-emitter": "^2.1.0",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"gulp": "5.0.0",
|
|
70
70
|
"gulp-babel": "8.0.0",
|
|
71
71
|
"handlebars": "4.7.8",
|
|
72
|
-
"jsep": "1.
|
|
72
|
+
"jsep": "1.4.0",
|
|
73
73
|
"karma": "6.4.4",
|
|
74
74
|
"karma-browserstack-launcher": "1.6.0",
|
|
75
75
|
"karma-firefox-launcher": "2.1.3",
|