{-# LANGUAGE CPP #-}
{-# LANGUAGE Rank2Types #-}
module Numeric.AD.Mode.Forward.Double
( AD
, ForwardDouble
, grad
, grad'
, gradWith
, gradWith'
, jacobian
, jacobian'
, jacobianWith
, jacobianWith'
, jacobianT
, jacobianWithT
, diff
, diff'
, diffF
, diffF'
, du
, du'
, duF
, duF'
) where
#if __GLASGOW_HASKELL__ < 710
import Data.Traversable (Traversable)
#endif
import Numeric.AD.Internal.Type (AD(AD), runAD)
import Numeric.AD.Internal.Forward.Double (ForwardDouble)
import qualified Numeric.AD.Rank1.Forward.Double as Rank1
du :: Functor f => (forall s. f (AD s ForwardDouble) -> AD s ForwardDouble) -> f (Double, Double) -> Double
du f = Rank1.du (runAD . f . fmap AD)
{-# INLINE du #-}
du' :: Functor f => (forall s. f (AD s ForwardDouble) -> AD s ForwardDouble) -> f (Double, Double) -> (Double, Double)
du' f = Rank1.du' (runAD . f . fmap AD)
{-# INLINE du' #-}
duF :: (Functor f, Functor g) => (forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)) -> f (Double, Double) -> g Double
duF f = Rank1.duF (fmap runAD . f . fmap AD)
{-# INLINE duF #-}
duF' :: (Functor f, Functor g) => (forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)) -> f (Double, Double) -> g (Double, Double)
duF' f = Rank1.duF' (fmap runAD . f . fmap AD)
{-# INLINE duF' #-}
diff :: (forall s. AD s ForwardDouble -> AD s ForwardDouble) -> Double -> Double
diff f = Rank1.diff (runAD.f.AD)
{-# INLINE diff #-}
diff' :: (forall s. AD s ForwardDouble -> AD s ForwardDouble) -> Double -> (Double, Double)
diff' f = Rank1.diff' (runAD.f.AD)
{-# INLINE diff' #-}
diffF :: Functor f => (forall s. AD s ForwardDouble -> f (AD s ForwardDouble)) -> Double -> f Double
diffF f = Rank1.diffF (fmap runAD.f.AD)
{-# INLINE diffF #-}
diffF' :: Functor f => (forall s. AD s ForwardDouble -> f (AD s ForwardDouble)) -> Double -> f (Double, Double)
diffF' f = Rank1.diffF' (fmap runAD.f.AD)
{-# INLINE diffF' #-}
jacobianT :: (Traversable f, Functor g) => (forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)) -> f Double -> f (g Double)
jacobianT f = Rank1.jacobianT (fmap runAD.f.fmap AD)
{-# INLINE jacobianT #-}
jacobianWithT :: (Traversable f, Functor g) => (Double -> Double -> b) -> (forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)) -> f Double -> f (g b)
jacobianWithT g f = Rank1.jacobianWithT g (fmap runAD.f.fmap AD)
{-# INLINE jacobianWithT #-}
jacobian :: (Traversable f, Traversable g) => (forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)) -> f Double -> g (f Double)
jacobian f = Rank1.jacobian (fmap runAD.f.fmap AD)
{-# INLINE jacobian #-}
jacobianWith :: (Traversable f, Traversable g) => (Double -> Double -> b) -> (forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)) -> f Double -> g (f b)
jacobianWith g f = Rank1.jacobianWith g (fmap runAD.f.fmap AD)
{-# INLINE jacobianWith #-}
jacobian' :: (Traversable f, Traversable g) => (forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)) -> f Double -> g (Double, f Double)
jacobian' f = Rank1.jacobian' (fmap runAD.f.fmap AD)
{-# INLINE jacobian' #-}
jacobianWith' :: (Traversable f, Traversable g) => (Double -> Double -> b) -> (forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)) -> f Double -> g (Double, f b)
jacobianWith' g f = Rank1.jacobianWith' g (fmap runAD.f.fmap AD)
{-# INLINE jacobianWith' #-}
grad :: Traversable f => (forall s. f (AD s ForwardDouble) -> AD s ForwardDouble) -> f Double -> f Double
grad f = Rank1.grad (runAD.f.fmap AD)
{-# INLINE grad #-}
grad' :: Traversable f => (forall s. f (AD s ForwardDouble) -> AD s ForwardDouble) -> f Double -> (Double, f Double)
grad' f = Rank1.grad' (runAD.f.fmap AD)
{-# INLINE grad' #-}
gradWith :: Traversable f => (Double -> Double -> b) -> (forall s. f (AD s ForwardDouble) -> AD s ForwardDouble) -> f Double -> f b
gradWith g f = Rank1.gradWith g (runAD.f.fmap AD)
{-# INLINE gradWith #-}
gradWith' :: Traversable f => (Double -> Double -> b) -> (forall s. f (AD s ForwardDouble) -> AD s ForwardDouble) -> f Double -> (Double, f b)
gradWith' g f = Rank1.gradWith' g (runAD.f.fmap AD)
{-# INLINE gradWith' #-}