mathjs 10.4.3 → 10.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. package/HISTORY.md +15 -0
  2. package/docs/reference/functions/lgamma.md +46 -0
  3. package/docs/reference/functions/pinv.md +44 -0
  4. package/docs/reference/functions/pow.md +8 -2
  5. package/docs/reference/functions.md +2 -0
  6. package/lib/browser/math.js +6 -6
  7. package/lib/browser/math.js.map +1 -1
  8. package/lib/cjs/entry/dependenciesAny/dependenciesDet.generated.js +5 -2
  9. package/lib/cjs/entry/dependenciesAny/dependenciesLgamma.generated.js +23 -0
  10. package/lib/cjs/entry/dependenciesAny/dependenciesPinv.generated.js +53 -0
  11. package/lib/cjs/entry/dependenciesAny/dependenciesPow.generated.js +3 -0
  12. package/lib/cjs/entry/dependenciesAny.generated.js +16 -0
  13. package/lib/cjs/entry/dependenciesNumber/dependenciesLgamma.generated.js +20 -0
  14. package/lib/cjs/entry/dependenciesNumber.generated.js +8 -0
  15. package/lib/cjs/entry/impureFunctionsAny.generated.js +96 -94
  16. package/lib/cjs/entry/impureFunctionsNumber.generated.js +5 -4
  17. package/lib/cjs/entry/pureFunctionsAny.generated.js +215 -193
  18. package/lib/cjs/entry/pureFunctionsNumber.generated.js +14 -10
  19. package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +6 -0
  20. package/lib/cjs/expression/embeddedDocs/function/arithmetic/pow.js +1 -1
  21. package/lib/cjs/expression/embeddedDocs/function/matrix/pinv.js +15 -0
  22. package/lib/cjs/expression/embeddedDocs/function/probability/lgamma.js +15 -0
  23. package/lib/cjs/factoriesAny.js +16 -0
  24. package/lib/cjs/factoriesNumber.js +3 -1
  25. package/lib/cjs/function/arithmetic/pow.js +25 -6
  26. package/lib/cjs/function/matrix/det.js +37 -31
  27. package/lib/cjs/function/matrix/pinv.js +223 -0
  28. package/lib/cjs/function/probability/lgamma.js +146 -0
  29. package/lib/cjs/header.js +2 -2
  30. package/lib/cjs/plain/number/probability.js +43 -3
  31. package/lib/cjs/utils/latex.js +6 -0
  32. package/lib/cjs/utils/number.js +17 -2
  33. package/lib/cjs/version.js +1 -1
  34. package/lib/esm/entry/dependenciesAny/dependenciesDet.generated.js +4 -2
  35. package/lib/esm/entry/dependenciesAny/dependenciesLgamma.generated.js +12 -0
  36. package/lib/esm/entry/dependenciesAny/dependenciesPinv.generated.js +32 -0
  37. package/lib/esm/entry/dependenciesAny/dependenciesPow.generated.js +2 -0
  38. package/lib/esm/entry/dependenciesAny.generated.js +2 -0
  39. package/lib/esm/entry/dependenciesNumber/dependenciesLgamma.generated.js +10 -0
  40. package/lib/esm/entry/dependenciesNumber.generated.js +1 -0
  41. package/lib/esm/entry/impureFunctionsAny.generated.js +90 -88
  42. package/lib/esm/entry/impureFunctionsNumber.generated.js +6 -5
  43. package/lib/esm/entry/pureFunctionsAny.generated.js +179 -159
  44. package/lib/esm/entry/pureFunctionsNumber.generated.js +8 -5
  45. package/lib/esm/expression/embeddedDocs/embeddedDocs.js +4 -0
  46. package/lib/esm/expression/embeddedDocs/function/arithmetic/pow.js +1 -1
  47. package/lib/esm/expression/embeddedDocs/function/matrix/pinv.js +8 -0
  48. package/lib/esm/expression/embeddedDocs/function/probability/lgamma.js +8 -0
  49. package/lib/esm/factoriesAny.js +2 -0
  50. package/lib/esm/factoriesNumber.js +2 -1
  51. package/lib/esm/function/arithmetic/pow.js +25 -6
  52. package/lib/esm/function/matrix/det.js +35 -31
  53. package/lib/esm/function/matrix/pinv.js +205 -0
  54. package/lib/esm/function/probability/lgamma.js +137 -0
  55. package/lib/esm/plain/number/probability.js +33 -1
  56. package/lib/esm/utils/latex.js +6 -0
  57. package/lib/esm/utils/number.js +13 -1
  58. package/lib/esm/version.js +1 -1
  59. package/package.json +7 -7
  60. package/types/index.d.ts +22 -1
  61. package/types/index.ts +10 -0
package/types/index.d.ts CHANGED
@@ -811,7 +811,21 @@ declare namespace math {
811
811
  ceil(x: Complex): Complex;
812
812
  ceil(x: MathArray): MathArray;
813
813
  ceil(x: Matrix): Matrix;
814
- ceil(x: Unit): Unit;
814
+
815
+ /**
816
+ * Round a value towards plus infinity If x is complex, both real and
817
+ * imaginary part are rounded towards plus infinity. For matrices, the
818
+ * function is evaluated element wise.
819
+ * @param x Number to be rounded
820
+ * @param n Number of decimals Default value: 0.
821
+ * @returns Rounded value
822
+ */
823
+ ceil(x: number, n: number | MathArray): number;
824
+ ceil(x: BigNumber, n: BigNumber | MathArray): BigNumber;
825
+ ceil(x: Fraction, n: number): Fraction;
826
+ ceil(x: Complex, n: number | MathArray): Complex;
827
+ ceil(x: MathArray, n: number): MathArray;
828
+ ceil(x: Matrix, n: number | BigNumber): Matrix;
815
829
 
816
830
  /**
817
831
  * Compute the cube of a value, x * x * x. For matrices, the function is
@@ -1818,6 +1832,13 @@ declare namespace math {
1818
1832
  */
1819
1833
  kldivergence(q: MathArray | Matrix, p: MathArray | Matrix): number;
1820
1834
 
1835
+ /**
1836
+ * Compute the log gamma function of a value, using Lanczos approximation for numbers and Stirling series for complex numbers.
1837
+ * @param n A real or complex number
1838
+ * @returns The log gamma of `n`
1839
+ */
1840
+ lgamma<T extends number | Complex>(n: T): NoLiteralType<T>;
1841
+
1821
1842
  /**
1822
1843
  * Multinomial Coefficients compute the number of ways of picking a1,
1823
1844
  * a2, ..., ai unordered outcomes from n possibilities. multinomial
package/types/index.ts CHANGED
@@ -831,3 +831,13 @@ Factory Test
831
831
  expectTypeOf(x).toMatchTypeOf<math.MathJsChain>()
832
832
  }
833
833
  }
834
+
835
+ /*
836
+ Probability function examples
837
+ */
838
+ {
839
+ const math = create(all, {});
840
+
841
+ expectTypeOf(math.lgamma(1.5)).toMatchTypeOf<number>()
842
+ expectTypeOf(math.lgamma(math.complex(1.5, -1.5))).toMatchTypeOf<math.Complex>()
843
+ }