ad- Automatic Differentiation

PortabilityGHC only



Dense Forward AD. Useful when the result involves the majority of the input elements. Do not use for Numeric.AD.Mode.Mixed.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)


data Dense f a Source


Lift !a 
Dense !a (f a) 


(Traversable f, Lifted (Dense f)) => Jacobian (Dense f) 
Primal (Dense f) 
(Traversable f, Lifted (Dense f)) => Mode (Dense f) 
Traversable f => Lifted (Dense f) 
Show a => Show (Dense f a) 

ds :: f a -> AD (Dense f) a -> f aSource

ds' :: f a -> AD (Dense f) a -> (a, f a)Source

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

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