ad 3.3.1.1 → 3.4
raw patch · 11 files changed
+151/−14 lines, 11 filesdep +erfPVP ok
version bump matches the API change (PVP)
Dependencies added: erf
API changes (from Hackage documentation)
+ Numeric.AD.Internal.Classes: erf1 :: (Lifted t, Erf a) => t a -> t a
+ Numeric.AD.Internal.Classes: erfc1 :: (Lifted t, Erf a) => t a -> t a
+ Numeric.AD.Internal.Classes: inverf1 :: (Lifted t, InvErf a) => t a -> t a
+ Numeric.AD.Internal.Classes: inverfc1 :: (Lifted t, InvErf a) => t a -> t a
+ Numeric.AD.Internal.Classes: invnormcdf1 :: (Lifted t, InvErf a) => t a -> t a
+ Numeric.AD.Internal.Classes: normcdf1 :: (Lifted t, Erf a) => t a -> t a
Files
- .ghci +1/−0
- .gitignore +13/−0
- .travis.yml +2/−4
- .vim.custom +21/−0
- CHANGELOG.markdown +4/−0
- ad.cabal +22/−3
- src/Numeric/AD/Internal/Classes.hs +18/−3
- src/Numeric/AD/Internal/Composition.hs +6/−0
- src/Numeric/AD/Internal/Identity.hs +21/−4
- travis/cabal-apt-install +27/−0
- travis/config +16/−0
+ .ghci view
@@ -0,0 +1,1 @@+:set -isrc -idist/build/autogen -optP-include -optPdist/build/autogen/cabal_macros.h
+ .gitignore view
@@ -0,0 +1,13 @@+dist+docs+wiki+TAGS+tags+wip+.DS_Store+.*.swp+.*.swo+*.o+*.hi+*~+*#
.travis.yml view
@@ -1,12 +1,10 @@ language: haskell before_install: # Uncomment whenever hackage is down.- # - mkdir -p ~/.cabal && cp config ~/.cabal/config && cabal update+ # - mkdir -p ~/.cabal && cp travis/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+ - travis/cabal-apt-install $mode install: - cabal configure -flib-Werror $mode
+ .vim.custom view
@@ -0,0 +1,21 @@+" Add the following to your .vimrc to automatically load this on startup+" if filereadable(".vim.custom")+" so .vim.custom+" endif++function StripTrailingWhitespace()+ let myline=line(".")+ let mycolumn = col(".")+ silent %s/ *$//+ call cursor(myline, mycolumn)+endfunction++syntax on+set tags=TAGS;/+set listchars=tab:‗‗,trail:‗+set list++map <F2> :exec ":!hasktags -x -c --ignore src"<CR><CR>++au BufWritePre *.hs,*.markdown silent! cal StripTrailingWhitespace()+au BufWritePost *.hs silent! :exec ":!hasktags -x -c --ignore src"
CHANGELOG.markdown view
@@ -1,3 +1,7 @@+3.4+---+* Added support for `erf` and `inverf`, etc. from `Data.Number.Erf`.+ 3.3.1 ----- * Build system improvements
ad.cabal view
@@ -1,5 +1,5 @@ name: ad-version: 3.3.1.1+version: 3.4 license: BSD3 license-File: LICENSE copyright: (c) Edward Kmett 2010-2013,@@ -12,7 +12,16 @@ bug-reports: http://github.com/ekmett/ad/issues build-type: Custom cabal-version: >= 1.8-extra-source-files: TODO .travis.yml CHANGELOG.markdown README.markdown+extra-source-files:+ .ghci+ .gitignore+ .travis.yml+ .vim.custom+ TODO+ CHANGELOG.markdown+ README.markdown+ travis/cabal-apt-install+ travis/config synopsis: Automatic Differentiation description: Forward-, reverse- and mixed- mode automatic differentiation combinators with a common API.@@ -61,6 +70,10 @@ . * @0@ means that the resulting derivative list is padded with 0s at the end. +flag lib-Werror+ default: False+ manual: True+ source-repository head type: git location: git://github.com/ekmett/ad.git@@ -91,6 +104,7 @@ comonad >= 3, containers >= 0.2 && < 0.6, data-reify >= 0.6 && < 0.7,+ erf >= 2.0 && < 2.1, free >= 3, mtl >= 2, reflection >= 1.1.6,@@ -131,7 +145,12 @@ Numeric.AD.Internal.Jet Numeric.AD.Internal.Identity - ghc-options: -Wall -fspec-constr -fdicts-cheap -O2+ if flag(lib-Werror)+ ghc-options: -Werror+ else+ ghc-options: -Wall++ ghc-options: -fspec-constr -fdicts-cheap -O2 -- Verify the results of the examples test-suite doctests
src/Numeric/AD/Internal/Classes.hs view
@@ -28,8 +28,9 @@ import Control.Applicative hiding ((<**>)) import Data.Char-import Language.Haskell.TH import Data.Function (on)+import Data.Number.Erf+import Language.Haskell.TH infixr 8 **!, <**> infixl 7 *!, /!, ^*, *^, ^/@@ -81,6 +82,12 @@ enumFromThenTo1 :: (Num a, Enum a) => t a -> t a -> t a -> [t a] minBound1 :: (Num a, Bounded a) => t a maxBound1 :: (Num a, Bounded a) => t a+ erf1 :: Erf a => t a -> t a+ erfc1 :: Erf a => t a -> t a+ normcdf1 :: Erf a => t a -> t a+ inverf1 :: InvErf a => t a -> t a+ inverfc1 :: InvErf a => t a -> t a+ invnormcdf1 :: InvErf a => t a -> t a class Lifted t => Mode t where -- | allowed to return False for items with a zero derivative, but we'll give more NaNs than strictly necessary@@ -268,8 +275,16 @@ truncate1 = discrete1 truncate round1 = discrete1 round ceiling1 = discrete1 ceiling- floor1 = discrete1 floor |]+ floor1 = discrete1 floor + erf1 = lift1 erf $ \x -> (fromInteger1 2 /! sqrt1 pi1) *! exp1 (negate1 x *! x)+ erfc1 = lift1 erfc $ \x -> (fromInteger1 (-2) /! sqrt1 pi1) *! exp1 (negate1 x *! x)+ normcdf1 = lift1 normcdf $ \x -> (fromInteger1 (-1) /! sqrt1 pi1) *! exp1 (x *! x *! fromRational1 (- recip 2) /! sqrt1 (fromInteger1 2))++ inverf1 = lift1 inverfc $ \x -> recip1 $ (fromInteger1 2 /! sqrt1 pi1) *! exp1 (negate1 x *! x)+ inverfc1 = lift1 inverfc $ \x -> recip1 $ negate1 (fromInteger1 2 /! sqrt1 pi1) *! exp1 (negate1 x *! x)+ invnormcdf1 = lift1 invnormcdf $ \x -> recip1 $ (fromInteger1 (-1) /! sqrt1 pi1) *! exp1 (x *! x *! fromRational1 (- recip 2) /! sqrt1 (fromInteger1 2)) |]+ varA :: Q Type varA = varT (mkName "a") @@ -302,7 +317,7 @@ members <- liftedMembers let keep n = nameBase n `elem` members xs <- lowerInstance keep ((classP ''Num [varA]:) . f) t `mapM` [''Enum, ''Eq, ''Ord, ''Bounded, ''Show]- ys <- lowerInstance keep f t `mapM` [''Num, ''Fractional, ''Floating, ''RealFloat,''RealFrac, ''Real]+ ys <- lowerInstance keep f t `mapM` [''Num, ''Fractional, ''Floating, ''RealFloat,''RealFrac, ''Real, ''Erf, ''InvErf] return (xs ++ ys) lowerInstance :: (Name -> Bool) -> ([Q Pred] -> [Q Pred]) -> Q Type -> Name -> Q Dec
src/Numeric/AD/Internal/Composition.hs view
@@ -164,6 +164,12 @@ enumFromThenTo1 (ComposeMode a) (ComposeMode b) (ComposeMode c) = map ComposeMode $ enumFromThenTo1 a b c minBound1 = ComposeMode minBound1 maxBound1 = ComposeMode maxBound1+ erf1 (ComposeMode a) = ComposeMode (erf1 a)+ erfc1 (ComposeMode a) = ComposeMode (erfc1 a)+ normcdf1 (ComposeMode a) = ComposeMode (normcdf1 a)+ inverf1 (ComposeMode a) = ComposeMode (inverf1 a)+ inverfc1 (ComposeMode a) = ComposeMode (inverfc1 a)+ invnormcdf1 (ComposeMode a) = ComposeMode (invnormcdf1 a) instance (Typeable1 f, Typeable1 g) => Typeable1 (ComposeMode f g) where typeOf1 tfga = mkTyConApp composeModeTyCon [typeOf1 (fa tfga), typeOf1 (ga tfga)]
src/Numeric/AD/Internal/Identity.hs view
@@ -19,13 +19,14 @@ ) where import Control.Applicative-import Numeric.AD.Internal.Classes-import Numeric.AD.Internal.Types-import Data.Monoid import Data.Data (Data)+import Data.Foldable (Foldable, foldMap)+import Data.Monoid+import Data.Number.Erf import Data.Typeable (Typeable) import Data.Traversable (Traversable, traverse)-import Data.Foldable (Foldable, foldMap)+import Numeric.AD.Internal.Classes+import Numeric.AD.Internal.Types newtype Id a = Id { runId :: a } deriving (Iso a, Eq, Ord, Show, Enum, Bounded, Num, Real, Fractional, Floating, RealFrac, RealFloat, Monoid, Data, Typeable)@@ -127,6 +128,12 @@ enumFromThenTo1 = enumFromThenTo minBound1 = minBound maxBound1 = maxBound+ erf1 = erf+ erfc1 = erfc+ normcdf1 = normcdf+ inverf1 = inverf+ inverfc1 = inverfc+ invnormcdf1 = invnormcdf instance Mode Id where auto = Id@@ -137,3 +144,13 @@ instance Primal Id where primal (Id a) = a++instance Erf a => Erf (Id a) where+ erf = Id . erf . runId+ erfc = Id . erfc . runId+ normcdf = Id . normcdf . runId++instance InvErf a => InvErf (Id a) where+ inverf = Id . inverf . runId+ inverfc = Id . inverfc . runId+ invnormcdf = Id . invnormcdf . runId
+ travis/cabal-apt-install view
@@ -0,0 +1,27 @@+#! /bin/bash+set -eu++APT="sudo apt-get -q -y"+CABAL_INSTALL_DEPS="cabal install --only-dependencies --force-reinstall"++$APT update+$APT install dctrl-tools++# Find potential system packages to satisfy cabal dependencies+deps()+{+ local M='^\([^ ]\+\)-[0-9.]\+ (.*$'+ local G=' -o ( -FPackage -X libghc-\L\1\E-dev )'+ local E="$($CABAL_INSTALL_DEPS "$@" --dry-run -v 2> /dev/null \+ | sed -ne "s/$M/$G/p" | sort -u)"+ grep-aptavail -n -sPackage \( -FNone -X None \) $E | sort -u+}++$APT install $(deps "$@") libghc-quickcheck2-dev # QuickCheck is special+$CABAL_INSTALL_DEPS "$@" # Install the rest via Hackage++if ! $APT install hlint ; then+ $APT install $(deps hlint)+ cabal install hlint+fi+
+ travis/config view
@@ -0,0 +1,16 @@+-- This provides a custom ~/.cabal/config file for use when hackage is down that should work on unix+--+-- This is particularly useful for travis-ci to get it to stop complaining+-- about a broken build when everything is still correct on our end.+--+-- This uses Luite Stegeman's mirror of hackage provided by his 'hdiff' site instead+--+-- To enable this, uncomment the before_script in .travis.yml++remote-repo: hdiff.luite.com:http://hdiff.luite.com/packages/archive+remote-repo-cache: ~/.cabal/packages+world-file: ~/.cabal/world+build-summary: ~/.cabal/logs/build.log+remote-build-reporting: anonymous+install-dirs user+install-dirs global