mathjs 13.2.3 → 14.0.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 +24 -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/derivative.js +64 -77
- 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/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/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/derivative.js +64 -77
- 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/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/string.js +2 -2
- package/lib/esm/version.js +1 -1
- package/package.json +13 -13
- package/types/index.d.ts +112 -23
|
@@ -82,7 +82,7 @@ const createRound = exports.createRound = /* #__PURE__ */(0, _factory.factory)(n
|
|
|
82
82
|
* @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x Value to be rounded
|
|
83
83
|
* @param {number | BigNumber | Array} [n=0] Number of decimals
|
|
84
84
|
* @param {Unit} [valuelessUnit] A valueless unit
|
|
85
|
-
* @return {number | BigNumber | Fraction | Complex | Array | Matrix} Rounded value
|
|
85
|
+
* @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Rounded value
|
|
86
86
|
*/
|
|
87
87
|
return typed(name, {
|
|
88
88
|
number: function (x) {
|
|
@@ -163,13 +163,11 @@ const createRound = exports.createRound = /* #__PURE__ */(0, _factory.factory)(n
|
|
|
163
163
|
return unit.multiply(self(valueless, n));
|
|
164
164
|
}),
|
|
165
165
|
'Unit, BigNumber, Unit': typed.referToSelf(self => (x, n, unit) => self(x, n.toNumber(), unit)),
|
|
166
|
-
'
|
|
167
|
-
'Array | Matrix, number, Unit': typed.referToSelf(self => (x, n, unit) => {
|
|
166
|
+
'Array | Matrix, number | BigNumber, Unit': typed.referToSelf(self => (x, n, unit) => {
|
|
168
167
|
// deep map collection, skip zeros since round(0) = 0
|
|
169
168
|
return (0, _collection.deepMap)(x, value => self(value, n, unit), true);
|
|
170
169
|
}),
|
|
171
|
-
'Array | Matrix
|
|
172
|
-
'Array | Matrix, Unit': typed.referToSelf(self => (x, unit) => self(x, 0, unit)),
|
|
170
|
+
'Array | Matrix | Unit, Unit': typed.referToSelf(self => (x, unit) => self(x, 0, unit)),
|
|
173
171
|
'Array | Matrix': typed.referToSelf(self => x => {
|
|
174
172
|
// deep map collection, skip zeros since round(0) = 0
|
|
175
173
|
return (0, _collection.deepMap)(x, self, true);
|
|
@@ -58,7 +58,7 @@ const createSign = exports.createSign = /* #__PURE__ */(0, _factory.factory)(nam
|
|
|
58
58
|
return x > 0n ? 1n : x < 0n ? -1n : 0n;
|
|
59
59
|
},
|
|
60
60
|
Fraction: function (x) {
|
|
61
|
-
return new Fraction(x.s
|
|
61
|
+
return new Fraction(x.s);
|
|
62
62
|
},
|
|
63
63
|
// deep map collection, skip zeros since sign(0) = 0
|
|
64
64
|
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self, true)),
|
|
@@ -12,20 +12,21 @@ var _factory = require("../../utils/factory.js");
|
|
|
12
12
|
var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
|
|
13
13
|
var _index = require("../../plain/number/index.js");
|
|
14
14
|
const name = 'bitXor';
|
|
15
|
-
const dependencies = ['typed', 'matrix', 'DenseMatrix', 'concat'];
|
|
15
|
+
const dependencies = ['typed', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
|
|
16
16
|
const createBitXor = exports.createBitXor = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
|
17
17
|
let {
|
|
18
18
|
typed,
|
|
19
19
|
matrix,
|
|
20
20
|
DenseMatrix,
|
|
21
|
-
concat
|
|
21
|
+
concat,
|
|
22
|
+
SparseMatrix
|
|
22
23
|
} = _ref;
|
|
23
24
|
const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
|
|
24
25
|
typed
|
|
25
26
|
});
|
|
26
27
|
const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
|
|
27
28
|
typed,
|
|
28
|
-
|
|
29
|
+
SparseMatrix
|
|
29
30
|
});
|
|
30
31
|
const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
|
|
31
32
|
typed,
|
|
@@ -11,20 +11,21 @@ var _factory = require("../../utils/factory.js");
|
|
|
11
11
|
var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
|
|
12
12
|
var _index = require("../../plain/number/index.js");
|
|
13
13
|
const name = 'xor';
|
|
14
|
-
const dependencies = ['typed', 'matrix', 'DenseMatrix', 'concat'];
|
|
14
|
+
const dependencies = ['typed', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
|
|
15
15
|
const createXor = exports.createXor = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
|
16
16
|
let {
|
|
17
17
|
typed,
|
|
18
18
|
matrix,
|
|
19
19
|
DenseMatrix,
|
|
20
|
-
concat
|
|
20
|
+
concat,
|
|
21
|
+
SparseMatrix
|
|
21
22
|
} = _ref;
|
|
22
23
|
const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
|
|
23
24
|
typed
|
|
24
25
|
});
|
|
25
26
|
const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
|
|
26
27
|
typed,
|
|
27
|
-
|
|
28
|
+
SparseMatrix
|
|
28
29
|
});
|
|
29
30
|
const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
|
|
30
31
|
typed,
|
|
@@ -10,21 +10,22 @@ var _matAlgo07xSSf = require("../../type/matrix/utils/matAlgo07xSSf.js");
|
|
|
10
10
|
var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
|
|
11
11
|
var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
|
|
12
12
|
const name = 'equal';
|
|
13
|
-
const dependencies = ['typed', 'matrix', 'equalScalar', 'DenseMatrix', 'concat'];
|
|
13
|
+
const dependencies = ['typed', 'matrix', 'equalScalar', 'DenseMatrix', 'concat', 'SparseMatrix'];
|
|
14
14
|
const createEqual = exports.createEqual = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
|
15
15
|
let {
|
|
16
16
|
typed,
|
|
17
17
|
matrix,
|
|
18
18
|
equalScalar,
|
|
19
19
|
DenseMatrix,
|
|
20
|
-
concat
|
|
20
|
+
concat,
|
|
21
|
+
SparseMatrix
|
|
21
22
|
} = _ref;
|
|
22
23
|
const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
|
|
23
24
|
typed
|
|
24
25
|
});
|
|
25
26
|
const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
|
|
26
27
|
typed,
|
|
27
|
-
|
|
28
|
+
SparseMatrix
|
|
28
29
|
});
|
|
29
30
|
const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
|
|
30
31
|
typed,
|
|
@@ -13,21 +13,22 @@ var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
|
|
|
13
13
|
var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
|
|
14
14
|
var _compareUnits = require("./compareUnits.js");
|
|
15
15
|
const name = 'larger';
|
|
16
|
-
const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat'];
|
|
16
|
+
const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
|
|
17
17
|
const createLarger = exports.createLarger = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
|
18
18
|
let {
|
|
19
19
|
typed,
|
|
20
20
|
config,
|
|
21
21
|
matrix,
|
|
22
22
|
DenseMatrix,
|
|
23
|
-
concat
|
|
23
|
+
concat,
|
|
24
|
+
SparseMatrix
|
|
24
25
|
} = _ref;
|
|
25
26
|
const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
|
|
26
27
|
typed
|
|
27
28
|
});
|
|
28
29
|
const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
|
|
29
30
|
typed,
|
|
30
|
-
|
|
31
|
+
SparseMatrix
|
|
31
32
|
});
|
|
32
33
|
const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
|
|
33
34
|
typed,
|
|
@@ -13,21 +13,22 @@ var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
|
|
|
13
13
|
var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
|
|
14
14
|
var _compareUnits = require("./compareUnits.js");
|
|
15
15
|
const name = 'largerEq';
|
|
16
|
-
const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat'];
|
|
16
|
+
const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
|
|
17
17
|
const createLargerEq = exports.createLargerEq = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
|
18
18
|
let {
|
|
19
19
|
typed,
|
|
20
20
|
config,
|
|
21
21
|
matrix,
|
|
22
22
|
DenseMatrix,
|
|
23
|
-
concat
|
|
23
|
+
concat,
|
|
24
|
+
SparseMatrix
|
|
24
25
|
} = _ref;
|
|
25
26
|
const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
|
|
26
27
|
typed
|
|
27
28
|
});
|
|
28
29
|
const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
|
|
29
30
|
typed,
|
|
30
|
-
|
|
31
|
+
SparseMatrix
|
|
31
32
|
});
|
|
32
33
|
const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
|
|
33
34
|
typed,
|
|
@@ -13,21 +13,22 @@ var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
|
|
|
13
13
|
var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
|
|
14
14
|
var _compareUnits = require("./compareUnits.js");
|
|
15
15
|
const name = 'smaller';
|
|
16
|
-
const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat'];
|
|
16
|
+
const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
|
|
17
17
|
const createSmaller = exports.createSmaller = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
|
18
18
|
let {
|
|
19
19
|
typed,
|
|
20
20
|
config,
|
|
21
21
|
matrix,
|
|
22
22
|
DenseMatrix,
|
|
23
|
-
concat
|
|
23
|
+
concat,
|
|
24
|
+
SparseMatrix
|
|
24
25
|
} = _ref;
|
|
25
26
|
const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
|
|
26
27
|
typed
|
|
27
28
|
});
|
|
28
29
|
const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
|
|
29
30
|
typed,
|
|
30
|
-
|
|
31
|
+
SparseMatrix
|
|
31
32
|
});
|
|
32
33
|
const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
|
|
33
34
|
typed,
|
|
@@ -13,21 +13,22 @@ var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
|
|
|
13
13
|
var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
|
|
14
14
|
var _compareUnits = require("./compareUnits.js");
|
|
15
15
|
const name = 'smallerEq';
|
|
16
|
-
const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat'];
|
|
16
|
+
const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
|
|
17
17
|
const createSmallerEq = exports.createSmallerEq = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
|
18
18
|
let {
|
|
19
19
|
typed,
|
|
20
20
|
config,
|
|
21
21
|
matrix,
|
|
22
22
|
DenseMatrix,
|
|
23
|
-
concat
|
|
23
|
+
concat,
|
|
24
|
+
SparseMatrix
|
|
24
25
|
} = _ref;
|
|
25
26
|
const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
|
|
26
27
|
typed
|
|
27
28
|
});
|
|
28
29
|
const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
|
|
29
30
|
typed,
|
|
30
|
-
|
|
31
|
+
SparseMatrix
|
|
31
32
|
});
|
|
32
33
|
const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
|
|
33
34
|
typed,
|
|
@@ -10,7 +10,7 @@ var _matAlgo07xSSf = require("../../type/matrix/utils/matAlgo07xSSf.js");
|
|
|
10
10
|
var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
|
|
11
11
|
var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
|
|
12
12
|
const name = 'unequal';
|
|
13
|
-
const dependencies = ['typed', 'config', 'equalScalar', 'matrix', 'DenseMatrix', 'concat'];
|
|
13
|
+
const dependencies = ['typed', 'config', 'equalScalar', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
|
|
14
14
|
const createUnequal = exports.createUnequal = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
|
15
15
|
let {
|
|
16
16
|
typed,
|
|
@@ -18,14 +18,15 @@ const createUnequal = exports.createUnequal = /* #__PURE__ */(0, _factory.factor
|
|
|
18
18
|
equalScalar,
|
|
19
19
|
matrix,
|
|
20
20
|
DenseMatrix,
|
|
21
|
-
concat
|
|
21
|
+
concat,
|
|
22
|
+
SparseMatrix
|
|
22
23
|
} = _ref;
|
|
23
24
|
const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
|
|
24
25
|
typed
|
|
25
26
|
});
|
|
26
27
|
const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
|
|
27
28
|
typed,
|
|
28
|
-
|
|
29
|
+
SparseMatrix
|
|
29
30
|
});
|
|
30
31
|
const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
|
|
31
32
|
typed,
|
|
@@ -53,7 +53,7 @@ const createIsInteger = exports.createIsInteger = /* #__PURE__ */(0, _factory.fa
|
|
|
53
53
|
return true;
|
|
54
54
|
},
|
|
55
55
|
Fraction: function (x) {
|
|
56
|
-
return x.d ===
|
|
56
|
+
return x.d === 1n;
|
|
57
57
|
},
|
|
58
58
|
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
|
59
59
|
});
|
|
@@ -49,7 +49,7 @@ const createIsNegative = exports.createIsNegative = /* #__PURE__ */(0, _factory.
|
|
|
49
49
|
number: x => (0, _number.nearlyEqual)(x, 0, config.relTol, config.absTol) ? false : (0, _index.isNegativeNumber)(x),
|
|
50
50
|
BigNumber: x => (0, _nearlyEqual.nearlyEqual)(x, new x.constructor(0), config.relTol, config.absTol) ? false : x.isNeg() && !x.isZero() && !x.isNaN(),
|
|
51
51
|
bigint: x => x < 0n,
|
|
52
|
-
Fraction: x => x.s <
|
|
52
|
+
Fraction: x => x.s < 0n,
|
|
53
53
|
// It's enough to decide on the sign
|
|
54
54
|
|
|
55
55
|
Unit: typed.referToSelf(self => x => typed.find(self, x.valueType())(x.value)),
|
|
@@ -51,7 +51,7 @@ const createIsPositive = exports.createIsPositive = /* #__PURE__ */(0, _factory.
|
|
|
51
51
|
number: x => (0, _number.nearlyEqual)(x, 0, config.relTol, config.absTol) ? false : (0, _index.isPositiveNumber)(x),
|
|
52
52
|
BigNumber: x => (0, _nearlyEqual.nearlyEqual)(x, new x.constructor(0), config.relTol, config.absTol) ? false : !x.isNeg() && !x.isZero() && !x.isNaN(),
|
|
53
53
|
bigint: x => x > 0n,
|
|
54
|
-
Fraction: x => x.s >
|
|
54
|
+
Fraction: x => x.s > 0n && x.n > 0n,
|
|
55
55
|
Unit: typed.referToSelf(self => x => typed.find(self, x.valueType())(x.value)),
|
|
56
56
|
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
|
57
57
|
});
|
package/lib/cjs/header.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* It features real and complex numbers, units, matrices, a large set of
|
|
7
7
|
* mathematical functions, and a flexible expression parser.
|
|
8
8
|
*
|
|
9
|
-
* @version
|
|
10
|
-
* @date 2024-11
|
|
9
|
+
* @version 14.0.1
|
|
10
|
+
* @date 2024-12-11
|
|
11
11
|
*
|
|
12
12
|
* @license
|
|
13
13
|
* Copyright (C) 2013-2024 Jos de Jong <wjosdejong@gmail.com>
|
|
@@ -78,9 +78,9 @@ const createBignumber = exports.createBignumber = /* #__PURE__ */(0, _factory.fa
|
|
|
78
78
|
return clone;
|
|
79
79
|
}),
|
|
80
80
|
Fraction: function (x) {
|
|
81
|
-
return new BigNumber(x.n).div(x.d).times(x.s);
|
|
81
|
+
return new BigNumber(String(x.n)).div(String(x.d)).times(String(x.s));
|
|
82
82
|
},
|
|
83
|
-
null: function (
|
|
83
|
+
null: function (_x) {
|
|
84
84
|
return new BigNumber(0);
|
|
85
85
|
},
|
|
86
86
|
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
|
@@ -23,20 +23,20 @@ const createFractionClass = exports.createFractionClass = /* #__PURE__ */(0, _fa
|
|
|
23
23
|
/**
|
|
24
24
|
* Get a JSON representation of a Fraction containing type information
|
|
25
25
|
* @returns {Object} Returns a JSON object structured as:
|
|
26
|
-
* `{"mathjs": "Fraction", "n": 3, "d": 8}`
|
|
26
|
+
* `{"mathjs": "Fraction", "n": "3", "d": "8"}`
|
|
27
27
|
*/
|
|
28
28
|
_fraction.default.prototype.toJSON = function () {
|
|
29
29
|
return {
|
|
30
30
|
mathjs: 'Fraction',
|
|
31
|
-
n: this.s * this.n,
|
|
32
|
-
d: this.d
|
|
31
|
+
n: String(this.s * this.n),
|
|
32
|
+
d: String(this.d)
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Instantiate a Fraction from a JSON object
|
|
38
38
|
* @param {Object} json a JSON object structured as:
|
|
39
|
-
* `{"mathjs": "Fraction", "n": 3, "d": 8}`
|
|
39
|
+
* `{"mathjs": "Fraction", "n": "3", "d": "8"}`
|
|
40
40
|
* @return {BigNumber}
|
|
41
41
|
*/
|
|
42
42
|
_fraction.default.fromJSON = function (json) {
|
|
@@ -63,6 +63,9 @@ const createFraction = exports.createFraction = /* #__PURE__ */(0, _factory.fact
|
|
|
63
63
|
'number, number': function (numerator, denominator) {
|
|
64
64
|
return new Fraction(numerator, denominator);
|
|
65
65
|
},
|
|
66
|
+
'bigint, bigint': function (numerator, denominator) {
|
|
67
|
+
return new Fraction(numerator, denominator);
|
|
68
|
+
},
|
|
66
69
|
null: function (x) {
|
|
67
70
|
return new Fraction(0);
|
|
68
71
|
},
|
|
@@ -7,31 +7,30 @@ exports.createMatAlgo07xSSf = void 0;
|
|
|
7
7
|
var _factory = require("../../../utils/factory.js");
|
|
8
8
|
var _DimensionError = require("../../../error/DimensionError.js");
|
|
9
9
|
const name = 'matAlgo07xSSf';
|
|
10
|
-
const dependencies = ['typed', '
|
|
10
|
+
const dependencies = ['typed', 'SparseMatrix'];
|
|
11
11
|
const createMatAlgo07xSSf = exports.createMatAlgo07xSSf = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
|
12
12
|
let {
|
|
13
13
|
typed,
|
|
14
|
-
|
|
14
|
+
SparseMatrix
|
|
15
15
|
} = _ref;
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
* Iterates over SparseMatrix A and SparseMatrix B items (zero and nonzero) and invokes the callback function f(Aij, Bij).
|
|
18
|
+
* Callback function invoked MxN times.
|
|
19
|
+
*
|
|
20
|
+
* C(i,j) = f(Aij, Bij)
|
|
21
|
+
*
|
|
22
|
+
* @param {Matrix} a The SparseMatrix instance (A)
|
|
23
|
+
* @param {Matrix} b The SparseMatrix instance (B)
|
|
24
|
+
* @param {Function} callback The f(Aij,Bij) operation to invoke
|
|
25
|
+
*
|
|
26
|
+
* @return {Matrix} SparseMatrix (C)
|
|
27
|
+
*
|
|
28
|
+
* see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294
|
|
29
|
+
*/
|
|
30
30
|
return function matAlgo07xSSf(a, b, callback) {
|
|
31
31
|
// sparse matrix arrays
|
|
32
32
|
const asize = a._size;
|
|
33
33
|
const adt = a._datatype || a._data === undefined ? a._datatype : a.getDataType();
|
|
34
|
-
// sparse matrix arrays
|
|
35
34
|
const bsize = b._size;
|
|
36
35
|
const bdt = b._datatype || b._data === undefined ? b._datatype : b.getDataType();
|
|
37
36
|
|
|
@@ -39,8 +38,6 @@ const createMatAlgo07xSSf = exports.createMatAlgo07xSSf = /* #__PURE__ */(0, _fa
|
|
|
39
38
|
if (asize.length !== bsize.length) {
|
|
40
39
|
throw new _DimensionError.DimensionError(asize.length, bsize.length);
|
|
41
40
|
}
|
|
42
|
-
|
|
43
|
-
// check rows & columns
|
|
44
41
|
if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) {
|
|
45
42
|
throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')');
|
|
46
43
|
}
|
|
@@ -51,59 +48,58 @@ const createMatAlgo07xSSf = exports.createMatAlgo07xSSf = /* #__PURE__ */(0, _fa
|
|
|
51
48
|
|
|
52
49
|
// datatype
|
|
53
50
|
let dt;
|
|
54
|
-
// zero value
|
|
55
51
|
let zero = 0;
|
|
56
|
-
// callback signature to use
|
|
57
52
|
let cf = callback;
|
|
58
53
|
|
|
59
54
|
// process data types
|
|
60
55
|
if (typeof adt === 'string' && adt === bdt && adt !== 'mixed') {
|
|
61
|
-
// datatype
|
|
62
56
|
dt = adt;
|
|
63
|
-
// convert 0 to the same datatype
|
|
64
57
|
zero = typed.convert(0, dt);
|
|
65
|
-
// callback
|
|
66
58
|
cf = typed.find(callback, [dt, dt]);
|
|
67
59
|
}
|
|
68
60
|
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
//
|
|
73
|
-
const cdata = [];
|
|
74
|
-
// initialize c
|
|
75
|
-
for (i = 0; i < rows; i++) {
|
|
76
|
-
cdata[i] = [];
|
|
77
|
-
}
|
|
61
|
+
// result arrays for sparse format
|
|
62
|
+
const cvalues = [];
|
|
63
|
+
const cindex = [];
|
|
64
|
+
const cptr = new Array(columns + 1).fill(0); // Start with column pointer array
|
|
78
65
|
|
|
79
66
|
// workspaces
|
|
80
67
|
const xa = [];
|
|
81
68
|
const xb = [];
|
|
82
|
-
// marks indicating we have a value in x for a given column
|
|
83
69
|
const wa = [];
|
|
84
70
|
const wb = [];
|
|
85
71
|
|
|
86
72
|
// loop columns
|
|
87
|
-
for (j = 0; j < columns; j++) {
|
|
88
|
-
// columns mark
|
|
73
|
+
for (let j = 0; j < columns; j++) {
|
|
89
74
|
const mark = j + 1;
|
|
90
|
-
|
|
75
|
+
let nonZeroCount = 0;
|
|
91
76
|
_scatter(a, j, wa, xa, mark);
|
|
92
|
-
// scatter the values of B(:,j) into workspace
|
|
93
77
|
_scatter(b, j, wb, xb, mark);
|
|
78
|
+
|
|
94
79
|
// loop rows
|
|
95
|
-
for (i = 0; i < rows; i++) {
|
|
96
|
-
// matrix values @ i,j
|
|
80
|
+
for (let i = 0; i < rows; i++) {
|
|
97
81
|
const va = wa[i] === mark ? xa[i] : zero;
|
|
98
82
|
const vb = wb[i] === mark ? xb[i] : zero;
|
|
83
|
+
|
|
99
84
|
// invoke callback
|
|
100
|
-
|
|
85
|
+
const cij = cf(va, vb);
|
|
86
|
+
// Store all non zero and true values
|
|
87
|
+
if (cij !== 0 && cij !== false) {
|
|
88
|
+
cindex.push(i); // row index
|
|
89
|
+
cvalues.push(cij); // computed value
|
|
90
|
+
nonZeroCount++;
|
|
91
|
+
}
|
|
101
92
|
}
|
|
93
|
+
|
|
94
|
+
// Update column pointer with cumulative count of non-zero values
|
|
95
|
+
cptr[j + 1] = cptr[j] + nonZeroCount;
|
|
102
96
|
}
|
|
103
97
|
|
|
104
|
-
//
|
|
105
|
-
return new
|
|
106
|
-
|
|
98
|
+
// Return the result as a sparse matrix
|
|
99
|
+
return new SparseMatrix({
|
|
100
|
+
values: cvalues,
|
|
101
|
+
index: cindex,
|
|
102
|
+
ptr: cptr,
|
|
107
103
|
size: [rows, columns],
|
|
108
104
|
datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined
|
|
109
105
|
});
|
|
@@ -3540,7 +3540,7 @@ const createUnitClass = exports.createUnitClass = /* #__PURE__ */(0, _factory.fa
|
|
|
3540
3540
|
*/
|
|
3541
3541
|
Unit.typeConverters = {
|
|
3542
3542
|
BigNumber: function (x) {
|
|
3543
|
-
if (x !== null && x !== void 0 && x.isFraction) return new BigNumber(x.n).div(x.d).times(x.s);
|
|
3543
|
+
if (x !== null && x !== void 0 && x.isFraction) return new BigNumber(String(x.n)).div(String(x.d)).times(String(x.s));
|
|
3544
3544
|
return new BigNumber(x + ''); // stringify to prevent constructor error
|
|
3545
3545
|
},
|
|
3546
3546
|
Fraction: function (x) {
|
package/lib/cjs/utils/string.js
CHANGED
|
@@ -80,7 +80,7 @@ function _format(value, options) {
|
|
|
80
80
|
if (looksLikeFraction(value)) {
|
|
81
81
|
if (!options || options.fraction !== 'decimal') {
|
|
82
82
|
// output as ratio, like '1/3'
|
|
83
|
-
return value.s * value.n
|
|
83
|
+
return `${value.s * value.n}/${value.d}`;
|
|
84
84
|
} else {
|
|
85
85
|
// output as decimal, like '0.(3)'
|
|
86
86
|
return value.toString();
|
|
@@ -182,7 +182,7 @@ function formatArray(array, options) {
|
|
|
182
182
|
* @return {boolean}
|
|
183
183
|
*/
|
|
184
184
|
function looksLikeFraction(value) {
|
|
185
|
-
return value && typeof value === 'object' && typeof value.s === '
|
|
185
|
+
return value && typeof value === 'object' && typeof value.s === 'bigint' && typeof value.n === 'bigint' && typeof value.d === 'bigint' || false;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
/**
|
package/lib/cjs/version.js
CHANGED
|
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.version = void 0;
|
|
7
|
-
const version = exports.version = '
|
|
7
|
+
const version = exports.version = '14.0.1';
|
|
8
8
|
// Note: This file is automatically generated when building math.js.
|
|
9
9
|
// Changes made in this file will be overwritten.
|
|
@@ -120,6 +120,7 @@ export function importFactory(typed, load, math, importedFactories) {
|
|
|
120
120
|
* @private
|
|
121
121
|
*/
|
|
122
122
|
function _import(name, value, options) {
|
|
123
|
+
var _math$Unit;
|
|
123
124
|
// TODO: refactor this function, it's to complicated and contains duplicate code
|
|
124
125
|
if (options.wrap && typeof value === 'function') {
|
|
125
126
|
// create a wrapper around the function
|
|
@@ -148,7 +149,9 @@ export function importFactory(typed, load, math, importedFactories) {
|
|
|
148
149
|
});
|
|
149
150
|
return;
|
|
150
151
|
}
|
|
151
|
-
|
|
152
|
+
var isDefined = math[name] !== undefined;
|
|
153
|
+
var isValuelessUnit = (_math$Unit = math.Unit) === null || _math$Unit === void 0 ? void 0 : _math$Unit.isValuelessUnit(name);
|
|
154
|
+
if (!isDefined && !isValuelessUnit || options.override) {
|
|
152
155
|
math[name] = value;
|
|
153
156
|
delete importedFactories[name];
|
|
154
157
|
_importTransform(name, value);
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
* DON'T MAKE CHANGES HERE
|
|
4
4
|
*/
|
|
5
5
|
import { DenseMatrixDependencies } from './dependenciesDenseMatrixClass.generated.js';
|
|
6
|
+
import { SparseMatrixDependencies } from './dependenciesSparseMatrixClass.generated.js';
|
|
6
7
|
import { concatDependencies } from './dependenciesConcat.generated.js';
|
|
7
8
|
import { matrixDependencies } from './dependenciesMatrix.generated.js';
|
|
8
9
|
import { typedDependencies } from './dependenciesTyped.generated.js';
|
|
9
10
|
import { createBitXor } from '../../factoriesAny.js';
|
|
10
11
|
export var bitXorDependencies = {
|
|
11
12
|
DenseMatrixDependencies,
|
|
13
|
+
SparseMatrixDependencies,
|
|
12
14
|
concatDependencies,
|
|
13
15
|
matrixDependencies,
|
|
14
16
|
typedDependencies,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* DON'T MAKE CHANGES HERE
|
|
4
4
|
*/
|
|
5
5
|
import { DenseMatrixDependencies } from './dependenciesDenseMatrixClass.generated.js';
|
|
6
|
+
import { SparseMatrixDependencies } from './dependenciesSparseMatrixClass.generated.js';
|
|
6
7
|
import { concatDependencies } from './dependenciesConcat.generated.js';
|
|
7
8
|
import { divideScalarDependencies } from './dependenciesDivideScalar.generated.js';
|
|
8
9
|
import { equalScalarDependencies } from './dependenciesEqualScalar.generated.js';
|
|
@@ -11,6 +12,7 @@ import { typedDependencies } from './dependenciesTyped.generated.js';
|
|
|
11
12
|
import { createDotDivide } from '../../factoriesAny.js';
|
|
12
13
|
export var dotDivideDependencies = {
|
|
13
14
|
DenseMatrixDependencies,
|
|
15
|
+
SparseMatrixDependencies,
|
|
14
16
|
concatDependencies,
|
|
15
17
|
divideScalarDependencies,
|
|
16
18
|
equalScalarDependencies,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* DON'T MAKE CHANGES HERE
|
|
4
4
|
*/
|
|
5
5
|
import { DenseMatrixDependencies } from './dependenciesDenseMatrixClass.generated.js';
|
|
6
|
+
import { SparseMatrixDependencies } from './dependenciesSparseMatrixClass.generated.js';
|
|
6
7
|
import { concatDependencies } from './dependenciesConcat.generated.js';
|
|
7
8
|
import { equalScalarDependencies } from './dependenciesEqualScalar.generated.js';
|
|
8
9
|
import { matrixDependencies } from './dependenciesMatrix.generated.js';
|
|
@@ -11,6 +12,7 @@ import { typedDependencies } from './dependenciesTyped.generated.js';
|
|
|
11
12
|
import { createDotPow } from '../../factoriesAny.js';
|
|
12
13
|
export var dotPowDependencies = {
|
|
13
14
|
DenseMatrixDependencies,
|
|
15
|
+
SparseMatrixDependencies,
|
|
14
16
|
concatDependencies,
|
|
15
17
|
equalScalarDependencies,
|
|
16
18
|
matrixDependencies,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* DON'T MAKE CHANGES HERE
|
|
4
4
|
*/
|
|
5
5
|
import { DenseMatrixDependencies } from './dependenciesDenseMatrixClass.generated.js';
|
|
6
|
+
import { SparseMatrixDependencies } from './dependenciesSparseMatrixClass.generated.js';
|
|
6
7
|
import { concatDependencies } from './dependenciesConcat.generated.js';
|
|
7
8
|
import { equalScalarDependencies } from './dependenciesEqualScalar.generated.js';
|
|
8
9
|
import { matrixDependencies } from './dependenciesMatrix.generated.js';
|
|
@@ -10,6 +11,7 @@ import { typedDependencies } from './dependenciesTyped.generated.js';
|
|
|
10
11
|
import { createEqual } from '../../factoriesAny.js';
|
|
11
12
|
export var equalDependencies = {
|
|
12
13
|
DenseMatrixDependencies,
|
|
14
|
+
SparseMatrixDependencies,
|
|
13
15
|
concatDependencies,
|
|
14
16
|
equalScalarDependencies,
|
|
15
17
|
matrixDependencies,
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
* DON'T MAKE CHANGES HERE
|
|
4
4
|
*/
|
|
5
5
|
import { DenseMatrixDependencies } from './dependenciesDenseMatrixClass.generated.js';
|
|
6
|
+
import { SparseMatrixDependencies } from './dependenciesSparseMatrixClass.generated.js';
|
|
6
7
|
import { concatDependencies } from './dependenciesConcat.generated.js';
|
|
7
8
|
import { matrixDependencies } from './dependenciesMatrix.generated.js';
|
|
8
9
|
import { typedDependencies } from './dependenciesTyped.generated.js';
|
|
9
10
|
import { createLarger } from '../../factoriesAny.js';
|
|
10
11
|
export var largerDependencies = {
|
|
11
12
|
DenseMatrixDependencies,
|
|
13
|
+
SparseMatrixDependencies,
|
|
12
14
|
concatDependencies,
|
|
13
15
|
matrixDependencies,
|
|
14
16
|
typedDependencies,
|