{-# 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
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 :: forall (f :: * -> *).
Functor f =>
(forall s. f (AD s ForwardDouble) -> AD s ForwardDouble)
-> f (Double, Double) -> Double
du forall s. f (AD s ForwardDouble) -> AD s ForwardDouble
f = (f ForwardDouble -> ForwardDouble) -> f (Double, Double) -> Double
forall (f :: * -> *).
Functor f =>
(f ForwardDouble -> ForwardDouble) -> f (Double, Double) -> Double
Rank1.du (AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD (AD Any ForwardDouble -> ForwardDouble)
-> (f ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble
-> ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f (AD Any ForwardDouble) -> AD Any ForwardDouble
forall s. f (AD s ForwardDouble) -> AD s ForwardDouble
f (f (AD Any ForwardDouble) -> AD Any ForwardDouble)
-> (f ForwardDouble -> f (AD Any ForwardDouble))
-> f ForwardDouble
-> AD Any ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble -> f (AD Any ForwardDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
AD)
{-# INLINE du #-}
du' :: Functor f => (forall s. f (AD s ForwardDouble) -> AD s ForwardDouble) -> f (Double, Double) -> (Double, Double)
du' :: forall (f :: * -> *).
Functor f =>
(forall s. f (AD s ForwardDouble) -> AD s ForwardDouble)
-> f (Double, Double) -> (Double, Double)
du' forall s. f (AD s ForwardDouble) -> AD s ForwardDouble
f = (f ForwardDouble -> ForwardDouble)
-> f (Double, Double) -> (Double, Double)
forall (f :: * -> *).
Functor f =>
(f ForwardDouble -> ForwardDouble)
-> f (Double, Double) -> (Double, Double)
Rank1.du' (AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD (AD Any ForwardDouble -> ForwardDouble)
-> (f ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble
-> ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f (AD Any ForwardDouble) -> AD Any ForwardDouble
forall s. f (AD s ForwardDouble) -> AD s ForwardDouble
f (f (AD Any ForwardDouble) -> AD Any ForwardDouble)
-> (f ForwardDouble -> f (AD Any ForwardDouble))
-> f ForwardDouble
-> AD Any ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble -> f (AD Any ForwardDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
AD)
{-# INLINE du' #-}
duF :: (Functor f, Functor g) => (forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)) -> f (Double, Double) -> g Double
duF :: forall (f :: * -> *) (g :: * -> *).
(Functor f, Functor g) =>
(forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble))
-> f (Double, Double) -> g Double
duF forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f = (f ForwardDouble -> g ForwardDouble)
-> f (Double, Double) -> g Double
forall (f :: * -> *) (g :: * -> *).
(Functor f, Functor g) =>
(f ForwardDouble -> g ForwardDouble)
-> f (Double, Double) -> g Double
Rank1.duF ((AD Any ForwardDouble -> ForwardDouble)
-> g (AD Any ForwardDouble) -> g ForwardDouble
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD (g (AD Any ForwardDouble) -> g ForwardDouble)
-> (f ForwardDouble -> g (AD Any ForwardDouble))
-> f ForwardDouble
-> g ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f (AD Any ForwardDouble) -> g (AD Any ForwardDouble)
forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f (f (AD Any ForwardDouble) -> g (AD Any ForwardDouble))
-> (f ForwardDouble -> f (AD Any ForwardDouble))
-> f ForwardDouble
-> g (AD Any ForwardDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble -> f (AD Any ForwardDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
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' :: forall (f :: * -> *) (g :: * -> *).
(Functor f, Functor g) =>
(forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble))
-> f (Double, Double) -> g (Double, Double)
duF' forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f = (f ForwardDouble -> g ForwardDouble)
-> f (Double, Double) -> g (Double, Double)
forall (f :: * -> *) (g :: * -> *).
(Functor f, Functor g) =>
(f ForwardDouble -> g ForwardDouble)
-> f (Double, Double) -> g (Double, Double)
Rank1.duF' ((AD Any ForwardDouble -> ForwardDouble)
-> g (AD Any ForwardDouble) -> g ForwardDouble
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD (g (AD Any ForwardDouble) -> g ForwardDouble)
-> (f ForwardDouble -> g (AD Any ForwardDouble))
-> f ForwardDouble
-> g ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f (AD Any ForwardDouble) -> g (AD Any ForwardDouble)
forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f (f (AD Any ForwardDouble) -> g (AD Any ForwardDouble))
-> (f ForwardDouble -> f (AD Any ForwardDouble))
-> f ForwardDouble
-> g (AD Any ForwardDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble -> f (AD Any ForwardDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
AD)
{-# INLINE duF' #-}
diff :: (forall s. AD s ForwardDouble -> AD s ForwardDouble) -> Double -> Double
diff :: (forall s. AD s ForwardDouble -> AD s ForwardDouble)
-> Double -> Double
diff forall s. AD s ForwardDouble -> AD s ForwardDouble
f = (ForwardDouble -> ForwardDouble) -> Double -> Double
Rank1.diff (AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD(AD Any ForwardDouble -> ForwardDouble)
-> (ForwardDouble -> AD Any ForwardDouble)
-> ForwardDouble
-> ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any ForwardDouble -> AD Any ForwardDouble
forall s. AD s ForwardDouble -> AD s ForwardDouble
f(AD Any ForwardDouble -> AD Any ForwardDouble)
-> (ForwardDouble -> AD Any ForwardDouble)
-> ForwardDouble
-> AD Any ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
AD)
{-# INLINE diff #-}
diff' :: (forall s. AD s ForwardDouble -> AD s ForwardDouble) -> Double -> (Double, Double)
diff' :: (forall s. AD s ForwardDouble -> AD s ForwardDouble)
-> Double -> (Double, Double)
diff' forall s. AD s ForwardDouble -> AD s ForwardDouble
f = (ForwardDouble -> ForwardDouble) -> Double -> (Double, Double)
Rank1.diff' (AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD(AD Any ForwardDouble -> ForwardDouble)
-> (ForwardDouble -> AD Any ForwardDouble)
-> ForwardDouble
-> ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any ForwardDouble -> AD Any ForwardDouble
forall s. AD s ForwardDouble -> AD s ForwardDouble
f(AD Any ForwardDouble -> AD Any ForwardDouble)
-> (ForwardDouble -> AD Any ForwardDouble)
-> ForwardDouble
-> AD Any ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
AD)
{-# INLINE diff' #-}
diffF :: Functor f => (forall s. AD s ForwardDouble -> f (AD s ForwardDouble)) -> Double -> f Double
diffF :: forall (f :: * -> *).
Functor f =>
(forall s. AD s ForwardDouble -> f (AD s ForwardDouble))
-> Double -> f Double
diffF forall s. AD s ForwardDouble -> f (AD s ForwardDouble)
f = (ForwardDouble -> f ForwardDouble) -> Double -> f Double
forall (f :: * -> *).
Functor f =>
(ForwardDouble -> f ForwardDouble) -> Double -> f Double
Rank1.diffF ((AD Any ForwardDouble -> ForwardDouble)
-> f (AD Any ForwardDouble) -> f ForwardDouble
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD(f (AD Any ForwardDouble) -> f ForwardDouble)
-> (ForwardDouble -> f (AD Any ForwardDouble))
-> ForwardDouble
-> f ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any ForwardDouble -> f (AD Any ForwardDouble)
forall s. AD s ForwardDouble -> f (AD s ForwardDouble)
f(AD Any ForwardDouble -> f (AD Any ForwardDouble))
-> (ForwardDouble -> AD Any ForwardDouble)
-> ForwardDouble
-> f (AD Any ForwardDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
AD)
{-# INLINE diffF #-}
diffF' :: Functor f => (forall s. AD s ForwardDouble -> f (AD s ForwardDouble)) -> Double -> f (Double, Double)
diffF' :: forall (f :: * -> *).
Functor f =>
(forall s. AD s ForwardDouble -> f (AD s ForwardDouble))
-> Double -> f (Double, Double)
diffF' forall s. AD s ForwardDouble -> f (AD s ForwardDouble)
f = (ForwardDouble -> f ForwardDouble) -> Double -> f (Double, Double)
forall (f :: * -> *).
Functor f =>
(ForwardDouble -> f ForwardDouble) -> Double -> f (Double, Double)
Rank1.diffF' ((AD Any ForwardDouble -> ForwardDouble)
-> f (AD Any ForwardDouble) -> f ForwardDouble
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD(f (AD Any ForwardDouble) -> f ForwardDouble)
-> (ForwardDouble -> f (AD Any ForwardDouble))
-> ForwardDouble
-> f ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any ForwardDouble -> f (AD Any ForwardDouble)
forall s. AD s ForwardDouble -> f (AD s ForwardDouble)
f(AD Any ForwardDouble -> f (AD Any ForwardDouble))
-> (ForwardDouble -> AD Any ForwardDouble)
-> ForwardDouble
-> f (AD Any ForwardDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
AD)
{-# INLINE diffF' #-}
jacobianT :: (Traversable f, Functor g) => (forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)) -> f Double -> f (g Double)
jacobianT :: forall (f :: * -> *) (g :: * -> *).
(Traversable f, Functor g) =>
(forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble))
-> f Double -> f (g Double)
jacobianT forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f = (f ForwardDouble -> g ForwardDouble) -> f Double -> f (g Double)
forall (f :: * -> *) (g :: * -> *).
(Traversable f, Functor g) =>
(f ForwardDouble -> g ForwardDouble) -> f Double -> f (g Double)
Rank1.jacobianT ((AD Any ForwardDouble -> ForwardDouble)
-> g (AD Any ForwardDouble) -> g ForwardDouble
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD(g (AD Any ForwardDouble) -> g ForwardDouble)
-> (f ForwardDouble -> g (AD Any ForwardDouble))
-> f ForwardDouble
-> g ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any ForwardDouble) -> g (AD Any ForwardDouble)
forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f(f (AD Any ForwardDouble) -> g (AD Any ForwardDouble))
-> (f ForwardDouble -> f (AD Any ForwardDouble))
-> f ForwardDouble
-> g (AD Any ForwardDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble -> f (AD Any ForwardDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
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 :: forall (f :: * -> *) (g :: * -> *) b.
(Traversable f, Functor g) =>
(Double -> Double -> b)
-> (forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble))
-> f Double
-> f (g b)
jacobianWithT Double -> Double -> b
g forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f = (Double -> Double -> b)
-> (f ForwardDouble -> g ForwardDouble) -> f Double -> f (g b)
forall (f :: * -> *) (g :: * -> *) b.
(Traversable f, Functor g) =>
(Double -> Double -> b)
-> (f ForwardDouble -> g ForwardDouble) -> f Double -> f (g b)
Rank1.jacobianWithT Double -> Double -> b
g ((AD Any ForwardDouble -> ForwardDouble)
-> g (AD Any ForwardDouble) -> g ForwardDouble
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD(g (AD Any ForwardDouble) -> g ForwardDouble)
-> (f ForwardDouble -> g (AD Any ForwardDouble))
-> f ForwardDouble
-> g ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any ForwardDouble) -> g (AD Any ForwardDouble)
forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f(f (AD Any ForwardDouble) -> g (AD Any ForwardDouble))
-> (f ForwardDouble -> f (AD Any ForwardDouble))
-> f ForwardDouble
-> g (AD Any ForwardDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble -> f (AD Any ForwardDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
AD)
{-# INLINE jacobianWithT #-}
jacobian :: (Traversable f, Traversable g) => (forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)) -> f Double -> g (f Double)
jacobian :: forall (f :: * -> *) (g :: * -> *).
(Traversable f, Traversable g) =>
(forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble))
-> f Double -> g (f Double)
jacobian forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f = (f ForwardDouble -> g ForwardDouble) -> f Double -> g (f Double)
forall (f :: * -> *) (g :: * -> *).
(Traversable f, Traversable g) =>
(f ForwardDouble -> g ForwardDouble) -> f Double -> g (f Double)
Rank1.jacobian ((AD Any ForwardDouble -> ForwardDouble)
-> g (AD Any ForwardDouble) -> g ForwardDouble
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD(g (AD Any ForwardDouble) -> g ForwardDouble)
-> (f ForwardDouble -> g (AD Any ForwardDouble))
-> f ForwardDouble
-> g ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any ForwardDouble) -> g (AD Any ForwardDouble)
forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f(f (AD Any ForwardDouble) -> g (AD Any ForwardDouble))
-> (f ForwardDouble -> f (AD Any ForwardDouble))
-> f ForwardDouble
-> g (AD Any ForwardDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble -> f (AD Any ForwardDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
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 :: forall (f :: * -> *) (g :: * -> *) b.
(Traversable f, Traversable g) =>
(Double -> Double -> b)
-> (forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble))
-> f Double
-> g (f b)
jacobianWith Double -> Double -> b
g forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f = (Double -> Double -> b)
-> (f ForwardDouble -> g ForwardDouble) -> f Double -> g (f b)
forall (f :: * -> *) (g :: * -> *) b.
(Traversable f, Traversable g) =>
(Double -> Double -> b)
-> (f ForwardDouble -> g ForwardDouble) -> f Double -> g (f b)
Rank1.jacobianWith Double -> Double -> b
g ((AD Any ForwardDouble -> ForwardDouble)
-> g (AD Any ForwardDouble) -> g ForwardDouble
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD(g (AD Any ForwardDouble) -> g ForwardDouble)
-> (f ForwardDouble -> g (AD Any ForwardDouble))
-> f ForwardDouble
-> g ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any ForwardDouble) -> g (AD Any ForwardDouble)
forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f(f (AD Any ForwardDouble) -> g (AD Any ForwardDouble))
-> (f ForwardDouble -> f (AD Any ForwardDouble))
-> f ForwardDouble
-> g (AD Any ForwardDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble -> f (AD Any ForwardDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
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' :: forall (f :: * -> *) (g :: * -> *).
(Traversable f, Traversable g) =>
(forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble))
-> f Double -> g (Double, f Double)
jacobian' forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f = (f ForwardDouble -> g ForwardDouble)
-> f Double -> g (Double, f Double)
forall (f :: * -> *) (g :: * -> *).
(Traversable f, Traversable g) =>
(f ForwardDouble -> g ForwardDouble)
-> f Double -> g (Double, f Double)
Rank1.jacobian' ((AD Any ForwardDouble -> ForwardDouble)
-> g (AD Any ForwardDouble) -> g ForwardDouble
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD(g (AD Any ForwardDouble) -> g ForwardDouble)
-> (f ForwardDouble -> g (AD Any ForwardDouble))
-> f ForwardDouble
-> g ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any ForwardDouble) -> g (AD Any ForwardDouble)
forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f(f (AD Any ForwardDouble) -> g (AD Any ForwardDouble))
-> (f ForwardDouble -> f (AD Any ForwardDouble))
-> f ForwardDouble
-> g (AD Any ForwardDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble -> f (AD Any ForwardDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
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' :: forall (f :: * -> *) (g :: * -> *) b.
(Traversable f, Traversable g) =>
(Double -> Double -> b)
-> (forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble))
-> f Double
-> g (Double, f b)
jacobianWith' Double -> Double -> b
g forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f = (Double -> Double -> b)
-> (f ForwardDouble -> g ForwardDouble)
-> f Double
-> g (Double, f b)
forall (f :: * -> *) (g :: * -> *) b.
(Traversable f, Traversable g) =>
(Double -> Double -> b)
-> (f ForwardDouble -> g ForwardDouble)
-> f Double
-> g (Double, f b)
Rank1.jacobianWith' Double -> Double -> b
g ((AD Any ForwardDouble -> ForwardDouble)
-> g (AD Any ForwardDouble) -> g ForwardDouble
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD(g (AD Any ForwardDouble) -> g ForwardDouble)
-> (f ForwardDouble -> g (AD Any ForwardDouble))
-> f ForwardDouble
-> g ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any ForwardDouble) -> g (AD Any ForwardDouble)
forall s. f (AD s ForwardDouble) -> g (AD s ForwardDouble)
f(f (AD Any ForwardDouble) -> g (AD Any ForwardDouble))
-> (f ForwardDouble -> f (AD Any ForwardDouble))
-> f ForwardDouble
-> g (AD Any ForwardDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble -> f (AD Any ForwardDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
AD)
{-# INLINE jacobianWith' #-}
grad :: Traversable f => (forall s. f (AD s ForwardDouble) -> AD s ForwardDouble) -> f Double -> f Double
grad :: forall (f :: * -> *).
Traversable f =>
(forall s. f (AD s ForwardDouble) -> AD s ForwardDouble)
-> f Double -> f Double
grad forall s. f (AD s ForwardDouble) -> AD s ForwardDouble
f = (f ForwardDouble -> ForwardDouble) -> f Double -> f Double
forall (f :: * -> *).
Traversable f =>
(f ForwardDouble -> ForwardDouble) -> f Double -> f Double
Rank1.grad (AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD(AD Any ForwardDouble -> ForwardDouble)
-> (f ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble
-> ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any ForwardDouble) -> AD Any ForwardDouble
forall s. f (AD s ForwardDouble) -> AD s ForwardDouble
f(f (AD Any ForwardDouble) -> AD Any ForwardDouble)
-> (f ForwardDouble -> f (AD Any ForwardDouble))
-> f ForwardDouble
-> AD Any ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble -> f (AD Any ForwardDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
AD)
{-# INLINE grad #-}
grad' :: Traversable f => (forall s. f (AD s ForwardDouble) -> AD s ForwardDouble) -> f Double -> (Double, f Double)
grad' :: forall (f :: * -> *).
Traversable f =>
(forall s. f (AD s ForwardDouble) -> AD s ForwardDouble)
-> f Double -> (Double, f Double)
grad' forall s. f (AD s ForwardDouble) -> AD s ForwardDouble
f = (f ForwardDouble -> ForwardDouble)
-> f Double -> (Double, f Double)
forall (f :: * -> *).
Traversable f =>
(f ForwardDouble -> ForwardDouble)
-> f Double -> (Double, f Double)
Rank1.grad' (AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD(AD Any ForwardDouble -> ForwardDouble)
-> (f ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble
-> ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any ForwardDouble) -> AD Any ForwardDouble
forall s. f (AD s ForwardDouble) -> AD s ForwardDouble
f(f (AD Any ForwardDouble) -> AD Any ForwardDouble)
-> (f ForwardDouble -> f (AD Any ForwardDouble))
-> f ForwardDouble
-> AD Any ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble -> f (AD Any ForwardDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
AD)
{-# INLINE grad' #-}
gradWith :: Traversable f => (Double -> Double -> b) -> (forall s. f (AD s ForwardDouble) -> AD s ForwardDouble) -> f Double -> f b
gradWith :: forall (f :: * -> *) b.
Traversable f =>
(Double -> Double -> b)
-> (forall s. f (AD s ForwardDouble) -> AD s ForwardDouble)
-> f Double
-> f b
gradWith Double -> Double -> b
g forall s. f (AD s ForwardDouble) -> AD s ForwardDouble
f = (Double -> Double -> b)
-> (f ForwardDouble -> ForwardDouble) -> f Double -> f b
forall (f :: * -> *) b.
Traversable f =>
(Double -> Double -> b)
-> (f ForwardDouble -> ForwardDouble) -> f Double -> f b
Rank1.gradWith Double -> Double -> b
g (AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD(AD Any ForwardDouble -> ForwardDouble)
-> (f ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble
-> ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any ForwardDouble) -> AD Any ForwardDouble
forall s. f (AD s ForwardDouble) -> AD s ForwardDouble
f(f (AD Any ForwardDouble) -> AD Any ForwardDouble)
-> (f ForwardDouble -> f (AD Any ForwardDouble))
-> f ForwardDouble
-> AD Any ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble -> f (AD Any ForwardDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
AD)
{-# INLINE gradWith #-}
gradWith' :: Traversable f => (Double -> Double -> b) -> (forall s. f (AD s ForwardDouble) -> AD s ForwardDouble) -> f Double -> (Double, f b)
gradWith' :: forall (f :: * -> *) b.
Traversable f =>
(Double -> Double -> b)
-> (forall s. f (AD s ForwardDouble) -> AD s ForwardDouble)
-> f Double
-> (Double, f b)
gradWith' Double -> Double -> b
g forall s. f (AD s ForwardDouble) -> AD s ForwardDouble
f = (Double -> Double -> b)
-> (f ForwardDouble -> ForwardDouble) -> f Double -> (Double, f b)
forall (f :: * -> *) b.
Traversable f =>
(Double -> Double -> b)
-> (f ForwardDouble -> ForwardDouble) -> f Double -> (Double, f b)
Rank1.gradWith' Double -> Double -> b
g (AD Any ForwardDouble -> ForwardDouble
forall s a. AD s a -> a
runAD(AD Any ForwardDouble -> ForwardDouble)
-> (f ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble
-> ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any ForwardDouble) -> AD Any ForwardDouble
forall s. f (AD s ForwardDouble) -> AD s ForwardDouble
f(f (AD Any ForwardDouble) -> AD Any ForwardDouble)
-> (f ForwardDouble -> f (AD Any ForwardDouble))
-> f ForwardDouble
-> AD Any ForwardDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(ForwardDouble -> AD Any ForwardDouble)
-> f ForwardDouble -> f (AD Any ForwardDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForwardDouble -> AD Any ForwardDouble
forall s a. a -> AD s a
AD)
{-# INLINE gradWith' #-}