mathjs 11.7.0 → 11.8.1

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 (88) hide show
  1. package/HISTORY.md +26 -0
  2. package/README.md +0 -26
  3. package/lib/browser/math.js +1 -1
  4. package/lib/browser/math.js.LICENSE.txt +2 -2
  5. package/lib/browser/math.js.map +1 -1
  6. package/lib/cjs/core/function/typed.js +1 -1
  7. package/lib/cjs/entry/dependenciesAny/dependenciesDistance.generated.js +2 -2
  8. package/lib/cjs/entry/pureFunctionsAny.generated.js +2 -2
  9. package/lib/cjs/expression/Parser.js +1 -1
  10. package/lib/cjs/expression/function/parser.js +1 -1
  11. package/lib/cjs/expression/node/FunctionAssignmentNode.js +1 -1
  12. package/lib/cjs/expression/node/OperatorNode.js +1 -3
  13. package/lib/cjs/expression/operators.js +19 -4
  14. package/lib/cjs/expression/transform/filter.transform.js +4 -13
  15. package/lib/cjs/expression/transform/forEach.transform.js +3 -12
  16. package/lib/cjs/expression/transform/map.transform.js +4 -13
  17. package/lib/cjs/factoriesNumber.js +18 -0
  18. package/lib/cjs/function/algebra/derivative.js +2 -2
  19. package/lib/cjs/function/algebra/leafCount.js +1 -1
  20. package/lib/cjs/function/algebra/polynomialRoot.js +1 -1
  21. package/lib/cjs/function/algebra/rationalize.js +5 -7
  22. package/lib/cjs/function/algebra/resolve.js +1 -1
  23. package/lib/cjs/function/algebra/simplify.js +7 -7
  24. package/lib/cjs/function/algebra/simplifyConstant.js +3 -3
  25. package/lib/cjs/function/algebra/simplifyCore.js +2 -2
  26. package/lib/cjs/function/algebra/sparse/csAmd.js +1 -3
  27. package/lib/cjs/function/algebra/sparse/csLeaf.js +1 -3
  28. package/lib/cjs/function/algebra/symbolicEqual.js +8 -8
  29. package/lib/cjs/function/geometry/distance.js +31 -29
  30. package/lib/cjs/function/matrix/eigs/complexEigs.js +3 -3
  31. package/lib/cjs/function/matrix/filter.js +2 -11
  32. package/lib/cjs/function/matrix/forEach.js +3 -12
  33. package/lib/cjs/function/matrix/map.js +6 -38
  34. package/lib/cjs/function/matrix/matrixFromColumns.js +1 -1
  35. package/lib/cjs/function/matrix/matrixFromRows.js +1 -1
  36. package/lib/cjs/function/matrix/sqrtm.js +1 -1
  37. package/lib/cjs/header.js +2 -2
  38. package/lib/cjs/type/bignumber/function/bignumber.js +7 -0
  39. package/lib/cjs/type/fraction/function/fraction.js +8 -1
  40. package/lib/cjs/type/matrix/DenseMatrix.js +41 -45
  41. package/lib/cjs/type/matrix/SparseMatrix.js +39 -41
  42. package/lib/cjs/type/number.js +7 -3
  43. package/lib/cjs/type/unit/Unit.js +2 -0
  44. package/lib/cjs/type/unit/function/splitUnit.js +1 -1
  45. package/lib/cjs/utils/applyCallback.js +73 -0
  46. package/lib/cjs/utils/bignumber/formatter.js +4 -3
  47. package/lib/cjs/utils/lruQueue.js +2 -6
  48. package/lib/cjs/utils/map.js +1 -1
  49. package/lib/cjs/utils/snapshot.js +7 -1
  50. package/lib/cjs/version.js +1 -1
  51. package/lib/esm/core/function/typed.js +1 -1
  52. package/lib/esm/entry/dependenciesAny/dependenciesDistance.generated.js +2 -2
  53. package/lib/esm/entry/pureFunctionsAny.generated.js +2 -2
  54. package/lib/esm/expression/Parser.js +1 -1
  55. package/lib/esm/expression/function/parser.js +1 -1
  56. package/lib/esm/expression/node/OperatorNode.js +1 -3
  57. package/lib/esm/expression/operators.js +1 -3
  58. package/lib/esm/expression/transform/filter.transform.js +4 -13
  59. package/lib/esm/expression/transform/forEach.transform.js +3 -12
  60. package/lib/esm/expression/transform/map.transform.js +4 -13
  61. package/lib/esm/function/algebra/derivative.js +2 -2
  62. package/lib/esm/function/algebra/leafCount.js +1 -1
  63. package/lib/esm/function/algebra/polynomialRoot.js +1 -1
  64. package/lib/esm/function/algebra/rationalize.js +5 -7
  65. package/lib/esm/function/algebra/resolve.js +1 -1
  66. package/lib/esm/function/algebra/simplify.js +7 -7
  67. package/lib/esm/function/algebra/simplifyConstant.js +2 -2
  68. package/lib/esm/function/algebra/simplifyCore.js +2 -2
  69. package/lib/esm/function/algebra/sparse/csAmd.js +1 -3
  70. package/lib/esm/function/algebra/sparse/csLeaf.js +1 -3
  71. package/lib/esm/function/algebra/symbolicEqual.js +8 -8
  72. package/lib/esm/function/geometry/distance.js +31 -29
  73. package/lib/esm/function/matrix/eigs/complexEigs.js +2 -2
  74. package/lib/esm/function/matrix/filter.js +2 -11
  75. package/lib/esm/function/matrix/forEach.js +3 -12
  76. package/lib/esm/function/matrix/map.js +6 -38
  77. package/lib/esm/function/matrix/sqrtm.js +1 -1
  78. package/lib/esm/type/bignumber/function/bignumber.js +5 -0
  79. package/lib/esm/type/fraction/function/fraction.js +6 -1
  80. package/lib/esm/type/number.js +5 -3
  81. package/lib/esm/type/unit/Unit.js +2 -0
  82. package/lib/esm/type/unit/function/splitUnit.js +1 -1
  83. package/lib/esm/utils/applyCallback.js +67 -0
  84. package/lib/esm/utils/bignumber/formatter.js +4 -3
  85. package/lib/esm/utils/lruQueue.js +2 -6
  86. package/lib/esm/version.js +1 -1
  87. package/package.json +21 -21
  88. package/types/index.d.ts +16 -16
package/types/index.d.ts CHANGED
@@ -585,7 +585,7 @@ declare namespace math {
585
585
  * @returns The created bignumber
586
586
  */
587
587
  bignumber(
588
- x?: number | string | Fraction | BigNumber | boolean | Fraction | null
588
+ x?: number | string | Fraction | BigNumber | Unit | boolean | null
589
589
  ): BigNumber
590
590
  bignumber<T extends MathCollection>(x: T): T
591
591
 
@@ -664,12 +664,12 @@ declare namespace math {
664
664
 
665
665
  /**
666
666
  * Create a fraction convert a value to a fraction.
667
- * @param args Arguments specifying the numerator and denominator of the
667
+ * @param value Arguments specifying the numerator and denominator of the
668
668
  * fraction
669
669
  * @returns Returns a fraction
670
670
  */
671
671
  fraction(
672
- value: number | string | BigNumber | Fraction | FractionDefinition
672
+ value: number | string | BigNumber | Unit | Fraction | FractionDefinition
673
673
  ): Fraction
674
674
  fraction(values: MathCollection): MathCollection
675
675
  /**
@@ -1186,9 +1186,10 @@ declare namespace math {
1186
1186
  * @param args Two or more integer numbers
1187
1187
  * @returns The greatest common divisor
1188
1188
  */
1189
- gcd<T extends (number | BigNumber | Fraction | MathCollection)[]>(
1189
+ gcd<T extends number | BigNumber | Fraction | MathCollection>(
1190
1190
  ...args: T[]
1191
1191
  ): T
1192
+ gcd<T extends number | BigNumber | Fraction | Matrix>(args: T[]): T
1192
1193
 
1193
1194
  /**
1194
1195
  * Calculate the hypotenusa of a list with values. The hypotenusa is
@@ -1580,12 +1581,14 @@ declare namespace math {
1580
1581
  * a 3D line, x0, y0, z0, a, b, c are from: (x−x0, y−y0, z−z0) = t(a, b,
1581
1582
  * c)
1582
1583
  * @param x Coordinates of the first point
1583
- * @param y Coordinates of the second point
1584
+ * @param y Coordinates of the second point OR coefficients of a line in 3D OR first end-point of a line if the calculation is for distance between point and a line in 2D
1585
+ * @param z Coordinates of second end-point of a line if the calculation is for distance between point and a line in 2D
1584
1586
  * @returns Returns the distance from two/three points
1585
1587
  */
1586
1588
  distance(
1587
1589
  x: MathCollection | object,
1588
- y: MathCollection | object
1590
+ y: MathCollection | object,
1591
+ z?: MathCollection | object
1589
1592
  ): number | BigNumber
1590
1593
 
1591
1594
  /**
@@ -2595,8 +2598,7 @@ declare namespace math {
2595
2598
  * @param args A single matrix or multiple scalar values
2596
2599
  * @returns The maximum value
2597
2600
  */
2598
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2599
- max(...args: MathType[]): any
2601
+ max<T extends MathType[]>(...args: T): T[number]
2600
2602
  /**
2601
2603
  * @param A A single matrix
2602
2604
  * @param dim The maximum over the selected dimension
@@ -2638,14 +2640,13 @@ declare namespace math {
2638
2640
 
2639
2641
  /**
2640
2642
  * Compute the minimum value of a matrix or a list of values. In case of
2641
- * a multi dimensional array, the minimun of the flattened array will be
2642
- * calculated. When dim is provided, the minimun over the selected
2643
+ * a multi dimensional array, the minimum of the flattened array will be
2644
+ * calculated. When dim is provided, the minimum over the selected
2643
2645
  * dimension will be calculated. Parameter dim is zero-based.
2644
2646
  * @param args A single matrix or or multiple scalar values
2645
2647
  * @returns The minimum value
2646
2648
  */
2647
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2648
- min(...args: MathType[]): any
2649
+ min<T extends MathType[]>(...args: T): T[number]
2649
2650
  /**
2650
2651
  * @param A A single matrix
2651
2652
  * @param dim The minimum over the selected dimension
@@ -4147,7 +4148,7 @@ declare namespace math {
4147
4148
  */
4148
4149
  bignumber(
4149
4150
  this: MathJsChain<
4150
- number | string | Fraction | BigNumber | boolean | Fraction | null
4151
+ number | string | Fraction | BigNumber | Unit | boolean | null
4151
4152
  >
4152
4153
  ): MathJsChain<BigNumber>
4153
4154
  bignumber<T extends MathCollection>(this: MathJsChain<T>): MathJsChain<T>
@@ -4213,7 +4214,7 @@ declare namespace math {
4213
4214
  */
4214
4215
  fraction(
4215
4216
  this: MathJsChain<
4216
- number | string | BigNumber | Fraction | FractionDefinition
4217
+ number | string | BigNumber | Unit | Fraction | FractionDefinition
4217
4218
  >,
4218
4219
  denominator?: number
4219
4220
  ): MathJsChain<Fraction>
@@ -4676,11 +4677,10 @@ declare namespace math {
4676
4677
  * Calculate the greatest common divisor for two or more values or
4677
4678
  * arrays. For matrices, the function is evaluated element wise.
4678
4679
  */
4679
- gcd<T extends number | BigNumber | MathCollection>(
4680
+ gcd<T extends number | BigNumber | Fraction | Matrix>(
4680
4681
  this: MathJsChain<T[]>,
4681
4682
  ...args: T[]
4682
4683
  ): MathJsChain<T>
4683
- gcd(this: MathJsChain<Complex[]>, ...args: Fraction[]): MathJsChain<Complex>
4684
4684
 
4685
4685
  /**
4686
4686
  * Calculate the hypotenusa of a list with values. The hypotenusa is