mathjs 13.0.2 → 13.1.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 -1
- package/lib/browser/math.js +1 -1
- package/lib/browser/math.js.LICENSE.txt +2 -2
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/core/create.js +12 -9
- package/lib/cjs/core/function/import.js +1 -1
- package/lib/cjs/core/function/typed.js +3 -4
- package/lib/cjs/entry/dependenciesAny/dependenciesFlatten.generated.js +0 -2
- package/lib/cjs/entry/dependenciesAny/dependenciesSqueeze.generated.js +0 -2
- package/lib/cjs/entry/impureFunctionsAny.generated.js +2 -2
- package/lib/cjs/entry/pureFunctionsAny.generated.js +6 -8
- package/lib/cjs/entry/typeChecks.js +18 -0
- package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +2 -2
- package/lib/cjs/expression/embeddedDocs/function/arithmetic/hypot.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/matrix/diff.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/matrix/fft.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/matrix/ifft.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/matrix/kron.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/matrix/map.js +3 -3
- package/lib/cjs/expression/embeddedDocs/function/special/zeta.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/statistics/quantileSeq.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/trigonometry/acoth.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/trigonometry/acsch.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/utils/clone.js +1 -1
- package/lib/cjs/expression/function/evaluate.js +5 -0
- package/lib/cjs/expression/node/FunctionNode.js +1 -1
- package/lib/cjs/expression/transform/filter.transform.js +2 -2
- package/lib/cjs/expression/transform/map.transform.js +104 -37
- package/lib/cjs/expression/transform/utils/dimToZeroBase.js +23 -0
- package/lib/cjs/expression/transform/utils/lastDimToZeroBase.js +3 -4
- package/lib/cjs/function/arithmetic/hypot.js +3 -3
- package/lib/cjs/function/matrix/apply.js +1 -1
- package/lib/cjs/function/matrix/fft.js +3 -3
- package/lib/cjs/function/matrix/filter.js +2 -2
- package/lib/cjs/function/matrix/flatten.js +5 -6
- package/lib/cjs/function/matrix/ifft.js +2 -2
- package/lib/cjs/function/matrix/kron.js +4 -4
- package/lib/cjs/function/matrix/map.js +109 -18
- package/lib/cjs/function/matrix/size.js +7 -7
- package/lib/cjs/function/matrix/squeeze.js +3 -4
- package/lib/cjs/function/probability/random.js +1 -1
- package/lib/cjs/function/probability/randomInt.js +1 -1
- package/lib/cjs/function/statistics/cumsum.js +2 -2
- package/lib/cjs/function/trigonometry/acoth.js +2 -2
- package/lib/cjs/function/trigonometry/acsch.js +2 -2
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/type/matrix/DenseMatrix.js +3 -28
- package/lib/cjs/type/matrix/SparseMatrix.js +5 -8
- package/lib/cjs/type/unit/Unit.js +57 -114
- package/lib/cjs/utils/array.js +27 -0
- package/lib/cjs/utils/collection.js +1 -1
- package/lib/cjs/utils/function.js +0 -14
- package/lib/cjs/utils/is.js +27 -0
- package/lib/cjs/utils/map.js +2 -20
- package/lib/cjs/version.js +1 -1
- package/lib/esm/core/create.js +9 -6
- package/lib/esm/core/function/import.js +1 -1
- package/lib/esm/core/function/typed.js +2 -3
- package/lib/esm/entry/dependenciesAny/dependenciesFlatten.generated.js +0 -2
- package/lib/esm/entry/dependenciesAny/dependenciesSqueeze.generated.js +0 -2
- package/lib/esm/entry/impureFunctionsAny.generated.js +3 -3
- package/lib/esm/entry/pureFunctionsAny.generated.js +7 -9
- package/lib/esm/entry/typeChecks.js +1 -1
- package/lib/esm/expression/embeddedDocs/embeddedDocs.js +2 -2
- package/lib/esm/expression/embeddedDocs/function/arithmetic/hypot.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/matrix/diff.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/matrix/fft.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/matrix/ifft.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/matrix/kron.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/matrix/map.js +3 -3
- package/lib/esm/expression/embeddedDocs/function/special/zeta.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/statistics/quantileSeq.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/trigonometry/acoth.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/trigonometry/acsch.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/utils/clone.js +1 -1
- package/lib/esm/expression/function/compile.js +1 -1
- package/lib/esm/expression/function/evaluate.js +8 -3
- package/lib/esm/expression/node/FunctionNode.js +1 -1
- package/lib/esm/expression/parse.js +2 -2
- package/lib/esm/expression/transform/filter.transform.js +4 -4
- package/lib/esm/expression/transform/forEach.transform.js +4 -4
- package/lib/esm/expression/transform/map.transform.js +104 -37
- package/lib/esm/expression/transform/print.transform.js +2 -2
- package/lib/esm/expression/transform/utils/dimToZeroBase.js +16 -0
- package/lib/esm/expression/transform/utils/lastDimToZeroBase.js +4 -6
- package/lib/esm/function/algebra/decomposition/slu.js +1 -1
- package/lib/esm/function/algebra/derivative.js +15 -15
- package/lib/esm/function/algebra/lyap.js +4 -4
- package/lib/esm/function/algebra/simplify/util.js +3 -3
- package/lib/esm/function/algebra/simplifyConstant.js +9 -9
- package/lib/esm/function/algebra/solver/lsolve.js +3 -3
- package/lib/esm/function/algebra/solver/lsolveAll.js +3 -3
- package/lib/esm/function/algebra/solver/lusolve.js +5 -5
- package/lib/esm/function/algebra/solver/usolve.js +3 -3
- package/lib/esm/function/algebra/solver/usolveAll.js +3 -3
- package/lib/esm/function/algebra/sylvester.js +7 -7
- package/lib/esm/function/arithmetic/addScalar.js +4 -4
- package/lib/esm/function/arithmetic/ceil.js +6 -6
- package/lib/esm/function/arithmetic/divide.js +5 -5
- package/lib/esm/function/arithmetic/divideScalar.js +5 -5
- package/lib/esm/function/arithmetic/fix.js +5 -5
- package/lib/esm/function/arithmetic/floor.js +6 -6
- package/lib/esm/function/arithmetic/hypot.js +3 -3
- package/lib/esm/function/arithmetic/mod.js +3 -3
- package/lib/esm/function/arithmetic/multiply.js +7 -7
- package/lib/esm/function/arithmetic/multiplyScalar.js +4 -4
- package/lib/esm/function/arithmetic/norm.js +2 -2
- package/lib/esm/function/arithmetic/pow.js +6 -6
- package/lib/esm/function/arithmetic/round.js +7 -7
- package/lib/esm/function/arithmetic/subtractScalar.js +4 -4
- package/lib/esm/function/arithmetic/xgcd.js +1 -1
- package/lib/esm/function/combinatorics/bellNumbers.js +1 -1
- package/lib/esm/function/combinatorics/catalan.js +1 -1
- package/lib/esm/function/combinatorics/composition.js +1 -1
- package/lib/esm/function/combinatorics/stirlingS2.js +1 -1
- package/lib/esm/function/geometry/distance.js +4 -4
- package/lib/esm/function/geometry/intersect.js +2 -2
- package/lib/esm/function/logical/and.js +2 -2
- package/lib/esm/function/logical/or.js +2 -2
- package/lib/esm/function/logical/xor.js +2 -2
- package/lib/esm/function/matrix/apply.js +2 -2
- package/lib/esm/function/matrix/column.js +1 -1
- package/lib/esm/function/matrix/concat.js +1 -1
- package/lib/esm/function/matrix/count.js +1 -1
- package/lib/esm/function/matrix/cross.js +3 -3
- package/lib/esm/function/matrix/diag.js +10 -10
- package/lib/esm/function/matrix/diff.js +2 -2
- package/lib/esm/function/matrix/eigs.js +3 -3
- package/lib/esm/function/matrix/fft.js +3 -3
- package/lib/esm/function/matrix/filter.js +4 -4
- package/lib/esm/function/matrix/flatten.js +5 -6
- package/lib/esm/function/matrix/forEach.js +4 -4
- package/lib/esm/function/matrix/identity.js +6 -6
- package/lib/esm/function/matrix/ifft.js +3 -3
- package/lib/esm/function/matrix/inv.js +1 -1
- package/lib/esm/function/matrix/kron.js +7 -7
- package/lib/esm/function/matrix/map.js +110 -19
- package/lib/esm/function/matrix/matrixFromFunction.js +6 -6
- package/lib/esm/function/matrix/ones.js +2 -2
- package/lib/esm/function/matrix/partitionSelect.js +2 -2
- package/lib/esm/function/matrix/pinv.js +1 -1
- package/lib/esm/function/matrix/range.js +10 -10
- package/lib/esm/function/matrix/reshape.js +2 -2
- package/lib/esm/function/matrix/rotate.js +4 -4
- package/lib/esm/function/matrix/rotationMatrix.js +6 -6
- package/lib/esm/function/matrix/row.js +1 -1
- package/lib/esm/function/matrix/size.js +8 -8
- package/lib/esm/function/matrix/sort.js +4 -4
- package/lib/esm/function/matrix/sqrtm.js +1 -1
- package/lib/esm/function/matrix/squeeze.js +3 -4
- package/lib/esm/function/matrix/subset.js +2 -2
- package/lib/esm/function/matrix/zeros.js +2 -2
- package/lib/esm/function/probability/combinations.js +1 -1
- package/lib/esm/function/probability/combinationsWithRep.js +2 -2
- package/lib/esm/function/probability/kldivergence.js +4 -4
- package/lib/esm/function/probability/multinomial.js +1 -1
- package/lib/esm/function/probability/permutations.js +2 -2
- package/lib/esm/function/probability/pickRandom.js +6 -6
- package/lib/esm/function/probability/random.js +1 -1
- package/lib/esm/function/probability/randomInt.js +1 -1
- package/lib/esm/function/relational/compare.js +6 -6
- package/lib/esm/function/relational/deepEqual.js +1 -1
- package/lib/esm/function/relational/equal.js +1 -1
- package/lib/esm/function/relational/equalScalar.js +7 -7
- package/lib/esm/function/relational/equalText.js +1 -1
- package/lib/esm/function/relational/larger.js +3 -3
- package/lib/esm/function/relational/largerEq.js +4 -4
- package/lib/esm/function/relational/smaller.js +3 -3
- package/lib/esm/function/relational/smallerEq.js +3 -3
- package/lib/esm/function/relational/unequal.js +1 -1
- package/lib/esm/function/set/setCartesian.js +1 -1
- package/lib/esm/function/set/setDifference.js +1 -1
- package/lib/esm/function/set/setDistinct.js +1 -1
- package/lib/esm/function/set/setIntersect.js +1 -1
- package/lib/esm/function/set/setIsSubset.js +1 -1
- package/lib/esm/function/set/setMultiplicity.js +1 -1
- package/lib/esm/function/set/setPowerset.js +1 -1
- package/lib/esm/function/set/setSize.js +2 -2
- package/lib/esm/function/set/setSymDifference.js +1 -1
- package/lib/esm/function/set/setUnion.js +1 -1
- package/lib/esm/function/signal/freqz.js +6 -6
- package/lib/esm/function/statistics/corr.js +2 -2
- package/lib/esm/function/statistics/cumsum.js +3 -3
- package/lib/esm/function/statistics/max.js +1 -1
- package/lib/esm/function/statistics/median.js +3 -3
- package/lib/esm/function/statistics/min.js +1 -1
- package/lib/esm/function/statistics/prod.js +1 -1
- package/lib/esm/function/statistics/variance.js +2 -2
- package/lib/esm/function/string/bin.js +2 -2
- package/lib/esm/function/string/hex.js +2 -2
- package/lib/esm/function/string/oct.js +2 -2
- package/lib/esm/function/trigonometry/acoth.js +2 -2
- package/lib/esm/function/trigonometry/acsch.js +2 -2
- package/lib/esm/type/bigint.js +1 -1
- package/lib/esm/type/complex/function/complex.js +2 -2
- package/lib/esm/type/fraction/function/fraction.js +1 -1
- package/lib/esm/type/matrix/DenseMatrix.js +13 -38
- package/lib/esm/type/matrix/SparseMatrix.js +5 -8
- package/lib/esm/type/matrix/function/index.js +1 -1
- package/lib/esm/type/matrix/function/matrix.js +1 -1
- package/lib/esm/type/matrix/function/sparse.js +2 -2
- package/lib/esm/type/number.js +1 -1
- package/lib/esm/type/unit/Unit.js +57 -114
- package/lib/esm/type/unit/function/createUnit.js +3 -3
- package/lib/esm/type/unit/function/splitUnit.js +1 -1
- package/lib/esm/type/unit/function/unit.js +2 -2
- package/lib/esm/utils/array.js +26 -0
- package/lib/esm/utils/collection.js +1 -1
- package/lib/esm/utils/function.js +0 -13
- package/lib/esm/utils/is.js +24 -0
- package/lib/esm/utils/map.js +2 -19
- package/lib/esm/version.js +1 -1
- package/package.json +19 -19
- package/types/index.d.ts +108 -25
package/lib/cjs/core/create.js
CHANGED
|
@@ -7,16 +7,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.create = create;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _typedFunction = _interopRequireDefault(require("typed-function"));
|
|
10
|
-
var _object = require("../utils/object.js");
|
|
11
|
-
var emitter = _interopRequireWildcard(require("./../utils/emitter.js"));
|
|
12
|
-
var _import = require("./function/import.js");
|
|
13
|
-
var _config = require("./function/config.js");
|
|
14
|
-
var _factory = require("../utils/factory.js");
|
|
15
|
-
var _is = require("../utils/is.js");
|
|
16
10
|
var _ArgumentsError = require("../error/ArgumentsError.js");
|
|
17
11
|
var _DimensionError = require("../error/DimensionError.js");
|
|
18
12
|
var _IndexError = require("../error/IndexError.js");
|
|
19
|
-
var
|
|
13
|
+
var _factory = require("../utils/factory.js");
|
|
14
|
+
var _is = require("../utils/is.js");
|
|
15
|
+
var _object = require("../utils/object.js");
|
|
16
|
+
var emitter = _interopRequireWildcard(require("./../utils/emitter.js"));
|
|
17
|
+
var _config = require("./config.js");
|
|
18
|
+
var _config2 = require("./function/config.js");
|
|
19
|
+
var _import = require("./function/import.js");
|
|
20
20
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
21
21
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
22
|
/**
|
|
@@ -62,7 +62,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
62
62
|
* - `on`, `off`, `once`, `emit` for events
|
|
63
63
|
*/
|
|
64
64
|
function create(factories, config) {
|
|
65
|
-
const configInternal = (0, _extends2.default)({},
|
|
65
|
+
const configInternal = (0, _extends2.default)({}, _config.DEFAULT_CONFIG, config);
|
|
66
66
|
|
|
67
67
|
// simple test for ES5 support
|
|
68
68
|
if (typeof Object.create !== 'function') {
|
|
@@ -93,6 +93,9 @@ function create(factories, config) {
|
|
|
93
93
|
isDate: _is.isDate,
|
|
94
94
|
isRegExp: _is.isRegExp,
|
|
95
95
|
isObject: _is.isObject,
|
|
96
|
+
isMap: _is.isMap,
|
|
97
|
+
isPartitionedMap: _is.isPartitionedMap,
|
|
98
|
+
isObjectWrappingMap: _is.isObjectWrappingMap,
|
|
96
99
|
isNull: _is.isNull,
|
|
97
100
|
isUndefined: _is.isUndefined,
|
|
98
101
|
isAccessorNode: _is.isAccessorNode,
|
|
@@ -115,7 +118,7 @@ function create(factories, config) {
|
|
|
115
118
|
});
|
|
116
119
|
|
|
117
120
|
// load config function and apply provided config
|
|
118
|
-
math.config = (0,
|
|
121
|
+
math.config = (0, _config2.configFactory)(configInternal, math.emit);
|
|
119
122
|
math.expression = {
|
|
120
123
|
transform: {},
|
|
121
124
|
mathWithTransform: {
|
|
@@ -225,7 +225,7 @@ function importFactory(typed, load, math, importedFactories) {
|
|
|
225
225
|
throw new Error('Factory name should not contain a nested path. ' + 'Name: ' + JSON.stringify(name));
|
|
226
226
|
}
|
|
227
227
|
const namespace = isTransformFunctionFactory(factory) ? math.expression.transform : math;
|
|
228
|
-
const existingTransform =
|
|
228
|
+
const existingTransform = name in math.expression.transform;
|
|
229
229
|
const existing = (0, _object.hasOwnProperty)(namespace, name) ? namespace[name] : undefined;
|
|
230
230
|
const resolver = function () {
|
|
231
231
|
// collect all dependencies, handle finding both functions and classes and other special cases
|
|
@@ -5,11 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.createTyped = void 0;
|
|
8
|
-
var _is = require("../../utils/is.js");
|
|
9
8
|
var _typedFunction = _interopRequireDefault(require("typed-function"));
|
|
10
|
-
var _number = require("../../utils/number.js");
|
|
11
9
|
var _factory = require("../../utils/factory.js");
|
|
12
|
-
var
|
|
10
|
+
var _is = require("../../utils/is.js");
|
|
11
|
+
var _number = require("../../utils/number.js");
|
|
13
12
|
/**
|
|
14
13
|
* Create a typed-function which checks the types of the arguments and
|
|
15
14
|
* can match them against multiple provided signatures. The typed-function
|
|
@@ -202,7 +201,7 @@ const createTyped = exports.createTyped = /* #__PURE__ */(0, _factory.factory)('
|
|
|
202
201
|
test: _is.isSymbolNode
|
|
203
202
|
}, {
|
|
204
203
|
name: 'Map',
|
|
205
|
-
test:
|
|
204
|
+
test: _is.isMap
|
|
206
205
|
}, {
|
|
207
206
|
name: 'Object',
|
|
208
207
|
test: _is.isObject
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.flattenDependencies = void 0;
|
|
7
|
-
var _dependenciesMatrixGenerated = require("./dependenciesMatrix.generated.js");
|
|
8
7
|
var _dependenciesTypedGenerated = require("./dependenciesTyped.generated.js");
|
|
9
8
|
var _factoriesAny = require("../../factoriesAny.js");
|
|
10
9
|
/**
|
|
@@ -13,7 +12,6 @@ var _factoriesAny = require("../../factoriesAny.js");
|
|
|
13
12
|
*/
|
|
14
13
|
|
|
15
14
|
const flattenDependencies = exports.flattenDependencies = {
|
|
16
|
-
matrixDependencies: _dependenciesMatrixGenerated.matrixDependencies,
|
|
17
15
|
typedDependencies: _dependenciesTypedGenerated.typedDependencies,
|
|
18
16
|
createFlatten: _factoriesAny.createFlatten
|
|
19
17
|
};
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.squeezeDependencies = void 0;
|
|
7
|
-
var _dependenciesMatrixGenerated = require("./dependenciesMatrix.generated.js");
|
|
8
7
|
var _dependenciesTypedGenerated = require("./dependenciesTyped.generated.js");
|
|
9
8
|
var _factoriesAny = require("../../factoriesAny.js");
|
|
10
9
|
/**
|
|
@@ -13,7 +12,6 @@ var _factoriesAny = require("../../factoriesAny.js");
|
|
|
13
12
|
*/
|
|
14
13
|
|
|
15
14
|
const squeezeDependencies = exports.squeezeDependencies = {
|
|
16
|
-
matrixDependencies: _dependenciesMatrixGenerated.matrixDependencies,
|
|
17
15
|
typedDependencies: _dependenciesTypedGenerated.typedDependencies,
|
|
18
16
|
createSqueeze: _factoriesAny.createSqueeze
|
|
19
17
|
};
|
|
@@ -314,6 +314,7 @@ const help = exports.help = (0, _factoriesAny.createHelp)({
|
|
|
314
314
|
exp: _pureFunctionsAnyGenerated.exp,
|
|
315
315
|
expm1: _pureFunctionsAnyGenerated.expm1,
|
|
316
316
|
filter: _pureFunctionsAnyGenerated.filter,
|
|
317
|
+
flatten: _pureFunctionsAnyGenerated.flatten,
|
|
317
318
|
forEach: _pureFunctionsAnyGenerated.forEach,
|
|
318
319
|
format: _pureFunctionsAnyGenerated.format,
|
|
319
320
|
getMatrixDataType: _pureFunctionsAnyGenerated.getMatrixDataType,
|
|
@@ -361,6 +362,7 @@ const help = exports.help = (0, _factoriesAny.createHelp)({
|
|
|
361
362
|
sinh: _pureFunctionsAnyGenerated.sinh,
|
|
362
363
|
sparse: _pureFunctionsAnyGenerated.sparse,
|
|
363
364
|
sqrt: _pureFunctionsAnyGenerated.sqrt,
|
|
365
|
+
squeeze: _pureFunctionsAnyGenerated.squeeze,
|
|
364
366
|
tanh: _pureFunctionsAnyGenerated.tanh,
|
|
365
367
|
unaryMinus: _pureFunctionsAnyGenerated.unaryMinus,
|
|
366
368
|
acoth: _pureFunctionsAnyGenerated.acoth,
|
|
@@ -375,7 +377,6 @@ const help = exports.help = (0, _factoriesAny.createHelp)({
|
|
|
375
377
|
prod: _pureFunctionsAnyGenerated.prod,
|
|
376
378
|
reshape: _pureFunctionsAnyGenerated.reshape,
|
|
377
379
|
size: _pureFunctionsAnyGenerated.size,
|
|
378
|
-
squeeze: _pureFunctionsAnyGenerated.squeeze,
|
|
379
380
|
transpose: _pureFunctionsAnyGenerated.transpose,
|
|
380
381
|
xgcd: _pureFunctionsAnyGenerated.xgcd,
|
|
381
382
|
zeros: _pureFunctionsAnyGenerated.zeros,
|
|
@@ -388,7 +389,6 @@ const help = exports.help = (0, _factoriesAny.createHelp)({
|
|
|
388
389
|
divideScalar: _pureFunctionsAnyGenerated.divideScalar,
|
|
389
390
|
dotDivide: _pureFunctionsAnyGenerated.dotDivide,
|
|
390
391
|
equal: _pureFunctionsAnyGenerated.equal,
|
|
391
|
-
flatten: _pureFunctionsAnyGenerated.flatten,
|
|
392
392
|
hasNumericValue: _pureFunctionsAnyGenerated.hasNumericValue,
|
|
393
393
|
identity: _pureFunctionsAnyGenerated.identity,
|
|
394
394
|
kron: _pureFunctionsAnyGenerated.kron,
|
|
@@ -193,6 +193,9 @@ const expm1 = exports.expm1 = /* #__PURE__ */(0, _factoriesAny.createExpm1)({
|
|
|
193
193
|
const filter = exports.filter = /* #__PURE__ */(0, _factoriesAny.createFilter)({
|
|
194
194
|
typed
|
|
195
195
|
});
|
|
196
|
+
const flatten = exports.flatten = /* #__PURE__ */(0, _factoriesAny.createFlatten)({
|
|
197
|
+
typed
|
|
198
|
+
});
|
|
196
199
|
const forEach = exports.forEach = /* #__PURE__ */(0, _factoriesAny.createForEach)({
|
|
197
200
|
typed
|
|
198
201
|
});
|
|
@@ -367,6 +370,9 @@ const sqrt = exports.sqrt = /* #__PURE__ */(0, _factoriesAny.createSqrt)({
|
|
|
367
370
|
config: _configReadonly.config,
|
|
368
371
|
typed
|
|
369
372
|
});
|
|
373
|
+
const squeeze = exports.squeeze = /* #__PURE__ */(0, _factoriesAny.createSqueeze)({
|
|
374
|
+
typed
|
|
375
|
+
});
|
|
370
376
|
const tanh = exports.tanh = /* #__PURE__ */(0, _factoriesAny.createTanh)({
|
|
371
377
|
typed
|
|
372
378
|
});
|
|
@@ -431,10 +437,6 @@ const size = exports.size = /* #__PURE__ */(0, _factoriesAny.createSize)({
|
|
|
431
437
|
config: _configReadonly.config,
|
|
432
438
|
typed
|
|
433
439
|
});
|
|
434
|
-
const squeeze = exports.squeeze = /* #__PURE__ */(0, _factoriesAny.createSqueeze)({
|
|
435
|
-
matrix,
|
|
436
|
-
typed
|
|
437
|
-
});
|
|
438
440
|
const transpose = exports.transpose = /* #__PURE__ */(0, _factoriesAny.createTranspose)({
|
|
439
441
|
matrix,
|
|
440
442
|
typed
|
|
@@ -506,10 +508,6 @@ const equal = exports.equal = /* #__PURE__ */(0, _factoriesAny.createEqual)({
|
|
|
506
508
|
matrix,
|
|
507
509
|
typed
|
|
508
510
|
});
|
|
509
|
-
const flatten = exports.flatten = /* #__PURE__ */(0, _factoriesAny.createFlatten)({
|
|
510
|
-
matrix,
|
|
511
|
-
typed
|
|
512
|
-
});
|
|
513
511
|
const hasNumericValue = exports.hasNumericValue = /* #__PURE__ */(0, _factoriesAny.createHasNumericValue)({
|
|
514
512
|
isNumeric,
|
|
515
513
|
typed
|
|
@@ -135,6 +135,12 @@ Object.defineProperty(exports, "isIndexNode", {
|
|
|
135
135
|
return _is.isIndexNode;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
|
+
Object.defineProperty(exports, "isMap", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function () {
|
|
141
|
+
return _is.isMap;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
138
144
|
Object.defineProperty(exports, "isMatrix", {
|
|
139
145
|
enumerable: true,
|
|
140
146
|
get: function () {
|
|
@@ -171,6 +177,12 @@ Object.defineProperty(exports, "isObjectNode", {
|
|
|
171
177
|
return _is.isObjectNode;
|
|
172
178
|
}
|
|
173
179
|
});
|
|
180
|
+
Object.defineProperty(exports, "isObjectWrappingMap", {
|
|
181
|
+
enumerable: true,
|
|
182
|
+
get: function () {
|
|
183
|
+
return _is.isObjectWrappingMap;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
174
186
|
Object.defineProperty(exports, "isOperatorNode", {
|
|
175
187
|
enumerable: true,
|
|
176
188
|
get: function () {
|
|
@@ -183,6 +195,12 @@ Object.defineProperty(exports, "isParenthesisNode", {
|
|
|
183
195
|
return _is.isParenthesisNode;
|
|
184
196
|
}
|
|
185
197
|
});
|
|
198
|
+
Object.defineProperty(exports, "isPartitionedMap", {
|
|
199
|
+
enumerable: true,
|
|
200
|
+
get: function () {
|
|
201
|
+
return _is.isPartitionedMap;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
186
204
|
Object.defineProperty(exports, "isRange", {
|
|
187
205
|
enumerable: true,
|
|
188
206
|
get: function () {
|
|
@@ -322,7 +322,7 @@ const embeddedDocs = exports.embeddedDocs = {
|
|
|
322
322
|
examples: ['elementaryCharge']
|
|
323
323
|
},
|
|
324
324
|
bohrMagneton: {
|
|
325
|
-
description: '
|
|
325
|
+
description: 'Bohr magneton',
|
|
326
326
|
examples: ['bohrMagneton']
|
|
327
327
|
},
|
|
328
328
|
conductanceQuantum: {
|
|
@@ -347,7 +347,7 @@ const embeddedDocs = exports.embeddedDocs = {
|
|
|
347
347
|
examples: ['klitzing']
|
|
348
348
|
},
|
|
349
349
|
bohrRadius: {
|
|
350
|
-
description: '
|
|
350
|
+
description: 'Bohr radius',
|
|
351
351
|
examples: ['bohrRadius']
|
|
352
352
|
},
|
|
353
353
|
classicalElectronRadius: {
|
|
@@ -8,7 +8,7 @@ const hypotDocs = exports.hypotDocs = {
|
|
|
8
8
|
name: 'hypot',
|
|
9
9
|
category: 'Arithmetic',
|
|
10
10
|
syntax: ['hypot(a, b, c, ...)', 'hypot([a, b, c, ...])'],
|
|
11
|
-
description: 'Calculate the
|
|
11
|
+
description: 'Calculate the hypotenuse of a list with values.',
|
|
12
12
|
examples: ['hypot(3, 4)', 'sqrt(3^2 + 4^2)', 'hypot(-2)', 'hypot([3, 4, 5])'],
|
|
13
13
|
seealso: ['abs', 'norm']
|
|
14
14
|
};
|
|
@@ -8,7 +8,7 @@ const diffDocs = exports.diffDocs = {
|
|
|
8
8
|
name: 'diff',
|
|
9
9
|
category: 'Matrix',
|
|
10
10
|
syntax: ['diff(arr)', 'diff(arr, dim)'],
|
|
11
|
-
description: ['Create a new matrix or array with the difference of the passed matrix or array.', 'Dim parameter is optional and used to
|
|
11
|
+
description: ['Create a new matrix or array with the difference of the passed matrix or array.', 'Dim parameter is optional and used to indicate the dimension of the array/matrix to apply the difference', 'If no dimension parameter is passed it is assumed as dimension 0', 'Dimension is zero-based in javascript and one-based in the parser', 'Arrays must be \'rectangular\' meaning arrays like [1, 2]', 'If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays'],
|
|
12
12
|
examples: ['A = [1, 2, 4, 7, 0]', 'diff(A)', 'diff(A, 1)', 'B = [[1, 2], [3, 4]]', 'diff(B)', 'diff(B, 1)', 'diff(B, 2)', 'diff(B, bignumber(2))', 'diff([[1, 2], matrix([3, 4])], 2)'],
|
|
13
13
|
seealso: ['subtract', 'partitionSelect']
|
|
14
14
|
};
|
|
@@ -8,7 +8,7 @@ const fftDocs = exports.fftDocs = {
|
|
|
8
8
|
name: 'fft',
|
|
9
9
|
category: 'Matrix',
|
|
10
10
|
syntax: ['fft(x)'],
|
|
11
|
-
description: 'Calculate N-dimensional
|
|
11
|
+
description: 'Calculate N-dimensional Fourier transform',
|
|
12
12
|
examples: ['fft([[1, 0], [1, 0]])'],
|
|
13
13
|
seealso: ['ifft']
|
|
14
14
|
};
|
|
@@ -8,7 +8,7 @@ const ifftDocs = exports.ifftDocs = {
|
|
|
8
8
|
name: 'ifft',
|
|
9
9
|
category: 'Matrix',
|
|
10
10
|
syntax: ['ifft(x)'],
|
|
11
|
-
description: 'Calculate N-dimensional inverse
|
|
11
|
+
description: 'Calculate N-dimensional inverse Fourier transform',
|
|
12
12
|
examples: ['ifft([[2, 2], [0, 0]])'],
|
|
13
13
|
seealso: ['fft']
|
|
14
14
|
};
|
|
@@ -8,7 +8,7 @@ const kronDocs = exports.kronDocs = {
|
|
|
8
8
|
name: 'kron',
|
|
9
9
|
category: 'Matrix',
|
|
10
10
|
syntax: ['kron(x, y)'],
|
|
11
|
-
description: 'Calculates the
|
|
11
|
+
description: 'Calculates the Kronecker product of 2 matrices or vectors.',
|
|
12
12
|
examples: ['kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])', 'kron([1,1], [2,3,4])'],
|
|
13
13
|
seealso: ['multiply', 'dot', 'cross']
|
|
14
14
|
};
|
|
@@ -7,8 +7,8 @@ exports.mapDocs = void 0;
|
|
|
7
7
|
const mapDocs = exports.mapDocs = {
|
|
8
8
|
name: 'map',
|
|
9
9
|
category: 'Matrix',
|
|
10
|
-
syntax: ['map(x, callback)'],
|
|
11
|
-
description: 'Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.',
|
|
12
|
-
examples: ['map([1, 2, 3], square)'],
|
|
10
|
+
syntax: ['map(x, callback)', 'map(x, y, ..., callback)'],
|
|
11
|
+
description: 'Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array or the matrices/arrays.',
|
|
12
|
+
examples: ['map([1, 2, 3], square)', 'map([1, 2], [3, 4], f(a,b) = a + b)'],
|
|
13
13
|
seealso: ['filter', 'forEach']
|
|
14
14
|
};
|
|
@@ -8,7 +8,7 @@ const zetaDocs = exports.zetaDocs = {
|
|
|
8
8
|
name: 'zeta',
|
|
9
9
|
category: 'Special',
|
|
10
10
|
syntax: ['zeta(s)'],
|
|
11
|
-
description: 'Compute the Riemann Zeta Function using an infinite series and
|
|
11
|
+
description: 'Compute the Riemann Zeta Function using an infinite series and Riemann\'s Functional Equation for the entire complex plane',
|
|
12
12
|
examples: ['zeta(0.2)', 'zeta(-0.5)', 'zeta(4)'],
|
|
13
13
|
seealso: []
|
|
14
14
|
};
|
|
@@ -8,7 +8,7 @@ const quantileSeqDocs = exports.quantileSeqDocs = {
|
|
|
8
8
|
name: 'quantileSeq',
|
|
9
9
|
category: 'Statistics',
|
|
10
10
|
syntax: ['quantileSeq(A, prob[, sorted])', 'quantileSeq(A, [prob1, prob2, ...][, sorted])', 'quantileSeq(A, N[, sorted])'],
|
|
11
|
-
description: 'Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of
|
|
11
|
+
description: 'Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probability are: Number, BigNumber. \n\nIn case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.',
|
|
12
12
|
examples: ['quantileSeq([3, -1, 5, 7], 0.5)', 'quantileSeq([3, -1, 5, 7], [1/3, 2/3])', 'quantileSeq([3, -1, 5, 7], 2)', 'quantileSeq([-1, 3, 5, 7], 0.5, true)'],
|
|
13
13
|
seealso: ['mean', 'median', 'min', 'max', 'prod', 'std', 'sum', 'variance']
|
|
14
14
|
};
|
|
@@ -8,7 +8,7 @@ const acothDocs = exports.acothDocs = {
|
|
|
8
8
|
name: 'acoth',
|
|
9
9
|
category: 'Trigonometry',
|
|
10
10
|
syntax: ['acoth(x)'],
|
|
11
|
-
description: 'Calculate the hyperbolic
|
|
11
|
+
description: 'Calculate the inverse hyperbolic tangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.',
|
|
12
12
|
examples: ['acoth(2)', 'acoth(0.5)'],
|
|
13
13
|
seealso: ['acsch', 'asech']
|
|
14
14
|
};
|
|
@@ -8,7 +8,7 @@ const acschDocs = exports.acschDocs = {
|
|
|
8
8
|
name: 'acsch',
|
|
9
9
|
category: 'Trigonometry',
|
|
10
10
|
syntax: ['acsch(x)'],
|
|
11
|
-
description: 'Calculate the hyperbolic
|
|
11
|
+
description: 'Calculate the inverse hyperbolic cosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.',
|
|
12
12
|
examples: ['acsch(0.5)'],
|
|
13
13
|
seealso: ['asech', 'acoth']
|
|
14
14
|
};
|
|
@@ -8,7 +8,7 @@ const cloneDocs = exports.cloneDocs = {
|
|
|
8
8
|
name: 'clone',
|
|
9
9
|
category: 'Utils',
|
|
10
10
|
syntax: ['clone(x)'],
|
|
11
|
-
description: 'Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices',
|
|
11
|
+
description: 'Clone a variable. Creates a copy of primitive variables, and a deep copy of matrices',
|
|
12
12
|
examples: ['clone(3.5)', 'clone(2 - 4i)', 'clone(45 deg)', 'clone([1, 2; 3, 4])', 'clone("hello world")'],
|
|
13
13
|
seealso: []
|
|
14
14
|
};
|
|
@@ -17,6 +17,11 @@ const createEvaluate = exports.createEvaluate = /* #__PURE__ */(0, _factory.fact
|
|
|
17
17
|
/**
|
|
18
18
|
* Evaluate an expression.
|
|
19
19
|
*
|
|
20
|
+
* The expression parser does not use JavaScript. Its syntax is close
|
|
21
|
+
* to JavaScript but more suited for mathematical expressions.
|
|
22
|
+
* See [https://mathjs.org/docs/expressions/syntax.html](https://mathjs.org/docs/expressions/syntax.html) to learn
|
|
23
|
+
* the syntax and get an overview of the exact differences from JavaScript.
|
|
24
|
+
*
|
|
20
25
|
* Note the evaluating arbitrary expressions may involve security risks,
|
|
21
26
|
* see [https://mathjs.org/docs/expressions/security.html](https://mathjs.org/docs/expressions/security.html) for more information.
|
|
22
27
|
*
|
|
@@ -104,7 +104,7 @@ const createFunctionNode = exports.createFunctionNode = /* #__PURE__ */(0, _fact
|
|
|
104
104
|
* invoke a list with arguments on a node
|
|
105
105
|
* @param {./Node | string} fn
|
|
106
106
|
* Item resolving to a function on which to invoke
|
|
107
|
-
* the arguments, typically a
|
|
107
|
+
* the arguments, typically a SymbolNode or AccessorNode
|
|
108
108
|
* @param {./Node[]} args
|
|
109
109
|
*/
|
|
110
110
|
constructor(fn, args) {
|
|
@@ -44,11 +44,11 @@ const createFilterTransform = exports.createFilterTransform = /* #__PURE__ */(0,
|
|
|
44
44
|
const filter = typed('filter', {
|
|
45
45
|
'Array, function': _filter,
|
|
46
46
|
'Matrix, function': function (x, test) {
|
|
47
|
-
return x.create(_filter(x.toArray(), test));
|
|
47
|
+
return x.create(_filter(x.toArray(), test), x.datatype());
|
|
48
48
|
},
|
|
49
49
|
'Array, RegExp': _array.filterRegExp,
|
|
50
50
|
'Matrix, RegExp': function (x, test) {
|
|
51
|
-
return x.create((0, _array.filterRegExp)(x.toArray(), test));
|
|
51
|
+
return x.create((0, _array.filterRegExp)(x.toArray(), test), x.datatype());
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
return filterTransform;
|
|
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createMapTransform = void 0;
|
|
7
|
-
var _applyCallback = require("../../utils/applyCallback.js");
|
|
8
|
-
var _array = require("../../utils/array.js");
|
|
9
7
|
var _factory = require("../../utils/factory.js");
|
|
10
8
|
var _is = require("../../utils/is.js");
|
|
9
|
+
var _map = require("../../function/matrix/map.js");
|
|
11
10
|
var _compileInlineExpression = require("./utils/compileInlineExpression.js");
|
|
12
11
|
const name = 'map';
|
|
13
12
|
const dependencies = ['typed'];
|
|
@@ -21,57 +20,125 @@ const createMapTransform = exports.createMapTransform = /* #__PURE__ */(0, _fact
|
|
|
21
20
|
*
|
|
22
21
|
* This transform creates a one-based index instead of a zero-based index
|
|
23
22
|
*/
|
|
23
|
+
const map = (0, _map.createMap)({
|
|
24
|
+
typed
|
|
25
|
+
});
|
|
24
26
|
function mapTransform(args, math, scope) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
x = args[0].compile().evaluate(scope);
|
|
27
|
+
if (args.length === 0) {
|
|
28
|
+
return map();
|
|
28
29
|
}
|
|
29
|
-
if (args
|
|
30
|
-
|
|
30
|
+
if (args.length === 1) {
|
|
31
|
+
return map(args[0]);
|
|
32
|
+
}
|
|
33
|
+
const N = args.length - 1;
|
|
34
|
+
let X, callback;
|
|
35
|
+
callback = args[N];
|
|
36
|
+
X = args.slice(0, N);
|
|
37
|
+
X = X.map(arg => _compileAndEvaluate(arg, scope));
|
|
38
|
+
if (callback) {
|
|
39
|
+
if ((0, _is.isSymbolNode)(callback) || (0, _is.isFunctionAssignmentNode)(callback)) {
|
|
31
40
|
// a function pointer, like filter([3, -2, 5], myTestFunction)
|
|
32
|
-
callback =
|
|
41
|
+
callback = _compileAndEvaluate(callback, scope);
|
|
33
42
|
} else {
|
|
34
43
|
// an expression like filter([3, -2, 5], x > 0)
|
|
35
|
-
callback = (0, _compileInlineExpression.compileInlineExpression)(
|
|
44
|
+
callback = (0, _compileInlineExpression.compileInlineExpression)(callback, math, scope);
|
|
36
45
|
}
|
|
37
46
|
}
|
|
38
|
-
return map(
|
|
47
|
+
return map(...X, _transformCallback(callback, N));
|
|
48
|
+
function _compileAndEvaluate(arg, scope) {
|
|
49
|
+
return arg.compile().evaluate(scope);
|
|
50
|
+
}
|
|
39
51
|
}
|
|
40
52
|
mapTransform.rawArgs = true;
|
|
53
|
+
return mapTransform;
|
|
41
54
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Transforms the given callback function based on its type and number of arrays.
|
|
57
|
+
*
|
|
58
|
+
* @param {Function} callback - The callback function to transform.
|
|
59
|
+
* @param {number} numberOfArrays - The number of arrays to pass to the callback function.
|
|
60
|
+
* @returns {*} - The transformed callback function.
|
|
61
|
+
*/
|
|
62
|
+
function _transformCallback(callback, numberOfArrays) {
|
|
63
|
+
if (typed.isTypedFunction(callback)) {
|
|
64
|
+
return _transformTypedCallbackFunction(callback, numberOfArrays);
|
|
65
|
+
} else {
|
|
66
|
+
return _transformCallbackFunction(callback, callback.length, numberOfArrays);
|
|
49
67
|
}
|
|
50
|
-
}
|
|
51
|
-
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Transforms the given typed callback function based on the number of arrays.
|
|
72
|
+
*
|
|
73
|
+
* @param {Function} typedFunction - The typed callback function to transform.
|
|
74
|
+
* @param {number} numberOfArrays - The number of arrays to pass to the callback function.
|
|
75
|
+
* @returns {*} - The transformed typed callback function.
|
|
76
|
+
*/
|
|
77
|
+
function _transformTypedCallbackFunction(typedFunction, numberOfArrays) {
|
|
78
|
+
const signatures = Object.fromEntries(Object.entries(typedFunction.signatures).map(_ref2 => {
|
|
79
|
+
let [signature, callbackFunction] = _ref2;
|
|
80
|
+
const numberOfCallbackInputs = signature.split(',').length;
|
|
81
|
+
if (typed.isTypedFunction(callbackFunction)) {
|
|
82
|
+
return [signature, _transformTypedCallbackFunction(callbackFunction, numberOfArrays)];
|
|
83
|
+
} else {
|
|
84
|
+
return [signature, _transformCallbackFunction(callbackFunction, numberOfCallbackInputs, numberOfArrays)];
|
|
85
|
+
}
|
|
86
|
+
}));
|
|
87
|
+
if (typeof typedFunction.name === 'string') {
|
|
88
|
+
return typed(typedFunction.name, signatures);
|
|
89
|
+
} else {
|
|
90
|
+
return typed(signatures);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
52
93
|
}, {
|
|
53
94
|
isTransformFunction: true
|
|
54
95
|
});
|
|
55
96
|
|
|
56
97
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
98
|
+
* Transforms the callback function based on the number of callback inputs and arrays.
|
|
99
|
+
* There are three cases:
|
|
100
|
+
* 1. The callback function has N arguments.
|
|
101
|
+
* 2. The callback function has N+1 arguments.
|
|
102
|
+
* 3. The callback function has 2N+1 arguments.
|
|
103
|
+
*
|
|
104
|
+
* @param {Function} callbackFunction - The callback function to transform.
|
|
105
|
+
* @param {number} numberOfCallbackInputs - The number of callback inputs.
|
|
106
|
+
* @param {number} numberOfArrays - The number of arrays.
|
|
107
|
+
* @returns {Function} The transformed callback function.
|
|
63
108
|
*/
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
109
|
+
function _transformCallbackFunction(callbackFunction, numberOfCallbackInputs, numberOfArrays) {
|
|
110
|
+
if (numberOfCallbackInputs === numberOfArrays) {
|
|
111
|
+
return callbackFunction;
|
|
112
|
+
} else if (numberOfCallbackInputs === numberOfArrays + 1) {
|
|
113
|
+
return function () {
|
|
114
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
115
|
+
args[_key] = arguments[_key];
|
|
116
|
+
}
|
|
117
|
+
const vals = args.slice(0, numberOfArrays);
|
|
118
|
+
const idx = _transformDims(args[numberOfArrays]);
|
|
119
|
+
return callbackFunction(...vals, idx);
|
|
120
|
+
};
|
|
121
|
+
} else if (numberOfCallbackInputs > numberOfArrays + 1) {
|
|
122
|
+
return function () {
|
|
123
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
124
|
+
args[_key2] = arguments[_key2];
|
|
125
|
+
}
|
|
126
|
+
const vals = args.slice(0, numberOfArrays);
|
|
127
|
+
const idx = _transformDims(args[numberOfArrays]);
|
|
128
|
+
const rest = args.slice(numberOfArrays + 1);
|
|
129
|
+
return callbackFunction(...vals, idx, ...rest);
|
|
130
|
+
};
|
|
131
|
+
} else {
|
|
132
|
+
return callbackFunction;
|
|
75
133
|
}
|
|
76
|
-
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Transforms the dimensions by adding 1 to each dimension.
|
|
138
|
+
*
|
|
139
|
+
* @param {Array} dims - The dimensions to transform.
|
|
140
|
+
* @returns {Array} The transformed dimensions.
|
|
141
|
+
*/
|
|
142
|
+
function _transformDims(dims) {
|
|
143
|
+
return dims.map(dim => dim.isBigNumber ? dim.plus(1) : dim + 1);
|
|
77
144
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dimToZeroBase = dimToZeroBase;
|
|
7
|
+
exports.isNumberOrBigNumber = isNumberOrBigNumber;
|
|
8
|
+
var _is = require("../../../utils/is.js");
|
|
9
|
+
/**
|
|
10
|
+
* Change last argument dim from one-based to zero-based.
|
|
11
|
+
*/
|
|
12
|
+
function dimToZeroBase(dim) {
|
|
13
|
+
if ((0, _is.isNumber)(dim)) {
|
|
14
|
+
return dim - 1;
|
|
15
|
+
} else if ((0, _is.isBigNumber)(dim)) {
|
|
16
|
+
return dim.minus(1);
|
|
17
|
+
} else {
|
|
18
|
+
return dim;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function isNumberOrBigNumber(n) {
|
|
22
|
+
return (0, _is.isNumber)(n) || (0, _is.isBigNumber)(n);
|
|
23
|
+
}
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.lastDimToZeroBase = lastDimToZeroBase;
|
|
7
7
|
var _is = require("../../../utils/is.js");
|
|
8
|
+
var _dimToZeroBase = require("./dimToZeroBase.js");
|
|
8
9
|
/**
|
|
9
10
|
* Change last argument dim from one-based to zero-based.
|
|
10
11
|
*/
|
|
@@ -12,10 +13,8 @@ function lastDimToZeroBase(args) {
|
|
|
12
13
|
if (args.length === 2 && (0, _is.isCollection)(args[0])) {
|
|
13
14
|
args = args.slice();
|
|
14
15
|
const dim = args[1];
|
|
15
|
-
if ((0,
|
|
16
|
-
args[1] = dim
|
|
17
|
-
} else if ((0, _is.isBigNumber)(dim)) {
|
|
18
|
-
args[1] = dim.minus(1);
|
|
16
|
+
if ((0, _dimToZeroBase.isNumberOrBigNumber)(dim)) {
|
|
17
|
+
args[1] = (0, _dimToZeroBase.dimToZeroBase)(dim);
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
return args;
|