ad 4.3.2 → 4.3.2.1
raw patch · 7 files changed
+100/−46 lines, 7 filesdep ~comonaddep ~doctestdep ~transformerssetup-changednew-uploaderPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: comonad, doctest, transformers
API changes (from Hackage documentation)
- Numeric.AD.Internal.Or: L :: a -> Or F a b
- Numeric.AD.Internal.Or: R :: b -> Or T a b
- Numeric.AD.Internal.Reverse: Binary :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> a -> a -> Cells -> Cells
- Numeric.AD.Internal.Reverse: Lift :: a -> Reverse s a
- Numeric.AD.Internal.Reverse: Nil :: Cells
- Numeric.AD.Internal.Reverse: Reverse :: {-# UNPACK #-} !Int -> a -> Reverse s a
- Numeric.AD.Internal.Reverse: Unary :: {-# UNPACK #-} !Int -> a -> Cells -> Cells
- Numeric.AD.Internal.Reverse: Zero :: Reverse s a
- Numeric.AD.Newton: CC :: (forall s. Reifies s Tape => f (Reverse s a) -> Reverse s a) -> CC f a
+ Numeric.AD: type family Scalar t;
+ Numeric.AD: }
+ Numeric.AD.Internal.Or: [L] :: a -> Or F a b
+ Numeric.AD.Internal.Or: [R] :: b -> Or T a b
+ Numeric.AD.Internal.Reverse: [Binary] :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> a -> a -> Cells -> Cells
+ Numeric.AD.Internal.Reverse: [Lift] :: a -> Reverse s a
+ Numeric.AD.Internal.Reverse: [Nil] :: Cells
+ Numeric.AD.Internal.Reverse: [Reverse] :: {-# UNPACK #-} !Int -> a -> Reverse s a
+ Numeric.AD.Internal.Reverse: [Unary] :: {-# UNPACK #-} !Int -> a -> Cells -> Cells
+ Numeric.AD.Internal.Reverse: [Zero] :: Reverse s a
+ Numeric.AD.Jacobian: type family D t :: *;
+ Numeric.AD.Jacobian: }
+ Numeric.AD.Mode: type family Scalar t;
+ Numeric.AD.Mode: }
+ Numeric.AD.Newton: [CC] :: forall f a. (forall s. Reifies s Tape => f (Reverse s a) -> Reverse s a) -> CC f a
- Numeric.AD: class (Num t, Num (Scalar t)) => Mode t where type family Scalar t isKnownConstant _ = False isKnownZero _ = False a *^ b = auto a * b a ^* b = a * auto b a ^/ b = a ^* recip b zero = auto 0
+ Numeric.AD: class (Num t, Num (Scalar t)) => Mode t where type Scalar t isKnownConstant _ = False isKnownZero _ = False a *^ b = auto a * b a ^* b = a * auto b a ^/ b = a ^* recip b zero = auto 0 where {
- Numeric.AD.Internal.Kahn: partials :: Num a => Kahn a -> [(Int, a)]
+ Numeric.AD.Internal.Kahn: partials :: forall a. Num a => Kahn a -> [(Int, a)]
- Numeric.AD.Internal.Reverse: partials :: (Reifies s Tape, Num a) => Reverse s a -> [a]
+ Numeric.AD.Internal.Reverse: partials :: forall s a. (Reifies s Tape, Num a) => Reverse s a -> [a]
- Numeric.AD.Jacobian: class (Mode t, Mode (D t), Num (D t)) => Jacobian t where type family D t :: *
+ Numeric.AD.Jacobian: class (Mode t, Mode (D t), Num (D t)) => Jacobian t where type D t :: * where {
- Numeric.AD.Mode: class (Num t, Num (Scalar t)) => Mode t where type family Scalar t isKnownConstant _ = False isKnownZero _ = False a *^ b = auto a * b a ^* b = a * auto b a ^/ b = a ^* recip b zero = auto 0
+ Numeric.AD.Mode: class (Num t, Num (Scalar t)) => Mode t where type Scalar t isKnownConstant _ = False isKnownZero _ = False a *^ b = auto a * b a ^* b = a * auto b a ^/ b = a ^* recip b zero = auto 0 where {
- Numeric.AD.Newton: constrainedDescent :: (Traversable f, RealFloat a, Floating a, Ord a) => (forall s. Reifies s Tape => f (Reverse s a) -> Reverse s a) -> [CC f a] -> f a -> [(a, f a)]
+ Numeric.AD.Newton: constrainedDescent :: forall f a. (Traversable f, RealFloat a, Floating a, Ord a) => (forall s. Reifies s Tape => f (Reverse s a) -> Reverse s a) -> [CC f a] -> f a -> [(a, f a)]
Files
- .travis.yml +77/−30
- CHANGELOG.markdown +6/−0
- Setup.lhs +4/−0
- ad.cabal +5/−5
- include/instances.h +4/−4
- src/Numeric/AD/Internal/Kahn.hs +1/−1
- tests/doctests.hs +3/−6
.travis.yml view
@@ -1,46 +1,92 @@+# This file has been generated -- see https://github.com/hvr/multi-ghc-travis+#+# Modifications: benchmarks disabled, cabal check disabled, IRC notifications language: c sudo: false +cache:+ directories:+ - $HOME/.cabsnap+ - $HOME/.cabal/packages++before_cache:+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar+ matrix: include:- - env: CABALVER=1.16 GHCVER=7.4.2 GHCOPTS="-Werror" JOPTS=""- addons: {apt: {packages: [cabal-install-1.16, ghc-7.4.2], sources: [hvr-ghc]}}- - env: CABALVER=1.18 GHCVER=7.6.3 GHCOPTS="-Werror" JOPTS="-j2"- addons: {apt: {packages: [cabal-install-1.18, ghc-7.6.3], sources: [hvr-ghc]}}- - env: CABALVER=1.18 GHCVER=7.8.4 GHCOPTS="-Werror" JOPTS="-j2"- addons: {apt: {packages: [cabal-install-1.18, ghc-7.8.4], sources: [hvr-ghc]}}- - env: CABALVER=1.22 GHCVER=7.10.1 GHCOPTS="" JOPTS="-j2"- addons: {apt: {packages: [cabal-install-1.22, ghc-7.10.1],sources: [hvr-ghc]}}- - env: CABALVER=head GHCVER=head GHCOPTS="" JOPTS="-j2"- addons: {apt: {packages: [cabal-install-head,ghc-head], sources: [hvr-ghc]}}-- allow_failures:- - env: CABALVER=head GHCVER=head GHCOPTS="" JOPTS="-j2"+ - env: CABALVER=1.16 GHCVER=7.4.2 ALEXVER=3.1.7 HAPPYVER=1.19.5+ compiler: ": #GHC 7.4.2"+ addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.2,alex-3.1.7,happy-1.19.5], sources: [hvr-ghc]}}+ - env: CABALVER=1.16 GHCVER=7.6.3 ALEXVER=3.1.7 HAPPYVER=1.19.5+ compiler: ": #GHC 7.6.3"+ addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3,alex-3.1.7,happy-1.19.5], sources: [hvr-ghc]}}+ - env: CABALVER=1.18 GHCVER=7.8.4 ALEXVER=3.1.7 HAPPYVER=1.19.5+ compiler: ": #GHC 7.8.4"+ addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4,alex-3.1.7,happy-1.19.5], sources: [hvr-ghc]}}+ - env: CABALVER=1.22 GHCVER=7.10.3 ALEXVER=3.1.7 HAPPYVER=1.19.5+ compiler: ": #GHC 7.10.3"+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,alex-3.1.7,happy-1.19.5], sources: [hvr-ghc]}}+ - env: CABALVER=1.24 GHCVER=8.0.1 ALEXVER=3.1.7 HAPPYVER=1.19.5+ compiler: ": #GHC 8.0.1"+ addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1,alex-3.1.7,happy-1.19.5], sources: [hvr-ghc]}} before_install:- - export PATH=~/.cabal/bin:/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH- - export CABAL=cabal-$CABALVER- - travis_retry $CABAL update- - if [ "$CABALVER" = "1.22" ]; then cabal install Cabal-1.22.4.0; fi- - $CABAL --version- - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"+ - unset CC+ - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:/opt/alex/$ALEXVER/bin:/opt/happy/$HAPPYVER/bin:$PATH install:- - | - if [ $GHCVER = "head" ] || [ $GHCVER = "7.8.4" ] || [ $GHCVER = "7.10.1" ]; then- $CABAL install --constraint=transformers\ installed happy alex- export PATH=$HOME/.cabal/bin:$PATH+ - cabal --version+ - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"+ - if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];+ then+ zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >+ $HOME/.cabal/packages/hackage.haskell.org/00-index.tar; fi- - $CABAL install $JOPTS --enable-tests --only-dependencies --force+ - travis_retry cabal update -v+ - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config+ - cabal install --only-dependencies --enable-tests --dry -v > installplan.txt+ - sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt -script:- - $CABAL configure -v2 --enable-tests- - $CABAL build $JOPTS --ghc-options=$GHCOPTS- - |- if [ $GHCVER != "head" ]; then- $CABAL test+# check whether current requested install-plan matches cached package-db snapshot+ - if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;+ then+ echo "cabal build-cache HIT";+ rm -rfv .ghc;+ cp -a $HOME/.cabsnap/ghc $HOME/.ghc;+ cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;+ else+ echo "cabal build-cache MISS";+ rm -rf $HOME/.cabsnap;+ mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;+ cabal install --only-dependencies --enable-tests; fi +# snapshot package-db on cache miss+ - if [ ! -d $HOME/.cabsnap ];+ then+ echo "snapshotting package-db to build-cache";+ mkdir $HOME/.cabsnap;+ cp -a $HOME/.ghc $HOME/.cabsnap/ghc;+ cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;+ fi++# Here starts the actual work to be performed for the package under test;+# any command which exits with a non-zero exit code causes the build to fail.+script:+ - if [ -f configure.ac ]; then autoreconf -i; fi+ - cabal configure --enable-tests -v2 # -v2 provides useful information for debugging+ - cabal build # this builds all libraries and executables (including tests)+ - cabal test+ - cabal sdist # tests that a source-distribution can be generated+ # - cabal check disabled due to spurious -O2 warning++# Check that the resulting source distribution can be built & installed.+# If there are no other `.tar.gz` files in `dist`, this can be even simpler:+# `cabal install --force-reinstalls dist/*-*.tar.gz`+ - SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&+ (cd dist && cabal install --force-reinstalls "$SRC_TGZ")+ notifications: irc: channels:@@ -48,3 +94,4 @@ skip_join: true template: - "\x0313ad\x0f/\x0306%{branch}\x0f \x0314%{commit}\x0f %{message} \x0302\x1f%{build_url}\x0f"+# EOF
CHANGELOG.markdown view
@@ -1,3 +1,9 @@+4.3.2.1+-----+* GHC 8 support+* Fix Kahn mode's `**` implementation+* Fix multiple problems in Erf and InvErf methods+ 4.3.2 ----- * Added `NoEq` versions of several combinators that can be used when `Eq` isn't available on the numeric type involved.
Setup.lhs view
@@ -30,6 +30,10 @@ withTestLBI pkg lbi $ \suite suitecfg -> do rewriteFile (dir </> "Build_" ++ testName suite ++ ".hs") $ unlines [ "module Build_" ++ testName suite ++ " where"+ , ""+ , "autogen_dir :: String"+ , "autogen_dir = " ++ show dir+ , "" , "deps :: [String]" , "deps = " ++ (show $ formatdeps (testDeps libcfg suitecfg)) ]
ad.cabal view
@@ -1,5 +1,5 @@ name: ad-version: 4.3.2+version: 4.3.2.1 license: BSD3 license-File: LICENSE copyright: (c) Edward Kmett 2010-2015,@@ -12,7 +12,7 @@ bug-reports: http://github.com/ekmett/ad/issues build-type: Custom cabal-version: >= 1.10-tested-with: GHC==7.0.1, GHC == 7.0.4, GHC == 7.2.2, GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.1, GHC == 7.10.2+tested-with: GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.1 synopsis: Automatic Differentiation extra-source-files: .ghci@@ -105,14 +105,14 @@ build-depends: array >= 0.2 && < 0.6, base >= 4.3 && < 5,- comonad >= 4 && < 5,+ comonad >= 4 && < 6, containers >= 0.2 && < 0.6, data-reify >= 0.6 && < 0.7, erf >= 2.0 && < 2.1, free >= 4.6.1 && < 5, nats >= 0.1.2 && < 2, reflection >= 1.4 && < 3,- transformers >= 0.3 && < 0.5+ transformers >= 0.3 && < 0.6 if impl(ghc < 7.8) build-depends: tagged >= 0.7 && < 1@@ -171,7 +171,7 @@ build-depends: base, directory,- doctest >= 0.9.0.1 && <= 0.11,+ doctest >= 0.9.0.1 && <= 0.12, filepath ghc-options: -Wall -threaded hs-source-dirs: tests
include/instances.h view
@@ -97,9 +97,9 @@ instance BODY1(Erf a) => Erf (HEAD) where erf = lift1 erf $ \x -> (2 / sqrt pi) * exp (negate x * x) erfc = lift1 erfc $ \x -> ((-2) / sqrt pi) * exp (negate x * x)- normcdf = lift1 normcdf $ \x -> ((-1) / sqrt pi) * exp (x * x * fromRational (- recip 2) / sqrt (2))+ normcdf = lift1 normcdf $ \x -> (recip $ sqrt (2 * pi)) * exp (- x * x / 2) instance BODY1(InvErf a) => InvErf (HEAD) where- inverf = lift1 inverfc $ \x -> recip $ (2 / sqrt pi) * exp (negate x * x)- inverfc = lift1 inverfc $ \x -> recip $ negate (2 / sqrt pi) * exp (negate x * x)- invnormcdf = lift1 invnormcdf $ \x -> recip $ ((-1) / sqrt pi) * exp (x * x * fromRational (- recip 2) / sqrt 2)+ inverf = lift1_ inverf $ \x _ -> sqrt pi / 2 * exp (x * x)+ inverfc = lift1_ inverfc $ \x _ -> negate (sqrt pi / 2) * exp (x * x)+ invnormcdf = lift1_ invnormcdf $ \x _ -> sqrt (2 * pi) * exp (x * x / 2)
src/Numeric/AD/Internal/Kahn.hs view
@@ -116,7 +116,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 <**> y = lift2_ (**) (\z xi yi -> (yi * z / xi, z * xi)) x y+x <**> y = lift2_ (**) (\z xi yi -> (yi * z / xi, z * log xi)) x y primal :: Num a => Kahn a -> a primal (Kahn Zero) = 0
tests/doctests.hs view
@@ -1,10 +1,7 @@-{-# LANGUAGE CPP #-} module Main where -import Build_doctests (deps)-#if __GLASGOW_HASKELL__ < 710+import Build_doctests (autogen_dir, deps) import Control.Applicative-#endif import Control.Monad import Data.List import System.Directory@@ -14,9 +11,9 @@ main :: IO () main = getSources >>= \sources -> doctest $ "-isrc"- : "-idist/build/autogen"+ : ("-i" ++ autogen_dir) : "-optP-include"- : "-optPdist/build/autogen/cabal_macros.h"+ : ("-optP" ++ autogen_dir ++ "/cabal_macros.h") : "-optP-I" : "-optPinclude" : "-hide-all-packages"