{-# LANGUAGE Rank2Types #-}
-----------------------------------------------------------------------------
-- |
-- Copyright   : (c) Edward Kmett 2010-2021
-- License     : BSD3
-- Maintainer  : ekmett@gmail.com
-- Stability   : experimental
-- Portability : GHC only
--
-- Higher order derivatives via a \"dual number tower\".
--
-----------------------------------------------------------------------------
module Numeric.AD.Mode.Tower.Double
  ( AD
  , TowerDouble
  , auto
  -- * Taylor Series
  , taylor
  , taylor0
  -- * Maclaurin Series
  , maclaurin
  , maclaurin0
  -- * Derivatives
  , diff    -- first derivative of (Double -> a)
  , diff'   -- answer and first derivative of (Double -> a)
  , diffs   -- answer and all derivatives of (Double -> a)
  , diffs0  -- zero padded derivatives of (Double -> a)
  , diffsF  -- answer and all derivatives of (Double -> f a)
  , diffs0F -- zero padded derivatives of (Double -> f a)
  -- * Directional Derivatives
  , du      -- directional derivative of (Double -> a)
  , du'     -- answer and directional derivative of (Double -> a)
  , dus     -- answer and all directional derivatives of (Double -> a)
  , dus0    -- answer and all zero padded directional derivatives of (Double -> a)
  , duF     -- directional derivative of (Double -> f a)
  , duF'    -- answer and directional derivative of (Double -> f a)
  , dusF    -- answer and all directional derivatives of (Double -> f a)
  , dus0F   -- answer and all zero padded directional derivatives of (Double -> a)
  ) where

import qualified Numeric.AD.Rank1.Tower.Double as Rank1
import Numeric.AD.Internal.Tower.Double (TowerDouble)
import Numeric.AD.Internal.Type (AD(..))
import Numeric.AD.Mode

diffs :: (forall s. AD s TowerDouble -> AD s TowerDouble) -> Double -> [Double]
diffs :: (forall s. AD s TowerDouble -> AD s TowerDouble)
-> Double -> [Double]
diffs forall s. AD s TowerDouble -> AD s TowerDouble
f = (TowerDouble -> TowerDouble) -> Double -> [Double]
Rank1.diffs (AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(AD Any TowerDouble -> TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any TowerDouble -> AD Any TowerDouble
forall s. AD s TowerDouble -> AD s TowerDouble
f(AD Any TowerDouble -> AD Any TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> AD Any TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE diffs #-}

diffs0 :: (forall s. AD s TowerDouble -> AD s TowerDouble) -> Double -> [Double]
diffs0 :: (forall s. AD s TowerDouble -> AD s TowerDouble)
-> Double -> [Double]
diffs0 forall s. AD s TowerDouble -> AD s TowerDouble
f = (TowerDouble -> TowerDouble) -> Double -> [Double]
Rank1.diffs0 (AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(AD Any TowerDouble -> TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any TowerDouble -> AD Any TowerDouble
forall s. AD s TowerDouble -> AD s TowerDouble
f(AD Any TowerDouble -> AD Any TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> AD Any TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE diffs0 #-}

diffsF :: Functor f => (forall s. AD s TowerDouble -> f (AD s TowerDouble)) -> Double -> f [Double]
diffsF :: forall (f :: * -> *).
Functor f =>
(forall s. AD s TowerDouble -> f (AD s TowerDouble))
-> Double -> f [Double]
diffsF forall s. AD s TowerDouble -> f (AD s TowerDouble)
f = (TowerDouble -> f TowerDouble) -> Double -> f [Double]
forall (f :: * -> *).
Functor f =>
(TowerDouble -> f TowerDouble) -> Double -> f [Double]
Rank1.diffsF ((AD Any TowerDouble -> TowerDouble)
-> f (AD Any TowerDouble) -> f TowerDouble
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(f (AD Any TowerDouble) -> f TowerDouble)
-> (TowerDouble -> f (AD Any TowerDouble))
-> TowerDouble
-> f TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any TowerDouble -> f (AD Any TowerDouble)
forall s. AD s TowerDouble -> f (AD s TowerDouble)
f(AD Any TowerDouble -> f (AD Any TowerDouble))
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> f (AD Any TowerDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE diffsF #-}

diffs0F :: Functor f => (forall s. AD s TowerDouble -> f (AD s TowerDouble)) -> Double -> f [Double]
diffs0F :: forall (f :: * -> *).
Functor f =>
(forall s. AD s TowerDouble -> f (AD s TowerDouble))
-> Double -> f [Double]
diffs0F forall s. AD s TowerDouble -> f (AD s TowerDouble)
f = (TowerDouble -> f TowerDouble) -> Double -> f [Double]
forall (f :: * -> *).
Functor f =>
(TowerDouble -> f TowerDouble) -> Double -> f [Double]
Rank1.diffs0F ((AD Any TowerDouble -> TowerDouble)
-> f (AD Any TowerDouble) -> f TowerDouble
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(f (AD Any TowerDouble) -> f TowerDouble)
-> (TowerDouble -> f (AD Any TowerDouble))
-> TowerDouble
-> f TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any TowerDouble -> f (AD Any TowerDouble)
forall s. AD s TowerDouble -> f (AD s TowerDouble)
f(AD Any TowerDouble -> f (AD Any TowerDouble))
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> f (AD Any TowerDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE diffs0F #-}

taylor :: (forall s. AD s TowerDouble -> AD s TowerDouble) -> Double -> Double -> [Double]
taylor :: (forall s. AD s TowerDouble -> AD s TowerDouble)
-> Double -> Double -> [Double]
taylor forall s. AD s TowerDouble -> AD s TowerDouble
f = (TowerDouble -> TowerDouble) -> Double -> Double -> [Double]
Rank1.taylor (AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(AD Any TowerDouble -> TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any TowerDouble -> AD Any TowerDouble
forall s. AD s TowerDouble -> AD s TowerDouble
f(AD Any TowerDouble -> AD Any TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> AD Any TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)

taylor0 :: (forall s. AD s TowerDouble -> AD s TowerDouble) -> Double -> Double -> [Double]
taylor0 :: (forall s. AD s TowerDouble -> AD s TowerDouble)
-> Double -> Double -> [Double]
taylor0 forall s. AD s TowerDouble -> AD s TowerDouble
f = (TowerDouble -> TowerDouble) -> Double -> Double -> [Double]
Rank1.taylor0 (AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(AD Any TowerDouble -> TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any TowerDouble -> AD Any TowerDouble
forall s. AD s TowerDouble -> AD s TowerDouble
f(AD Any TowerDouble -> AD Any TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> AD Any TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE taylor0 #-}

maclaurin :: (forall s. AD s TowerDouble -> AD s TowerDouble) -> Double -> [Double]
maclaurin :: (forall s. AD s TowerDouble -> AD s TowerDouble)
-> Double -> [Double]
maclaurin forall s. AD s TowerDouble -> AD s TowerDouble
f = (TowerDouble -> TowerDouble) -> Double -> [Double]
Rank1.maclaurin (AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(AD Any TowerDouble -> TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any TowerDouble -> AD Any TowerDouble
forall s. AD s TowerDouble -> AD s TowerDouble
f(AD Any TowerDouble -> AD Any TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> AD Any TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE maclaurin #-}

maclaurin0 :: (forall s. AD s TowerDouble -> AD s TowerDouble) -> Double -> [Double]
maclaurin0 :: (forall s. AD s TowerDouble -> AD s TowerDouble)
-> Double -> [Double]
maclaurin0 forall s. AD s TowerDouble -> AD s TowerDouble
f = (TowerDouble -> TowerDouble) -> Double -> [Double]
Rank1.maclaurin0 (AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(AD Any TowerDouble -> TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any TowerDouble -> AD Any TowerDouble
forall s. AD s TowerDouble -> AD s TowerDouble
f(AD Any TowerDouble -> AD Any TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> AD Any TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE maclaurin0 #-}

diff :: (forall s. AD s TowerDouble -> AD s TowerDouble) -> Double -> Double
diff :: (forall s. AD s TowerDouble -> AD s TowerDouble)
-> Double -> Double
diff forall s. AD s TowerDouble -> AD s TowerDouble
f = (TowerDouble -> TowerDouble) -> Double -> Double
Rank1.diff (AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(AD Any TowerDouble -> TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any TowerDouble -> AD Any TowerDouble
forall s. AD s TowerDouble -> AD s TowerDouble
f(AD Any TowerDouble -> AD Any TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> AD Any TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE diff #-}

diff' :: (forall s. AD s TowerDouble -> AD s TowerDouble) -> Double -> (Double, Double)
diff' :: (forall s. AD s TowerDouble -> AD s TowerDouble)
-> Double -> (Double, Double)
diff' forall s. AD s TowerDouble -> AD s TowerDouble
f = (TowerDouble -> TowerDouble) -> Double -> (Double, Double)
Rank1.diff' (AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(AD Any TowerDouble -> TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any TowerDouble -> AD Any TowerDouble
forall s. AD s TowerDouble -> AD s TowerDouble
f(AD Any TowerDouble -> AD Any TowerDouble)
-> (TowerDouble -> AD Any TowerDouble)
-> TowerDouble
-> AD Any TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE diff' #-}

du :: Functor f => (forall s. f (AD s TowerDouble) -> AD s TowerDouble) -> f (Double, Double) -> Double
du :: forall (f :: * -> *).
Functor f =>
(forall s. f (AD s TowerDouble) -> AD s TowerDouble)
-> f (Double, Double) -> Double
du forall s. f (AD s TowerDouble) -> AD s TowerDouble
f = (f TowerDouble -> TowerDouble) -> f (Double, Double) -> Double
forall (f :: * -> *).
Functor f =>
(f TowerDouble -> TowerDouble) -> f (Double, Double) -> Double
Rank1.du (AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(AD Any TowerDouble -> TowerDouble)
-> (f TowerDouble -> AD Any TowerDouble)
-> f TowerDouble
-> TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any TowerDouble) -> AD Any TowerDouble
forall s. f (AD s TowerDouble) -> AD s TowerDouble
f(f (AD Any TowerDouble) -> AD Any TowerDouble)
-> (f TowerDouble -> f (AD Any TowerDouble))
-> f TowerDouble
-> AD Any TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TowerDouble -> AD Any TowerDouble)
-> f TowerDouble -> f (AD Any TowerDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE du #-}

du' :: Functor f => (forall s. f (AD s TowerDouble) -> AD s TowerDouble) -> f (Double, Double) -> (Double, Double)
du' :: forall (f :: * -> *).
Functor f =>
(forall s. f (AD s TowerDouble) -> AD s TowerDouble)
-> f (Double, Double) -> (Double, Double)
du' forall s. f (AD s TowerDouble) -> AD s TowerDouble
f = (f TowerDouble -> TowerDouble)
-> f (Double, Double) -> (Double, Double)
forall (f :: * -> *).
Functor f =>
(f TowerDouble -> TowerDouble)
-> f (Double, Double) -> (Double, Double)
Rank1.du' (AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(AD Any TowerDouble -> TowerDouble)
-> (f TowerDouble -> AD Any TowerDouble)
-> f TowerDouble
-> TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any TowerDouble) -> AD Any TowerDouble
forall s. f (AD s TowerDouble) -> AD s TowerDouble
f(f (AD Any TowerDouble) -> AD Any TowerDouble)
-> (f TowerDouble -> f (AD Any TowerDouble))
-> f TowerDouble
-> AD Any TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(TowerDouble -> AD Any TowerDouble)
-> f TowerDouble -> f (AD Any TowerDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE du' #-}

duF :: (Functor f, Functor g) => (forall s. f (AD s TowerDouble) -> g (AD s TowerDouble)) -> f (Double, Double) -> g Double
duF :: forall (f :: * -> *) (g :: * -> *).
(Functor f, Functor g) =>
(forall s. f (AD s TowerDouble) -> g (AD s TowerDouble))
-> f (Double, Double) -> g Double
duF forall s. f (AD s TowerDouble) -> g (AD s TowerDouble)
f = (f TowerDouble -> g TowerDouble) -> f (Double, Double) -> g Double
forall (f :: * -> *) (g :: * -> *).
(Functor f, Functor g) =>
(f TowerDouble -> g TowerDouble) -> f (Double, Double) -> g Double
Rank1.duF ((AD Any TowerDouble -> TowerDouble)
-> g (AD Any TowerDouble) -> g TowerDouble
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(g (AD Any TowerDouble) -> g TowerDouble)
-> (f TowerDouble -> g (AD Any TowerDouble))
-> f TowerDouble
-> g TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any TowerDouble) -> g (AD Any TowerDouble)
forall s. f (AD s TowerDouble) -> g (AD s TowerDouble)
f(f (AD Any TowerDouble) -> g (AD Any TowerDouble))
-> (f TowerDouble -> f (AD Any TowerDouble))
-> f TowerDouble
-> g (AD Any TowerDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(TowerDouble -> AD Any TowerDouble)
-> f TowerDouble -> f (AD Any TowerDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE duF #-}

duF' :: (Functor f, Functor g) => (forall s. f (AD s TowerDouble) -> g (AD s TowerDouble)) -> f (Double, Double) -> g (Double, Double)
duF' :: forall (f :: * -> *) (g :: * -> *).
(Functor f, Functor g) =>
(forall s. f (AD s TowerDouble) -> g (AD s TowerDouble))
-> f (Double, Double) -> g (Double, Double)
duF' forall s. f (AD s TowerDouble) -> g (AD s TowerDouble)
f = (f TowerDouble -> g TowerDouble)
-> f (Double, Double) -> g (Double, Double)
forall (f :: * -> *) (g :: * -> *).
(Functor f, Functor g) =>
(f TowerDouble -> g TowerDouble)
-> f (Double, Double) -> g (Double, Double)
Rank1.duF' ((AD Any TowerDouble -> TowerDouble)
-> g (AD Any TowerDouble) -> g TowerDouble
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(g (AD Any TowerDouble) -> g TowerDouble)
-> (f TowerDouble -> g (AD Any TowerDouble))
-> f TowerDouble
-> g TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any TowerDouble) -> g (AD Any TowerDouble)
forall s. f (AD s TowerDouble) -> g (AD s TowerDouble)
f(f (AD Any TowerDouble) -> g (AD Any TowerDouble))
-> (f TowerDouble -> f (AD Any TowerDouble))
-> f TowerDouble
-> g (AD Any TowerDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(TowerDouble -> AD Any TowerDouble)
-> f TowerDouble -> f (AD Any TowerDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE duF' #-}

dus :: Functor f => (forall s. f (AD s TowerDouble) -> AD s TowerDouble) -> f [Double] -> [Double]
dus :: forall (f :: * -> *).
Functor f =>
(forall s. f (AD s TowerDouble) -> AD s TowerDouble)
-> f [Double] -> [Double]
dus forall s. f (AD s TowerDouble) -> AD s TowerDouble
f = (f TowerDouble -> TowerDouble) -> f [Double] -> [Double]
forall (f :: * -> *).
Functor f =>
(f TowerDouble -> TowerDouble) -> f [Double] -> [Double]
Rank1.dus (AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(AD Any TowerDouble -> TowerDouble)
-> (f TowerDouble -> AD Any TowerDouble)
-> f TowerDouble
-> TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any TowerDouble) -> AD Any TowerDouble
forall s. f (AD s TowerDouble) -> AD s TowerDouble
f(f (AD Any TowerDouble) -> AD Any TowerDouble)
-> (f TowerDouble -> f (AD Any TowerDouble))
-> f TowerDouble
-> AD Any TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(TowerDouble -> AD Any TowerDouble)
-> f TowerDouble -> f (AD Any TowerDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE dus #-}

dus0 :: Functor f => (forall s. f (AD s TowerDouble) -> AD s TowerDouble) -> f [Double] -> [Double]
dus0 :: forall (f :: * -> *).
Functor f =>
(forall s. f (AD s TowerDouble) -> AD s TowerDouble)
-> f [Double] -> [Double]
dus0 forall s. f (AD s TowerDouble) -> AD s TowerDouble
f = (f TowerDouble -> TowerDouble) -> f [Double] -> [Double]
forall (f :: * -> *).
Functor f =>
(f TowerDouble -> TowerDouble) -> f [Double] -> [Double]
Rank1.dus0 (AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(AD Any TowerDouble -> TowerDouble)
-> (f TowerDouble -> AD Any TowerDouble)
-> f TowerDouble
-> TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any TowerDouble) -> AD Any TowerDouble
forall s. f (AD s TowerDouble) -> AD s TowerDouble
f(f (AD Any TowerDouble) -> AD Any TowerDouble)
-> (f TowerDouble -> f (AD Any TowerDouble))
-> f TowerDouble
-> AD Any TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(TowerDouble -> AD Any TowerDouble)
-> f TowerDouble -> f (AD Any TowerDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE dus0 #-}

dusF :: (Functor f, Functor g) => (forall s. f (AD s TowerDouble) -> g (AD s TowerDouble)) -> f [Double] -> g [Double]
dusF :: forall (f :: * -> *) (g :: * -> *).
(Functor f, Functor g) =>
(forall s. f (AD s TowerDouble) -> g (AD s TowerDouble))
-> f [Double] -> g [Double]
dusF forall s. f (AD s TowerDouble) -> g (AD s TowerDouble)
f = (f TowerDouble -> g TowerDouble) -> f [Double] -> g [Double]
forall (f :: * -> *) (g :: * -> *).
(Functor f, Functor g) =>
(f TowerDouble -> g TowerDouble) -> f [Double] -> g [Double]
Rank1.dusF ((AD Any TowerDouble -> TowerDouble)
-> g (AD Any TowerDouble) -> g TowerDouble
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(g (AD Any TowerDouble) -> g TowerDouble)
-> (f TowerDouble -> g (AD Any TowerDouble))
-> f TowerDouble
-> g TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any TowerDouble) -> g (AD Any TowerDouble)
forall s. f (AD s TowerDouble) -> g (AD s TowerDouble)
f(f (AD Any TowerDouble) -> g (AD Any TowerDouble))
-> (f TowerDouble -> f (AD Any TowerDouble))
-> f TowerDouble
-> g (AD Any TowerDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(TowerDouble -> AD Any TowerDouble)
-> f TowerDouble -> f (AD Any TowerDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE dusF #-}

dus0F :: (Functor f, Functor g) => (forall s. f (AD s TowerDouble) -> g (AD s TowerDouble)) -> f [Double] -> g [Double]
dus0F :: forall (f :: * -> *) (g :: * -> *).
(Functor f, Functor g) =>
(forall s. f (AD s TowerDouble) -> g (AD s TowerDouble))
-> f [Double] -> g [Double]
dus0F forall s. f (AD s TowerDouble) -> g (AD s TowerDouble)
f = (f TowerDouble -> g TowerDouble) -> f [Double] -> g [Double]
forall (f :: * -> *) (g :: * -> *).
(Functor f, Functor g) =>
(f TowerDouble -> g TowerDouble) -> f [Double] -> g [Double]
Rank1.dus0F ((AD Any TowerDouble -> TowerDouble)
-> g (AD Any TowerDouble) -> g TowerDouble
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any TowerDouble -> TowerDouble
forall s a. AD s a -> a
runAD(g (AD Any TowerDouble) -> g TowerDouble)
-> (f TowerDouble -> g (AD Any TowerDouble))
-> f TowerDouble
-> g TowerDouble
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any TowerDouble) -> g (AD Any TowerDouble)
forall s. f (AD s TowerDouble) -> g (AD s TowerDouble)
f(f (AD Any TowerDouble) -> g (AD Any TowerDouble))
-> (f TowerDouble -> f (AD Any TowerDouble))
-> f TowerDouble
-> g (AD Any TowerDouble)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(TowerDouble -> AD Any TowerDouble)
-> f TowerDouble -> f (AD Any TowerDouble)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TowerDouble -> AD Any TowerDouble
forall s a. a -> AD s a
AD)
{-# INLINE dus0F #-}