packages feed

ad 3.3.0.1 → 3.3.1

raw patch · 23 files changed

+147/−59 lines, 23 filesdep ~comonaddep ~freedep ~mtlbuild-type:Customsetup-changedPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: comonad, free, mtl, reflection, tagged

API changes (from Hackage documentation)

Files

.travis.yml view
@@ -1,1 +1,28 @@ language: haskell+before_install:+  # Uncomment whenever hackage is down.+  # - mkdir -p ~/.cabal && cp config ~/.cabal/config && cabal update++  # Try installing some of the build-deps with apt-get for speed.+  - ./travis-cabal-apt-install --only-dependencies --force-reinstall $mode++  - sudo apt-get -q -y install hlint || cabal install hlint++install:+  - cabal configure -flib-Werror $mode+  - cabal build++script:+  - $script+  - hlint src --cpp-define HLINT++notifications:+  irc:+    channels:+      - "irc.freenode.org#haskell-lens"+    skip_join: true+    template:+      - "\x0313ad\x03/\x0306%{branch}\x03 \x0314%{commit}\x03 %{build_url} %{message}"++env:+  - mode="--enable-tests" script="cabal test"
CHANGELOG.markdown view
@@ -1,3 +1,10 @@+3.3.1+-----+* Build system improvements+* Removed unused LANGUAGE pragmas+* Added HLint configuration+* We now use exactly the same versions of the packages used to build `ad` when running the doctests.+ 3.3 --- * Renamed `Reverse` to `Kahn` and `Wengert` to `Reverse`. We use Arthur Kahn's topological sorting algorithm to
README.markdown view
@@ -31,6 +31,12 @@     Prelude Numeric.AD> diff' (exp . log) 2     (2.0,1.0) +You can compute the derivative of a function with a constant parameter using `auto` from Numeric.AD.Types:++    Prelude Numeric.AD Numeric.AD.Types> let t = 2.0 :: Double+    Prelude Numeric.AD Numeric.AD.Types> diff (\ x -> auto t * sin x) 0+    2.0+ You can use a symbolic numeric type, like the one from `simple-reflect` to obtain symbolic derivatives:      Prelude Debug.SimpleReflect Numeric.AD> diff atanh x
Setup.lhs view
@@ -1,7 +1,44 @@ #!/usr/bin/runhaskell-> module Main (main) where+\begin{code}+{-# OPTIONS_GHC -Wall #-}+module Main (main) where -> import Distribution.Simple+import Data.List ( nub )+import Data.Version ( showVersion )+import Distribution.Package ( PackageName(PackageName), PackageId, InstalledPackageId, packageVersion, packageName )+import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) )+import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )+import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose )+import Distribution.Simple.BuildPaths ( autogenModulesDir )+import Distribution.Simple.Setup ( BuildFlags(buildVerbosity), fromFlag )+import Distribution.Simple.LocalBuildInfo ( withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps) )+import Distribution.Verbosity ( Verbosity )+import System.FilePath ( (</>) ) -> main :: IO ()-> main = defaultMain+main :: IO ()+main = defaultMainWithHooks simpleUserHooks+  { buildHook = \pkg lbi hooks flags -> do+     generateBuildModule (fromFlag (buildVerbosity flags)) pkg lbi+     buildHook simpleUserHooks pkg lbi hooks flags+  }++generateBuildModule :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()+generateBuildModule verbosity pkg lbi = do+  let dir = autogenModulesDir lbi+  createDirectoryIfMissingVerbose verbosity True dir+  withLibLBI pkg lbi $ \_ libcfg -> do+    withTestLBI pkg lbi $ \suite suitecfg -> do+      rewriteFile (dir </> "Build_" ++ testName suite ++ ".hs") $ unlines+        [ "module Build_" ++ testName suite ++ " where"+        , "deps :: [String]"+        , "deps = " ++ (show $ formatdeps (testDeps libcfg suitecfg))+        ]+  where+    formatdeps = map (formatone . snd)+    formatone p = case packageName p of+      PackageName n -> n ++ "-" ++ showVersion (packageVersion p)++testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]+testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys++\end{code}
TODO view
@@ -1,21 +1,21 @@ * Use the f-branching stream and tensors to generate: -    gradients :: Traversable f => FU f a -> f a -> Stream f a +    gradients :: Traversable f => FU f a -> f a -> Stream f a  * Allow the type to vary within our AD data type container, in the same fashion as Numeric.FAD. -    Although, while Pearlmutter and Siskind provided the functionality to permit -    it in the derivative combinators, they provided no combinators to convert, +    Although, while Pearlmutter and Siskind provided the functionality to permit+    it in the derivative combinators, they provided no combinators to convert,     say, @Dual tag Float@ to a @Dual tag Double@, so that extra functionality cannot     currently be leveraged. -  One approach: GADT'd Tape. +  One approach: GADT'd Tape.     Lets us use local matrix-valued jacobians as blackboxes.     However, this requires a custom higher-order data-reify.  * Do we need some kind of Array implementation? These'd be easy: -    (new)?type ADArray s i e = Array i (AD s e) +    (new)?type ADArray s i e = Array i (AD s e)     (new)?type ADIOArray s i e = IOArray i (AD s e)     (new)?type ADSTArray s i e = STArray i (AD s e) @@ -34,8 +34,8 @@         , MArray (ADIOArray s) e IO         , Lifted s) => LiftedArray s e where -     type ADArr s e  :: * -> * -> * -     type ADSTArr s e :: * -> * -> * +     type ADArr s e  :: * -> * -> *+     type ADSTArr s e :: * -> * -> *      type ADIOArr s e :: * -> * -> *    newtype ADArray s i e = ADArray (ADArr s e i e)
ad.cabal view
@@ -1,8 +1,8 @@ name:         ad-version:      3.3.0.1+version:      3.3.1 license:      BSD3 license-File: LICENSE-copyright:    (c) Edward Kmett 2010-2012,+copyright:    (c) Edward Kmett 2010-2013,               (c) Barak Pearlmutter and Jeffrey Mark Siskind 2008-2009 author:       Edward Kmett maintainer:   ekmett@gmail.com@@ -10,7 +10,7 @@ category:     Math homepage:     http://github.com/ekmett/ad bug-reports:  http://github.com/ekmett/ad/issues-build-type:   Simple+build-type:   Custom cabal-version: >= 1.8 extra-source-files: TODO .travis.yml CHANGELOG.markdown README.markdown synopsis:     Automatic Differentiation@@ -88,13 +88,13 @@   build-depends:     array            >= 0.2 && < 0.5,     base             == 4.*,-    comonad          == 3.0.*,+    comonad          >= 3,     containers       >= 0.2 && < 0.6,     data-reify       >= 0.6 && < 0.7,-    free             >= 3.0 && <= 3.4,-    mtl,-    reflection       >= 1.1.6 && < 1.2,-    tagged           >= 0.4.2.1 && < 0.5,+    free             >= 3,+    mtl              >= 2,+    reflection       >= 1.1.6,+    tagged           >= 0.4.2.1,     template-haskell >= 2.5 && < 2.9    exposed-modules:
src/Numeric/AD/Halley.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE Rank2Types, BangPatterns, ScopedTypeVariables #-}+{-# LANGUAGE Rank2Types, ScopedTypeVariables #-} ----------------------------------------------------------------------------- -- | -- Module      :  Numeric.AD.Halley
src/Numeric/AD/Internal/Composition.hs view
@@ -1,6 +1,4 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE Rank2Types, TypeFamilies, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, FlexibleContexts, TemplateHaskell, UndecidableInstances, TypeOperators #-}--- {-# OPTIONS_HADDOCK hide, prune #-}+{-# LANGUAGE CPP, Rank2Types, TypeFamilies, MultiParamTypeClasses, FlexibleInstances, FlexibleContexts, UndecidableInstances, TypeOperators #-} ----------------------------------------------------------------------------- -- | -- Module      :  Numeric.AD.Internal.Composition@@ -34,6 +32,9 @@ import Data.Traversable (Traversable(traverse)) import Numeric.AD.Internal.Classes import Numeric.AD.Internal.Types++{-# ANN module "Hlint: ignore Eta reduce" #-}+{-# ANN module "Hlint: ignore Reduce duplication" #-}  -- | Functor composition, used to nest the use of jacobian and grad newtype ComposeFunctor f g a = ComposeFunctor { decomposeFunctor :: f (g a) }
src/Numeric/AD/Internal/Dense.hs view
@@ -92,7 +92,7 @@      Zero <**> y      = auto (0 ** primal y)     _    <**> Zero   = auto 1-    x    <**> Lift y = lift1 (**y) (\z -> (y *^ z ** Id (y-1))) x+    x    <**> Lift y = lift1 (**y) (\z -> y *^ z ** Id (y - 1)) x     x    <**> y      = lift2_ (**) (\z xi yi -> (yi *! z /! xi, z *! log1 xi)) x y      _ *^ Zero       = Zero
src/Numeric/AD/Internal/Forward.hs view
@@ -37,6 +37,8 @@ import Numeric.AD.Internal.Classes import Numeric.AD.Internal.Identity +{-# ANN module "HLint: ignore Reduce duplication" #-}+ -- | 'Forward' mode AD data Forward a   = Forward !a a@@ -88,7 +90,7 @@      Zero <**> y      = auto (0 ** primal y)     _    <**> Zero   = auto 1-    x    <**> Lift y = lift1 (**y) (\z -> (y *^ z ** Id (y-1))) x+    x    <**> Lift y = lift1 (**y) (\z -> y *^ z ** Id (y - 1)) x     x    <**> y      = lift2_ (**) (\z xi yi -> (yi *! z /! xi, z *! log1 xi)) x y      a *^ Forward b db = Forward (a * b) (a * db)
src/Numeric/AD/Internal/Jet.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, TypeOperators, TemplateHaskell, ScopedTypeVariables, FlexibleContexts #-}+{-# LANGUAGE CPP, TypeOperators, ScopedTypeVariables, FlexibleContexts #-} {-# OPTIONS_HADDOCK hide #-} ----------------------------------------------------------------------------- -- |@@ -48,7 +48,7 @@   showsPrec d (Showable f) = f d  showable :: Show a => a -> Showable-showable a = Showable (\d -> showsPrec d a)+showable a = Showable (`showsPrec` a)  -- Polymorphic recursion precludes 'Data' in its current form, as no Data1 class exists -- Polymorphic recursion also breaks 'show' for 'Jet'!
src/Numeric/AD/Internal/Kahn.hs view
@@ -1,4 +1,5 @@-{-# LANGUAGE Rank2Types, TypeFamilies, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, FlexibleContexts, TemplateHaskell, UndecidableInstances, DeriveDataTypeable #-}+{-# LANGUAGE Rank2Types, MultiParamTypeClasses, FlexibleInstances, UndecidableInstances, ScopedTypeVariables, TemplateHaskell, TypeFamilies, DeriveDataTypeable, FunctionalDependencies #-}+ -- {-# OPTIONS_HADDOCK hide, prune #-} ----------------------------------------------------------------------------- -- |@@ -91,7 +92,7 @@      Kahn Zero <**> y                = auto (0 ** primal y)     _            <**> Kahn Zero     = auto 1-    x            <**> Kahn (Lift y) = lift1 (**y) (\z -> (y *^ z ** Id (y-1))) x+    x            <**> Kahn (Lift y) = lift1 (**y) (\z -> y *^ z ** Id (y-1)) x     x            <**> y                = lift2_ (**) (\z xi yi -> (yi *! z /! xi, z *! log1 xi)) x y  instance Primal Kahn where@@ -147,22 +148,21 @@  -- | back propagate sensitivities along a tape. backPropagate :: Num a => (Vertex -> (Tape a Int, Int, [Int])) -> STArray s Int a -> Vertex -> ST s ()-backPropagate vmap ss v = do-        case node of-            Unary _ g b -> do-                da <- readArray ss i-                db <- readArray ss b-                writeArray ss b (db + g*da)-            Binary _ gb gc b c -> do-                da <- readArray ss i-                db <- readArray ss b-                writeArray ss b (db + gb*da)-                dc <- readArray ss c-                writeArray ss c (dc + gc*da)-            _ -> return ()-    where-        (node, i, _) = vmap v-        -- this isn't _quite_ right, as it should allow negative zeros to multiply through+backPropagate vmap ss v = case node of+  Unary _ g b -> do+      da <- readArray ss i+      db <- readArray ss b+      writeArray ss b (db + g*da)+  Binary _ gb gc b c -> do+      da <- readArray ss i+      db <- readArray ss b+      writeArray ss b (db + gb*da)+      dc <- readArray ss c+      writeArray ss c (dc + gc*da)+  _ -> return ()+  where+    (node, i, _) = vmap v+    -- this isn't _quite_ right, as it should allow negative zeros to multiply through  topSortAcyclic :: Graph -> [Vertex] topSortAcyclic g = reverse $ runST $ do@@ -176,7 +176,7 @@                 add (m:ms) = do                     b <- ok (tg!m)                     ms' <- add ms-                    if b then return (m:ms') else return ms'+                    return $ if b then m : ms' else ms'                 ok [] = return True                 ok (x:xs) = do b <- readArray del x; if b then ok xs else return False             ns' <- add (g!n)
src/Numeric/AD/Internal/Reverse.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE Rank2Types, TypeFamilies, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, FlexibleContexts, TemplateHaskell, UndecidableInstances, DeriveDataTypeable, GADTs, ScopedTypeVariables #-}+{-# LANGUAGE CPP, Rank2Types, MultiParamTypeClasses, FlexibleInstances, UndecidableInstances, ScopedTypeVariables, TemplateHaskell, GADTs, TypeFamilies, DeriveDataTypeable, FlexibleContexts #-} -- {-# OPTIONS_HADDOCK hide, prune #-} ----------------------------------------------------------------------------- -- |@@ -51,11 +51,15 @@ import System.IO.Unsafe (unsafePerformIO) import Unsafe.Coerce +{-# ANN module "HLint: ignore Reduce duplication" #-}+ -- evil untyped tape+#ifndef HLINT data Cells where   Nil    :: Cells   Unary  :: {-# UNPACK #-} !Int -> a -> Cells -> Cells   Binary :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> a -> a -> Cells -> Cells+#endif  dropCells :: Int -> Cells -> Cells dropCells 0 xs = xs@@ -95,11 +99,13 @@ binarily f di dj i b j c = Reverse (unsafePerformIO (modifyTape (Proxy :: Proxy s) (bin i j di dj))) $! f b c {-# INLINE binarily #-} +#ifndef HLINT data Reverse s a where   Zero :: Reverse s a   Lift :: a -> Reverse s a   Reverse :: {-# UNPACK #-} !Int -> a -> Reverse s a   deriving (Show, Typeable)+#endif  instance (Reifies s Tape, Lifted (Reverse s)) => Mode (Reverse s) where   isKnownZero Zero = True@@ -117,7 +123,7 @@    Zero <**> y      = auto (0 ** primal y)   _    <**> Zero   = auto 1-  x    <**> Lift y = lift1 (**y) (\z -> (y *^ z ** Id (y-1))) x+  x    <**> Lift y = lift1 (**y) (\z -> y *^ z ** Id (y - 1)) x   x    <**> y      = lift2_ (**) (\z xi yi -> (yi *! z /! xi, z *! log1 xi)) x y  instance Primal (Reverse s) where
src/Numeric/AD/Internal/Sparse.hs view
@@ -153,7 +153,7 @@     Zero <**> y    = auto (0 ** primal y)     _    <**> Zero = auto 1     x    <**> y@(Sparse b bs)-      | IntMap.null bs = lift1 (**b) (\z -> (b *^ z <**> Sparse (b-1) IntMap.empty)) x+      | IntMap.null bs = lift1 (**b) (\z -> b *^ z <**> Sparse (b-1) IntMap.empty) x       | otherwise      = lift2_ (**) (\z xi yi -> (yi *! z /! xi, z *! log1 xi)) x y     Zero <+> a = a     a <+> Zero = a
src/Numeric/AD/Internal/Tower.hs view
@@ -107,7 +107,7 @@     zero = Tower []     Tower [] <**> y         = auto (0 ** primal y)     _        <**> Tower []  = auto 1-    x        <**> Tower [y] = lift1 (**y) (\z -> (y *^ z <**> Tower [y-1])) x+    x        <**> Tower [y] = lift1 (**y) (\z -> y *^ z <**> Tower [y-1]) x     x        <**> y         = lift2_ (**) (\z xi yi -> (yi *! z /! xi, z *! log1 xi)) x y      Tower [] <+> bs = bs
src/Numeric/AD/Internal/Types.hs view
@@ -28,6 +28,8 @@ import Language.Haskell.TH import Numeric.AD.Internal.Classes +{-# ANN module "HLint: ignore Eta reduce" #-}+ -- | 'AD' serves as a common wrapper for different 'Mode' instances, exposing a traditional -- numerical tower. Universal quantification is used to limit the actions in user code to -- machinery that will return the same answers under all AD modes, allowing us to use modes
src/Numeric/AD/Mode/Forward.hs view
@@ -120,6 +120,7 @@ jacobianWithT g f = bindWith g' f     where g' a ga = g a . tangent <$> ga {-# INLINE jacobianWithT #-}+{-# ANN jacobianWithT "HLint: ignore Eta reduce" #-}  -- | Compute the Jacobian using 'Forward' mode 'AD'. This must transpose the result, so 'jacobianT' is faster and allows more result types. --
src/Numeric/AD/Mode/Kahn.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE Rank2Types, TemplateHaskell, BangPatterns, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, ScopedTypeVariables #-}+{-# LANGUAGE Rank2Types, TemplateHaskell, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, ScopedTypeVariables #-} ----------------------------------------------------------------------------- -- | -- Module      :  Numeric.AD.Mode.Kahn
src/Numeric/AD/Mode/Sparse.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE Rank2Types, BangPatterns #-}+{-# LANGUAGE Rank2Types #-} ----------------------------------------------------------------------------- -- | -- Module      : Numeric.AD.Mode.Sparse
src/Numeric/AD/Variadic.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE Rank2Types, TemplateHaskell, BangPatterns, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, ScopedTypeVariables #-} ----------------------------------------------------------------------------- -- | -- Module      :  Numeric.AD.Variadic
src/Numeric/AD/Variadic/Kahn.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE Rank2Types, TemplateHaskell, BangPatterns, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, ScopedTypeVariables #-} ----------------------------------------------------------------------------- -- | -- Module      :  Numeric.AD.Variadic.Kahn
src/Numeric/AD/Variadic/Sparse.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE Rank2Types, TemplateHaskell, BangPatterns, MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, ScopedTypeVariables #-} ----------------------------------------------------------------------------- -- | -- Module      :  Numeric.AD.Variadic.Sparse
tests/doctests.hs view
@@ -1,11 +1,12 @@ module Main where -import Test.DocTest-import System.Directory-import System.FilePath+import Build_doctests (deps) import Control.Applicative import Control.Monad import Data.List+import System.Directory+import System.FilePath+import Test.DocTest  main :: IO () main = getSources >>= \sources -> doctest $@@ -13,7 +14,8 @@   : "-idist/build/autogen"   : "-optP-include"   : "-optPdist/build/autogen/cabal_macros.h"-  : sources+  : "-hide-all-packages"+  : map ("-package="++) deps ++ sources  getSources :: IO [FilePath] getSources = filter (isSuffixOf ".hs") <$> go "src"