Copyright (c) Edward Kmett 2010-2015 BSD3 ekmett@gmail.com experimental GHC only None Haskell2010

Description

Higher order derivatives via a "dual number tower".

Synopsis

# Documentation

data Sparse a Source #

We only store partials in sorted order, so the map contained in a partial will only contain partials with equal or greater keys to that of the map in which it was found. This should be key for efficiently computing sparse hessians. there are only n + k - 1 choose k distinct nth partial derivatives of a function with k inputs.

Instances

auto :: Mode t => Scalar t -> t Source #

Embed a constant

grad :: (Traversable f, Num a) => (f (Sparse a) -> Sparse a) -> f a -> f a Source #

grad' :: (Traversable f, Num a) => (f (Sparse a) -> Sparse a) -> f a -> (a, f a) Source #

gradWith :: (Traversable f, Num a) => (a -> a -> b) -> (f (Sparse a) -> Sparse a) -> f a -> f b Source #

gradWith' :: (Traversable f, Num a) => (a -> a -> b) -> (f (Sparse a) -> Sparse a) -> f a -> (a, f b) Source #

Unfortunately, variadicity comes at the expense of being able to use quantification to avoid sensitivity confusion, so be careful when counting the number of auto calls you use when taking the gradient of a function that takes gradients!

class Num a => Grad i o o' a | i -> a o o', o -> a i o', o' -> a i o Source #

Minimal complete definition

Instances
 Num a => Grad (Sparse a) [a] (a, [a]) a Source # Instance detailsDefined in Numeric.AD.Internal.Sparse Methodspack :: Sparse a -> [Sparse a] -> Sparse a Source #unpack :: ([a] -> [a]) -> [a] Source #unpack' :: ([a] -> (a, [a])) -> (a, [a]) Source # Grad i o o' a => Grad (Sparse a -> i) (a -> o) (a -> o') a Source # Instance detailsDefined in Numeric.AD.Internal.Sparse Methodspack :: (Sparse a -> i) -> [Sparse a] -> Sparse a Source #unpack :: ([a] -> [a]) -> a -> o Source #unpack' :: ([a] -> (a, [a])) -> a -> o' Source #

vgrad :: Grad i o o' a => i -> o Source #

grads :: (Traversable f, Num a) => (f (Sparse a) -> Sparse a) -> f a -> Cofree f a Source #

class Num a => Grads i o a | i -> a o, o -> a i Source #

Minimal complete definition

Instances
 Num a => Grads (Sparse a) (Cofree [] a) a Source # Instance detailsDefined in Numeric.AD.Internal.Sparse Methodspacks :: Sparse a -> [Sparse a] -> Sparse a Source #unpacks :: ([a] -> Cofree [] a) -> Cofree [] a Source # Grads i o a => Grads (Sparse a -> i) (a -> o) a Source # Instance detailsDefined in Numeric.AD.Internal.Sparse Methodspacks :: (Sparse a -> i) -> [Sparse a] -> Sparse a Source #unpacks :: ([a] -> Cofree [] a) -> a -> o Source #

vgrads :: Grads i o a => i -> o Source #

# Sparse Jacobians (synonyms)

jacobian :: (Traversable f, Functor g, Num a) => (f (Sparse a) -> g (Sparse a)) -> f a -> g (f a) Source #

jacobian' :: (Traversable f, Functor g, Num a) => (f (Sparse a) -> g (Sparse a)) -> f a -> g (a, f a) Source #

jacobianWith :: (Traversable f, Functor g, Num a) => (a -> a -> b) -> (f (Sparse a) -> g (Sparse a)) -> f a -> g (f b) Source #

jacobianWith' :: (Traversable f, Functor g, Num a) => (a -> a -> b) -> (f (Sparse a) -> g (Sparse a)) -> f a -> g (a, f b) Source #

jacobians :: (Traversable f, Functor g, Num a) => (f (Sparse a) -> g (Sparse a)) -> f a -> g (Cofree f a) Source #

# Sparse Hessians

hessian :: (Traversable f, Num a) => (f (Sparse a) -> Sparse a) -> f a -> f (f a) Source #

hessian' :: (Traversable f, Num a) => (f (Sparse a) -> Sparse a) -> f a -> (a, f (a, f a)) Source #

hessianF :: (Traversable f, Functor g, Num a) => (f (Sparse a) -> g (Sparse a)) -> f a -> g (f (f a)) Source #

hessianF' :: (Traversable f, Functor g, Num a) => (f (Sparse a) -> g (Sparse a)) -> f a -> g (a, f (a, f a)) Source #