ad-4.5.6: Automatic Differentiation
Copyright(c) Edward Kmett 2010-2021
LicenseBSD3
Maintainerekmett@gmail.com
Stabilityexperimental
PortabilityGHC only
Safe HaskellSafe-Inferred
LanguageHaskell2010

Numeric.AD.Mode.Sparse.Double

Description

Higher order derivatives via a "dual number tower".

Synopsis

Documentation

data AD s a Source #

Instances

Instances details
Mode a => Mode (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

Associated Types

type Scalar (AD s a) Source #

Methods

isKnownConstant :: AD s a -> Bool Source #

asKnownConstant :: AD s a -> Maybe (Scalar (AD s a)) Source #

isKnownZero :: AD s a -> Bool Source #

auto :: Scalar (AD s a) -> AD s a Source #

(*^) :: Scalar (AD s a) -> AD s a -> AD s a Source #

(^*) :: AD s a -> Scalar (AD s a) -> AD s a Source #

(^/) :: AD s a -> Scalar (AD s a) -> AD s a Source #

zero :: AD s a Source #

Bounded a => Bounded (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

Methods

minBound :: AD s a #

maxBound :: AD s a #

Enum a => Enum (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

Methods

succ :: AD s a -> AD s a #

pred :: AD s a -> AD s a #

toEnum :: Int -> AD s a #

fromEnum :: AD s a -> Int #

enumFrom :: AD s a -> [AD s a] #

enumFromThen :: AD s a -> AD s a -> [AD s a] #

enumFromTo :: AD s a -> AD s a -> [AD s a] #

enumFromThenTo :: AD s a -> AD s a -> AD s a -> [AD s a] #

Floating a => Floating (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

Methods

pi :: AD s a #

exp :: AD s a -> AD s a #

log :: AD s a -> AD s a #

sqrt :: AD s a -> AD s a #

(**) :: AD s a -> AD s a -> AD s a #

logBase :: AD s a -> AD s a -> AD s a #

sin :: AD s a -> AD s a #

cos :: AD s a -> AD s a #

tan :: AD s a -> AD s a #

asin :: AD s a -> AD s a #

acos :: AD s a -> AD s a #

atan :: AD s a -> AD s a #

sinh :: AD s a -> AD s a #

cosh :: AD s a -> AD s a #

tanh :: AD s a -> AD s a #

asinh :: AD s a -> AD s a #

acosh :: AD s a -> AD s a #

atanh :: AD s a -> AD s a #

log1p :: AD s a -> AD s a #

expm1 :: AD s a -> AD s a #

log1pexp :: AD s a -> AD s a #

log1mexp :: AD s a -> AD s a #

RealFloat a => RealFloat (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

Methods

floatRadix :: AD s a -> Integer #

floatDigits :: AD s a -> Int #

floatRange :: AD s a -> (Int, Int) #

decodeFloat :: AD s a -> (Integer, Int) #

encodeFloat :: Integer -> Int -> AD s a #

exponent :: AD s a -> Int #

significand :: AD s a -> AD s a #

scaleFloat :: Int -> AD s a -> AD s a #

isNaN :: AD s a -> Bool #

isInfinite :: AD s a -> Bool #

isDenormalized :: AD s a -> Bool #

isNegativeZero :: AD s a -> Bool #

isIEEE :: AD s a -> Bool #

atan2 :: AD s a -> AD s a -> AD s a #

Num a => Num (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

Methods

(+) :: AD s a -> AD s a -> AD s a #

(-) :: AD s a -> AD s a -> AD s a #

(*) :: AD s a -> AD s a -> AD s a #

negate :: AD s a -> AD s a #

abs :: AD s a -> AD s a #

signum :: AD s a -> AD s a #

fromInteger :: Integer -> AD s a #

Read a => Read (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

Methods

readsPrec :: Int -> ReadS (AD s a) #

readList :: ReadS [AD s a] #

readPrec :: ReadPrec (AD s a) #

readListPrec :: ReadPrec [AD s a] #

Fractional a => Fractional (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

Methods

(/) :: AD s a -> AD s a -> AD s a #

recip :: AD s a -> AD s a #

fromRational :: Rational -> AD s a #

Real a => Real (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

Methods

toRational :: AD s a -> Rational #

RealFrac a => RealFrac (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

Methods

properFraction :: Integral b => AD s a -> (b, AD s a) #

truncate :: Integral b => AD s a -> b #

round :: Integral b => AD s a -> b #

ceiling :: Integral b => AD s a -> b #

floor :: Integral b => AD s a -> b #

Show a => Show (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

Methods

showsPrec :: Int -> AD s a -> ShowS #

show :: AD s a -> String #

showList :: [AD s a] -> ShowS #

Erf a => Erf (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

Methods

erf :: AD s a -> AD s a #

erfc :: AD s a -> AD s a #

erfcx :: AD s a -> AD s a #

normcdf :: AD s a -> AD s a #

InvErf a => InvErf (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

Methods

inverf :: AD s a -> AD s a #

inverfc :: AD s a -> AD s a #

invnormcdf :: AD s a -> AD s a #

Eq a => Eq (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

Methods

(==) :: AD s a -> AD s a -> Bool #

(/=) :: AD s a -> AD s a -> Bool #

Ord a => Ord (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

Methods

compare :: AD s a -> AD s a -> Ordering #

(<) :: AD s a -> AD s a -> Bool #

(<=) :: AD s a -> AD s a -> Bool #

(>) :: AD s a -> AD s a -> Bool #

(>=) :: AD s a -> AD s a -> Bool #

max :: AD s a -> AD s a -> AD s a #

min :: AD s a -> AD s a -> AD s a #

type Scalar (AD s a) Source # 
Instance details

Defined in Numeric.AD.Internal.Type

type Scalar (AD s a) = Scalar a

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

Instances details
Jacobian SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Associated Types

type D SparseDouble Source #

Mode SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Associated Types

type Scalar SparseDouble Source #

Data SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SparseDouble -> c SparseDouble #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SparseDouble #

toConstr :: SparseDouble -> Constr #

dataTypeOf :: SparseDouble -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SparseDouble) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SparseDouble) #

gmapT :: (forall b. Data b => b -> b) -> SparseDouble -> SparseDouble #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SparseDouble -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SparseDouble -> r #

gmapQ :: (forall d. Data d => d -> u) -> SparseDouble -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SparseDouble -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SparseDouble -> m SparseDouble #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SparseDouble -> m SparseDouble #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SparseDouble -> m SparseDouble #

Enum SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Floating SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

RealFloat SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Num SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Fractional SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Real SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

RealFrac SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Show SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Erf SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

InvErf SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Eq SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Ord SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Grad SparseDouble [Double] (Double, [Double]) Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Grads SparseDouble (Cofree List Double) Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Grads i o => Grads (SparseDouble -> i) (Double -> o) Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Grad i o o' => Grad (SparseDouble -> i) (Double -> o) (Double -> o') Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

Methods

pack :: (SparseDouble -> i) -> [SparseDouble] -> SparseDouble Source #

unpack :: ([Double] -> [Double]) -> Double -> o Source #

unpack' :: ([Double] -> (Double, [Double])) -> Double -> o' Source #

type D SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

type Scalar SparseDouble Source # 
Instance details

Defined in Numeric.AD.Internal.Sparse.Double

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

Embed a constant

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 #