mathjs 13.0.2 → 13.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -9,7 +9,7 @@ export var createKron = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
9
9
|
multiplyScalar
|
10
10
|
} = _ref;
|
11
11
|
/**
|
12
|
-
* Calculates the
|
12
|
+
* Calculates the Kronecker product of 2 matrices or vectors.
|
13
13
|
*
|
14
14
|
* NOTE: If a one dimensional vector / matrix is given, it will be
|
15
15
|
* wrapped so its two dimensions.
|
@@ -33,26 +33,26 @@ export var createKron = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
33
33
|
*
|
34
34
|
* @param {Array | Matrix} x First vector
|
35
35
|
* @param {Array | Matrix} y Second vector
|
36
|
-
* @return {Array | Matrix} Returns the
|
36
|
+
* @return {Array | Matrix} Returns the Kronecker product of `x` and `y`
|
37
37
|
*/
|
38
38
|
return typed(name, {
|
39
|
-
'Matrix, Matrix': function
|
39
|
+
'Matrix, Matrix': function Matrix_Matrix(x, y) {
|
40
40
|
return matrix(_kron(x.toArray(), y.toArray()));
|
41
41
|
},
|
42
|
-
'Matrix, Array': function
|
42
|
+
'Matrix, Array': function Matrix_Array(x, y) {
|
43
43
|
return matrix(_kron(x.toArray(), y));
|
44
44
|
},
|
45
|
-
'Array, Matrix': function
|
45
|
+
'Array, Matrix': function Array_Matrix(x, y) {
|
46
46
|
return matrix(_kron(x, y.toArray()));
|
47
47
|
},
|
48
48
|
'Array, Array': _kron
|
49
49
|
});
|
50
50
|
|
51
51
|
/**
|
52
|
-
* Calculate the
|
52
|
+
* Calculate the Kronecker product of two matrices / vectors
|
53
53
|
* @param {Array} a First vector
|
54
54
|
* @param {Array} b Second vector
|
55
|
-
* @returns {Array} Returns the
|
55
|
+
* @returns {Array} Returns the Kronecker product of x and y
|
56
56
|
* @private
|
57
57
|
*/
|
58
58
|
function _kron(a, b) {
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { applyCallback } from '../../utils/applyCallback.js';
|
2
|
+
import { arraySize, broadcastSizes, broadcastTo, get } from '../../utils/array.js';
|
2
3
|
import { factory } from '../../utils/factory.js';
|
3
4
|
var name = 'map';
|
4
5
|
var dependencies = ['typed'];
|
@@ -10,9 +11,12 @@ export var createMap = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
10
11
|
* Create a new matrix or array with the results of a callback function executed on
|
11
12
|
* each entry of a given matrix/array.
|
12
13
|
*
|
13
|
-
* For each entry of the input,
|
14
|
-
*
|
15
|
-
*
|
14
|
+
* For each entry of the input,
|
15
|
+
*
|
16
|
+
* the callback is invoked with 2N + 1 arguments:
|
17
|
+
* the N values of the entry, the index at which that entry occurs, and the N full
|
18
|
+
* broadcasted matrix/array being traversed where N is the number of matrices being traversed.
|
19
|
+
* Note that because the matrix/array might be
|
16
20
|
* multidimensional, the "index" argument is always an array of numbers giving
|
17
21
|
* the index in each dimension. This is true even for vectors: the "index"
|
18
22
|
* argument is an array of length 1, rather than simply a number.
|
@@ -20,17 +24,23 @@ export var createMap = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
20
24
|
* Syntax:
|
21
25
|
*
|
22
26
|
* math.map(x, callback)
|
27
|
+
* math.map(x, y, ..., callback)
|
23
28
|
*
|
24
29
|
* Examples:
|
25
30
|
*
|
26
31
|
* math.map([1, 2, 3], function(value) {
|
27
32
|
* return value * value
|
28
33
|
* }) // returns [1, 4, 9]
|
34
|
+
* math.map([1, 2], [3, 4], function(a, b) {
|
35
|
+
* return a + b
|
36
|
+
* }) // returns [4, 6]
|
29
37
|
*
|
30
38
|
* // The callback is normally called with three arguments:
|
31
39
|
* // callback(value, index, Array)
|
32
40
|
* // If you want to call with only one argument, use:
|
33
41
|
* math.map([1, 2, 3], x => math.format(x)) // returns ['1', '2', '3']
|
42
|
+
* // It can also be called with 2N + 1 arguments: for N arrays
|
43
|
+
* // callback(value1, value2, index, BroadcastedArray1, BroadcastedArray2)
|
34
44
|
*
|
35
45
|
* See also:
|
36
46
|
*
|
@@ -43,11 +53,82 @@ export var createMap = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
43
53
|
* Transformed map of x; always has the same type and shape as x
|
44
54
|
*/
|
45
55
|
return typed(name, {
|
46
|
-
'Array, function':
|
47
|
-
'Matrix, function': function
|
56
|
+
'Array, function': _mapArray,
|
57
|
+
'Matrix, function': function Matrix_function(x, callback) {
|
48
58
|
return x.map(callback);
|
49
|
-
}
|
59
|
+
},
|
60
|
+
'Array|Matrix, Array|Matrix, ...Array|Matrix|function': (A, B, rest) => _mapMultiple([A, B, ...rest.slice(0, rest.length - 1)], rest[rest.length - 1])
|
50
61
|
});
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Maps over multiple arrays or matrices.
|
65
|
+
*
|
66
|
+
* @param {Array<Array|Matrix>} Arrays - An array of arrays or matrices to map over.
|
67
|
+
* @param {function} multiCallback - The callback function to apply to each element.
|
68
|
+
* @throws {Error} If the last argument is not a callback function.
|
69
|
+
* @returns {Array|Matrix} A new array or matrix with each element being the result of the callback function.
|
70
|
+
*
|
71
|
+
* @example
|
72
|
+
* _mapMultiple([[1, 2, 3], [4, 5, 6]], (a, b) => a + b); // Returns [5, 7, 9]
|
73
|
+
*/
|
74
|
+
function _mapMultiple(Arrays, multiCallback) {
|
75
|
+
if (typeof multiCallback !== 'function') {
|
76
|
+
throw new Error('Last argument must be a callback function');
|
77
|
+
}
|
78
|
+
var firstArrayIsMatrix = Arrays[0].isMatrix;
|
79
|
+
var newSize = broadcastSizes(...Arrays.map(M => M.isMatrix ? M.size() : arraySize(M)));
|
80
|
+
var _get = firstArrayIsMatrix ? (matrix, idx) => matrix.get(idx) : get;
|
81
|
+
var broadcastedArrays = firstArrayIsMatrix ? Arrays.map(M => M.isMatrix ? M.create(broadcastTo(M.toArray(), newSize), M.datatype()) : Arrays[0].create(broadcastTo(M.valueOf(), newSize))) : Arrays.map(M => M.isMatrix ? broadcastTo(M.toArray(), newSize) : broadcastTo(M, newSize));
|
82
|
+
var callback;
|
83
|
+
if (typed.isTypedFunction(multiCallback)) {
|
84
|
+
var firstIndex = newSize.map(() => 0);
|
85
|
+
var firstValues = broadcastedArrays.map(array => _get(array, firstIndex));
|
86
|
+
var callbackCase = _getTypedCallbackCase(multiCallback, firstValues, firstIndex, broadcastedArrays);
|
87
|
+
callback = _getLimitedCallback(callbackCase);
|
88
|
+
} else {
|
89
|
+
var numberOfArrays = Arrays.length;
|
90
|
+
var _callbackCase = _getCallbackCase(multiCallback, numberOfArrays);
|
91
|
+
callback = _getLimitedCallback(_callbackCase);
|
92
|
+
}
|
93
|
+
var broadcastedArraysCallback = (x, idx) => callback([x, ...broadcastedArrays.slice(1).map(Array => _get(Array, idx))], idx);
|
94
|
+
if (firstArrayIsMatrix) {
|
95
|
+
return broadcastedArrays[0].map(broadcastedArraysCallback);
|
96
|
+
} else {
|
97
|
+
return _mapArray(broadcastedArrays[0], broadcastedArraysCallback);
|
98
|
+
}
|
99
|
+
function _getLimitedCallback(callbackCase) {
|
100
|
+
switch (callbackCase) {
|
101
|
+
case 0:
|
102
|
+
return x => multiCallback(...x);
|
103
|
+
case 1:
|
104
|
+
return (x, idx) => multiCallback(...x, idx);
|
105
|
+
case 2:
|
106
|
+
return (x, idx) => multiCallback(...x, idx, ...broadcastedArrays);
|
107
|
+
}
|
108
|
+
}
|
109
|
+
function _getCallbackCase(callback, numberOfArrays) {
|
110
|
+
if (callback.length > numberOfArrays + 1) {
|
111
|
+
return 2;
|
112
|
+
}
|
113
|
+
if (callback.length === numberOfArrays + 1) {
|
114
|
+
return 1;
|
115
|
+
}
|
116
|
+
return 0;
|
117
|
+
}
|
118
|
+
function _getTypedCallbackCase(callback, values, idx, arrays) {
|
119
|
+
if (typed.resolve(callback, [...values, idx, ...arrays]) !== null) {
|
120
|
+
return 2;
|
121
|
+
}
|
122
|
+
if (typed.resolve(callback, [...values, idx]) !== null) {
|
123
|
+
return 1;
|
124
|
+
}
|
125
|
+
if (typed.resolve(callback, values) !== null) {
|
126
|
+
return 0;
|
127
|
+
}
|
128
|
+
// this should never happen
|
129
|
+
return 0;
|
130
|
+
}
|
131
|
+
}
|
51
132
|
});
|
52
133
|
|
53
134
|
/**
|
@@ -57,17 +138,27 @@ export var createMap = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
57
138
|
* @return {Array}
|
58
139
|
* @private
|
59
140
|
*/
|
60
|
-
function
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
141
|
+
function _mapArray(array, callback) {
|
142
|
+
return _recurse(array, [], array, callback);
|
143
|
+
}
|
144
|
+
|
145
|
+
/**
|
146
|
+
* Recursive function to map a multi-dimensional array.
|
147
|
+
*
|
148
|
+
* @param {*} value - The current value being processed in the array.
|
149
|
+
* @param {Array} index - The index of the current value being processed in the array.
|
150
|
+
* @param {Array} array - The array being processed.
|
151
|
+
* @param {Function} callback - Function that produces the element of the new Array, taking three arguments: the value of the element, the index of the element, and the Array being processed.
|
152
|
+
* @returns {*} The new array with each element being the result of the callback function.
|
153
|
+
*/
|
154
|
+
function _recurse(value, index, array, callback) {
|
155
|
+
if (Array.isArray(value)) {
|
156
|
+
return value.map(function (child, i) {
|
157
|
+
// we create a copy of the index array and append the new index value
|
158
|
+
return _recurse(child, index.concat(i), array, callback);
|
159
|
+
});
|
160
|
+
} else {
|
161
|
+
// invoke the callback function with the right number of arguments
|
162
|
+
return applyCallback(callback, value, index, array, 'map');
|
163
|
+
}
|
73
164
|
}
|
@@ -37,22 +37,22 @@ export var createMatrixFromFunction = /* #__PURE__ */factory(name, dependencies,
|
|
37
37
|
* @return {Array | Matrix} Returns the created matrix
|
38
38
|
*/
|
39
39
|
return typed(name, {
|
40
|
-
'Array | Matrix, function, string, string': function
|
40
|
+
'Array | Matrix, function, string, string': function Array__Matrix_function_string_string(size, fn, format, datatype) {
|
41
41
|
return _create(size, fn, format, datatype);
|
42
42
|
},
|
43
|
-
'Array | Matrix, function, string': function
|
43
|
+
'Array | Matrix, function, string': function Array__Matrix_function_string(size, fn, format) {
|
44
44
|
return _create(size, fn, format);
|
45
45
|
},
|
46
|
-
'Matrix, function': function
|
46
|
+
'Matrix, function': function Matrix_function(size, fn) {
|
47
47
|
return _create(size, fn, 'dense');
|
48
48
|
},
|
49
|
-
'Array, function': function
|
49
|
+
'Array, function': function Array_function(size, fn) {
|
50
50
|
return _create(size, fn, 'dense').toArray();
|
51
51
|
},
|
52
|
-
'Array | Matrix, string, function': function
|
52
|
+
'Array | Matrix, string, function': function Array__Matrix_string_function(size, format, fn) {
|
53
53
|
return _create(size, fn, format);
|
54
54
|
},
|
55
|
-
'Array | Matrix, string, string, function': function
|
55
|
+
'Array | Matrix, string, string, function': function Array__Matrix_string_string_function(size, format, datatype, fn) {
|
56
56
|
return _create(size, fn, format, datatype);
|
57
57
|
}
|
58
58
|
});
|
@@ -51,7 +51,7 @@ export var createOnes = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
51
51
|
},
|
52
52
|
// math.ones(m, n, p, ..., format)
|
53
53
|
// TODO: more accurate signature '...number | BigNumber, string' as soon as typed-function supports this
|
54
|
-
'...number | BigNumber | string': function
|
54
|
+
'...number | BigNumber | string': function number__BigNumber__string(size) {
|
55
55
|
var last = size[size.length - 1];
|
56
56
|
if (typeof last === 'string') {
|
57
57
|
var format = size.pop();
|
@@ -67,7 +67,7 @@ export var createOnes = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
67
67
|
var format = size.storage();
|
68
68
|
return _ones(size.valueOf(), format);
|
69
69
|
},
|
70
|
-
'Array | Matrix, string': function
|
70
|
+
'Array | Matrix, string': function Array__Matrix_string(size, format) {
|
71
71
|
return _ones(size.valueOf(), format);
|
72
72
|
}
|
73
73
|
});
|
@@ -51,10 +51,10 @@ export var createPartitionSelect = /* #__PURE__ */factory(name, dependencies, _r
|
|
51
51
|
* @return {*} Returns the kth lowest value.
|
52
52
|
*/
|
53
53
|
return typed(name, {
|
54
|
-
'Array | Matrix, number': function
|
54
|
+
'Array | Matrix, number': function Array__Matrix_number(x, k) {
|
55
55
|
return _partitionSelect(x, k, asc);
|
56
56
|
},
|
57
|
-
'Array | Matrix, number, string': function
|
57
|
+
'Array | Matrix, number, string': function Array__Matrix_number_string(x, k, compare) {
|
58
58
|
if (compare === 'asc') {
|
59
59
|
return _partitionSelect(x, k, asc);
|
60
60
|
} else if (compare === 'desc') {
|
@@ -41,7 +41,7 @@ export var createPinv = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
41
41
|
* @return {number | Complex | Array | Matrix} The inverse of `x`.
|
42
42
|
*/
|
43
43
|
return typed(name, {
|
44
|
-
'Array | Matrix': function
|
44
|
+
'Array | Matrix': function Array__Matrix(x) {
|
45
45
|
var size = isMatrix(x) ? x.size() : arraySize(x);
|
46
46
|
switch (size.length) {
|
47
47
|
case 1:
|
@@ -65,36 +65,36 @@ export var createRange = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
65
65
|
// TODO: a number or boolean should not be converted to string here
|
66
66
|
string: _strRange,
|
67
67
|
'string, boolean': _strRange,
|
68
|
-
'number, number': function
|
68
|
+
'number, number': function number_number(start, end) {
|
69
69
|
return _out(_range(start, end, 1, false));
|
70
70
|
},
|
71
|
-
'number, number, number': function
|
71
|
+
'number, number, number': function number_number_number(start, end, step) {
|
72
72
|
return _out(_range(start, end, step, false));
|
73
73
|
},
|
74
|
-
'number, number, boolean': function
|
74
|
+
'number, number, boolean': function number_number_boolean(start, end, includeEnd) {
|
75
75
|
return _out(_range(start, end, 1, includeEnd));
|
76
76
|
},
|
77
|
-
'number, number, number, boolean': function
|
77
|
+
'number, number, number, boolean': function number_number_number_boolean(start, end, step, includeEnd) {
|
78
78
|
return _out(_range(start, end, step, includeEnd));
|
79
79
|
},
|
80
|
-
'BigNumber, BigNumber': function
|
80
|
+
'BigNumber, BigNumber': function BigNumber_BigNumber(start, end) {
|
81
81
|
var BigNumber = start.constructor;
|
82
82
|
return _out(_range(start, end, new BigNumber(1), false));
|
83
83
|
},
|
84
|
-
'BigNumber, BigNumber, BigNumber': function
|
84
|
+
'BigNumber, BigNumber, BigNumber': function BigNumber_BigNumber_BigNumber(start, end, step) {
|
85
85
|
return _out(_range(start, end, step, false));
|
86
86
|
},
|
87
|
-
'BigNumber, BigNumber, boolean': function
|
87
|
+
'BigNumber, BigNumber, boolean': function BigNumber_BigNumber_boolean(start, end, includeEnd) {
|
88
88
|
var BigNumber = start.constructor;
|
89
89
|
return _out(_range(start, end, new BigNumber(1), includeEnd));
|
90
90
|
},
|
91
|
-
'BigNumber, BigNumber, BigNumber, boolean': function
|
91
|
+
'BigNumber, BigNumber, BigNumber, boolean': function BigNumber_BigNumber_BigNumber_boolean(start, end, step, includeEnd) {
|
92
92
|
return _out(_range(start, end, step, includeEnd));
|
93
93
|
},
|
94
|
-
'Unit, Unit, Unit': function
|
94
|
+
'Unit, Unit, Unit': function Unit_Unit_Unit(start, end, step) {
|
95
95
|
return _out(_range(start, end, step, false));
|
96
96
|
},
|
97
|
-
'Unit, Unit, Unit, boolean': function
|
97
|
+
'Unit, Unit, Unit, boolean': function Unit_Unit_Unit_boolean(start, end, step, includeEnd) {
|
98
98
|
return _out(_range(start, end, step, includeEnd));
|
99
99
|
}
|
100
100
|
});
|
@@ -48,10 +48,10 @@ export var createReshape = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
48
48
|
* not equal that of the old ones
|
49
49
|
*/
|
50
50
|
return typed(name, {
|
51
|
-
'Matrix, Array': function
|
51
|
+
'Matrix, Array': function Matrix_Array(x, sizes) {
|
52
52
|
return x.reshape(sizes, true);
|
53
53
|
},
|
54
|
-
'Array, Array': function
|
54
|
+
'Array, Array': function Array_Array(x, sizes) {
|
55
55
|
sizes.forEach(function (size) {
|
56
56
|
if (!isInteger(size)) {
|
57
57
|
throw new TypeError('Invalid size for dimension: ' + size);
|
@@ -37,21 +37,21 @@ export var createRotate = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
37
37
|
* @return {Array | Matrix} Multiplication of the rotation matrix and w
|
38
38
|
*/
|
39
39
|
return typed(name, {
|
40
|
-
'Array , number | BigNumber | Complex | Unit': function
|
40
|
+
'Array , number | BigNumber | Complex | Unit': function Array__number__BigNumber__Complex__Unit(w, theta) {
|
41
41
|
_validateSize(w, 2);
|
42
42
|
var matrixRes = multiply(rotationMatrix(theta), w);
|
43
43
|
return matrixRes.toArray();
|
44
44
|
},
|
45
|
-
'Matrix , number | BigNumber | Complex | Unit': function
|
45
|
+
'Matrix , number | BigNumber | Complex | Unit': function Matrix__number__BigNumber__Complex__Unit(w, theta) {
|
46
46
|
_validateSize(w, 2);
|
47
47
|
return multiply(rotationMatrix(theta), w);
|
48
48
|
},
|
49
|
-
'Array, number | BigNumber | Complex | Unit, Array | Matrix': function
|
49
|
+
'Array, number | BigNumber | Complex | Unit, Array | Matrix': function Array_number__BigNumber__Complex__Unit_Array__Matrix(w, theta, v) {
|
50
50
|
_validateSize(w, 3);
|
51
51
|
var matrixRes = multiply(rotationMatrix(theta, v), w);
|
52
52
|
return matrixRes;
|
53
53
|
},
|
54
|
-
'Matrix, number | BigNumber | Complex | Unit, Array | Matrix': function
|
54
|
+
'Matrix, number | BigNumber | Complex | Unit, Array | Matrix': function Matrix_number__BigNumber__Complex__Unit_Array__Matrix(w, theta, v) {
|
55
55
|
_validateSize(w, 3);
|
56
56
|
return multiply(rotationMatrix(theta, v), w);
|
57
57
|
}
|
@@ -57,28 +57,28 @@ export var createRotationMatrix = /* #__PURE__ */factory(name, dependencies, _re
|
|
57
57
|
string: function string(format) {
|
58
58
|
return matrix(format);
|
59
59
|
},
|
60
|
-
'number | BigNumber | Complex | Unit': function
|
60
|
+
'number | BigNumber | Complex | Unit': function number__BigNumber__Complex__Unit(theta) {
|
61
61
|
return _rotationMatrix2x2(theta, config.matrix === 'Matrix' ? 'dense' : undefined);
|
62
62
|
},
|
63
|
-
'number | BigNumber | Complex | Unit, string': function
|
63
|
+
'number | BigNumber | Complex | Unit, string': function number__BigNumber__Complex__Unit_string(theta, format) {
|
64
64
|
return _rotationMatrix2x2(theta, format);
|
65
65
|
},
|
66
|
-
'number | BigNumber | Complex | Unit, Array': function
|
66
|
+
'number | BigNumber | Complex | Unit, Array': function number__BigNumber__Complex__Unit_Array(theta, v) {
|
67
67
|
var matrixV = matrix(v);
|
68
68
|
_validateVector(matrixV);
|
69
69
|
return _rotationMatrix3x3(theta, matrixV, undefined);
|
70
70
|
},
|
71
|
-
'number | BigNumber | Complex | Unit, Matrix': function
|
71
|
+
'number | BigNumber | Complex | Unit, Matrix': function number__BigNumber__Complex__Unit_Matrix(theta, v) {
|
72
72
|
_validateVector(v);
|
73
73
|
var storageType = v.storage() || (config.matrix === 'Matrix' ? 'dense' : undefined);
|
74
74
|
return _rotationMatrix3x3(theta, v, storageType);
|
75
75
|
},
|
76
|
-
'number | BigNumber | Complex | Unit, Array, string': function
|
76
|
+
'number | BigNumber | Complex | Unit, Array, string': function number__BigNumber__Complex__Unit_Array_string(theta, v, format) {
|
77
77
|
var matrixV = matrix(v);
|
78
78
|
_validateVector(matrixV);
|
79
79
|
return _rotationMatrix3x3(theta, matrixV, format);
|
80
80
|
},
|
81
|
-
'number | BigNumber | Complex | Unit, Matrix, string': function
|
81
|
+
'number | BigNumber | Complex | Unit, Matrix, string': function number__BigNumber__Complex__Unit_Matrix_string(theta, v, format) {
|
82
82
|
_validateVector(v);
|
83
83
|
return _rotationMatrix3x3(theta, v, format);
|
84
84
|
}
|
@@ -34,7 +34,7 @@ export var createRow = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
34
34
|
*/
|
35
35
|
return typed(name, {
|
36
36
|
'Matrix, number': _row,
|
37
|
-
'Array, number': function
|
37
|
+
'Array, number': function Array_number(value, row) {
|
38
38
|
return _row(matrix(clone(value)), row).valueOf();
|
39
39
|
}
|
40
40
|
});
|
@@ -18,12 +18,12 @@ export var createSize = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
18
18
|
*
|
19
19
|
* Examples:
|
20
20
|
*
|
21
|
-
* math.size(2.3)
|
22
|
-
* math.size('hello world')
|
21
|
+
* math.size(2.3) // returns []
|
22
|
+
* math.size('hello world') // returns [11]
|
23
23
|
*
|
24
24
|
* const A = [[1, 2, 3], [4, 5, 6]]
|
25
|
-
* math.size(A)
|
26
|
-
* math.size(math.range(1,6))
|
25
|
+
* math.size(A) // returns [2, 3]
|
26
|
+
* math.size(math.range(1,6).toArray()) // returns [5]
|
27
27
|
*
|
28
28
|
* See also:
|
29
29
|
*
|
@@ -34,15 +34,15 @@ export var createSize = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
34
34
|
*/
|
35
35
|
return typed(name, {
|
36
36
|
Matrix: function Matrix(x) {
|
37
|
-
return x.create(x.size());
|
37
|
+
return x.create(x.size(), 'number');
|
38
38
|
},
|
39
39
|
Array: arraySize,
|
40
40
|
string: function string(x) {
|
41
|
-
return config.matrix === 'Array' ? [x.length] : matrix([x.length]);
|
41
|
+
return config.matrix === 'Array' ? [x.length] : matrix([x.length], 'dense', 'number');
|
42
42
|
},
|
43
|
-
'number | Complex | BigNumber | Unit | boolean | null': function
|
43
|
+
'number | Complex | BigNumber | Unit | boolean | null': function number__Complex__BigNumber__Unit__boolean__null(x) {
|
44
44
|
// scalar
|
45
|
-
return config.matrix === 'Array' ? [] : matrix ? matrix([]) : noMatrix();
|
45
|
+
return config.matrix === 'Array' ? [] : matrix ? matrix([], 'dense', 'number') : noMatrix();
|
46
46
|
}
|
47
47
|
});
|
48
48
|
});
|
@@ -52,19 +52,19 @@ export var createSort = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
52
52
|
_matrixIsVector(x);
|
53
53
|
return matrix(x.toArray().sort(compareAsc), x.storage());
|
54
54
|
},
|
55
|
-
'Array, function': function
|
55
|
+
'Array, function': function Array_function(x, _comparator) {
|
56
56
|
_arrayIsVector(x);
|
57
57
|
return x.sort(_comparator);
|
58
58
|
},
|
59
|
-
'Matrix, function': function
|
59
|
+
'Matrix, function': function Matrix_function(x, _comparator) {
|
60
60
|
_matrixIsVector(x);
|
61
61
|
return matrix(x.toArray().sort(_comparator), x.storage());
|
62
62
|
},
|
63
|
-
'Array, string': function
|
63
|
+
'Array, string': function Array_string(x, order) {
|
64
64
|
_arrayIsVector(x);
|
65
65
|
return x.sort(_comparator(order));
|
66
66
|
},
|
67
|
-
'Matrix, string': function
|
67
|
+
'Matrix, string': function Matrix_string(x, order) {
|
68
68
|
_matrixIsVector(x);
|
69
69
|
return matrix(x.toArray().sort(_comparator(order)), x.storage());
|
70
70
|
}
|
@@ -69,7 +69,7 @@ export var createSqrtm = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
69
69
|
* @return {Array | Matrix} The principal square root of matrix `A`
|
70
70
|
*/
|
71
71
|
return typed(name, {
|
72
|
-
'Array | Matrix': function
|
72
|
+
'Array | Matrix': function Array__Matrix(A) {
|
73
73
|
var size = isMatrix(A) ? A.size() : arraySize(A);
|
74
74
|
switch (size.length) {
|
75
75
|
case 1:
|
@@ -2,11 +2,10 @@ import { clone } from '../../utils/object.js';
|
|
2
2
|
import { squeeze as arraySqueeze } from '../../utils/array.js';
|
3
3
|
import { factory } from '../../utils/factory.js';
|
4
4
|
var name = 'squeeze';
|
5
|
-
var dependencies = ['typed'
|
5
|
+
var dependencies = ['typed'];
|
6
6
|
export var createSqueeze = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
|
-
typed
|
9
|
-
matrix
|
8
|
+
typed
|
10
9
|
} = _ref;
|
11
10
|
/**
|
12
11
|
* Squeeze a matrix, remove inner and outer singleton dimensions from a matrix.
|
@@ -44,7 +43,7 @@ export var createSqueeze = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
44
43
|
Matrix: function Matrix(x) {
|
45
44
|
var res = arraySqueeze(x.toArray());
|
46
45
|
// FIXME: return the same type of matrix as the input
|
47
|
-
return Array.isArray(res) ?
|
46
|
+
return Array.isArray(res) ? x.create(res, x.datatype()) : res;
|
48
47
|
},
|
49
48
|
any: function any(x) {
|
50
49
|
// scalar
|
@@ -62,7 +62,7 @@ export var createSubset = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
62
62
|
|
63
63
|
return typed(name, {
|
64
64
|
// get subset
|
65
|
-
'Matrix, Index': function
|
65
|
+
'Matrix, Index': function Matrix_Index(value, index) {
|
66
66
|
if (isEmptyIndex(index)) {
|
67
67
|
return matrix();
|
68
68
|
}
|
@@ -78,7 +78,7 @@ export var createSubset = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
78
78
|
'Object, Index': _getObjectProperty,
|
79
79
|
'string, Index': _getSubstring,
|
80
80
|
// set subset
|
81
|
-
'Matrix, Index, any, any': function
|
81
|
+
'Matrix, Index, any, any': function Matrix_Index_any_any(value, index, replacement, defaultValue) {
|
82
82
|
if (isEmptyIndex(index)) {
|
83
83
|
return value;
|
84
84
|
}
|
@@ -49,7 +49,7 @@ export var createZeros = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
49
49
|
},
|
50
50
|
// math.zeros(m, n, p, ..., format)
|
51
51
|
// TODO: more accurate signature '...number | BigNumber, string' as soon as typed-function supports this
|
52
|
-
'...number | BigNumber | string': function
|
52
|
+
'...number | BigNumber | string': function number__BigNumber__string(size) {
|
53
53
|
var last = size[size.length - 1];
|
54
54
|
if (typeof last === 'string') {
|
55
55
|
var format = size.pop();
|
@@ -65,7 +65,7 @@ export var createZeros = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
65
65
|
var format = size.storage();
|
66
66
|
return _zeros(size.valueOf(), format);
|
67
67
|
},
|
68
|
-
'Array | Matrix, string': function
|
68
|
+
'Array | Matrix, string': function Array__Matrix_string(size, format) {
|
69
69
|
return _zeros(size.valueOf(), format);
|
70
70
|
}
|
71
71
|
});
|
@@ -31,7 +31,7 @@ export var createCombinations = /* #__PURE__ */factory(name, dependencies, _ref
|
|
31
31
|
*/
|
32
32
|
return typed(name, {
|
33
33
|
'number, number': combinationsNumber,
|
34
|
-
'BigNumber, BigNumber': function
|
34
|
+
'BigNumber, BigNumber': function BigNumber_BigNumber(n, k) {
|
35
35
|
var BigNumber = n.constructor;
|
36
36
|
var result, i;
|
37
37
|
var nMinusk = n.minus(k);
|
@@ -31,7 +31,7 @@ export var createCombinationsWithRep = /* #__PURE__ */factory(name, dependencies
|
|
31
31
|
* @return {number | BigNumber} Number of possible combinations with replacement.
|
32
32
|
*/
|
33
33
|
return typed(name, {
|
34
|
-
'number, number': function
|
34
|
+
'number, number': function number_number(n, k) {
|
35
35
|
if (!isInteger(n) || n < 0) {
|
36
36
|
throw new TypeError('Positive integer value expected in function combinationsWithRep');
|
37
37
|
}
|
@@ -48,7 +48,7 @@ export var createCombinationsWithRep = /* #__PURE__ */factory(name, dependencies
|
|
48
48
|
var prodrange = product(k + 1, n + k - 1);
|
49
49
|
return prodrange / product(1, n - 1);
|
50
50
|
},
|
51
|
-
'BigNumber, BigNumber': function
|
51
|
+
'BigNumber, BigNumber': function BigNumber_BigNumber(n, k) {
|
52
52
|
var BigNumber = n.constructor;
|
53
53
|
var result, i;
|
54
54
|
var one = new BigNumber(1);
|
@@ -30,16 +30,16 @@ export var createKldivergence = /* #__PURE__ */factory(name, dependencies, _ref
|
|
30
30
|
* @return {number} Returns distance between q and p
|
31
31
|
*/
|
32
32
|
return typed(name, {
|
33
|
-
'Array, Array': function
|
33
|
+
'Array, Array': function Array_Array(q, p) {
|
34
34
|
return _kldiv(matrix(q), matrix(p));
|
35
35
|
},
|
36
|
-
'Matrix, Array': function
|
36
|
+
'Matrix, Array': function Matrix_Array(q, p) {
|
37
37
|
return _kldiv(q, matrix(p));
|
38
38
|
},
|
39
|
-
'Array, Matrix': function
|
39
|
+
'Array, Matrix': function Array_Matrix(q, p) {
|
40
40
|
return _kldiv(matrix(q), p);
|
41
41
|
},
|
42
|
-
'Matrix, Matrix': function
|
42
|
+
'Matrix, Matrix': function Matrix_Matrix(q, p) {
|
43
43
|
return _kldiv(q, p);
|
44
44
|
}
|
45
45
|
});
|
@@ -34,7 +34,7 @@ export var createMultinomial = /* #__PURE__ */factory(name, dependencies, _ref =
|
|
34
34
|
* @return {Number | BigNumber} Multinomial coefficient.
|
35
35
|
*/
|
36
36
|
return typed(name, {
|
37
|
-
'Array | Matrix': function
|
37
|
+
'Array | Matrix': function Array__Matrix(a) {
|
38
38
|
var sum = 0;
|
39
39
|
var denom = 1;
|
40
40
|
deepForEach(a, function (ai) {
|
@@ -35,7 +35,7 @@ export var createPermutations = /* #__PURE__ */factory(name, dependencies, _ref
|
|
35
35
|
*/
|
36
36
|
return typed(name, {
|
37
37
|
'number | BigNumber': factorial,
|
38
|
-
'number, number': function
|
38
|
+
'number, number': function number_number(n, k) {
|
39
39
|
if (!isInteger(n) || n < 0) {
|
40
40
|
throw new TypeError('Positive integer value expected in function permutations');
|
41
41
|
}
|
@@ -48,7 +48,7 @@ export var createPermutations = /* #__PURE__ */factory(name, dependencies, _ref
|
|
48
48
|
// Permute n objects, k at a time
|
49
49
|
return product(n - k + 1, n);
|
50
50
|
},
|
51
|
-
'BigNumber, BigNumber': function
|
51
|
+
'BigNumber, BigNumber': function BigNumber_BigNumber(n, k) {
|
52
52
|
var result, i;
|
53
53
|
if (!isPositiveInteger(n) || !isPositiveInteger(k)) {
|
54
54
|
throw new TypeError('Positive integer value expected in function permutations');
|