Portability | GHC only |
---|---|

Stability | experimental |

Maintainer | ekmett@gmail.com |

Safe Haskell | None |

Reverse-Mode Automatic Differentiation using a single 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.

- data Chain 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 (Chain s) a -> [a]
- partialArrayOf :: (Reifies s Tape, Num a) => Proxy s -> (Int, Int) -> AD (Chain s) a -> Array Int a
- partialMapOf :: (Reifies s Tape, Num a) => Proxy s -> AD (Chain s) a -> IntMap a
- derivativeOf :: (Reifies s Tape, Num a) => Proxy s -> AD (Chain s) a -> a
- derivativeOf' :: (Reifies s Tape, Num a) => Proxy s -> AD (Chain s) a -> (a, a)

# Documentation

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 (Chain 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 (Chain s) a -> Array Int aSource

partialMapOf :: (Reifies s Tape, Num a) => Proxy s -> AD (Chain s) a -> IntMap aSource

Return an `IntMap`

of sparse partials