mathjs 13.0.2 → 13.1.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -12,6 +12,7 @@
12
12
  // for security reasons, so these functions are not exposed in the expression
13
13
  // parser.
14
14
 
15
+ import { ObjectWrappingMap } from './map.js';
15
16
  export function isNumber(x) {
16
17
  return typeof x === 'number';
17
18
  }
@@ -88,6 +89,29 @@ export function isRegExp(x) {
88
89
  export function isObject(x) {
89
90
  return !!(x && typeof x === 'object' && x.constructor === Object && !isComplex(x) && !isFraction(x));
90
91
  }
92
+
93
+ /**
94
+ * Returns `true` if the passed object appears to be a Map (i.e. duck typing).
95
+ *
96
+ * Methods looked for are `get`, `set`, `keys` and `has`.
97
+ *
98
+ * @param {Map | object} object
99
+ * @returns
100
+ */
101
+ export function isMap(object) {
102
+ // We can use the fast instanceof, or a slower duck typing check.
103
+ // The duck typing method needs to cover enough methods to not be confused with DenseMatrix.
104
+ if (!object) {
105
+ return false;
106
+ }
107
+ return object instanceof Map || object instanceof ObjectWrappingMap || typeof object.set === 'function' && typeof object.get === 'function' && typeof object.keys === 'function' && typeof object.has === 'function';
108
+ }
109
+ export function isPartitionedMap(object) {
110
+ return isMap(object) && isMap(object.a) && isMap(object.b);
111
+ }
112
+ export function isObjectWrappingMap(object) {
113
+ return isMap(object) && isObject(object.wrappedObject);
114
+ }
91
115
  export function isNull(x) {
92
116
  return x === null;
93
117
  }
@@ -1,5 +1,5 @@
1
- import { setSafeProperty, hasSafeProperty, getSafeProperty } from './customs.js';
2
- import { isObject } from './is.js';
1
+ import { getSafeProperty, hasSafeProperty, setSafeProperty } from './customs.js';
2
+ import { isMap, isObject } from './is.js';
3
3
 
4
4
  /**
5
5
  * A map facade on a bare object.
@@ -172,23 +172,6 @@ export function toObject(map) {
172
172
  return object;
173
173
  }
174
174
 
175
- /**
176
- * Returns `true` if the passed object appears to be a Map (i.e. duck typing).
177
- *
178
- * Methods looked for are `get`, `set`, `keys` and `has`.
179
- *
180
- * @param {Map | object} object
181
- * @returns
182
- */
183
- export function isMap(object) {
184
- // We can use the fast instanceof, or a slower duck typing check.
185
- // The duck typing method needs to cover enough methods to not be confused with DenseMatrix.
186
- if (!object) {
187
- return false;
188
- }
189
- return object instanceof Map || object instanceof ObjectWrappingMap || typeof object.set === 'function' && typeof object.get === 'function' && typeof object.keys === 'function' && typeof object.has === 'function';
190
- }
191
-
192
175
  /**
193
176
  * Copies the contents of key-value pairs from each `objects` in to `map`.
194
177
  *
@@ -1,3 +1,3 @@
1
- export var version = '13.0.2';
1
+ export var version = '13.1.0';
2
2
  // Note: This file is automatically generated when building math.js.
3
3
  // Changes made in this file will be overwritten.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mathjs",
3
- "version": "13.0.2",
3
+ "version": "13.1.0",
4
4
  "description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
5
5
  "author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
6
6
  "homepage": "https://mathjs.org",
@@ -25,7 +25,7 @@
25
25
  "unit"
26
26
  ],
27
27
  "dependencies": {
28
- "@babel/runtime": "^7.24.7",
28
+ "@babel/runtime": "^7.25.4",
29
29
  "complex.js": "^2.1.1",
30
30
  "decimal.js": "^10.4.3",
31
31
  "escape-latex": "^1.2.0",
@@ -36,48 +36,48 @@
36
36
  "typed-function": "^4.2.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/core": "7.24.7",
39
+ "@babel/core": "7.25.2",
40
40
  "@babel/plugin-transform-object-assign": "7.24.7",
41
41
  "@babel/plugin-transform-optional-catch-binding": "7.24.7",
42
- "@babel/plugin-transform-runtime": "7.24.7",
43
- "@babel/preset-env": "7.24.7",
42
+ "@babel/plugin-transform-runtime": "7.25.4",
43
+ "@babel/preset-env": "7.25.4",
44
44
  "@babel/register": "7.24.6",
45
45
  "@types/assert": "1.5.10",
46
46
  "@types/mocha": "10.0.7",
47
- "@typescript-eslint/eslint-plugin": "7.15.0",
48
- "@typescript-eslint/parser": "7.15.0",
47
+ "@typescript-eslint/eslint-plugin": "7.16.1",
48
+ "@typescript-eslint/parser": "7.16.1",
49
49
  "assert": "2.1.0",
50
50
  "babel-loader": "9.1.3",
51
51
  "benchmark": "2.1.4",
52
52
  "c8": "10.1.2",
53
53
  "codecov": "3.8.3",
54
- "core-js": "3.37.1",
54
+ "core-js": "3.38.1",
55
55
  "del": "7.1.0",
56
56
  "dtslint": "4.2.1",
57
57
  "eslint": "8.57.0",
58
58
  "eslint-config-prettier": "9.1.0",
59
59
  "eslint-config-standard": "17.1.0",
60
60
  "eslint-plugin-import": "2.29.1",
61
- "eslint-plugin-mocha": "10.4.3",
61
+ "eslint-plugin-mocha": "10.5.0",
62
62
  "eslint-plugin-n": "16.6.2",
63
- "eslint-plugin-prettier": "5.1.3",
64
- "eslint-plugin-promise": "6.4.0",
65
- "expect-type": "0.19.0",
63
+ "eslint-plugin-prettier": "5.2.1",
64
+ "eslint-plugin-promise": "6.6.0",
65
+ "expect-type": "0.20.0",
66
66
  "expr-eval": "2.0.2",
67
67
  "fancy-log": "2.0.0",
68
- "glob": "10.4.2",
68
+ "glob": "11.0.0",
69
69
  "gulp": "5.0.0",
70
70
  "gulp-babel": "8.0.0",
71
71
  "handlebars": "4.7.8",
72
- "jsep": "1.3.8",
73
- "karma": "6.4.3",
72
+ "jsep": "1.3.9",
73
+ "karma": "6.4.4",
74
74
  "karma-browserstack-launcher": "1.6.0",
75
75
  "karma-firefox-launcher": "2.1.3",
76
76
  "karma-mocha": "2.0.1",
77
77
  "karma-mocha-reporter": "2.2.5",
78
78
  "karma-webpack": "5.0.1",
79
79
  "mkdirp": "3.0.1",
80
- "mocha": "10.6.0",
80
+ "mocha": "10.7.3",
81
81
  "mocha-junit-reporter": "2.2.1",
82
82
  "ndarray": "1.0.19",
83
83
  "ndarray-determinant": "1.0.0",
@@ -86,13 +86,13 @@
86
86
  "ndarray-pack": "1.2.1",
87
87
  "numericjs": "1.2.6",
88
88
  "pad-right": "0.2.2",
89
- "prettier": "3.3.2",
89
+ "prettier": "3.3.3",
90
90
  "process": "0.11.10",
91
91
  "sinon": "18.0.0",
92
92
  "sylvester": "0.0.21",
93
93
  "ts-node": "10.9.2",
94
- "typescript": "5.5.3",
95
- "webpack": "5.92.1",
94
+ "typescript": "5.5.4",
95
+ "webpack": "5.94.0",
96
96
  "zeros": "1.0.0"
97
97
  },
98
98
  "type": "module",
package/types/index.d.ts CHANGED
@@ -508,6 +508,7 @@ export interface MathJsInstance extends MathJsFactory {
508
508
  RelationalNode: RelationalNodeCtor
509
509
  SymbolNode: SymbolNodeCtor
510
510
 
511
+ Unit: UnitCtor
511
512
  Matrix: MatrixCtor
512
513
 
513
514
  /**
@@ -1244,9 +1245,9 @@ export interface MathJsInstance extends MathJsFactory {
1244
1245
  gcd<T extends number | BigNumber | Fraction | Matrix>(args: T[]): T
1245
1246
 
1246
1247
  /**
1247
- * Calculate the hypotenusa of a list with values. The hypotenusa is
1248
+ * Calculate the hypotenuse of a list with values. The hypotenuse is
1248
1249
  * defined as: hypot(a, b, c, ...) = sqrt(a^2 + b^2 + c^2 + ...) For
1249
- * matrix input, the hypotenusa is calculated for all values in the
1250
+ * matrix input, the hypotenuse is calculated for all values in the
1250
1251
  * matrix.
1251
1252
  * @param args A list with numeric values or an Array or Matrix. Matrix
1252
1253
  * and Array input is flattened and returns a single number for the
@@ -1947,10 +1948,10 @@ export interface MathJsInstance extends MathJsFactory {
1947
1948
  inv<T extends number | Complex | MathCollection>(x: T): NoLiteralType<T>
1948
1949
 
1949
1950
  /**
1950
- * Calculate the kronecker product of two matrices or vectors
1951
+ * Calculate the Kronecker product of two matrices or vectors
1951
1952
  * @param x First vector
1952
1953
  * @param y Second vector
1953
- * @returns Returns the kronecker product of x and y
1954
+ * @returns Returns the Kronecker product of x and y
1954
1955
  */
1955
1956
  kron(x: MathCollection, y: MathCollection): Matrix
1956
1957
 
@@ -1966,7 +1967,29 @@ export interface MathJsInstance extends MathJsFactory {
1966
1967
  map<T extends MathCollection>(
1967
1968
  x: T,
1968
1969
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1969
- callback: (value: any, index: any, matrix: T) => MathType | string
1970
+ callback: (value: any, index: number[], matrix: T) => MathType | string
1971
+ ): T
1972
+
1973
+ /**
1974
+ * Iterate over all elements of multiple matrices/arrays, and executes the given
1975
+ * callback function.
1976
+ * @param x The first matrix to iterate on.
1977
+ * @param args The rest of the matrices and at the end the callback function is invoked with multiple
1978
+ * parameters: the values of the elements, the indices of the elements, and
1979
+ * the matrices/arrays being traversed.
1980
+ * @returns Transformed map of matrices
1981
+ */
1982
+ map<T extends MathCollection>(
1983
+ x: T,
1984
+ ...args: Array<
1985
+ | T
1986
+ | ((
1987
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1988
+ value: any,
1989
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1990
+ ...args: Array<any | number[] | T>
1991
+ ) => MathType | string)
1992
+ >
1970
1993
  ): T
1971
1994
 
1972
1995
  /**
@@ -2240,16 +2263,16 @@ export interface MathJsInstance extends MathJsFactory {
2240
2263
  **/
2241
2264
 
2242
2265
  /**
2243
- * Calculate N-dimensional fourier transform
2266
+ * Calculate N-dimensional Fourier transform
2244
2267
  * @param {Array | Matrix} arr An array or matrix
2245
- * @return {Array | Matrix} N-dimensional fourier transformation of the array
2268
+ * @return {Array | Matrix} N-dimensional Fourier transformation of the array
2246
2269
  */
2247
2270
  fft<T extends MathCollection>(arr: T): T
2248
2271
 
2249
2272
  /**
2250
- * Calculate N-dimensional inverse fourier transform
2273
+ * Calculate N-dimensional inverse Fourier transform
2251
2274
  * @param {Array | Matrix} arr An array or matrix
2252
- * @return {Array | Matrix} N-dimensional fourier transformation of the array
2275
+ * @return {Array | Matrix} N-dimensional Fourier transformation of the array
2253
2276
  */
2254
2277
  ifft<T extends MathCollection>(arr: T): T
2255
2278
 
@@ -3135,10 +3158,10 @@ export interface MathJsInstance extends MathJsFactory {
3135
3158
  acot<T extends BigNumber | Complex>(x: T): T
3136
3159
 
3137
3160
  /**
3138
- * Calculate the hyperbolic arccotangent of a value, defined as acoth(x)
3161
+ * Calculate the inverse hyperbolic tangent of a value, defined as acoth(x)
3139
3162
  * = (ln((x+1)/x) + ln(x/(x-1))) / 2.
3140
3163
  * @param x Function input
3141
- * @returns The hyperbolic arccotangent of x
3164
+ * @returns The inverse hyperbolic tangent of x
3142
3165
  */
3143
3166
  acoth(x: number): number
3144
3167
  acoth<T extends BigNumber | Complex>(x: T): T
@@ -3152,10 +3175,10 @@ export interface MathJsInstance extends MathJsFactory {
3152
3175
  acsc<T extends BigNumber | Complex>(x: T): T
3153
3176
 
3154
3177
  /**
3155
- * Calculate the hyperbolic arccosecant of a value, defined as acsch(x)
3178
+ * Calculate the inverse hyperbolic cosecant of a value, defined as acsch(x)
3156
3179
  * = ln(1/x + sqrt(1/x^2 + 1)).
3157
3180
  * @param x Function input
3158
- * @returns The hyperbolic arccosecant of x
3181
+ * @returns The inverse hyperbolic cosecant of x
3159
3182
  */
3160
3183
  acsch(x: number): number
3161
3184
  acsch<T extends BigNumber | Complex>(x: T): T
@@ -3380,6 +3403,14 @@ export interface MathJsInstance extends MathJsFactory {
3380
3403
 
3381
3404
  isObject(x: unknown): boolean
3382
3405
 
3406
+ isMap<T, U>(x: unknown): x is Map<T, U>
3407
+
3408
+ isPartitionedMap<T, U>(x: unknown): x is PartitionedMap<T, U>
3409
+
3410
+ isObjectWrappingMap<T extends string | number | symbol, U>(
3411
+ x: unknown
3412
+ ): x is ObjectWrappingMap<T, U>
3413
+
3383
3414
  isNull(x: unknown): x is null
3384
3415
 
3385
3416
  isUndefined(x: unknown): x is undefined
@@ -3989,15 +4020,17 @@ export interface MathJSON {
3989
4020
  fixPrefix?: boolean
3990
4021
  }
3991
4022
 
4023
+ export interface BaseUnit {
4024
+ dimensions: number[]
4025
+ key: string
4026
+ }
4027
+
3992
4028
  export interface UnitComponent {
3993
4029
  power: number
3994
4030
  prefix: string
3995
4031
  unit: {
3996
4032
  name: string
3997
- base: {
3998
- dimensions: number[]
3999
- key: string
4000
- }
4033
+ base: BaseUnit
4001
4034
  prefixes: Record<string, UnitPrefix>
4002
4035
  value: number
4003
4036
  offset: number
@@ -4014,8 +4047,7 @@ export interface UnitPrefix {
4014
4047
  export interface Unit {
4015
4048
  valueOf(): string
4016
4049
  clone(): Unit
4017
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4018
- hasBase(base: any): boolean
4050
+ hasBase(base: BaseUnit | string | undefined): boolean
4019
4051
  equalBase(unit: Unit): boolean
4020
4052
  equals(unit: Unit): boolean
4021
4053
  multiply(unit: Unit): Unit
@@ -4040,6 +4072,40 @@ export interface Unit {
4040
4072
  skipAutomaticSimplification: true
4041
4073
  }
4042
4074
 
4075
+ export type UnitSystemName = 'si' | 'cgs' | 'us' | 'auto'
4076
+
4077
+ export interface UnitStatic {
4078
+ PREFIXES: Record<string, UnitPrefix>
4079
+ BASE_DIMENSIONS: string[]
4080
+ BASE_UNITS: Record<string, BaseUnit>
4081
+ UNIT_SYSTEMS: Record<
4082
+ UnitSystemName,
4083
+ Record<string, { unit: Unit; prefix: UnitPrefix }>
4084
+ >
4085
+ UNITS: Record<string, Unit>
4086
+ parse(str: string): Unit
4087
+ isValuelessUnit(name: string): boolean
4088
+ fromJSON(json: MathJSON): Unit
4089
+ isValidAlpha(c: string): boolean
4090
+ createUnit(
4091
+ obj: Record<string, string | Unit | UnitDefinition>,
4092
+ options?: { override: boolean }
4093
+ ): Unit
4094
+ createUnitSingle(
4095
+ name: string,
4096
+ definition: string | Unit | UnitDefinition
4097
+ ): Unit
4098
+ getUnitSystem(): UnitSystemName
4099
+ setUnitSystem(name: UnitSystemName): void
4100
+ }
4101
+
4102
+ export interface UnitCtor extends UnitStatic {
4103
+ new (
4104
+ value: number | BigNumber | Fraction | Complex | boolean,
4105
+ name: string
4106
+ ): Unit
4107
+ }
4108
+
4043
4109
  export interface CreateUnitOptions {
4044
4110
  prefixes?: 'none' | 'short' | 'long' | 'binary_short' | 'binary_long'
4045
4111
  aliases?: string[]
@@ -4121,6 +4187,15 @@ export interface UnitDefinition {
4121
4187
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
4122
4188
  export interface Index {}
4123
4189
 
4190
+ export interface PartitionedMap<T, U> {
4191
+ a: Map<T, U>
4192
+ b: Map<T, U>
4193
+ }
4194
+
4195
+ export interface ObjectWrappingMap<T extends string | number | symbol, U> {
4196
+ wrappedObject: Record<T, U>
4197
+ }
4198
+
4124
4199
  export interface EvalFunction {
4125
4200
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4126
4201
  evaluate(scope?: any): any
@@ -4352,7 +4427,14 @@ export interface FormatOptions {
4352
4427
  * elsewhere. Lower bound is included, upper bound is excluded. For
4353
4428
  * example '123.4' and '1.4e7'.
4354
4429
  */
4355
- notation?: 'fixed' | 'exponential' | 'engineering' | 'auto'
4430
+ notation?:
4431
+ | 'fixed'
4432
+ | 'exponential'
4433
+ | 'engineering'
4434
+ | 'auto'
4435
+ | 'hex'
4436
+ | 'bin'
4437
+ | 'oct'
4356
4438
 
4357
4439
  /**
4358
4440
  * A number between 0 and 16 to round the digits of the number. In case
@@ -5016,9 +5098,9 @@ export interface MathJsChain<TValue> {
5016
5098
  ): MathJsChain<T>
5017
5099
 
5018
5100
  /**
5019
- * Calculate the hypotenusa of a list with values. The hypotenusa is
5101
+ * Calculate the hypotenuse of a list with values. The hypotenuse is
5020
5102
  * defined as: hypot(a, b, c, ...) = sqrt(a^2 + b^2 + c^2 + ...) For
5021
- * matrix input, the hypotenusa is calculated for all values in the
5103
+ * matrix input, the hypotenuse is calculated for all values in the
5022
5104
  * matrix.
5023
5105
  */
5024
5106
  hypot<T extends number | BigNumber>(this: MathJsChain<T[]>): MathJsChain<T>
@@ -5627,7 +5709,7 @@ export interface MathJsChain<TValue> {
5627
5709
  ): MathJsChain<NoLiteralType<T>>
5628
5710
 
5629
5711
  /**
5630
- * Calculate the kronecker product of two matrices or vectors
5712
+ * Calculate the Kronecker product of two matrices or vectors
5631
5713
  * @param y Second vector
5632
5714
  */
5633
5715
  kron(
@@ -6485,7 +6567,7 @@ export interface MathJsChain<TValue> {
6485
6567
  ): MathJsChain<T>
6486
6568
 
6487
6569
  /**
6488
- * Calculate the hyperbolic arccotangent of a value, defined as acoth(x)
6570
+ * Calculate the inverse hyperbolic tangent of a value, defined as acoth(x)
6489
6571
  * = (ln((x+1)/x) + ln(x/(x-1))) / 2. For matrices, the function is
6490
6572
  * evaluated element wise.
6491
6573
  */
@@ -6504,7 +6586,7 @@ export interface MathJsChain<TValue> {
6504
6586
  ): MathJsChain<T>
6505
6587
 
6506
6588
  /**
6507
- * Calculate the hyperbolic arccosecant of a value, defined as acsch(x)
6589
+ * Calculate the inverse hyperbolic cosecant of a value, defined as acsch(x)
6508
6590
  * = ln(1/x + sqrt(1/x^2 + 1)). For matrices, the function is evaluated
6509
6591
  * element wise.
6510
6592
  */
@@ -6846,6 +6928,7 @@ export const {
6846
6928
  RelationalNode,
6847
6929
  SymbolNode,
6848
6930
  Matrix,
6931
+ Unit,
6849
6932
 
6850
6933
  uninitialized,
6851
6934
  version,