packages feed

digamma (empty) → 0.1

raw patch · 4 files changed

+76/−0 lines, 4 filesdep +basedep +polynomialsetup-changed

Dependencies added: base, polynomial

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c)2012, Ben Gamari++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Ben Gamari nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Numeric/Digamma.hs view
@@ -0,0 +1,22 @@+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 #-}+
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ digamma.cabal view
@@ -0,0 +1,22 @@+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.+Homepage:            https://github.com/bgamari/digamma+License:             BSD3+License-file:        LICENSE+Author:              Ben Gamari+Maintainer:          bgamari@gmail.com+Category:            Math+Build-type:          Simple+Cabal-version:       >=1.6++Source-repository head+  Type:              git+  Location:          git://github.com/bgamari/digamma.git++Library+  Exposed-modules:   Numeric.Digamma+  Build-depends:     base >= 4 && < 5, polynomial >= 0.6.5 && < 0.7+