Copyright (c) Edward Kmett 2010-2021 BSD3 ekmett@gmail.com experimental GHC only Safe-Inferred Haskell2010

Description

Higher order derivatives via a "dual number tower".

Synopsis

# Documentation

data AD s a Source #

#### Instances

Instances details

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

Instances details

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

Embed a constant

grad :: Traversable f => (forall s. f (AD s SparseDouble) -> AD s SparseDouble) -> f Double -> f Double Source #

The grad function calculates the gradient of a non-scalar-to-scalar function with sparse-mode AD in a single pass.

>>> grad (\[x,y,z] -> x*y+z) [1,2,3]
[2.0,1.0,1.0]

>>> grad (\[x,y] -> x**y) [0,2]
[0.0,NaN]


grad' :: Traversable f => (forall s. f (AD s SparseDouble) -> AD s SparseDouble) -> f Double -> (Double, f Double) Source #

grads :: Traversable f => (forall s. f (AD s SparseDouble) -> AD s SparseDouble) -> f Double -> Cofree f Double Source #

gradWith :: Traversable f => (Double -> Double -> b) -> (forall s. f (AD s SparseDouble) -> AD s SparseDouble) -> f Double -> f b Source #

gradWith' :: Traversable f => (Double -> Double -> b) -> (forall s. f (AD s SparseDouble) -> AD s SparseDouble) -> f Double -> (Double, f b) Source #

# Sparse Jacobians (synonyms)

jacobian :: (Traversable f, Functor g) => (forall s. f (AD s SparseDouble) -> g (AD s SparseDouble)) -> f Double -> g (f Double) Source #

jacobian' :: (Traversable f, Functor g) => (forall s. f (AD s SparseDouble) -> g (AD s SparseDouble)) -> f Double -> g (Double, f Double) Source #

jacobianWith :: (Traversable f, Functor g) => (Double -> Double -> b) -> (forall s. f (AD s SparseDouble) -> g (AD s SparseDouble)) -> f Double -> g (f b) Source #

jacobianWith' :: (Traversable f, Functor g) => (Double -> Double -> b) -> (forall s. f (AD s SparseDouble) -> g (AD s SparseDouble)) -> f Double -> g (Double, f b) Source #

jacobians :: (Traversable f, Functor g) => (forall s. f (AD s SparseDouble) -> g (AD s SparseDouble)) -> f Double -> g (Cofree f Double) Source #

# Sparse Hessians

hessian :: Traversable f => (forall s. f (AD s SparseDouble) -> AD s SparseDouble) -> f Double -> f (f Double) Source #

hessian' :: Traversable f => (forall s. f (AD s SparseDouble) -> AD s SparseDouble) -> f Double -> (Double, f (Double, f Double)) Source #

hessianF :: (Traversable f, Functor g) => (forall s. f (AD s SparseDouble) -> g (AD s SparseDouble)) -> f Double -> g (f (f Double)) Source #

hessianF' :: (Traversable f, Functor g) => (forall s. f (AD s SparseDouble) -> g (AD s SparseDouble)) -> f Double -> g (Double, f (Double, f Double)) Source #