| Portability | GHC only |
|---|---|
| Stability | experimental |
| Maintainer | ekmett@gmail.com |
| Safe Haskell | None |
Numeric.AD.Internal.Reverse
Description
Reverse-Mode Automatic Differentiation using a single Wengert list (or "tape").
This version uses Data.Reflection to find and update the tape.
This is asymptotically faster than using Reverse, which
is forced to reify and topologically sort the graph, but it requires
a fairly expensive rendezvous during construction when updated using
multiple threads.
- data Reverse s a where
- newtype Tape = Tape {}
- data Head = Head !Int Cells
- data Cells where
- reifyTape :: Int -> (forall s. Reifies s Tape => Proxy s -> r) -> r
- partials :: forall s a. (Reifies s Tape, Num a) => AD (Reverse s) a -> [a]
- partialArrayOf :: (Reifies s Tape, Num a) => Proxy s -> (Int, Int) -> AD (Reverse s) a -> Array Int a
- partialMapOf :: (Reifies s Tape, Num a) => Proxy s -> AD (Reverse s) a -> IntMap a
- derivativeOf :: (Reifies s Tape, Num a) => Proxy s -> AD (Reverse s) a -> a
- derivativeOf' :: (Reifies s Tape, Num a) => Proxy s -> AD (Reverse s) a -> (a, a)
Documentation
Instances
reifyTape :: Int -> (forall s. Reifies s Tape => Proxy s -> r) -> rSource
Construct a tape that starts with n variables.
partials :: forall s a. (Reifies s Tape, Num a) => AD (Reverse s) a -> [a]Source
Extract the partials from the current chain for a given AD variable.
partialArrayOf :: (Reifies s Tape, Num a) => Proxy s -> (Int, Int) -> AD (Reverse s) a -> Array Int aSource
partialMapOf :: (Reifies s Tape, Num a) => Proxy s -> AD (Reverse s) a -> IntMap aSource
Return an IntMap of sparse partials