packages feed

log-domain 0.13.1 → 0.13.2

raw patch · 4 files changed

+25/−34 lines, 4 filesdep −ghc-primdep ~deepseqdep ~hashabledep ~semigroupoids

Dependencies removed: ghc-prim

Dependency ranges changed: deepseq, hashable, semigroupoids, vector

Files

CHANGELOG.markdown view
@@ -1,3 +1,8 @@+0.13.2 [2021.11.15]+-------------------+* Add an `Eq1 Log` instance.+* Allow building with `hashable-1.4.*`.+ 0.13.1 [2021.02.17] ------------------- * The build-type has been changed from `Custom` to `Simple`.
log-domain.cabal view
@@ -1,6 +1,6 @@ name:          log-domain category:      Numeric-version:       0.13.1+version:       0.13.2 license:       BSD3 cabal-version: >= 1.10 license-file:  LICENSE@@ -15,8 +15,10 @@              , GHC == 8.2.2              , GHC == 8.4.4              , GHC == 8.6.5-             , GHC == 8.8.3-             , GHC == 8.10.1+             , GHC == 8.8.4+             , GHC == 8.10.7+             , GHC == 9.0.1+             , GHC == 9.2.1 synopsis:      Log-domain arithmetic description:   This package provides log-domain floats, doubles and complex numbers. @@ -42,17 +44,14 @@     comonad                   >= 4        && < 6,     deepseq                   >= 1.3      && < 1.5,     distributive              >= 0.3      && < 1,-    hashable                  >= 1.2.5    && < 1.4,+    hashable                  >= 1.2.5    && < 1.5,     semigroupoids             >= 4        && < 6,     semigroups                >= 0.8.4    && < 1,-    vector                    >= 0.9      && < 0.13+    vector                    >= 0.11     && < 0.13    exposed-modules:     Numeric.Log Numeric.Log.Signed -  if impl(ghc < 7.6)-    build-depends: ghc-prim--  ghc-options: -Wall -fwarn-tabs -O2+  ghc-options: -Wall -Wtabs -O2   hs-source-dirs: src   default-language: Haskell2010
src/Numeric/Log.hs view
@@ -19,9 +19,6 @@   ) where  import Prelude hiding (maximum, sum)-#if __GLASGOW_HASKELL__ < 710-import Control.Applicative-#endif import Control.Comonad import Control.DeepSeq import Data.Binary as Binary@@ -30,22 +27,21 @@ import Data.Distributive import Data.Foldable as Foldable hiding (sum) import Data.Functor.Bind+import Data.Functor.Classes import Data.Functor.Extend import Data.Hashable import Data.Hashable.Lifted import Data.Int-import Data.List as List hiding (sum)+import qualified Data.List as List import Data.List.NonEmpty (NonEmpty(..)) import Data.Semigroup import Data.Semigroup.Foldable import Data.Semigroup.Traversable import Data.Serialize as Serialize-#if __GLASGOW_HASKELL__ < 710-import Data.Traversable-#endif-import Data.Vector.Unboxed as U hiding (sum)-import Data.Vector.Generic as G hiding (sum)-import Data.Vector.Generic.Mutable as M+import qualified Data.Vector.Unboxed as U+import Data.Vector.Unboxed (Unbox)+import qualified Data.Vector.Generic as G+import qualified Data.Vector.Generic.Mutable as M import Foreign.Ptr import Foreign.Storable import GHC.Generics@@ -57,7 +53,7 @@ -- >>> let Exp x ~= Exp y = abs ((exp x-exp y) / exp x) < 0.01  -- | @Log@-domain @Float@ and @Double@ values.-newtype Log a = Exp { ln :: a } deriving (Eq,Ord,Data,Typeable,Generic)+newtype Log a = Exp { ln :: a } deriving (Eq,Ord,Data,Generic)  instance (Floating a, Show a) => Show (Log a) where   showsPrec d (Exp a) = T.showsPrec d (exp a)@@ -97,6 +93,9 @@   liftHashWithSalt hws i (Exp a) = hws i a   {-# INLINE liftHashWithSalt #-} +instance Eq1 Log where+  liftEq eq (Exp a) (Exp b) = eq a b+ instance Storable a => Storable (Log a) where   sizeOf = sizeOf . ln   {-# INLINE sizeOf #-}@@ -352,9 +351,7 @@   {-# INLINE basicUnsafeRead #-}   {-# INLINE basicUnsafeWrite #-}   {-# INLINE basicClear #-}-#if MIN_VERSION_vector(0,11,0)   {-# INLINE basicInitialize #-}-#endif   {-# INLINE basicSet #-}   {-# INLINE basicUnsafeCopy #-}   {-# INLINE basicUnsafeGrow #-}@@ -366,9 +363,7 @@   basicUnsafeRead (MV_Log v) i = Exp <$> M.basicUnsafeRead v i   basicUnsafeWrite (MV_Log v) i (Exp x) = M.basicUnsafeWrite v i x   basicClear (MV_Log v) = M.basicClear v-#if MIN_VERSION_vector(0,11,0)   basicInitialize (MV_Log v) = M.basicInitialize v-#endif   basicSet (MV_Log v) (Exp x) = M.basicSet v x   basicUnsafeCopy (MV_Log v1) (MV_Log v2) = M.basicUnsafeCopy v1 v2   basicUnsafeGrow (MV_Log v) n = MV_Log <$> M.basicUnsafeGrow v n@@ -386,7 +381,7 @@   basicUnsafeSlice i n (V_Log v) = V_Log $ G.basicUnsafeSlice i n v   basicUnsafeIndexM (V_Log v) i = Exp <$> G.basicUnsafeIndexM v i   basicUnsafeCopy (MV_Log mv) (V_Log v) = G.basicUnsafeCopy mv v-  elemseq _ (Exp x) z = G.elemseq (undefined :: U.Vector a) x z+  elemseq _ (Exp x) = G.elemseq (undefined :: U.Vector a) x  instance (RealFloat a, Ord a) => Real (Log a) where   toRational (Exp a) = toRational (exp a)
src/Numeric/Log/Signed.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE MultiParamTypeClasses #-}@@ -17,21 +16,14 @@ ( SignedLog(..) ) where -#if __GLASGOW_HASKELL__ < 710-import Data.Monoid (Monoid(..))-#endif import Data.Data (Data(..)) import GHC.Generics (Generic(..))-import Data.Typeable (Typeable) import Numeric import Text.Read as T import Text.Show as T-#if __GLASGOW_HASKELL__ < 710-import Data.Functor ((<$>))-#endif  -- | @Log@-domain @Float@ and @Double@ values, with a sign bit.-data SignedLog a = SLExp { signSL :: Bool, lnSL :: a} deriving (Data, Typeable, Generic)+data SignedLog a = SLExp { signSL :: Bool, lnSL :: a} deriving (Data, Generic)  negInf :: Fractional a => a negInf = (-1)/0