Copyright | (c) Edward Kmett 2010-2021 |
---|---|
License | BSD3 |
Maintainer | ekmett@gmail.com |
Stability | experimental |
Portability | GHC only |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Higher order derivatives via a "dual number tower".
Synopsis
- data AD s a
- data SparseDouble
- auto :: Mode t => Scalar t -> t
- grad :: Traversable f => (forall s. f (AD s SparseDouble) -> AD s SparseDouble) -> f Double -> f Double
- grad' :: Traversable f => (forall s. f (AD s SparseDouble) -> AD s SparseDouble) -> f Double -> (Double, f Double)
- grads :: Traversable f => (forall s. f (AD s SparseDouble) -> AD s SparseDouble) -> f Double -> Cofree f Double
- gradWith :: Traversable f => (Double -> Double -> b) -> (forall s. f (AD s SparseDouble) -> AD s SparseDouble) -> f Double -> f b
- gradWith' :: Traversable f => (Double -> Double -> b) -> (forall s. f (AD s SparseDouble) -> AD s SparseDouble) -> f Double -> (Double, f b)
- jacobian :: (Traversable f, Functor g) => (forall s. f (AD s SparseDouble) -> g (AD s SparseDouble)) -> f Double -> g (f Double)
- jacobian' :: (Traversable f, Functor g) => (forall s. f (AD s SparseDouble) -> g (AD s SparseDouble)) -> f Double -> g (Double, f Double)
- jacobianWith :: (Traversable f, Functor g) => (Double -> Double -> b) -> (forall s. f (AD s SparseDouble) -> g (AD s SparseDouble)) -> f Double -> g (f b)
- jacobianWith' :: (Traversable f, Functor g) => (Double -> Double -> b) -> (forall s. f (AD s SparseDouble) -> g (AD s SparseDouble)) -> f Double -> g (Double, f b)
- jacobians :: (Traversable f, Functor g) => (forall s. f (AD s SparseDouble) -> g (AD s SparseDouble)) -> f Double -> g (Cofree f Double)
- hessian :: Traversable f => (forall s. f (AD s SparseDouble) -> AD s SparseDouble) -> f Double -> f (f Double)
- hessian' :: Traversable f => (forall s. f (AD s SparseDouble) -> AD s SparseDouble) -> f Double -> (Double, f (Double, f Double))
- hessianF :: (Traversable f, Functor g) => (forall s. f (AD s SparseDouble) -> g (AD s SparseDouble)) -> f Double -> g (f (f Double))
- hessianF' :: (Traversable f, Functor g) => (forall s. f (AD s SparseDouble) -> g (AD s SparseDouble)) -> f Double -> g (Double, f (Double, f Double))
Documentation
Instances
data SparseDouble 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
Sparse Gradients
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 #