log-domain 0.9.3 → 0.10
raw patch · 4 files changed
+48/−14 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.markdown +7/−0
- LICENSE +1/−5
- log-domain.cabal +9/−2
- src/Numeric/Log.hs +31/−7
CHANGELOG.markdown view
@@ -1,3 +1,10 @@+0.10+----+* `(**)` is now much more accurately defined.+* We now avoid comparisons for equality with infinities.+* Fixed a bug in `negate`.+* On windows we avoid FFI into the math library, and accept less accurate results. (Sorry!)+ 0.9.3 ------- * Fixed subtraction again. For real this time.
LICENSE view
@@ -1,4 +1,4 @@-Copyright 2011 Edward Kmett+Copyright 2011-2015 Edward Kmett All rights reserved. @@ -12,10 +12,6 @@ 2. 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.--3. Neither the name of the author nor the names of his contributors- may be used to endorse or promote products derived from this software- without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
log-domain.cabal view
@@ -1,6 +1,6 @@ name: log-domain category: Numeric-version: 0.9.3+version: 0.10 license: BSD3 cabal-version: >= 1.8 license-file: LICENSE@@ -9,7 +9,7 @@ stability: provisional homepage: http://github.com/analytics/log-domain/ bug-reports: http://github.com/analytics/log-domain/issues-copyright: Copyright (C) 2013 Edward A. Kmett+copyright: Copyright (C) 2013-2015 Edward A. Kmett build-type: Custom tested-with: GHC == 7.4.1, GHC == 7.6.3 synopsis: Log-domain arithmetic@@ -39,6 +39,10 @@ default: False manual: True +flag ffi+ default: True+ manual: True+ library build-depends: base >= 4.3 && < 5,@@ -61,6 +65,9 @@ if flag(lib-Werror) ghc-options: -Werror++ if flag(ffi) && !os(windows)+ cpp-options: -D__USE_FFI__ ghc-options: -Wall -fwarn-tabs -O2 hs-source-dirs: src
src/Numeric/Log.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}@@ -8,7 +9,7 @@ {-# LANGUAGE Trustworthy #-} -------------------------------------------------------------------- -- |--- Copyright : (c) Edward Kmett 2013+-- Copyright : (c) Edward Kmett 2013-2015 -- License : BSD3 -- Maintainer: Edward Kmett <ekmett@gmail.com> -- Stability : experimental@@ -214,15 +215,14 @@ | otherwise = Exp (b + log1pexp (a - b)) {-# INLINE (+) #-} Exp a - Exp b- | a == negInf && b == negInf = Exp negInf+ | isInfinite a && isInfinite b && a < 0 && b < 0 = Exp negInf | otherwise = Exp (a + log1mexp (b - a)) {-# INLINE (-) #-} signum (Exp a)- | a == negInf = 0- | a > negInf = 1- | otherwise = negInf+ | isInfinite a && a < 0 = Exp negInf -- 0+ | otherwise = Exp 0 -- 1 {-# INLINE signum #-}- negate _ = negInf+ negate _ = Exp negInf {-# INLINE negate #-} abs = id {-# INLINE abs #-}@@ -233,7 +233,7 @@ -- n/0 == infinity is handled seamlessly for us. We must catch 0/0 and infinity/infinity NaNs, and handle 0/infinity. Exp a / Exp b | a == b && isInfinite a && isInfinite b = Exp negInf- | a == negInf = Exp negInf+ | isInfinite a && a < 0 = Exp negInf | otherwise = Exp (a-b) {-# INLINE (/) #-} fromRational = Exp . log . fromRational@@ -348,6 +348,8 @@ {-# INLINE exp #-} log (Exp a) = Exp (log a) {-# INLINE log #-}+ Exp b ** Exp e = Exp (b * exp e)+ {-# INLINE (**) #-} sqrt (Exp a) = Exp (a / 2) {-# INLINE sqrt #-} logBase (Exp a) (Exp b) = Exp (log (logBase (exp a) (exp b)))@@ -456,7 +458,29 @@ | otherwise = log (1 + x) {-# INLINE log1p #-} +#ifdef __USE_FFI__+ foreign import ccall unsafe "math.h log1p" c_log1p :: Double -> Double foreign import ccall unsafe "math.h expm1" c_expm1 :: Double -> Double foreign import ccall unsafe "math.h expm1f" c_expm1f :: Float -> Float foreign import ccall unsafe "math.h log1pf" c_log1pf :: Float -> Float++#else++c_log1p :: Double -> Double+{-# INLINE c_log1p #-}+c_log1p x = log (1 + x)++c_expm1 :: Double -> Double+{-# INLINE c_expm1 #-}+c_expm1 x = exp x - 1++c_expm1f :: Float -> Float+{-# INLINE c_expm1f #-}+c_expm1f x = exp x - 1++c_log1pf :: Float -> Float+{-# INLINE c_log1pf #-}+c_log1pf x = log (1 + x)++#endif