ad-1.3: Automatic Differentiation

Portability GHC only experimental ekmett@gmail.com

Numeric.AD.Mode.Sparse

Description

Higher order derivatives via a "dual number tower".

Synopsis

# Sparse Gradients

grad :: (Traversable f, Num a) => FU f a -> f a -> f aSource

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

gradWith :: (Traversable f, Num a) => (a -> a -> b) -> FU f a -> f a -> f bSource

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

grads :: (Traversable f, Num a) => FU f a -> f a -> Cofree f aSource

# Sparse Jacobians (synonyms)

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

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

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

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

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

# Sparse Hessians

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

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

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

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

# Unsafe gradients

vgrad :: Grad i o o' a => i -> oSource

vgrads :: Grads i o a => i -> oSource

# Exposed Types

class Lifted t => Mode t whereSource

Methods

lift :: Num a => a -> t aSource

Embed a constant

(<+>) :: Num a => t a -> t a -> t aSource

Vector sum

(*^) :: Num a => a -> t a -> t aSource

Scalar-vector multiplication

(^*) :: Num a => t a -> a -> t aSource

Vector-scalar multiplication

(^/) :: Fractional a => t a -> a -> t aSource

Scalar division

zero :: Num a => t aSource

``` 'zero' = 'lift' 0
```

Instances

 Mode Id Lifted Forward => Mode Forward Lifted Tower => Mode Tower Lifted Reverse => Mode Reverse Lifted Sparse => Mode Sparse Mode f => Mode (AD f) (Traversable f, Lifted (Dense f)) => Mode (Dense f) (Mode f, Mode g) => Mode (ComposeMode f g)

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

Instances

 Num a => Grad (AD Sparse a) [a] (a, [a]) a Grad i o o' a => Grad (AD Sparse a -> i) (a -> o) (a -> o') a

class Num a => Grads i o a | i -> a o, o -> a iSource

Instances

 Grads i o a => Grads (AD Sparse a -> i) (a -> o) a Num a => Grads (AD Sparse a) (Cofree [] a) a