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 SparseDouble
- auto :: Mode t => Scalar t -> t
- grad :: Traversable f => (f SparseDouble -> SparseDouble) -> f Double -> f Double
- grad' :: Traversable f => (f SparseDouble -> SparseDouble) -> f Double -> (Double, f Double)
- gradWith :: Traversable f => (Double -> Double -> b) -> (f SparseDouble -> SparseDouble) -> f Double -> f b
- gradWith' :: Traversable f => (Double -> Double -> b) -> (f SparseDouble -> SparseDouble) -> f Double -> (Double, f b)
- class Grad i o o' | i -> o o', o -> i o', o' -> i o
- vgrad :: Grad i o o' => i -> o
- grads :: Traversable f => (f SparseDouble -> SparseDouble) -> f Double -> Cofree f Double
- class Grads i o | i -> o, o -> i
- vgrads :: Grads i o => i -> o
- jacobian :: (Traversable f, Functor g) => (f SparseDouble -> g SparseDouble) -> f Double -> g (f Double)
- jacobian' :: (Traversable f, Functor g) => (f SparseDouble -> g SparseDouble) -> f Double -> g (Double, f Double)
- jacobianWith :: (Traversable f, Functor g) => (Double -> Double -> b) -> (f SparseDouble -> g SparseDouble) -> f Double -> g (f b)
- jacobianWith' :: (Traversable f, Functor g) => (Double -> Double -> b) -> (f SparseDouble -> g SparseDouble) -> f Double -> g (Double, f b)
- jacobians :: (Traversable f, Functor g) => (f SparseDouble -> g SparseDouble) -> f Double -> g (Cofree f Double)
- hessian :: Traversable f => (f SparseDouble -> SparseDouble) -> f Double -> f (f Double)
- hessian' :: Traversable f => (f SparseDouble -> SparseDouble) -> f Double -> (Double, f (Double, f Double))
- hessianF :: (Traversable f, Functor g) => (f SparseDouble -> g SparseDouble) -> f Double -> g (f (f Double))
- hessianF' :: (Traversable f, Functor g) => (f SparseDouble -> g SparseDouble) -> f Double -> g (Double, f (Double, f Double))
Documentation
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 => (f SparseDouble -> SparseDouble) -> f Double -> f Double Source #
grad' :: Traversable f => (f SparseDouble -> SparseDouble) -> f Double -> (Double, f Double) Source #
gradWith :: Traversable f => (Double -> Double -> b) -> (f SparseDouble -> SparseDouble) -> f Double -> f b Source #
gradWith' :: Traversable f => (Double -> Double -> b) -> (f SparseDouble -> SparseDouble) -> f Double -> (Double, f b) Source #
Variadic Gradients
Variadic combinators for variadic mixed-mode automatic differentiation.
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 Grad i o o' | i -> o o', o -> i o', o' -> i o Source #
Instances
Grad SparseDouble [Double] (Double, [Double]) Source # | |
Grad i o o' => Grad (SparseDouble -> i) (Double -> o) (Double -> o') Source # | |
Defined in Numeric.AD.Internal.Sparse.Double |
Higher-Order Gradients
grads :: Traversable f => (f SparseDouble -> SparseDouble) -> f Double -> Cofree f Double Source #
Variadic Higher-Order Gradients
class Grads i o | i -> o, o -> i Source #
Instances
Grads SparseDouble (Cofree List Double) Source # | |
Defined in Numeric.AD.Internal.Sparse.Double | |
Grads i o => Grads (SparseDouble -> i) (Double -> o) Source # | |
Defined in Numeric.AD.Internal.Sparse.Double packs :: (SparseDouble -> i) -> [SparseDouble] -> SparseDouble Source # unpacks :: ([Double] -> Cofree List Double) -> Double -> o Source # |
Sparse Jacobians (synonyms)
jacobian :: (Traversable f, Functor g) => (f SparseDouble -> g SparseDouble) -> f Double -> g (f Double) Source #
jacobian' :: (Traversable f, Functor g) => (f SparseDouble -> g SparseDouble) -> f Double -> g (Double, f Double) Source #
jacobianWith :: (Traversable f, Functor g) => (Double -> Double -> b) -> (f SparseDouble -> g SparseDouble) -> f Double -> g (f b) Source #
jacobianWith' :: (Traversable f, Functor g) => (Double -> Double -> b) -> (f SparseDouble -> g SparseDouble) -> f Double -> g (Double, f b) Source #
jacobians :: (Traversable f, Functor g) => (f SparseDouble -> g SparseDouble) -> f Double -> g (Cofree f Double) Source #
Sparse Hessians
hessian :: Traversable f => (f SparseDouble -> SparseDouble) -> f Double -> f (f Double) Source #
hessian' :: Traversable f => (f SparseDouble -> SparseDouble) -> f Double -> (Double, f (Double, f Double)) Source #
hessianF :: (Traversable f, Functor g) => (f SparseDouble -> g SparseDouble) -> f Double -> g (f (f Double)) Source #
hessianF' :: (Traversable f, Functor g) => (f SparseDouble -> g SparseDouble) -> f Double -> g (Double, f (Double, f Double)) Source #