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.
Files changed (214) hide show
  1. package/HISTORY.md +26 -1
  2. package/lib/browser/math.js +1 -1
  3. package/lib/browser/math.js.LICENSE.txt +2 -2
  4. package/lib/browser/math.js.map +1 -1
  5. package/lib/cjs/core/create.js +12 -9
  6. package/lib/cjs/core/function/import.js +1 -1
  7. package/lib/cjs/core/function/typed.js +3 -4
  8. package/lib/cjs/entry/dependenciesAny/dependenciesFlatten.generated.js +0 -2
  9. package/lib/cjs/entry/dependenciesAny/dependenciesSqueeze.generated.js +0 -2
  10. package/lib/cjs/entry/impureFunctionsAny.generated.js +2 -2
  11. package/lib/cjs/entry/pureFunctionsAny.generated.js +6 -8
  12. package/lib/cjs/entry/typeChecks.js +18 -0
  13. package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +2 -2
  14. package/lib/cjs/expression/embeddedDocs/function/arithmetic/hypot.js +1 -1
  15. package/lib/cjs/expression/embeddedDocs/function/matrix/diff.js +1 -1
  16. package/lib/cjs/expression/embeddedDocs/function/matrix/fft.js +1 -1
  17. package/lib/cjs/expression/embeddedDocs/function/matrix/ifft.js +1 -1
  18. package/lib/cjs/expression/embeddedDocs/function/matrix/kron.js +1 -1
  19. package/lib/cjs/expression/embeddedDocs/function/matrix/map.js +3 -3
  20. package/lib/cjs/expression/embeddedDocs/function/special/zeta.js +1 -1
  21. package/lib/cjs/expression/embeddedDocs/function/statistics/quantileSeq.js +1 -1
  22. package/lib/cjs/expression/embeddedDocs/function/trigonometry/acoth.js +1 -1
  23. package/lib/cjs/expression/embeddedDocs/function/trigonometry/acsch.js +1 -1
  24. package/lib/cjs/expression/embeddedDocs/function/utils/clone.js +1 -1
  25. package/lib/cjs/expression/function/evaluate.js +5 -0
  26. package/lib/cjs/expression/node/FunctionNode.js +1 -1
  27. package/lib/cjs/expression/transform/filter.transform.js +2 -2
  28. package/lib/cjs/expression/transform/map.transform.js +104 -37
  29. package/lib/cjs/expression/transform/utils/dimToZeroBase.js +23 -0
  30. package/lib/cjs/expression/transform/utils/lastDimToZeroBase.js +3 -4
  31. package/lib/cjs/function/arithmetic/hypot.js +3 -3
  32. package/lib/cjs/function/matrix/apply.js +1 -1
  33. package/lib/cjs/function/matrix/fft.js +3 -3
  34. package/lib/cjs/function/matrix/filter.js +2 -2
  35. package/lib/cjs/function/matrix/flatten.js +5 -6
  36. package/lib/cjs/function/matrix/ifft.js +2 -2
  37. package/lib/cjs/function/matrix/kron.js +4 -4
  38. package/lib/cjs/function/matrix/map.js +109 -18
  39. package/lib/cjs/function/matrix/size.js +7 -7
  40. package/lib/cjs/function/matrix/squeeze.js +3 -4
  41. package/lib/cjs/function/probability/random.js +1 -1
  42. package/lib/cjs/function/probability/randomInt.js +1 -1
  43. package/lib/cjs/function/statistics/cumsum.js +2 -2
  44. package/lib/cjs/function/trigonometry/acoth.js +2 -2
  45. package/lib/cjs/function/trigonometry/acsch.js +2 -2
  46. package/lib/cjs/header.js +2 -2
  47. package/lib/cjs/type/matrix/DenseMatrix.js +3 -28
  48. package/lib/cjs/type/matrix/SparseMatrix.js +5 -8
  49. package/lib/cjs/type/unit/Unit.js +57 -114
  50. package/lib/cjs/utils/array.js +27 -0
  51. package/lib/cjs/utils/collection.js +1 -1
  52. package/lib/cjs/utils/function.js +0 -14
  53. package/lib/cjs/utils/is.js +27 -0
  54. package/lib/cjs/utils/map.js +2 -20
  55. package/lib/cjs/version.js +1 -1
  56. package/lib/esm/core/create.js +9 -6
  57. package/lib/esm/core/function/import.js +1 -1
  58. package/lib/esm/core/function/typed.js +2 -3
  59. package/lib/esm/entry/dependenciesAny/dependenciesFlatten.generated.js +0 -2
  60. package/lib/esm/entry/dependenciesAny/dependenciesSqueeze.generated.js +0 -2
  61. package/lib/esm/entry/impureFunctionsAny.generated.js +3 -3
  62. package/lib/esm/entry/pureFunctionsAny.generated.js +7 -9
  63. package/lib/esm/entry/typeChecks.js +1 -1
  64. package/lib/esm/expression/embeddedDocs/embeddedDocs.js +2 -2
  65. package/lib/esm/expression/embeddedDocs/function/arithmetic/hypot.js +1 -1
  66. package/lib/esm/expression/embeddedDocs/function/matrix/diff.js +1 -1
  67. package/lib/esm/expression/embeddedDocs/function/matrix/fft.js +1 -1
  68. package/lib/esm/expression/embeddedDocs/function/matrix/ifft.js +1 -1
  69. package/lib/esm/expression/embeddedDocs/function/matrix/kron.js +1 -1
  70. package/lib/esm/expression/embeddedDocs/function/matrix/map.js +3 -3
  71. package/lib/esm/expression/embeddedDocs/function/special/zeta.js +1 -1
  72. package/lib/esm/expression/embeddedDocs/function/statistics/quantileSeq.js +1 -1
  73. package/lib/esm/expression/embeddedDocs/function/trigonometry/acoth.js +1 -1
  74. package/lib/esm/expression/embeddedDocs/function/trigonometry/acsch.js +1 -1
  75. package/lib/esm/expression/embeddedDocs/function/utils/clone.js +1 -1
  76. package/lib/esm/expression/function/compile.js +1 -1
  77. package/lib/esm/expression/function/evaluate.js +8 -3
  78. package/lib/esm/expression/node/FunctionNode.js +1 -1
  79. package/lib/esm/expression/parse.js +2 -2
  80. package/lib/esm/expression/transform/filter.transform.js +4 -4
  81. package/lib/esm/expression/transform/forEach.transform.js +4 -4
  82. package/lib/esm/expression/transform/map.transform.js +104 -37
  83. package/lib/esm/expression/transform/print.transform.js +2 -2
  84. package/lib/esm/expression/transform/utils/dimToZeroBase.js +16 -0
  85. package/lib/esm/expression/transform/utils/lastDimToZeroBase.js +4 -6
  86. package/lib/esm/function/algebra/decomposition/slu.js +1 -1
  87. package/lib/esm/function/algebra/derivative.js +15 -15
  88. package/lib/esm/function/algebra/lyap.js +4 -4
  89. package/lib/esm/function/algebra/simplify/util.js +3 -3
  90. package/lib/esm/function/algebra/simplifyConstant.js +9 -9
  91. package/lib/esm/function/algebra/solver/lsolve.js +3 -3
  92. package/lib/esm/function/algebra/solver/lsolveAll.js +3 -3
  93. package/lib/esm/function/algebra/solver/lusolve.js +5 -5
  94. package/lib/esm/function/algebra/solver/usolve.js +3 -3
  95. package/lib/esm/function/algebra/solver/usolveAll.js +3 -3
  96. package/lib/esm/function/algebra/sylvester.js +7 -7
  97. package/lib/esm/function/arithmetic/addScalar.js +4 -4
  98. package/lib/esm/function/arithmetic/ceil.js +6 -6
  99. package/lib/esm/function/arithmetic/divide.js +5 -5
  100. package/lib/esm/function/arithmetic/divideScalar.js +5 -5
  101. package/lib/esm/function/arithmetic/fix.js +5 -5
  102. package/lib/esm/function/arithmetic/floor.js +6 -6
  103. package/lib/esm/function/arithmetic/hypot.js +3 -3
  104. package/lib/esm/function/arithmetic/mod.js +3 -3
  105. package/lib/esm/function/arithmetic/multiply.js +7 -7
  106. package/lib/esm/function/arithmetic/multiplyScalar.js +4 -4
  107. package/lib/esm/function/arithmetic/norm.js +2 -2
  108. package/lib/esm/function/arithmetic/pow.js +6 -6
  109. package/lib/esm/function/arithmetic/round.js +7 -7
  110. package/lib/esm/function/arithmetic/subtractScalar.js +4 -4
  111. package/lib/esm/function/arithmetic/xgcd.js +1 -1
  112. package/lib/esm/function/combinatorics/bellNumbers.js +1 -1
  113. package/lib/esm/function/combinatorics/catalan.js +1 -1
  114. package/lib/esm/function/combinatorics/composition.js +1 -1
  115. package/lib/esm/function/combinatorics/stirlingS2.js +1 -1
  116. package/lib/esm/function/geometry/distance.js +4 -4
  117. package/lib/esm/function/geometry/intersect.js +2 -2
  118. package/lib/esm/function/logical/and.js +2 -2
  119. package/lib/esm/function/logical/or.js +2 -2
  120. package/lib/esm/function/logical/xor.js +2 -2
  121. package/lib/esm/function/matrix/apply.js +2 -2
  122. package/lib/esm/function/matrix/column.js +1 -1
  123. package/lib/esm/function/matrix/concat.js +1 -1
  124. package/lib/esm/function/matrix/count.js +1 -1
  125. package/lib/esm/function/matrix/cross.js +3 -3
  126. package/lib/esm/function/matrix/diag.js +10 -10
  127. package/lib/esm/function/matrix/diff.js +2 -2
  128. package/lib/esm/function/matrix/eigs.js +3 -3
  129. package/lib/esm/function/matrix/fft.js +3 -3
  130. package/lib/esm/function/matrix/filter.js +4 -4
  131. package/lib/esm/function/matrix/flatten.js +5 -6
  132. package/lib/esm/function/matrix/forEach.js +4 -4
  133. package/lib/esm/function/matrix/identity.js +6 -6
  134. package/lib/esm/function/matrix/ifft.js +3 -3
  135. package/lib/esm/function/matrix/inv.js +1 -1
  136. package/lib/esm/function/matrix/kron.js +7 -7
  137. package/lib/esm/function/matrix/map.js +110 -19
  138. package/lib/esm/function/matrix/matrixFromFunction.js +6 -6
  139. package/lib/esm/function/matrix/ones.js +2 -2
  140. package/lib/esm/function/matrix/partitionSelect.js +2 -2
  141. package/lib/esm/function/matrix/pinv.js +1 -1
  142. package/lib/esm/function/matrix/range.js +10 -10
  143. package/lib/esm/function/matrix/reshape.js +2 -2
  144. package/lib/esm/function/matrix/rotate.js +4 -4
  145. package/lib/esm/function/matrix/rotationMatrix.js +6 -6
  146. package/lib/esm/function/matrix/row.js +1 -1
  147. package/lib/esm/function/matrix/size.js +8 -8
  148. package/lib/esm/function/matrix/sort.js +4 -4
  149. package/lib/esm/function/matrix/sqrtm.js +1 -1
  150. package/lib/esm/function/matrix/squeeze.js +3 -4
  151. package/lib/esm/function/matrix/subset.js +2 -2
  152. package/lib/esm/function/matrix/zeros.js +2 -2
  153. package/lib/esm/function/probability/combinations.js +1 -1
  154. package/lib/esm/function/probability/combinationsWithRep.js +2 -2
  155. package/lib/esm/function/probability/kldivergence.js +4 -4
  156. package/lib/esm/function/probability/multinomial.js +1 -1
  157. package/lib/esm/function/probability/permutations.js +2 -2
  158. package/lib/esm/function/probability/pickRandom.js +6 -6
  159. package/lib/esm/function/probability/random.js +1 -1
  160. package/lib/esm/function/probability/randomInt.js +1 -1
  161. package/lib/esm/function/relational/compare.js +6 -6
  162. package/lib/esm/function/relational/deepEqual.js +1 -1
  163. package/lib/esm/function/relational/equal.js +1 -1
  164. package/lib/esm/function/relational/equalScalar.js +7 -7
  165. package/lib/esm/function/relational/equalText.js +1 -1
  166. package/lib/esm/function/relational/larger.js +3 -3
  167. package/lib/esm/function/relational/largerEq.js +4 -4
  168. package/lib/esm/function/relational/smaller.js +3 -3
  169. package/lib/esm/function/relational/smallerEq.js +3 -3
  170. package/lib/esm/function/relational/unequal.js +1 -1
  171. package/lib/esm/function/set/setCartesian.js +1 -1
  172. package/lib/esm/function/set/setDifference.js +1 -1
  173. package/lib/esm/function/set/setDistinct.js +1 -1
  174. package/lib/esm/function/set/setIntersect.js +1 -1
  175. package/lib/esm/function/set/setIsSubset.js +1 -1
  176. package/lib/esm/function/set/setMultiplicity.js +1 -1
  177. package/lib/esm/function/set/setPowerset.js +1 -1
  178. package/lib/esm/function/set/setSize.js +2 -2
  179. package/lib/esm/function/set/setSymDifference.js +1 -1
  180. package/lib/esm/function/set/setUnion.js +1 -1
  181. package/lib/esm/function/signal/freqz.js +6 -6
  182. package/lib/esm/function/statistics/corr.js +2 -2
  183. package/lib/esm/function/statistics/cumsum.js +3 -3
  184. package/lib/esm/function/statistics/max.js +1 -1
  185. package/lib/esm/function/statistics/median.js +3 -3
  186. package/lib/esm/function/statistics/min.js +1 -1
  187. package/lib/esm/function/statistics/prod.js +1 -1
  188. package/lib/esm/function/statistics/variance.js +2 -2
  189. package/lib/esm/function/string/bin.js +2 -2
  190. package/lib/esm/function/string/hex.js +2 -2
  191. package/lib/esm/function/string/oct.js +2 -2
  192. package/lib/esm/function/trigonometry/acoth.js +2 -2
  193. package/lib/esm/function/trigonometry/acsch.js +2 -2
  194. package/lib/esm/type/bigint.js +1 -1
  195. package/lib/esm/type/complex/function/complex.js +2 -2
  196. package/lib/esm/type/fraction/function/fraction.js +1 -1
  197. package/lib/esm/type/matrix/DenseMatrix.js +13 -38
  198. package/lib/esm/type/matrix/SparseMatrix.js +5 -8
  199. package/lib/esm/type/matrix/function/index.js +1 -1
  200. package/lib/esm/type/matrix/function/matrix.js +1 -1
  201. package/lib/esm/type/matrix/function/sparse.js +2 -2
  202. package/lib/esm/type/number.js +1 -1
  203. package/lib/esm/type/unit/Unit.js +57 -114
  204. package/lib/esm/type/unit/function/createUnit.js +3 -3
  205. package/lib/esm/type/unit/function/splitUnit.js +1 -1
  206. package/lib/esm/type/unit/function/unit.js +2 -2
  207. package/lib/esm/utils/array.js +26 -0
  208. package/lib/esm/utils/collection.js +1 -1
  209. package/lib/esm/utils/function.js +0 -13
  210. package/lib/esm/utils/is.js +24 -0
  211. package/lib/esm/utils/map.js +2 -19
  212. package/lib/esm/version.js +1 -1
  213. package/package.json +19 -19
  214. 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 kronecker product of 2 matrices or vectors.
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 kronecker product of `x` and `y`
36
+ * @return {Array | Matrix} Returns the Kronecker product of `x` and `y`
37
37
  */
38
38
  return typed(name, {
39
- 'Matrix, Matrix': function MatrixMatrix(x, y) {
39
+ 'Matrix, Matrix': function Matrix_Matrix(x, y) {
40
40
  return matrix(_kron(x.toArray(), y.toArray()));
41
41
  },
42
- 'Matrix, Array': function MatrixArray(x, y) {
42
+ 'Matrix, Array': function Matrix_Array(x, y) {
43
43
  return matrix(_kron(x.toArray(), y));
44
44
  },
45
- 'Array, Matrix': function ArrayMatrix(x, y) {
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 kronecker product of two matrices / vectors
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 kronecker product of x and y
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, the callback is invoked with three arguments:
14
- * the value of the entry, the index at which that entry occurs, and the full
15
- * matrix/array being traversed. Note that because the matrix/array might be
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': _map,
47
- 'Matrix, function': function MatrixFunction(x, callback) {
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 _map(array, callback) {
61
- var recurse = function recurse(value, index) {
62
- if (Array.isArray(value)) {
63
- return value.map(function (child, i) {
64
- // we create a copy of the index array and append the new index value
65
- return recurse(child, index.concat(i));
66
- });
67
- } else {
68
- // invoke the callback function with the right number of arguments
69
- return applyCallback(callback, value, index, array, 'map');
70
- }
71
- };
72
- return recurse(array, []);
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 ArrayMatrixFunctionStringString(size, fn, format, datatype) {
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 ArrayMatrixFunctionString(size, fn, format) {
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 MatrixFunction(size, fn) {
46
+ 'Matrix, function': function Matrix_function(size, fn) {
47
47
  return _create(size, fn, 'dense');
48
48
  },
49
- 'Array, function': function ArrayFunction(size, fn) {
49
+ 'Array, function': function Array_function(size, fn) {
50
50
  return _create(size, fn, 'dense').toArray();
51
51
  },
52
- 'Array | Matrix, string, function': function ArrayMatrixStringFunction(size, format, fn) {
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 ArrayMatrixStringStringFunction(size, format, datatype, fn) {
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 numberBigNumberString(size) {
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 ArrayMatrixString(size, format) {
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 ArrayMatrixNumber(x, k) {
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 ArrayMatrixNumberString(x, k, compare) {
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 ArrayMatrix(x) {
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 numberNumber(start, end) {
68
+ 'number, number': function number_number(start, end) {
69
69
  return _out(_range(start, end, 1, false));
70
70
  },
71
- 'number, number, number': function numberNumberNumber(start, end, step) {
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 numberNumberBoolean(start, end, includeEnd) {
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 numberNumberNumberBoolean(start, end, step, includeEnd) {
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 BigNumberBigNumber(start, end) {
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 BigNumberBigNumberBigNumber(start, end, step) {
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 BigNumberBigNumberBoolean(start, end, includeEnd) {
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 BigNumberBigNumberBigNumberBoolean(start, end, step, includeEnd) {
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 UnitUnitUnit(start, end, step) {
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 UnitUnitUnitBoolean(start, end, step, includeEnd) {
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 MatrixArray(x, sizes) {
51
+ 'Matrix, Array': function Matrix_Array(x, sizes) {
52
52
  return x.reshape(sizes, true);
53
53
  },
54
- 'Array, Array': function ArrayArray(x, sizes) {
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 ArrayNumberBigNumberComplexUnit(w, theta) {
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 MatrixNumberBigNumberComplexUnit(w, theta) {
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 ArrayNumberBigNumberComplexUnitArrayMatrix(w, theta, v) {
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 MatrixNumberBigNumberComplexUnitArrayMatrix(w, theta, v) {
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 numberBigNumberComplexUnit(theta) {
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 numberBigNumberComplexUnitString(theta, format) {
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 numberBigNumberComplexUnitArray(theta, v) {
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 numberBigNumberComplexUnitMatrix(theta, v) {
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 numberBigNumberComplexUnitArrayString(theta, v, format) {
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 numberBigNumberComplexUnitMatrixString(theta, v, format) {
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 ArrayNumber(value, row) {
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) // returns []
22
- * math.size('hello world') // returns [11]
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) // returns [2, 3]
26
- * math.size(math.range(1,6)) // returns [5]
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 numberComplexBigNumberUnitBooleanNull(x) {
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 ArrayFunction(x, _comparator) {
55
+ 'Array, function': function Array_function(x, _comparator) {
56
56
  _arrayIsVector(x);
57
57
  return x.sort(_comparator);
58
58
  },
59
- 'Matrix, function': function MatrixFunction(x, _comparator) {
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 ArrayString(x, order) {
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 MatrixString(x, order) {
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 ArrayMatrix(A) {
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', 'matrix'];
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) ? matrix(res) : 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 MatrixIndex(value, index) {
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 MatrixIndexAnyAny(value, index, replacement, defaultValue) {
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 numberBigNumberString(size) {
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 ArrayMatrixString(size, format) {
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 BigNumberBigNumber(n, k) {
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 numberNumber(n, k) {
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 BigNumberBigNumber(n, k) {
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 ArrayArray(q, p) {
33
+ 'Array, Array': function Array_Array(q, p) {
34
34
  return _kldiv(matrix(q), matrix(p));
35
35
  },
36
- 'Matrix, Array': function MatrixArray(q, p) {
36
+ 'Matrix, Array': function Matrix_Array(q, p) {
37
37
  return _kldiv(q, matrix(p));
38
38
  },
39
- 'Array, Matrix': function ArrayMatrix(q, p) {
39
+ 'Array, Matrix': function Array_Matrix(q, p) {
40
40
  return _kldiv(matrix(q), p);
41
41
  },
42
- 'Matrix, Matrix': function MatrixMatrix(q, p) {
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 ArrayMatrix(a) {
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 numberNumber(n, k) {
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 BigNumberBigNumber(n, k) {
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');