ad 0.45.0 → 0.46.0
raw patch · 7 files changed
+13/−53 lines, 7 filesdep +comonad
Dependencies added: comonad
Files
- Numeric/AD/Classes.hs +1/−7
- Numeric/AD/Halley.hs +1/−1
- Numeric/AD/Internal/Comonad.hs +0/−29
- Numeric/AD/Internal/Stream.hs +2/−4
- Numeric/AD/Internal/Tensors.hs +0/−7
- Numeric/AD/Newton.hs +1/−1
- ad.cabal +8/−4
Numeric/AD/Classes.hs view
@@ -10,13 +10,7 @@ ----------------------------------------------------------------------------- module Numeric.AD.Classes- ( - -- * AD Modes- Mode(..)- -- * Comonads- , Copointed(..)- , Comonad(..)+ ( Mode(..) ) where import Numeric.AD.Internal.Classes-import Numeric.AD.Internal.Comonad
Numeric/AD/Halley.hs view
@@ -52,7 +52,7 @@ findZero :: Fractional a => UU a -> a -> [a] findZero f = go where- go x = x : go (x - 2*y*y'/(2*y'*y'-y*y''))+ go x = x : if y == 0 then [] else go (x - 2*y*y'/(2*y'*y'-y*y'')) where (y:y':y'':_) = diffs0 f x {-# INLINE findZero #-}
− Numeric/AD/Internal/Comonad.hs
@@ -1,29 +0,0 @@-{-# LANGUAGE TypeOperators, TemplateHaskell, ScopedTypeVariables #-}-{-# OPTIONS_HADDOCK hide #-}--------------------------------------------------------------------------------- |--- Module : Numeric.AD.Internal.Comonad--- Copyright : (c) Edward Kmett 2010--- License : BSD3--- Maintainer : ekmett@gmail.com--- Stability : experimental--- Portability : GHC only------------------------------------------------------------------------------------- TODO: separate a \"comonads\" package from \"category-extras\"--module Numeric.AD.Internal.Comonad- ( Copointed(..)- , Comonad(..)- ) where--class Functor f => Copointed f where- extract :: f a -> a--class Copointed f => Comonad f where- duplicate :: f a -> f (f a)- extend :: (f a -> b) -> f a -> f b-- duplicate = extend id- extend f = fmap f . duplicate
Numeric/AD/Internal/Stream.hs view
@@ -19,12 +19,12 @@ ) where import Control.Applicative+import Control.Comonad import Data.Monoid import Data.Foldable import Data.Traversable import Data.Data (Data(..), mkDataType, DataType, mkConstr, Constr, constrIndex, Fixity(Infix)) import Data.Typeable (Typeable1(..), TyCon, mkTyCon, mkTyConApp, gcast1)-import Numeric.AD.Internal.Comonad infixl 3 :< @@ -35,10 +35,8 @@ instance Functor f => Functor (Stream f) where fmap f (a :< as) = f a :< fmap f <$> as -instance Functor f => Copointed (Stream f) where- extract (a :< _) = a- instance Functor f => Comonad (Stream f) where+ extract (a :< _) = a duplicate aas@(_ :< as) = aas :< duplicate <$> as extend f aas@(_ :< as) = f aas :< extend f <$> as
Numeric/AD/Internal/Tensors.hs view
@@ -23,7 +23,6 @@ import Data.Traversable import Data.Monoid import Data.Typeable (Typeable1(..), TyCon, mkTyCon, mkTyConApp)-import Numeric.AD.Internal.Comonad import Numeric.AD.Internal.Stream infixl 3 :-@@ -41,12 +40,6 @@ instance Traversable f => Traversable (Tensors f) where traverse f (a :- as) = (:-) <$> f a <*> traverse (traverse f) as---- | While we can not be a 'Comonad' without a 'fzip'-like operation, you can use the--- comonad for @'Stream' f a@ to manipulate a structure comonadically that you can turn --- into 'Tensors'.-instance Functor f => Copointed (Tensors f) where- extract (a :- _) = a tailT :: Tensors f a -> Tensors f (f a) tailT (_ :- as) = as
Numeric/AD/Newton.hs view
@@ -49,7 +49,7 @@ findZero :: Fractional a => UU a -> a -> [a] findZero f = go where- go x = x : go (x - y/y') + go x = x : if y == 0 then [] else go (x - y/y') where (y,y') = diff' f x {-# INLINE findZero #-}
ad.cabal view
@@ -1,8 +1,8 @@ name: ad-version: 0.45.0+version: 0.46.0 license: BSD3 license-File: LICENSE-copyright: (c) Edward Kmett 2010,+copyright: (c) Edward Kmett 2010-2011, (c) Barak Pearlmutter and Jeffrey Mark Siskind 2008-2009 author: Edward Kmett maintainer: ekmett@gmail.com@@ -56,6 +56,10 @@ . * @0@ means that the resulting derivative list is padded with 0s at the end. .+ Changes since 0.45.0+ .+ * Converted 'Stream' to use the external 'comonad' package+ . Changes since 0.44.5 . * Added Halley's method@@ -82,7 +86,8 @@ data-reify >= 0.5 && < 0.6, containers >= 0.2 && < 0.4, template-haskell >= 2.4 && < 2.5,- array >= 0.2 && < 0.4+ array >= 0.2 && < 0.4,+ comonad >= 0.6 && < 0.7 exposed-modules: Numeric.AD@@ -110,7 +115,6 @@ other-modules: Numeric.AD.Internal.Types- Numeric.AD.Internal.Comonad Numeric.AD.Internal.Stream Numeric.AD.Internal.Tensors Numeric.AD.Internal.Identity