packages feed

digamma 0.1 → 1.0

raw patch · 2 files changed

+7/−25 lines, 2 filesdep +math-functionsdep −polynomial

Dependencies added: math-functions

Dependencies removed: polynomial

Files

Numeric/Digamma.hs view
@@ -1,22 +1,3 @@ module Numeric.Digamma (digamma) where -import Math.Polynomial---- | A robust implementation of the digamma function--- This code is based on the implementation by Tom Minka-digamma :: RealFloat a => a -> a-digamma 0 = -1/0 -- Should we bail here?-digamma x | x < 0 = let x' = -1*x in digamma (x'+1) + pi / tan (pi*x') -- Use reflection formula-digamma 1 = -0.5772156649015328606065121 -- Euler-Mascheroni constant-digamma 2 = pi**2 / 6-digamma x | x <= small = digamma 1 - 1/x + digamma 2 * x-          -- Reduce to digamma(x+n) where (x+n) >= large-          | x > small && x < large = digamma (x+1) - 1/x -- TODO-  where small = 1e-6-        large = 9.5-digamma x = let r = 1/x-            in log x -  p `evalPoly` (1/x)-  where p = poly LE [ 0, 1/2, 1/12, 1/120, 1/252, 1/240, 1/132, 691/32760, 1/12, 3617/8160 ]-{-# SPECIALIZE digamma :: Double -> Double #-}-{-# SPECIALIZE digamma :: Float -> Float #-}-+import Numeric.SpecFunctions (digamma)
digamma.cabal view
@@ -1,8 +1,9 @@ Name:                digamma-Version:             0.1-Synopsis:            A robust implementation of the digamma function-Description:         An implementation of the digamma function-                     based on Thomas Minka's Matlab code.+Version:             1.0+Synopsis:            A (deprecated) implementation of the digamma function+Description:+    /deprecated/ This package has been superceded by+    'Numeric.SpecFunctions.digamma' from the @math-functions@ package. Homepage:            https://github.com/bgamari/digamma License:             BSD3 License-file:        LICENSE@@ -18,5 +19,5 @@  Library   Exposed-modules:   Numeric.Digamma-  Build-depends:     base >= 4 && < 5, polynomial >= 0.6.5 && < 0.7+  Build-depends:     base >= 4 && < 5, math-functions