mathjs 14.2.1 → 14.3.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 (73) hide show
  1. package/HISTORY.md +16 -0
  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/entry/dependenciesAny/dependenciesMax.generated.js +2 -0
  6. package/lib/cjs/entry/dependenciesAny/dependenciesMaxTransform.generated.js +2 -0
  7. package/lib/cjs/entry/dependenciesAny/dependenciesMin.generated.js +2 -0
  8. package/lib/cjs/entry/dependenciesAny/dependenciesMinTransform.generated.js +2 -0
  9. package/lib/cjs/entry/dependenciesNumber/dependenciesMax.generated.js +2 -0
  10. package/lib/cjs/entry/dependenciesNumber/dependenciesMaxTransform.generated.js +2 -0
  11. package/lib/cjs/entry/dependenciesNumber/dependenciesMin.generated.js +2 -0
  12. package/lib/cjs/entry/dependenciesNumber/dependenciesMinTransform.generated.js +2 -0
  13. package/lib/cjs/entry/impureFunctionsAny.generated.js +2 -0
  14. package/lib/cjs/entry/impureFunctionsNumber.generated.js +2 -0
  15. package/lib/cjs/entry/pureFunctionsAny.generated.js +2 -0
  16. package/lib/cjs/entry/pureFunctionsNumber.generated.js +2 -0
  17. package/lib/cjs/expression/embeddedDocs/function/matrix/mapSlices.js +1 -1
  18. package/lib/cjs/expression/embeddedDocs/function/relational/larger.js +1 -1
  19. package/lib/cjs/expression/embeddedDocs/function/relational/smaller.js +1 -1
  20. package/lib/cjs/expression/embeddedDocs/function/statistics/max.js +1 -1
  21. package/lib/cjs/expression/embeddedDocs/function/statistics/min.js +1 -1
  22. package/lib/cjs/expression/transform/max.transform.js +5 -3
  23. package/lib/cjs/expression/transform/min.transform.js +5 -3
  24. package/lib/cjs/expression/transform/variance.transform.js +2 -2
  25. package/lib/cjs/function/matrix/flatten.js +1 -1
  26. package/lib/cjs/function/matrix/forEach.js +1 -1
  27. package/lib/cjs/function/matrix/map.js +1 -1
  28. package/lib/cjs/function/matrix/partitionSelect.js +2 -2
  29. package/lib/cjs/function/statistics/max.js +5 -4
  30. package/lib/cjs/function/statistics/min.js +5 -4
  31. package/lib/cjs/function/statistics/mode.js +2 -2
  32. package/lib/cjs/function/statistics/variance.js +2 -2
  33. package/lib/cjs/header.js +2 -2
  34. package/lib/cjs/type/matrix/DenseMatrix.js +45 -48
  35. package/lib/cjs/utils/array.js +120 -48
  36. package/lib/cjs/utils/collection.js +14 -15
  37. package/lib/cjs/utils/optimizeCallback.js +19 -2
  38. package/lib/cjs/version.js +1 -1
  39. package/lib/esm/entry/dependenciesAny/dependenciesMax.generated.js +2 -0
  40. package/lib/esm/entry/dependenciesAny/dependenciesMaxTransform.generated.js +2 -0
  41. package/lib/esm/entry/dependenciesAny/dependenciesMin.generated.js +2 -0
  42. package/lib/esm/entry/dependenciesAny/dependenciesMinTransform.generated.js +2 -0
  43. package/lib/esm/entry/dependenciesNumber/dependenciesMax.generated.js +2 -0
  44. package/lib/esm/entry/dependenciesNumber/dependenciesMaxTransform.generated.js +2 -0
  45. package/lib/esm/entry/dependenciesNumber/dependenciesMin.generated.js +2 -0
  46. package/lib/esm/entry/dependenciesNumber/dependenciesMinTransform.generated.js +2 -0
  47. package/lib/esm/entry/impureFunctionsAny.generated.js +2 -0
  48. package/lib/esm/entry/impureFunctionsNumber.generated.js +2 -0
  49. package/lib/esm/entry/pureFunctionsAny.generated.js +2 -0
  50. package/lib/esm/entry/pureFunctionsNumber.generated.js +2 -0
  51. package/lib/esm/expression/embeddedDocs/function/matrix/mapSlices.js +1 -1
  52. package/lib/esm/expression/embeddedDocs/function/relational/larger.js +1 -1
  53. package/lib/esm/expression/embeddedDocs/function/relational/smaller.js +1 -1
  54. package/lib/esm/expression/embeddedDocs/function/statistics/max.js +1 -1
  55. package/lib/esm/expression/embeddedDocs/function/statistics/min.js +1 -1
  56. package/lib/esm/expression/transform/max.transform.js +5 -3
  57. package/lib/esm/expression/transform/min.transform.js +5 -3
  58. package/lib/esm/expression/transform/variance.transform.js +2 -2
  59. package/lib/esm/function/matrix/flatten.js +1 -1
  60. package/lib/esm/function/matrix/forEach.js +2 -2
  61. package/lib/esm/function/matrix/map.js +2 -2
  62. package/lib/esm/function/matrix/partitionSelect.js +2 -2
  63. package/lib/esm/function/statistics/max.js +5 -4
  64. package/lib/esm/function/statistics/min.js +5 -4
  65. package/lib/esm/function/statistics/mode.js +2 -2
  66. package/lib/esm/function/statistics/variance.js +2 -2
  67. package/lib/esm/type/matrix/DenseMatrix.js +46 -49
  68. package/lib/esm/utils/array.js +118 -47
  69. package/lib/esm/utils/collection.js +15 -16
  70. package/lib/esm/utils/optimizeCallback.js +19 -2
  71. package/lib/esm/version.js +1 -1
  72. package/package.json +9 -9
  73. package/types/index.d.ts +2 -1
@@ -11,6 +11,8 @@ exports.broadcastTo = broadcastTo;
11
11
  exports.checkBroadcastingRules = checkBroadcastingRules;
12
12
  exports.clone = clone;
13
13
  exports.concat = concat;
14
+ exports.deepForEach = deepForEach;
15
+ exports.deepMap = deepMap;
14
16
  exports.filter = filter;
15
17
  exports.filterRegExp = filterRegExp;
16
18
  exports.flatten = flatten;
@@ -25,7 +27,6 @@ exports.join = join;
25
27
  exports.last = last;
26
28
  exports.map = map;
27
29
  exports.processSizesWildcard = processSizesWildcard;
28
- exports.recurse = recurse;
29
30
  exports.reshape = reshape;
30
31
  exports.resize = resize;
31
32
  exports.squeeze = squeeze;
@@ -46,7 +47,7 @@ var _object = require("./object.js");
46
47
  * This function checks the size of the first entry, it does not validate
47
48
  * whether all dimensions match. (use function `validate` for that)
48
49
  * @param {Array} x
49
- * @Return {Number[]} size
50
+ * @return {number[]} size
50
51
  */
51
52
  function arraySize(x) {
52
53
  const s = [];
@@ -62,7 +63,7 @@ function arraySize(x) {
62
63
  * has a size corresponding to the provided size array.
63
64
  * @param {Array} array Array to be validated
64
65
  * @param {number[]} size Array with the size of each dimension
65
- * @param {number} dim Current dimension
66
+ * @param {number} dim Current dimension
66
67
  * @throws DimensionError
67
68
  * @private
68
69
  */
@@ -83,7 +84,7 @@ function _validate(array, size, dim) {
83
84
  _validate(array[i], size, dimNext);
84
85
  }
85
86
  } else {
86
- // last dimension. none of the childs may be an array
87
+ // last dimension. none of the children may be an array
87
88
  for (i = 0; i < len; i++) {
88
89
  if (Array.isArray(array[i])) {
89
90
  throw new _DimensionError.DimensionError(size.length + 1, size.length, '>');
@@ -114,7 +115,7 @@ function validate(array, size) {
114
115
 
115
116
  /**
116
117
  * Validate whether the source of the index matches the size of the Array
117
- * @param {Array | Matrix} array Array to be validated
118
+ * @param {Array | Matrix} value Array to be validated
118
119
  * @param {Index} index Index with the source information to validate
119
120
  * @throws DimensionError
120
121
  */
@@ -147,8 +148,8 @@ function validateIndex(index, length) {
147
148
  }
148
149
 
149
150
  /**
150
- * Test if and index has empty values
151
- * @param {number} index Zero-based index
151
+ * Test if an index has empty values
152
+ * @param {Index} index Zero-based index
152
153
  */
153
154
  function isEmptyIndex(index) {
154
155
  for (let i = 0; i < index._dimensions.length; ++i) {
@@ -174,7 +175,7 @@ function isEmptyIndex(index) {
174
175
  * Resize a multi dimensional array. The resized array is returned.
175
176
  * @param {Array | number} array Array to be resized
176
177
  * @param {number[]} size Array with the size of each dimension
177
- * @param {*} [defaultValue=0] Value to be filled in in new entries,
178
+ * @param {*} [defaultValue=0] Value to be filled in new entries,
178
179
  * zero by default. Specify for example `null`,
179
180
  * to clearly see entries that are not explicitly
180
181
  * set.
@@ -212,7 +213,7 @@ function resize(array, size, defaultValue) {
212
213
  * @param {Array} array Array to be resized
213
214
  * @param {number[]} size Array with the size of each dimension
214
215
  * @param {number} dim Current dimension
215
- * @param {*} [defaultValue] Value to be filled in in new entries,
216
+ * @param {*} [defaultValue] Value to be filled in new entries,
216
217
  * undefined by default.
217
218
  * @private
218
219
  */
@@ -302,7 +303,7 @@ function reshape(array, sizes) {
302
303
 
303
304
  /**
304
305
  * Replaces the wildcard -1 in the sizes array.
305
- * @param {number[]} sizes List of sizes for each dimension. At most on wildcard.
306
+ * @param {number[]} sizes List of sizes for each dimension. At most one wildcard.
306
307
  * @param {number} currentLength Number of elements in the array.
307
308
  * @throws {Error} If more than one wildcard or unable to replace it.
308
309
  * @returns {number[]} The sizes array with wildcard replaced.
@@ -349,7 +350,7 @@ function _reshape(array, sizes) {
349
350
  // testing if there are enough elements for the requested shape
350
351
  let tmpArray = array;
351
352
  let tmpArray2;
352
- // for each dimensions starting by the last one and ignoring the first one
353
+ // for each dimension starting by the last one and ignoring the first one
353
354
  for (let sizeIndex = sizes.length - 1; sizeIndex > 0; sizeIndex--) {
354
355
  const size = sizes[sizeIndex];
355
356
  tmpArray2 = [];
@@ -420,7 +421,7 @@ function _squeeze(array, dims, dim) {
420
421
  /**
421
422
  * Unsqueeze a multi dimensional array: add dimensions when missing
422
423
  *
423
- * Paramter `size` will be mutated to match the new, unqueezed matrix size.
424
+ * Parameter `size` will be mutated to match the new, unsqueezed matrix size.
424
425
  *
425
426
  * @param {Array} array
426
427
  * @param {number} dims Desired number of dimensions of the array
@@ -453,7 +454,7 @@ function unsqueeze(array, dims, outer, size) {
453
454
  * @param {Array} array
454
455
  * @param {number} dims Required number of dimensions
455
456
  * @param {number} dim Current dimension
456
- * @returns {Array | *} Returns the squeezed array
457
+ * @returns {Array | *} Returns the unsqueezed array
457
458
  * @private
458
459
  */
459
460
  function _unsqueeze(array, dims, dim) {
@@ -523,7 +524,7 @@ function filter(array, callback) {
523
524
  }
524
525
 
525
526
  /**
526
- * Filter values in a callback given a regular expression
527
+ * Filter values in an array given a regular expression
527
528
  * @param {Array} array
528
529
  * @param {RegExp} regexp
529
530
  * @return {Array} Returns the filtered array
@@ -637,7 +638,7 @@ function getArrayDataType(array, typeOf) {
637
638
 
638
639
  /**
639
640
  * Return the last item from an array
640
- * @param {array}
641
+ * @param {Array} array
641
642
  * @returns {*}
642
643
  */
643
644
  function last(array) {
@@ -646,8 +647,8 @@ function last(array) {
646
647
 
647
648
  /**
648
649
  * Get all but the last element of array.
649
- * @param {array}
650
- * @returns {*}
650
+ * @param {Array} array
651
+ * @returns {Array}
651
652
  */
652
653
  function initial(array) {
653
654
  return array.slice(0, array.length - 1);
@@ -655,7 +656,7 @@ function initial(array) {
655
656
 
656
657
  /**
657
658
  * Recursively concatenate two matrices.
658
- * The contents of the matrices is not cloned.
659
+ * The contents of the matrices are not cloned.
659
660
  * @param {Array} a Multi dimensional array
660
661
  * @param {Array} b Multi dimensional array
661
662
  * @param {number} concatDim The dimension on which to concatenate (zero-based)
@@ -684,8 +685,8 @@ function concatRecursive(a, b, concatDim, dim) {
684
685
  * Concatenates many arrays in the specified direction
685
686
  * @param {...Array} arrays All the arrays to concatenate
686
687
  * @param {number} concatDim The dimension on which to concatenate (zero-based)
687
- * @returns
688
- */
688
+ * @returns {Array}
689
+ */
689
690
  function concat() {
690
691
  const arrays = Array.prototype.slice.call(arguments, 0, -1);
691
692
  const concatDim = Array.prototype.slice.call(arguments, -1);
@@ -702,9 +703,9 @@ function concat() {
702
703
  }
703
704
 
704
705
  /**
705
- * Receives two or more sizes and get's the broadcasted size for both.
706
+ * Receives two or more sizes and gets the broadcasted size for both.
706
707
  * @param {...number[]} sizes Sizes to broadcast together
707
- * @returns
708
+ * @returns {number[]} The broadcasted size
708
709
  */
709
710
  function broadcastSizes() {
710
711
  for (var _len = arguments.length, sizes = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -741,16 +742,16 @@ function checkBroadcastingRules(size, toSize) {
741
742
  for (let j = 0; j < dim; j++) {
742
743
  const n = N - dim + j;
743
744
  if (size[j] < toSize[n] && size[j] > 1 || size[j] > toSize[n]) {
744
- throw new Error(`shape missmatch: missmatch is found in arg with shape (${size}) not possible to broadcast dimension ${dim} with size ${size[j]} to size ${toSize[n]}`);
745
+ throw new Error(`shape mismatch: mismatch is found in arg with shape (${size}) not possible to broadcast dimension ${dim} with size ${size[j]} to size ${toSize[n]}`);
745
746
  }
746
747
  }
747
748
  }
748
749
 
749
750
  /**
750
751
  * Broadcasts a single array to a certain size
751
- * @param {array} array Array to be broadcasted
752
+ * @param {Array} array Array to be broadcasted
752
753
  * @param {number[]} toSize Size to broadcast the array
753
- * @returns The broadcasted array
754
+ * @returns {Array} The broadcasted array
754
755
  */
755
756
  function broadcastTo(array, toSize) {
756
757
  let Asize = arraySize(array);
@@ -781,14 +782,14 @@ function broadcastTo(array, toSize) {
781
782
  /**
782
783
  * Broadcasts arrays and returns the broadcasted arrays in an array
783
784
  * @param {...Array | any} arrays
784
- * @returns
785
+ * @returns {Array[]} The broadcasted arrays
785
786
  */
786
787
  function broadcastArrays() {
787
788
  for (var _len2 = arguments.length, arrays = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
788
789
  arrays[_key2] = arguments[_key2];
789
790
  }
790
791
  if (arrays.length === 0) {
791
- throw new Error('Insuficient number of argumnets in function broadcastArrays');
792
+ throw new Error('Insufficient number of arguments in function broadcastArrays');
792
793
  }
793
794
  if (arrays.length === 1) {
794
795
  return arrays[0];
@@ -805,11 +806,11 @@ function broadcastArrays() {
805
806
  }
806
807
 
807
808
  /**
808
- * stretches a matrix up to a certain size in a certain dimension
809
+ * Stretches a matrix up to a certain size in a certain dimension
809
810
  * @param {Array} arrayToStretch
810
811
  * @param {number[]} sizeToStretch
811
812
  * @param {number} dimToStretch
812
- * @returns
813
+ * @returns {Array} The stretched array
813
814
  */
814
815
  function stretch(arrayToStretch, sizeToStretch, dimToStretch) {
815
816
  return concat(...Array(sizeToStretch).fill(arrayToStretch), dimToStretch);
@@ -819,13 +820,13 @@ function stretch(arrayToStretch, sizeToStretch, dimToStretch) {
819
820
  * Retrieves a single element from an array given an index.
820
821
  *
821
822
  * @param {Array} array - The array from which to retrieve the value.
822
- * @param {Array<number>} idx - An array of indices specifying the position of the desired element in each dimension.
823
+ * @param {Array<number>} index - An array of indices specifying the position of the desired element in each dimension.
823
824
  * @returns {*} - The value at the specified position in the array.
824
825
  *
825
826
  * @example
826
827
  * const arr = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
827
828
  * const index = [1, 0, 1];
828
- * console.log(getValue(arr, index)); // 6
829
+ * console.log(get(arr, index)); // 6
829
830
  */
830
831
  function get(array, index) {
831
832
  if (!Array.isArray(array)) {
@@ -842,30 +843,101 @@ function get(array, index) {
842
843
  }
843
844
 
844
845
  /**
845
- * Recursive function to map a multi-dimensional array.
846
+ * Recursively maps over each element of nested array using a provided callback function.
846
847
  *
847
- * @param {*} value - The current value being processed in the array.
848
- * @param {Array} index - The index of the current value being processed in the array.
849
- * @param {Array} array - The array being processed.
850
- * @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.
851
- * @returns {*} The new array with each element being the result of the callback function.
852
- */
853
- function recurse(value, index, array, callback) {
854
- if (Array.isArray(value)) {
855
- return value.map(function (child, i) {
856
- // we create a copy of the index array and append the new index value
857
- return recurse(child, index.concat(i), array, callback);
858
- });
859
- } else {
860
- // invoke the callback function with the right number of arguments
861
- return callback(value, index, array);
848
+ * @param {Array} array - The array to be mapped.
849
+ * @param {Function} callback - The function to execute on each element, taking three arguments:
850
+ * - `value` (any): The current element being processed in the array.
851
+ * - `index` (Array<number>): The index of the current element being processed in the array.
852
+ * - `array` (Array): The array `deepMap` was called upon.
853
+ * @param {boolean} [skipIndex=false] - If true, the callback function is called with only the value.
854
+ * @returns {Array} A new array with each element being the result of the callback function.
855
+ */
856
+ function deepMap(array, callback) {
857
+ let skipIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
858
+ if (array.length === 0) {
859
+ return [];
860
+ }
861
+ if (skipIndex) {
862
+ return recursiveMap(array);
863
+ }
864
+ const index = [];
865
+ return recursiveMapWithIndex(array, 0);
866
+ function recursiveMapWithIndex(value, depth) {
867
+ if (Array.isArray(value)) {
868
+ const N = value.length;
869
+ const result = Array(N);
870
+ for (let i = 0; i < N; i++) {
871
+ index[depth] = i;
872
+ result[i] = recursiveMapWithIndex(value[i], depth + 1);
873
+ }
874
+ return result;
875
+ } else {
876
+ return callback(value, index.slice(0, depth), array);
877
+ }
878
+ }
879
+ function recursiveMap(value) {
880
+ if (Array.isArray(value)) {
881
+ const N = value.length;
882
+ const result = Array(N);
883
+ for (let i = 0; i < N; i++) {
884
+ result[i] = recursiveMap(value[i]);
885
+ }
886
+ return result;
887
+ } else {
888
+ return callback(value);
889
+ }
890
+ }
891
+ }
892
+
893
+ /**
894
+ * Recursively iterates over each element in a multi-dimensional array and applies a callback function.
895
+ *
896
+ * @param {Array} array - The multi-dimensional array to iterate over.
897
+ * @param {Function} callback - The function to execute for each element. It receives three arguments:
898
+ * - {any} value: The current element being processed in the array.
899
+ * - {Array<number>} index: The index of the current element in each dimension.
900
+ * - {Array} array: The original array being processed.
901
+ * @param {boolean} [skipIndex=false] - If true, the callback function is called with only the value.
902
+ */
903
+ function deepForEach(array, callback) {
904
+ let skipIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
905
+ if (array.length === 0) {
906
+ return;
907
+ }
908
+ if (skipIndex) {
909
+ recursiveForEach(array);
910
+ return;
911
+ }
912
+ const index = [];
913
+ recursiveForEachWithIndex(array, 0);
914
+ function recursiveForEachWithIndex(value, depth) {
915
+ if (Array.isArray(value)) {
916
+ const N = value.length;
917
+ for (let i = 0; i < N; i++) {
918
+ index[depth] = i;
919
+ recursiveForEachWithIndex(value[i], depth + 1);
920
+ }
921
+ } else {
922
+ callback(value, index.slice(0, depth), array);
923
+ }
924
+ }
925
+ function recursiveForEach(value) {
926
+ if (Array.isArray(value)) {
927
+ const N = value.length;
928
+ for (let i = 0; i < N; i++) {
929
+ recursiveForEach(value[i]);
930
+ }
931
+ } else {
932
+ callback(value);
933
+ }
862
934
  }
863
935
  }
864
936
 
865
937
  /**
866
938
  * Deep clones a multidimensional array
867
939
  * @param {Array} array
868
- * @returns cloned array
940
+ * @returns {Array} cloned array
869
941
  */
870
942
  function clone(array) {
871
943
  return (0, _extends2.default)([], array);
@@ -36,15 +36,9 @@ function containsCollections(array) {
36
36
  */
37
37
  function deepForEach(array, callback) {
38
38
  if ((0, _is.isMatrix)(array)) {
39
- array = array.valueOf();
40
- }
41
- for (let i = 0, ii = array.length; i < ii; i++) {
42
- const value = array[i];
43
- if (Array.isArray(value)) {
44
- deepForEach(value, callback);
45
- } else {
46
- callback(value);
47
- }
39
+ array.forEach(x => callback(x));
40
+ } else {
41
+ (0, _array.deepForEach)(array, callback, true);
48
42
  }
49
43
  }
50
44
 
@@ -61,13 +55,18 @@ function deepForEach(array, callback) {
61
55
  * @return {Array | Matrix} res
62
56
  */
63
57
  function deepMap(array, callback, skipZeros) {
64
- if (array && typeof array.map === 'function') {
65
- // TODO: replace array.map with a for loop to improve performance
66
- return array.map(function (x) {
67
- return deepMap(x, callback, skipZeros);
68
- });
58
+ if (!skipZeros) {
59
+ if ((0, _is.isMatrix)(array)) {
60
+ return array.map(x => callback(x));
61
+ } else {
62
+ return (0, _array.deepMap)(array, callback, true);
63
+ }
64
+ }
65
+ const skipZerosCallback = x => x === 0 ? x : callback(x);
66
+ if ((0, _is.isMatrix)(array)) {
67
+ return array.map(x => skipZerosCallback(x));
69
68
  } else {
70
- return callback(array);
69
+ return (0, _array.deepMap)(array, skipZerosCallback, true);
71
70
  }
72
71
  }
73
72
 
@@ -20,9 +20,14 @@ function optimizeCallback(callback, array, name) {
20
20
  if (_typedFunction.default.isTypedFunction(callback)) {
21
21
  const firstIndex = (array.isMatrix ? array.size() : (0, _array.arraySize)(array)).map(() => 0);
22
22
  const firstValue = array.isMatrix ? array.get(firstIndex) : (0, _array.get)(array, firstIndex);
23
- const hasSingleSignature = Object.keys(callback.signatures).length === 1;
24
23
  const numberOfArguments = _findNumberOfArguments(callback, firstValue, firstIndex, array);
25
- const fastCallback = hasSingleSignature ? Object.values(callback.signatures)[0] : callback;
24
+ let fastCallback;
25
+ if (array.isMatrix && array.dataType !== 'mixed' && array.dataType !== undefined) {
26
+ const singleSignature = _findSingleSignatureWithArity(callback, numberOfArguments);
27
+ fastCallback = singleSignature !== undefined ? singleSignature : callback;
28
+ } else {
29
+ fastCallback = callback;
30
+ }
26
31
  if (numberOfArguments >= 1 && numberOfArguments <= 3) {
27
32
  return function () {
28
33
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -40,6 +45,18 @@ function optimizeCallback(callback, array, name) {
40
45
  }
41
46
  return callback;
42
47
  }
48
+ function _findSingleSignatureWithArity(callback, arity) {
49
+ const matchingFunctions = [];
50
+ Object.entries(callback.signatures).forEach(_ref => {
51
+ let [signature, func] = _ref;
52
+ if (signature.split(',').length === arity) {
53
+ matchingFunctions.push(func);
54
+ }
55
+ });
56
+ if (matchingFunctions.length === 1) {
57
+ return matchingFunctions[0];
58
+ }
59
+ }
43
60
  function _findNumberOfArguments(callback, value, index, array) {
44
61
  const testArgs = [value, index, array];
45
62
  for (let i = 3; i > 0; i--) {
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = void 0;
7
- const version = exports.version = '14.2.1';
7
+ const version = exports.version = '14.3.0';
8
8
  // Note: This file is automatically generated when building math.js.
9
9
  // Changes made in this file will be overwritten.
@@ -2,11 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
+ import { isNaNDependencies } from './dependenciesIsNaN.generated.js';
5
6
  import { largerDependencies } from './dependenciesLarger.generated.js';
6
7
  import { numericDependencies } from './dependenciesNumeric.generated.js';
7
8
  import { typedDependencies } from './dependenciesTyped.generated.js';
8
9
  import { createMax } from '../../factoriesAny.js';
9
10
  export var maxDependencies = {
11
+ isNaNDependencies,
10
12
  largerDependencies,
11
13
  numericDependencies,
12
14
  typedDependencies,
@@ -2,11 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
+ import { isNaNDependencies } from './dependenciesIsNaN.generated.js';
5
6
  import { largerDependencies } from './dependenciesLarger.generated.js';
6
7
  import { numericDependencies } from './dependenciesNumeric.generated.js';
7
8
  import { typedDependencies } from './dependenciesTyped.generated.js';
8
9
  import { createMaxTransform } from '../../factoriesAny.js';
9
10
  export var maxTransformDependencies = {
11
+ isNaNDependencies,
10
12
  largerDependencies,
11
13
  numericDependencies,
12
14
  typedDependencies,
@@ -2,11 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
+ import { isNaNDependencies } from './dependenciesIsNaN.generated.js';
5
6
  import { numericDependencies } from './dependenciesNumeric.generated.js';
6
7
  import { smallerDependencies } from './dependenciesSmaller.generated.js';
7
8
  import { typedDependencies } from './dependenciesTyped.generated.js';
8
9
  import { createMin } from '../../factoriesAny.js';
9
10
  export var minDependencies = {
11
+ isNaNDependencies,
10
12
  numericDependencies,
11
13
  smallerDependencies,
12
14
  typedDependencies,
@@ -2,11 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
+ import { isNaNDependencies } from './dependenciesIsNaN.generated.js';
5
6
  import { numericDependencies } from './dependenciesNumeric.generated.js';
6
7
  import { smallerDependencies } from './dependenciesSmaller.generated.js';
7
8
  import { typedDependencies } from './dependenciesTyped.generated.js';
8
9
  import { createMinTransform } from '../../factoriesAny.js';
9
10
  export var minTransformDependencies = {
11
+ isNaNDependencies,
10
12
  numericDependencies,
11
13
  smallerDependencies,
12
14
  typedDependencies,
@@ -2,11 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
+ import { isNaNDependencies } from './dependenciesIsNaN.generated.js';
5
6
  import { largerDependencies } from './dependenciesLarger.generated.js';
6
7
  import { numericDependencies } from './dependenciesNumeric.generated.js';
7
8
  import { typedDependencies } from './dependenciesTyped.generated.js';
8
9
  import { createMax } from '../../factoriesNumber.js';
9
10
  export var maxDependencies = {
11
+ isNaNDependencies,
10
12
  largerDependencies,
11
13
  numericDependencies,
12
14
  typedDependencies,
@@ -2,11 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
+ import { isNaNDependencies } from './dependenciesIsNaN.generated.js';
5
6
  import { largerDependencies } from './dependenciesLarger.generated.js';
6
7
  import { numericDependencies } from './dependenciesNumeric.generated.js';
7
8
  import { typedDependencies } from './dependenciesTyped.generated.js';
8
9
  import { createMaxTransform } from '../../factoriesNumber.js';
9
10
  export var maxTransformDependencies = {
11
+ isNaNDependencies,
10
12
  largerDependencies,
11
13
  numericDependencies,
12
14
  typedDependencies,
@@ -2,11 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
+ import { isNaNDependencies } from './dependenciesIsNaN.generated.js';
5
6
  import { numericDependencies } from './dependenciesNumeric.generated.js';
6
7
  import { smallerDependencies } from './dependenciesSmaller.generated.js';
7
8
  import { typedDependencies } from './dependenciesTyped.generated.js';
8
9
  import { createMin } from '../../factoriesNumber.js';
9
10
  export var minDependencies = {
11
+ isNaNDependencies,
10
12
  numericDependencies,
11
13
  smallerDependencies,
12
14
  typedDependencies,
@@ -2,11 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
+ import { isNaNDependencies } from './dependenciesIsNaN.generated.js';
5
6
  import { numericDependencies } from './dependenciesNumeric.generated.js';
6
7
  import { smallerDependencies } from './dependenciesSmaller.generated.js';
7
8
  import { typedDependencies } from './dependenciesTyped.generated.js';
8
9
  import { createMinTransform } from '../../factoriesNumber.js';
9
10
  export var minTransformDependencies = {
11
+ isNaNDependencies,
10
12
  numericDependencies,
11
13
  smallerDependencies,
12
14
  typedDependencies,
@@ -610,6 +610,7 @@ _extends(mathWithTransform, math, {
610
610
  }),
611
611
  min: createMinTransform({
612
612
  config,
613
+ isNaN,
613
614
  numeric,
614
615
  smaller,
615
616
  typed
@@ -641,6 +642,7 @@ _extends(mathWithTransform, math, {
641
642
  }),
642
643
  max: createMaxTransform({
643
644
  config,
645
+ isNaN,
644
646
  larger,
645
647
  numeric,
646
648
  typed
@@ -448,12 +448,14 @@ _extends(mathWithTransform, math, {
448
448
  }),
449
449
  max: createMaxTransform({
450
450
  config,
451
+ isNaN,
451
452
  larger,
452
453
  numeric,
453
454
  typed
454
455
  }),
455
456
  min: createMinTransform({
456
457
  config,
458
+ isNaN,
457
459
  numeric,
458
460
  smaller,
459
461
  typed
@@ -740,12 +740,14 @@ export var matrixFromColumns = /* #__PURE__ */createMatrixFromColumns({
740
740
  });
741
741
  export var max = /* #__PURE__ */createMax({
742
742
  config,
743
+ isNaN,
743
744
  larger,
744
745
  numeric,
745
746
  typed
746
747
  });
747
748
  export var min = /* #__PURE__ */createMin({
748
749
  config,
750
+ isNaN,
749
751
  numeric,
750
752
  smaller,
751
753
  typed
@@ -596,12 +596,14 @@ export var corr = /* #__PURE__ */createCorr({
596
596
  });
597
597
  export var max = /* #__PURE__ */createMax({
598
598
  config,
599
+ isNaN,
599
600
  larger,
600
601
  numeric,
601
602
  typed
602
603
  });
603
604
  export var min = /* #__PURE__ */createMin({
604
605
  config,
606
+ isNaN,
605
607
  numeric,
606
608
  smaller,
607
609
  typed
@@ -5,7 +5,7 @@ export var mapSlicesDocs = {
5
5
  description: 'Generate a matrix one dimension less than A by applying callback to ' + 'each slice of A along dimension dim.',
6
6
  examples: ['A = [[1, 2], [3, 4]]', 'mapSlices(A, 1, sum)',
7
7
  // returns [4, 6]
8
- 'mapSlices(A, 2, product)' // returns [2, 12]
8
+ 'mapSlices(A, 2, prod)' // returns [2, 12]
9
9
  ],
10
10
  seealso: ['map', 'forEach']
11
11
  };
@@ -2,7 +2,7 @@ export var largerDocs = {
2
2
  name: 'larger',
3
3
  category: 'Relational',
4
4
  syntax: ['x > y', 'larger(x, y)'],
5
- description: 'Check if value x is larger than y. Returns true if x is larger than y, and false if not.',
5
+ description: 'Check if value x is larger than y. Returns true if x is larger than y, and false if not. Comparing a value with NaN returns false.',
6
6
  examples: ['2 > 3', '5 > 2*2', 'a = 3.3', 'b = 6-2.8', '(a > b)', '(b < a)', '5 cm > 2 inch'],
7
7
  seealso: ['equal', 'unequal', 'smaller', 'smallerEq', 'largerEq', 'compare']
8
8
  };
@@ -2,7 +2,7 @@ export var smallerDocs = {
2
2
  name: 'smaller',
3
3
  category: 'Relational',
4
4
  syntax: ['x < y', 'smaller(x, y)'],
5
- description: 'Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.',
5
+ description: 'Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not. Comparing a value with NaN returns false.',
6
6
  examples: ['2 < 3', '5 < 2*2', 'a = 3.3', 'b = 6-2.8', '(a < b)', '5 cm < 2 inch'],
7
7
  seealso: ['equal', 'unequal', 'larger', 'smallerEq', 'largerEq', 'compare']
8
8
  };