diff --git a/changelog.md b/changelog.md index b9d634c21..6fd12e62f 100644 --- a/changelog.md +++ b/changelog.md @@ -87,6 +87,7 @@ - Added the parameter ``val`` for the ``CritBitTree[int].inc`` proc. - An exception raised from ``test`` block of ``unittest`` now shows its type in the error message +- The proc ``tgamma`` was renamed to ``gamma``. ``tgamma`` is deprecated. ### Language additions diff --git a/lib/pure/math.nim b/lib/pure/math.nim index 6658b6307..8ea8ee203 100644 --- a/lib/pure/math.nim +++ b/lib/pure/math.nim @@ -280,12 +280,18 @@ when not defined(JS): # C proc erfc*(x: float64): float64 {.importc: "erfc", header: "".} ## The complementary error function + proc gamma*(x: float32): float32 {.importc: "tgammaf", header: "".} + proc gamma*(x: float64): float64 {.importc: "tgamma", header: "".} + ## The gamma function + proc tgamma*(x: float32): float32 + {.deprecated: "use gamma instead", importc: "tgammaf", header: "".} + proc tgamma*(x: float64): float64 + {.deprecated: "use gamma instead", importc: "tgamma", header: "".} + ## The gamma function + ## **Deprecated since version 0.19.0**: Use ``gamma`` instead. proc lgamma*(x: float32): float32 {.importc: "lgammaf", header: "".} proc lgamma*(x: float64): float64 {.importc: "lgamma", header: "".} ## Natural log of the gamma function - proc tgamma*(x: float32): float32 {.importc: "tgammaf", header: "".} - proc tgamma*(x: float64): float64 {.importc: "tgamma", header: "".} - ## The gamma function proc floor*(x: float32): float32 {.importc: "floorf", header: "".} proc floor*(x: float64): float64 {.importc: "floor", header: "".} @@ -557,6 +563,7 @@ when isMainModule and not defined(JS): return sqrt(num) # check gamma function + assert(gamma(5.0) == 24.0) # 4! assert($tgamma(5.0) == $24.0) # 4! assert(lgamma(1.0) == 0.0) # ln(1.0) == 0.0 assert(erf(6.0) > erf(5.0))