mathjs 11.5.0 → 11.6.0
Sign up to get free protection for your applications and to get access to all the features.
- package/HISTORY.md +39 -0
- package/NOTICE +1 -1
- package/README.md +2 -2
- package/bin/cli.js +1 -1
- package/lib/browser/math.js +1 -1
- package/lib/browser/math.js.LICENSE.txt +3 -3
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesAdd.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesAnd.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesAtan2.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesBitAnd.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesBitOr.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesBitXor.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesCompare.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesCompareText.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesDotDivide.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesDotMultiply.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/dependenciesFft.generated.js +10 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesGcd.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/dependenciesLcm.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesLeftShift.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesMod.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesNthRoot.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesOr.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesRightArithShift.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesRightLogShift.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSimplifyConstant.generated.js +0 -2
- 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/dependenciesSubtract.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesTo.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/dependenciesSimplifyConstant.generated.js +0 -2
- package/lib/cjs/entry/impureFunctionsAny.generated.js +102 -103
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +41 -42
- package/lib/cjs/entry/pureFunctionsAny.generated.js +405 -372
- package/lib/cjs/expression/embeddedDocs/function/arithmetic/invmod.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/arithmetic/pow.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/matrix/matrixFromColumns.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/matrix/matrixFromFunction.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/matrix/matrixFromRows.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/matrix/rotate.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/matrix/sort.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/probability/lgamma.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/statistics/max.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/statistics/mean.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/statistics/min.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/statistics/std.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/statistics/sum.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/statistics/variance.js +1 -1
- package/lib/cjs/function/algebra/simplifyConstant.js +1 -2
- package/lib/cjs/function/arithmetic/add.js +38 -37
- package/lib/cjs/function/arithmetic/dotDivide.js +5 -3
- package/lib/cjs/function/arithmetic/dotMultiply.js +5 -3
- package/lib/cjs/function/arithmetic/dotPow.js +5 -3
- package/lib/cjs/function/arithmetic/gcd.js +5 -3
- package/lib/cjs/function/arithmetic/lcm.js +5 -3
- package/lib/cjs/function/arithmetic/mod.js +5 -3
- package/lib/cjs/function/arithmetic/nthRoot.js +5 -3
- package/lib/cjs/function/arithmetic/subtract.js +5 -3
- package/lib/cjs/function/bitwise/bitAnd.js +5 -3
- package/lib/cjs/function/bitwise/bitOr.js +5 -3
- package/lib/cjs/function/bitwise/bitXor.js +5 -3
- package/lib/cjs/function/bitwise/leftShift.js +5 -3
- package/lib/cjs/function/bitwise/rightArithShift.js +5 -3
- package/lib/cjs/function/bitwise/rightLogShift.js +5 -3
- package/lib/cjs/function/geometry/distance.js +3 -3
- package/lib/cjs/function/logical/and.js +5 -3
- package/lib/cjs/function/logical/or.js +5 -3
- package/lib/cjs/function/logical/xor.js +5 -3
- package/lib/cjs/function/matrix/column.js +3 -1
- package/lib/cjs/function/matrix/fft.js +43 -4
- package/lib/cjs/function/matrix/getMatrixDataType.js +1 -1
- package/lib/cjs/function/matrix/row.js +3 -1
- package/lib/cjs/function/matrix/subset.js +1 -1
- package/lib/cjs/function/relational/compare.js +5 -3
- package/lib/cjs/function/relational/compareText.js +5 -3
- package/lib/cjs/function/relational/equal.js +5 -3
- package/lib/cjs/function/relational/larger.js +5 -3
- package/lib/cjs/function/relational/largerEq.js +5 -3
- package/lib/cjs/function/relational/smaller.js +5 -3
- package/lib/cjs/function/relational/smallerEq.js +5 -3
- package/lib/cjs/function/relational/unequal.js +5 -3
- package/lib/cjs/function/statistics/max.js +3 -3
- package/lib/cjs/function/statistics/mean.js +2 -2
- package/lib/cjs/function/statistics/min.js +2 -2
- package/lib/cjs/function/statistics/mode.js +1 -1
- package/lib/cjs/function/statistics/prod.js +1 -1
- package/lib/cjs/function/statistics/quantileSeq.js +5 -4
- package/lib/cjs/function/statistics/sum.js +3 -2
- package/lib/cjs/function/statistics/variance.js +1 -1
- package/lib/cjs/function/trigonometry/atan2.js +5 -3
- package/lib/cjs/function/unit/to.js +8 -6
- package/lib/cjs/header.js +3 -3
- package/lib/cjs/type/matrix/utils/broadcast.js +84 -0
- package/lib/cjs/type/matrix/utils/matrixAlgorithmSuite.js +27 -20
- package/lib/cjs/version.js +1 -1
- package/lib/esm/entry/dependenciesAny/dependenciesAdd.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesAnd.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesAtan2.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesBitAnd.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesBitOr.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesBitXor.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesCompare.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesCompareText.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesDotDivide.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesDotMultiply.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/dependenciesFft.generated.js +10 -0
- package/lib/esm/entry/dependenciesAny/dependenciesGcd.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/dependenciesLcm.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesLeftShift.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesMod.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesNthRoot.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesOr.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesRightArithShift.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesRightLogShift.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSimplifyConstant.generated.js +0 -2
- 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/dependenciesSubtract.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesTo.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/dependenciesSimplifyConstant.generated.js +0 -2
- package/lib/esm/entry/impureFunctionsAny.generated.js +100 -101
- package/lib/esm/entry/impureFunctionsNumber.generated.js +38 -39
- package/lib/esm/entry/pureFunctionsAny.generated.js +332 -299
- package/lib/esm/expression/embeddedDocs/function/arithmetic/invmod.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/arithmetic/pow.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/matrix/matrixFromColumns.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/matrix/matrixFromFunction.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/matrix/matrixFromRows.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/matrix/rotate.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/matrix/sort.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/probability/lgamma.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/statistics/max.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/statistics/mean.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/statistics/min.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/statistics/std.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/statistics/sum.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/statistics/variance.js +1 -1
- package/lib/esm/function/algebra/simplifyConstant.js +1 -2
- package/lib/esm/function/arithmetic/add.js +38 -37
- package/lib/esm/function/arithmetic/dotDivide.js +5 -3
- package/lib/esm/function/arithmetic/dotMultiply.js +5 -3
- package/lib/esm/function/arithmetic/dotPow.js +5 -3
- package/lib/esm/function/arithmetic/gcd.js +5 -3
- package/lib/esm/function/arithmetic/lcm.js +5 -3
- package/lib/esm/function/arithmetic/mod.js +5 -3
- package/lib/esm/function/arithmetic/nthRoot.js +5 -3
- package/lib/esm/function/arithmetic/subtract.js +5 -3
- package/lib/esm/function/bitwise/bitAnd.js +5 -3
- package/lib/esm/function/bitwise/bitOr.js +5 -3
- package/lib/esm/function/bitwise/bitXor.js +5 -3
- package/lib/esm/function/bitwise/leftShift.js +5 -3
- package/lib/esm/function/bitwise/rightArithShift.js +5 -3
- package/lib/esm/function/bitwise/rightLogShift.js +5 -3
- package/lib/esm/function/geometry/distance.js +3 -3
- package/lib/esm/function/logical/and.js +5 -3
- package/lib/esm/function/logical/or.js +5 -3
- package/lib/esm/function/logical/xor.js +5 -3
- package/lib/esm/function/matrix/column.js +3 -1
- package/lib/esm/function/matrix/fft.js +37 -4
- package/lib/esm/function/matrix/getMatrixDataType.js +1 -1
- package/lib/esm/function/matrix/row.js +3 -1
- package/lib/esm/function/matrix/subset.js +1 -1
- package/lib/esm/function/relational/compare.js +5 -3
- package/lib/esm/function/relational/compareText.js +5 -3
- package/lib/esm/function/relational/equal.js +5 -3
- package/lib/esm/function/relational/larger.js +5 -3
- package/lib/esm/function/relational/largerEq.js +5 -3
- package/lib/esm/function/relational/smaller.js +5 -3
- package/lib/esm/function/relational/smallerEq.js +5 -3
- package/lib/esm/function/relational/unequal.js +5 -3
- package/lib/esm/function/statistics/max.js +3 -3
- package/lib/esm/function/statistics/mean.js +2 -2
- package/lib/esm/function/statistics/min.js +2 -2
- package/lib/esm/function/statistics/mode.js +1 -1
- package/lib/esm/function/statistics/prod.js +1 -1
- package/lib/esm/function/statistics/quantileSeq.js +5 -4
- package/lib/esm/function/statistics/sum.js +3 -2
- package/lib/esm/function/statistics/variance.js +1 -1
- package/lib/esm/function/trigonometry/atan2.js +5 -3
- package/lib/esm/function/unit/to.js +8 -6
- package/lib/esm/header.js +1 -1
- package/lib/esm/type/matrix/utils/broadcast.js +75 -0
- package/lib/esm/type/matrix/utils/matrixAlgorithmSuite.js +25 -20
- package/lib/esm/version.js +1 -1
- package/package.json +21 -23
- package/types/index.d.ts +70 -13
@@ -1,15 +1,17 @@
|
|
1
1
|
import { factory } from '../../utils/factory.js';
|
2
2
|
import { createMatrixAlgorithmSuite } from '../../type/matrix/utils/matrixAlgorithmSuite.js';
|
3
3
|
var name = 'to';
|
4
|
-
var dependencies = ['typed', 'matrix'];
|
4
|
+
var dependencies = ['typed', 'matrix', 'concat'];
|
5
5
|
export var createTo = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed,
|
8
|
-
matrix
|
8
|
+
matrix,
|
9
|
+
concat
|
9
10
|
} = _ref;
|
10
11
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
11
12
|
typed,
|
12
|
-
matrix
|
13
|
+
matrix,
|
14
|
+
concat
|
13
15
|
});
|
14
16
|
|
15
17
|
/**
|
@@ -23,9 +25,9 @@ export var createTo = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
23
25
|
*
|
24
26
|
* Examples:
|
25
27
|
*
|
26
|
-
* math.to(math.unit('2 inch'), 'cm')
|
27
|
-
* math.to(math.unit('2 inch'), math.unit(
|
28
|
-
* math.to(math.unit(16, 'bytes'), 'bits')
|
28
|
+
* math.to(math.unit('2 inch'), 'cm') // returns Unit 5.08 cm
|
29
|
+
* math.to(math.unit('2 inch'), math.unit('cm')) // returns Unit 5.08 cm
|
30
|
+
* math.to(math.unit(16, 'bytes'), 'bits') // returns Unit 128 bits
|
29
31
|
*
|
30
32
|
* See also:
|
31
33
|
*
|
package/lib/esm/header.js
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
* @date @@date
|
11
11
|
*
|
12
12
|
* @license
|
13
|
-
* Copyright (C) 2013-
|
13
|
+
* Copyright (C) 2013-2023 Jos de Jong <wjosdejong@gmail.com>
|
14
14
|
*
|
15
15
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
16
16
|
* use this file except in compliance with the License. You may obtain a copy
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import { factory } from '../../../utils/factory.js';
|
2
|
+
var name = 'broadcast';
|
3
|
+
var dependancies = ['concat'];
|
4
|
+
export var createBroadcast = /* #__PURE__ */factory(name, dependancies, _ref => {
|
5
|
+
var {
|
6
|
+
concat
|
7
|
+
} = _ref;
|
8
|
+
/**
|
9
|
+
* Broadcasts two matrices, and return both in an array
|
10
|
+
* It checks if it's possible with broadcasting rules
|
11
|
+
*
|
12
|
+
* @param {Matrix} A First Matrix
|
13
|
+
* @param {Matrix} B Second Matrix
|
14
|
+
*
|
15
|
+
* @return {Matrix[]} [ broadcastedA, broadcastedB ]
|
16
|
+
*/
|
17
|
+
return function (A, B) {
|
18
|
+
var N = Math.max(A._size.length, B._size.length); // max number of dims
|
19
|
+
if (A._size.length === B._size.length) {
|
20
|
+
if (A._size.every((dim, i) => dim === B._size[i])) {
|
21
|
+
// If matrices have the same size return them
|
22
|
+
return [A, B];
|
23
|
+
}
|
24
|
+
}
|
25
|
+
var sizeA = _padLeft(A._size, N, 0); // pad to the left to align dimensions to the right
|
26
|
+
var sizeB = _padLeft(B._size, N, 0); // pad to the left to align dimensions to the right
|
27
|
+
|
28
|
+
// calculate the max dimensions
|
29
|
+
var sizeMax = [];
|
30
|
+
for (var dim = 0; dim < N; dim++) {
|
31
|
+
sizeMax[dim] = Math.max(sizeA[dim], sizeB[dim]);
|
32
|
+
}
|
33
|
+
|
34
|
+
// check if the broadcasting rules applyes for both matrices
|
35
|
+
for (var _dim = 0; _dim < N; _dim++) {
|
36
|
+
_checkRules(sizeA, sizeMax, _dim);
|
37
|
+
_checkRules(sizeB, sizeMax, _dim);
|
38
|
+
}
|
39
|
+
|
40
|
+
// reshape A or B if needed to make them ready for concat
|
41
|
+
var AA = A.clone();
|
42
|
+
var BB = B.clone();
|
43
|
+
if (AA._size.length < N) {
|
44
|
+
AA.reshape(_padLeft(AA._size, N, 1));
|
45
|
+
} else if (BB._size.length < N) {
|
46
|
+
BB.reshape(_padLeft(BB._size, N, 1));
|
47
|
+
}
|
48
|
+
|
49
|
+
// stretches the matrices on each dimension to make them the same size
|
50
|
+
for (var _dim2 = 0; _dim2 < N; _dim2++) {
|
51
|
+
if (AA._size[_dim2] < sizeMax[_dim2]) {
|
52
|
+
AA = _stretch(AA, sizeMax[_dim2], _dim2);
|
53
|
+
}
|
54
|
+
if (BB._size[_dim2] < sizeMax[_dim2]) {
|
55
|
+
BB = _stretch(BB, sizeMax[_dim2], _dim2);
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
// return the array with the two broadcasted matrices
|
60
|
+
return [AA, BB];
|
61
|
+
};
|
62
|
+
function _padLeft(shape, N, filler) {
|
63
|
+
// pads an array of dimensions with numbers to the left, unitl the number of dimensions is N
|
64
|
+
return [...Array(N - shape.length).fill(filler), ...shape];
|
65
|
+
}
|
66
|
+
function _stretch(arrayToStretch, sizeToStretch, dimToStretch) {
|
67
|
+
// stretches a matrix up to a certain size in a certain dimension
|
68
|
+
return concat(...Array(sizeToStretch).fill(arrayToStretch), dimToStretch);
|
69
|
+
}
|
70
|
+
function _checkRules(shape, sizeMax, dim) {
|
71
|
+
if (shape[dim] < sizeMax[dim] & shape[dim] > 1) {
|
72
|
+
throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(shape, ") not possible to broadcast dimension ").concat(dim, " with size ").concat(shape[dim], " to size ").concat(sizeMax[dim]));
|
73
|
+
}
|
74
|
+
}
|
75
|
+
});
|
@@ -2,12 +2,14 @@ import { factory } from '../../../utils/factory.js';
|
|
2
2
|
import { extend } from '../../../utils/object.js';
|
3
3
|
import { createMatAlgo13xDD } from './matAlgo13xDD.js';
|
4
4
|
import { createMatAlgo14xDs } from './matAlgo14xDs.js';
|
5
|
+
import { createBroadcast } from './broadcast.js';
|
5
6
|
var name = 'matrixAlgorithmSuite';
|
6
|
-
var dependencies = ['typed', 'matrix'];
|
7
|
+
var dependencies = ['typed', 'matrix', 'concat'];
|
7
8
|
export var createMatrixAlgorithmSuite = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
9
|
var {
|
9
10
|
typed,
|
10
|
-
matrix
|
11
|
+
matrix,
|
12
|
+
concat
|
11
13
|
} = _ref;
|
12
14
|
var matAlgo13xDD = createMatAlgo13xDD({
|
13
15
|
typed
|
@@ -15,6 +17,9 @@ export var createMatrixAlgorithmSuite = /* #__PURE__ */factory(name, dependencie
|
|
15
17
|
var matAlgo14xDs = createMatAlgo14xDs({
|
16
18
|
typed
|
17
19
|
});
|
20
|
+
var broadcast = createBroadcast({
|
21
|
+
concat
|
22
|
+
});
|
18
23
|
|
19
24
|
/**
|
20
25
|
* Return a signatures object with the usual boilerplate of
|
@@ -40,60 +45,60 @@ export var createMatrixAlgorithmSuite = /* #__PURE__ */factory(name, dependencie
|
|
40
45
|
if (elop) {
|
41
46
|
// First the dense ones
|
42
47
|
matrixSignatures = {
|
43
|
-
'DenseMatrix, DenseMatrix': (x, y) => matAlgo13xDD(x, y, elop),
|
44
|
-
'Array, Array': (x, y) => matAlgo13xDD(matrix(x), matrix(y), elop).valueOf(),
|
45
|
-
'Array, DenseMatrix': (x, y) => matAlgo13xDD(matrix(x), y, elop),
|
46
|
-
'DenseMatrix, Array': (x, y) => matAlgo13xDD(x, matrix(y), elop)
|
48
|
+
'DenseMatrix, DenseMatrix': (x, y) => matAlgo13xDD(...broadcast(x, y), elop),
|
49
|
+
'Array, Array': (x, y) => matAlgo13xDD(...broadcast(matrix(x), matrix(y)), elop).valueOf(),
|
50
|
+
'Array, DenseMatrix': (x, y) => matAlgo13xDD(...broadcast(matrix(x), y), elop),
|
51
|
+
'DenseMatrix, Array': (x, y) => matAlgo13xDD(...broadcast(x, matrix(y)), elop)
|
47
52
|
};
|
48
53
|
// Now incorporate sparse matrices
|
49
54
|
if (options.SS) {
|
50
|
-
matrixSignatures['SparseMatrix, SparseMatrix'] = (x, y) => options.SS(x, y, elop, false);
|
55
|
+
matrixSignatures['SparseMatrix, SparseMatrix'] = (x, y) => options.SS(...broadcast(x, y), elop, false);
|
51
56
|
}
|
52
57
|
if (options.DS) {
|
53
|
-
matrixSignatures['DenseMatrix, SparseMatrix'] = (x, y) => options.DS(x, y, elop, false);
|
54
|
-
matrixSignatures['Array, SparseMatrix'] = (x, y) => options.DS(matrix(x), y, elop, false);
|
58
|
+
matrixSignatures['DenseMatrix, SparseMatrix'] = (x, y) => options.DS(...broadcast(x, y), elop, false);
|
59
|
+
matrixSignatures['Array, SparseMatrix'] = (x, y) => options.DS(...broadcast(matrix(x), y), elop, false);
|
55
60
|
}
|
56
61
|
if (SD) {
|
57
|
-
matrixSignatures['SparseMatrix, DenseMatrix'] = (x, y) => SD(y, x, elop, true);
|
58
|
-
matrixSignatures['SparseMatrix, Array'] = (x, y) => SD(matrix(y), x, elop, true);
|
62
|
+
matrixSignatures['SparseMatrix, DenseMatrix'] = (x, y) => SD(...broadcast(y, x), elop, true);
|
63
|
+
matrixSignatures['SparseMatrix, Array'] = (x, y) => SD(...broadcast(matrix(y), x), elop, true);
|
59
64
|
}
|
60
65
|
} else {
|
61
66
|
// No elop, use this
|
62
67
|
// First the dense ones
|
63
68
|
matrixSignatures = {
|
64
69
|
'DenseMatrix, DenseMatrix': typed.referToSelf(self => (x, y) => {
|
65
|
-
return matAlgo13xDD(x, y, self);
|
70
|
+
return matAlgo13xDD(...broadcast(x, y), self);
|
66
71
|
}),
|
67
72
|
'Array, Array': typed.referToSelf(self => (x, y) => {
|
68
|
-
return matAlgo13xDD(matrix(x), matrix(y), self).valueOf();
|
73
|
+
return matAlgo13xDD(...broadcast(matrix(x), matrix(y)), self).valueOf();
|
69
74
|
}),
|
70
75
|
'Array, DenseMatrix': typed.referToSelf(self => (x, y) => {
|
71
|
-
return matAlgo13xDD(matrix(x), y, self);
|
76
|
+
return matAlgo13xDD(...broadcast(matrix(x), y), self);
|
72
77
|
}),
|
73
78
|
'DenseMatrix, Array': typed.referToSelf(self => (x, y) => {
|
74
|
-
return matAlgo13xDD(x, matrix(y), self);
|
79
|
+
return matAlgo13xDD(...broadcast(x, matrix(y)), self);
|
75
80
|
})
|
76
81
|
};
|
77
82
|
// Now incorporate sparse matrices
|
78
83
|
if (options.SS) {
|
79
84
|
matrixSignatures['SparseMatrix, SparseMatrix'] = typed.referToSelf(self => (x, y) => {
|
80
|
-
return options.SS(x, y, self, false);
|
85
|
+
return options.SS(...broadcast(x, y), self, false);
|
81
86
|
});
|
82
87
|
}
|
83
88
|
if (options.DS) {
|
84
89
|
matrixSignatures['DenseMatrix, SparseMatrix'] = typed.referToSelf(self => (x, y) => {
|
85
|
-
return options.DS(x, y, self, false);
|
90
|
+
return options.DS(...broadcast(x, y), self, false);
|
86
91
|
});
|
87
92
|
matrixSignatures['Array, SparseMatrix'] = typed.referToSelf(self => (x, y) => {
|
88
|
-
return options.DS(matrix(x), y, self, false);
|
93
|
+
return options.DS(...broadcast(matrix(x), y), self, false);
|
89
94
|
});
|
90
95
|
}
|
91
96
|
if (SD) {
|
92
97
|
matrixSignatures['SparseMatrix, DenseMatrix'] = typed.referToSelf(self => (x, y) => {
|
93
|
-
return SD(y, x, self, true);
|
98
|
+
return SD(...broadcast(y, x), self, true);
|
94
99
|
});
|
95
100
|
matrixSignatures['SparseMatrix, Array'] = typed.referToSelf(self => (x, y) => {
|
96
|
-
return SD(matrix(y), x, self, true);
|
101
|
+
return SD(...broadcast(matrix(y), x), self, true);
|
97
102
|
});
|
98
103
|
}
|
99
104
|
}
|
package/lib/esm/version.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mathjs",
|
3
|
-
"version": "11.
|
3
|
+
"version": "11.6.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",
|
@@ -25,7 +25,7 @@
|
|
25
25
|
"unit"
|
26
26
|
],
|
27
27
|
"dependencies": {
|
28
|
-
"@babel/runtime": "^7.
|
28
|
+
"@babel/runtime": "^7.21.0",
|
29
29
|
"complex.js": "^2.1.1",
|
30
30
|
"decimal.js": "^10.4.3",
|
31
31
|
"escape-latex": "^1.2.0",
|
@@ -36,48 +36,47 @@
|
|
36
36
|
"typed-function": "^4.1.0"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
|
-
"@babel/core": "7.
|
39
|
+
"@babel/core": "7.21.0",
|
40
40
|
"@babel/plugin-transform-object-assign": "7.18.6",
|
41
|
-
"@babel/plugin-transform-runtime": "7.
|
41
|
+
"@babel/plugin-transform-runtime": "7.21.0",
|
42
42
|
"@babel/preset-env": "7.20.2",
|
43
|
-
"@babel/register": "7.
|
43
|
+
"@babel/register": "7.21.0",
|
44
44
|
"@types/assert": "1.5.6",
|
45
45
|
"@types/mocha": "10.0.1",
|
46
|
-
"@typescript-eslint/eslint-plugin": "5.
|
47
|
-
"@typescript-eslint/parser": "5.
|
46
|
+
"@typescript-eslint/eslint-plugin": "5.53.0",
|
47
|
+
"@typescript-eslint/parser": "5.53.0",
|
48
48
|
"assert": "2.0.0",
|
49
|
-
"babel-loader": "9.1.
|
49
|
+
"babel-loader": "9.1.2",
|
50
50
|
"benchmark": "2.1.4",
|
51
|
+
"c8": "7.13.0",
|
51
52
|
"codecov": "3.8.3",
|
52
|
-
"core-js": "3.
|
53
|
+
"core-js": "3.28.0",
|
53
54
|
"del": "6.1.1",
|
54
55
|
"dtslint": "4.2.1",
|
55
|
-
"eslint": "8.
|
56
|
-
"eslint-config-prettier": "8.
|
56
|
+
"eslint": "8.34.0",
|
57
|
+
"eslint-config-prettier": "8.6.0",
|
57
58
|
"eslint-config-standard": "17.0.0",
|
58
|
-
"eslint-plugin-import": "2.
|
59
|
+
"eslint-plugin-import": "2.27.5",
|
59
60
|
"eslint-plugin-mocha": "10.1.0",
|
60
|
-
"eslint-plugin-n": "15.6.
|
61
|
+
"eslint-plugin-n": "15.6.1",
|
61
62
|
"eslint-plugin-prettier": "4.2.1",
|
62
63
|
"eslint-plugin-promise": "6.1.1",
|
63
64
|
"expect-type": "0.15.0",
|
64
65
|
"expr-eval": "2.0.2",
|
65
66
|
"fancy-log": "2.0.0",
|
66
|
-
"glob": "8.0
|
67
|
+
"glob": "8.1.0",
|
67
68
|
"gulp": "4.0.2",
|
68
69
|
"gulp-babel": "8.0.0",
|
69
70
|
"handlebars": "4.7.7",
|
70
|
-
"
|
71
|
-
"jsep": "1.3.7",
|
71
|
+
"jsep": "1.3.8",
|
72
72
|
"karma": "6.4.1",
|
73
73
|
"karma-browserstack-launcher": "1.6.0",
|
74
74
|
"karma-firefox-launcher": "2.1.2",
|
75
75
|
"karma-mocha": "2.0.1",
|
76
76
|
"karma-mocha-reporter": "2.2.5",
|
77
77
|
"karma-webpack": "5.0.0",
|
78
|
-
"
|
79
|
-
"
|
80
|
-
"mocha": "10.1.0",
|
78
|
+
"mkdirp": "2.1.3",
|
79
|
+
"mocha": "10.2.0",
|
81
80
|
"mocha-junit-reporter": "2.2.0",
|
82
81
|
"ndarray": "1.0.19",
|
83
82
|
"ndarray-determinant": "1.0.0",
|
@@ -85,13 +84,12 @@
|
|
85
84
|
"ndarray-ops": "1.2.2",
|
86
85
|
"ndarray-pack": "1.2.1",
|
87
86
|
"numericjs": "1.2.6",
|
88
|
-
"nyc": "15.1.0",
|
89
87
|
"pad-right": "0.2.2",
|
90
|
-
"prettier": "2.8.
|
88
|
+
"prettier": "2.8.4",
|
91
89
|
"process": "0.11.10",
|
92
90
|
"sylvester": "0.0.21",
|
93
91
|
"ts-node": "10.9.1",
|
94
|
-
"typescript": "4.9.
|
92
|
+
"typescript": "4.9.5",
|
95
93
|
"webpack": "5.75.0",
|
96
94
|
"zeros": "1.0.0"
|
97
95
|
},
|
@@ -163,7 +161,7 @@
|
|
163
161
|
"test:browser": "karma start test/browser-test-config/local-karma.js",
|
164
162
|
"test:browserstack": "karma start test/browser-test-config/browserstack-karma.js",
|
165
163
|
"test:types": " tsc -p ./tsconfig.json && node --loader ts-node/esm ./test/typescript-tests/testTypes.ts",
|
166
|
-
"coverage": "
|
164
|
+
"coverage": "c8 --reporter=lcov --reporter=text-summary mocha test/unit-tests && echo \"\nDetailed coverage report is available at ./coverage/lcov-report/index.html\"",
|
167
165
|
"prepublishOnly": "npm run test:all && npm run lint",
|
168
166
|
"update-authors": "node ./tools/update-authors.js"
|
169
167
|
},
|
package/types/index.d.ts
CHANGED
@@ -622,7 +622,7 @@ declare namespace math {
|
|
622
622
|
* complex number
|
623
623
|
* @returns Returns a complex value
|
624
624
|
*/
|
625
|
-
complex(arg?:
|
625
|
+
complex(arg?: MathNumericType | string | PolarCoordinates): Complex
|
626
626
|
complex(arg?: MathCollection): MathCollection
|
627
627
|
/**
|
628
628
|
* @param re Argument specifying the real part of the complex number
|
@@ -776,7 +776,7 @@ declare namespace math {
|
|
776
776
|
* @param unit The unit to be created
|
777
777
|
* @returns The created unit
|
778
778
|
*/
|
779
|
-
unit(value: number | BigNumber, unit: string): Unit
|
779
|
+
unit(value: number | BigNumber | Fraction | Complex, unit: string): Unit
|
780
780
|
unit(value: MathCollection, unit: string): Unit[]
|
781
781
|
|
782
782
|
/*************************************************************************
|
@@ -899,6 +899,8 @@ declare namespace math {
|
|
899
899
|
threshold?: number
|
900
900
|
): MathArray
|
901
901
|
|
902
|
+
lusolve(A: LUDecomposition, b: Matrix | MathArray): Matrix
|
903
|
+
|
902
904
|
/* Finds the roots of a polynomial of degree three or less. Coefficients are given constant first
|
903
905
|
* followed by linear and higher powers in order; coefficients beyond the degree of the polynomial
|
904
906
|
* need not be specified.
|
@@ -1147,7 +1149,11 @@ declare namespace math {
|
|
1147
1149
|
* @param y Denominator
|
1148
1150
|
* @returns Quotient, x ./ y
|
1149
1151
|
*/
|
1150
|
-
dotDivide(x:
|
1152
|
+
dotDivide<T extends MathCollection>(x: T, y: MathType): T
|
1153
|
+
dotDivide<T extends MathCollection>(x: MathType, y: T): T
|
1154
|
+
dotDivide(x: Unit, y: MathType): Unit
|
1155
|
+
dotDivide(x: MathType, y: Unit): Unit
|
1156
|
+
dotDivide(x: MathNumericType, y: MathNumericType): MathNumericType
|
1151
1157
|
|
1152
1158
|
/**
|
1153
1159
|
* Multiply two matrices element wise. The function accepts both
|
@@ -1156,7 +1162,11 @@ declare namespace math {
|
|
1156
1162
|
* @param y Right hand value
|
1157
1163
|
* @returns Multiplication of x and y
|
1158
1164
|
*/
|
1159
|
-
dotMultiply(x:
|
1165
|
+
dotMultiply<T extends MathCollection>(x: T, y: MathType): T
|
1166
|
+
dotMultiply<T extends MathCollection>(x: MathType, y: T): T
|
1167
|
+
dotMultiply(x: Unit, y: MathType): Unit
|
1168
|
+
dotMultiply(x: MathType, y: Unit): Unit
|
1169
|
+
dotMultiply(x: MathNumericType, y: MathNumericType): MathNumericType
|
1160
1170
|
|
1161
1171
|
/**
|
1162
1172
|
* Calculates the power of x to y element wise.
|
@@ -1164,7 +1174,7 @@ declare namespace math {
|
|
1164
1174
|
* @param y The exponent
|
1165
1175
|
* @returns The value of x to the power y
|
1166
1176
|
*/
|
1167
|
-
dotPow(x:
|
1177
|
+
dotPow<T extends MathType>(x: T, y: MathType): T
|
1168
1178
|
|
1169
1179
|
/**
|
1170
1180
|
* Calculate the exponent of a value. For matrices, the function is
|
@@ -1666,7 +1676,7 @@ declare namespace math {
|
|
1666
1676
|
w: MathCollection,
|
1667
1677
|
x: MathCollection,
|
1668
1678
|
y: MathCollection,
|
1669
|
-
z
|
1679
|
+
z?: MathCollection
|
1670
1680
|
): MathArray
|
1671
1681
|
|
1672
1682
|
/*************************************************************************
|
@@ -2072,6 +2082,19 @@ declare namespace math {
|
|
2072
2082
|
defaultValue?: number | string
|
2073
2083
|
): T
|
2074
2084
|
|
2085
|
+
/**
|
2086
|
+
* Return a Rotation Matrix for a given angle in radians
|
2087
|
+
* @param {number | BigNumber | Complex | Unit} theta Rotation angle
|
2088
|
+
* @param {Array | Matrix} [v] Rotation axis
|
2089
|
+
* @param {string} [format] Result Matrix storage format. Default value: 'dense'.
|
2090
|
+
* @return {Matrix} Rotation Matrix
|
2091
|
+
*/
|
2092
|
+
rotationMatrix<T extends MathCollection>(
|
2093
|
+
theta?: number | BigNumber | Complex | Unit,
|
2094
|
+
axis?: T,
|
2095
|
+
format?: 'sparse' | 'dense'
|
2096
|
+
): T
|
2097
|
+
|
2075
2098
|
/**
|
2076
2099
|
* Return a row from a Matrix.
|
2077
2100
|
* @param value An array or matrix
|
@@ -3771,12 +3794,12 @@ declare namespace math {
|
|
3771
3794
|
size(): number[]
|
3772
3795
|
map(
|
3773
3796
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
3774
|
-
callback: (a: any, b: number, c: Matrix) => any,
|
3797
|
+
callback: (a: any, b: number[], c: Matrix) => any,
|
3775
3798
|
skipZeros?: boolean
|
3776
3799
|
): Matrix
|
3777
3800
|
forEach(
|
3778
3801
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
3779
|
-
callback: (a: any, b: number, c: Matrix) => void,
|
3802
|
+
callback: (a: any, b: number[], c: Matrix) => void,
|
3780
3803
|
skipZeros?: boolean
|
3781
3804
|
): void
|
3782
3805
|
toArray(): MathArray
|
@@ -4374,7 +4397,7 @@ declare namespace math {
|
|
4374
4397
|
unit(this: MathJsChain<string>, unit?: string): MathJsChain<Unit>
|
4375
4398
|
unit(this: MathJsChain<Unit>, unit?: string): MathJsChain<Unit>
|
4376
4399
|
unit(
|
4377
|
-
this: MathJsChain<number | BigNumber>,
|
4400
|
+
this: MathJsChain<number | BigNumber | Fraction | Complex>,
|
4378
4401
|
unit?: string
|
4379
4402
|
): MathJsChain<Unit>
|
4380
4403
|
unit(this: MathJsChain<MathCollection>, unit?: string): MathJsChain<Unit[]>
|
@@ -4504,6 +4527,11 @@ declare namespace math {
|
|
4504
4527
|
threshold?: number
|
4505
4528
|
): MathJsChain<MathArray>
|
4506
4529
|
|
4530
|
+
lusolve(
|
4531
|
+
this: MathJsChain<LUDecomposition>,
|
4532
|
+
b: Matrix | MathArray
|
4533
|
+
): MathJsChain<Matrix>
|
4534
|
+
|
4507
4535
|
/**
|
4508
4536
|
* Calculate the Matrix QR decomposition. Matrix A is decomposed in two
|
4509
4537
|
* matrices (Q, R) where Q is an orthogonal matrix and R is an upper
|
@@ -4724,20 +4752,49 @@ declare namespace math {
|
|
4724
4752
|
* and scalar values.
|
4725
4753
|
* @param y Denominator
|
4726
4754
|
*/
|
4727
|
-
dotDivide
|
4755
|
+
dotDivide<T extends MathCollection>(
|
4756
|
+
this: MathJsChain<T>,
|
4757
|
+
y: MathType
|
4758
|
+
): MathJsChain<T>
|
4759
|
+
dotDivide<T extends MathCollection>(
|
4760
|
+
this: MathJsChain<MathType>,
|
4761
|
+
y: T
|
4762
|
+
): MathJsChain<T>
|
4763
|
+
dotDivide(this: MathJsChain<Unit>, y: MathType): MathJsChain<Unit>
|
4764
|
+
dotDivide(this: MathJsChain<MathType>, y: Unit): MathJsChain<Unit>
|
4765
|
+
dotDivide(
|
4766
|
+
this: MathJsChain<MathNumericType>,
|
4767
|
+
y: MathNumericType
|
4768
|
+
): MathJsChain<MathNumericType>
|
4728
4769
|
|
4729
4770
|
/**
|
4730
4771
|
* Multiply two matrices element wise. The function accepts both
|
4731
4772
|
* matrices and scalar values.
|
4732
4773
|
* @param y Right hand value
|
4733
4774
|
*/
|
4734
|
-
dotMultiply
|
4775
|
+
dotMultiply<T extends MathCollection>(
|
4776
|
+
this: MathJsChain<T>,
|
4777
|
+
y: MathType
|
4778
|
+
): MathJsChain<T>
|
4779
|
+
dotMultiply<T extends MathCollection>(
|
4780
|
+
this: MathJsChain<MathType>,
|
4781
|
+
y: T
|
4782
|
+
): MathJsChain<T>
|
4783
|
+
dotMultiply(this: MathJsChain<Unit>, y: MathType): MathJsChain<Unit>
|
4784
|
+
dotMultiply(this: MathJsChain<MathType>, y: Unit): MathJsChain<Unit>
|
4785
|
+
dotMultiply(
|
4786
|
+
this: MathJsChain<MathNumericType>,
|
4787
|
+
y: MathNumericType
|
4788
|
+
): MathJsChain<MathNumericType>
|
4735
4789
|
|
4736
4790
|
/**
|
4737
4791
|
* Calculates the power of x to y element wise.
|
4738
4792
|
* @param y The exponent
|
4739
4793
|
*/
|
4740
|
-
dotPow
|
4794
|
+
dotPow<T extends MathType>(
|
4795
|
+
this: MathJsChain<T>,
|
4796
|
+
y: MathType
|
4797
|
+
): MathJsChain<T>
|
4741
4798
|
|
4742
4799
|
/**
|
4743
4800
|
* Calculate the exponent of a value. For matrices, the function is
|
@@ -5213,7 +5270,7 @@ declare namespace math {
|
|
5213
5270
|
this: MathJsChain<MathCollection>,
|
5214
5271
|
x: MathCollection,
|
5215
5272
|
y: MathCollection,
|
5216
|
-
z
|
5273
|
+
z?: MathCollection
|
5217
5274
|
): MathJsChain<MathArray>
|
5218
5275
|
|
5219
5276
|
/*************************************************************************
|