Portability GHC only experimental ekmett@gmail.com None

Description

Dense Forward AD. Useful when the result involves the majority of the input elements. Do not use for hessian and beyond, since they only contain a small number of unique nth derivatives -- (n + k - 1) choose k for functions of k inputs rather than the k^n that would be generated by using Dense, not to mention the redundant intermediate derivatives that would be calculated over and over during that process!

Assumes all instances of f have the same number of elements.

NB: We don't need the full power of Traversable here, we could get by with a notion of zippable that can plug in 0's for the missing entries. This might allow for gradients where f has exponentials like ((->) a)

# Documentation

data Dense f a s Source

Constructors

 Lift !a Dense !a (f a) Zero

Instances

 (Traversable f, Num a, Bounded a) => Bounded (Dense f a s) (Traversable f, Num a, Enum a) => Enum (Dense f a s) (Traversable f, Num a, Eq a) => Eq (Dense f a s) (Traversable f, Floating a) => Floating (Dense f a s) (Traversable f, Fractional a) => Fractional (Dense f a s) (Traversable f, Num a) => Num (Dense f a s) (Traversable f, Num a, Ord a) => Ord (Dense f a s) (Traversable f, Real a) => Real (Dense f a s) (Traversable f, RealFloat a) => RealFloat (Dense f a s) (Traversable f, RealFrac a) => RealFrac (Dense f a s) Show a => Show (Dense f a s) (Traversable f, Erf a) => Erf (Dense f a s) (Traversable f, InvErf a) => InvErf (Dense f a s) (Num a, Traversable f) => Mode (Dense f a s) (Traversable f, Num a) => Jacobian (Dense f a s)

ds :: f a -> Dense f a s -> f aSource

ds' :: Num a => f a -> Dense f a s -> (a, f a)Source

vars :: (Traversable f, Num a) => f a -> f (Dense f a s)Source

apply :: (Traversable f, Num a) => (f (Dense f a s) -> b) -> f a -> bSource