Portability | GHC only |
---|---|
Stability | experimental |
Maintainer | ekmett@gmail.com |
- class Lifted t => Mode t where
- one :: (Mode t, Num a) => t a
- class (Mode t, Mode (D t)) => Jacobian t where
- type D t :: * -> *
- unary :: Num a => (a -> a) -> D t a -> t a -> t a
- lift1 :: Num a => (a -> a) -> (D t a -> D t a) -> t a -> t a
- lift1_ :: Num a => (a -> a) -> (D t a -> D t a -> D t a) -> t a -> t a
- binary :: Num a => (a -> a -> a) -> D t a -> D t a -> t a -> t a -> t a
- lift2 :: Num a => (a -> a -> a) -> (D t a -> D t a -> (D t a, D t a)) -> t a -> t a -> t a
- lift2_ :: Num a => (a -> a -> a) -> (D t a -> D t a -> D t a -> (D t a, D t a)) -> t a -> t a -> t a
- class Primal t where
- deriveLifted :: Q Type -> Q [Dec]
- deriveNumeric :: Q Type -> Q Type -> Q [Dec]
- class Lifted t where
- showsPrec1 :: Show a => Int -> t a -> ShowS
- (==!) :: (Num a, Eq a) => t a -> t a -> Bool
- compare1 :: (Num a, Ord a) => t a -> t a -> Ordering
- fromInteger1 :: Num a => Integer -> t a
- (+!) :: Num a => t a -> t a -> t a
- (*!) :: Num a => t a -> t a -> t a
- (-!) :: Num a => t a -> t a -> t a
- negate1 :: Num a => t a -> t a
- signum1 :: Num a => t a -> t a
- abs1 :: Num a => t a -> t a
- (/!) :: Fractional a => t a -> t a -> t a
- recip1 :: Fractional a => t a -> t a
- fromRational1 :: Fractional a => Rational -> t a
- toRational1 :: Real a => t a -> Rational
- pi1 :: Floating a => t a
- exp1 :: Floating a => t a -> t a
- sqrt1 :: Floating a => t a -> t a
- log1 :: Floating a => t a -> t a
- (**!) :: Floating a => t a -> t a -> t a
- logBase1 :: Floating a => t a -> t a -> t a
- sin1 :: Floating a => t a -> t a
- atan1 :: Floating a => t a -> t a
- acos1 :: Floating a => t a -> t a
- asin1 :: Floating a => t a -> t a
- tan1 :: Floating a => t a -> t a
- cos1 :: Floating a => t a -> t a
- sinh1 :: Floating a => t a -> t a
- atanh1 :: Floating a => t a -> t a
- acosh1 :: Floating a => t a -> t a
- asinh1 :: Floating a => t a -> t a
- tanh1 :: Floating a => t a -> t a
- cosh1 :: Floating a => t a -> t a
- properFraction1 :: (RealFrac a, Integral b) => t a -> (b, t a)
- truncate1 :: (RealFrac a, Integral b) => t a -> b
- floor1 :: (RealFrac a, Integral b) => t a -> b
- ceiling1 :: (RealFrac a, Integral b) => t a -> b
- round1 :: (RealFrac a, Integral b) => t a -> b
- floatRadix1 :: RealFloat a => t a -> Integer
- floatDigits1 :: RealFloat a => t a -> Int
- floatRange1 :: RealFloat a => t a -> (Int, Int)
- decodeFloat1 :: RealFloat a => t a -> (Integer, Int)
- encodeFloat1 :: RealFloat a => Integer -> Int -> t a
- exponent1 :: RealFloat a => t a -> Int
- significand1 :: RealFloat a => t a -> t a
- scaleFloat1 :: RealFloat a => Int -> t a -> t a
- isNaN1 :: RealFloat a => t a -> Bool
- isIEEE1 :: RealFloat a => t a -> Bool
- isNegativeZero1 :: RealFloat a => t a -> Bool
- isDenormalized1 :: RealFloat a => t a -> Bool
- isInfinite1 :: RealFloat a => t a -> Bool
- atan21 :: RealFloat a => t a -> t a -> t a
- succ1 :: (Num a, Enum a) => t a -> t a
- pred1 :: (Num a, Enum a) => t a -> t a
- toEnum1 :: (Num a, Enum a) => Int -> t a
- fromEnum1 :: (Num a, Enum a) => t a -> Int
- enumFrom1 :: (Num a, Enum a) => t a -> [t a]
- enumFromThen1 :: (Num a, Enum a) => t a -> t a -> [t a]
- enumFromTo1 :: (Num a, Enum a) => t a -> t a -> [t a]
- enumFromThenTo1 :: (Num a, Enum a) => t a -> t a -> t a -> [t a]
- minBound1 :: (Num a, Bounded a) => t a
- maxBound1 :: (Num a, Bounded a) => t a
AD modes
class Lifted t => Mode t whereSource
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' = 'lift' 0
Automatically Deriving AD
class (Mode t, Mode (D t)) => Jacobian t whereSource
Jacobian
is used by deriveMode
but is not exposed
via Mode
to prevent its abuse by end users
via the AD
data type.
unary :: Num a => (a -> a) -> D t a -> t a -> t aSource
lift1 :: Num a => (a -> a) -> (D t a -> D t a) -> t a -> t aSource
lift1_ :: Num a => (a -> a) -> (D t a -> D t a -> D t a) -> t a -> t aSource
binary :: Num a => (a -> a -> a) -> D t a -> D t a -> t a -> t a -> t aSource
lift2 :: Num a => (a -> a -> a) -> (D t a -> D t a -> (D t a, D t a)) -> t a -> t a -> t aSource
lift2_ :: Num a => (a -> a -> a) -> (D t a -> D t a -> D t a -> (D t a, D t a)) -> t a -> t a -> t aSource
Primal
is used by deriveMode
but is not exposed
via the Mode
class to prevent its abuse by end users
via the AD data type.
It provides direct access to the result, stripped of its derivative information, but this is unsafe in general as (lift . primal) would discard derivative information. The end user is protected from accidentally using this function by the universal quantification on the various combinators we expose.
deriveLifted :: Q Type -> Q [Dec]Source
provides
deriveLifted
t
instance Lifted $t
given supplied instances for
instance Lifted $t => Primal $t where ... instance Lifted $t => Jacobian $t where ...
The seemingly redundant
constraints are caused by Template Haskell staging restrictions.
Lifted
$t
deriveNumeric :: Q Type -> Q Type -> Q [Dec]Source
provides the following instances:
deriveNumeric
f g
instance ('Lifted' $f, 'Num' a, 'Enum' a) => 'Enum' ($g a) instance ('Lifted' $f, 'Num' a, 'Eq' a) => 'Eq' ($g a) instance ('Lifted' $f, 'Num' a, 'Ord' a) => 'Ord' ($g a) instance ('Lifted' $f, 'Num a, 'Bounded' a) => 'Bounded' ($g a) instance ('Lifted' $f, 'Show' a) => 'Show' ($g a) instance ('Lifted' $f, 'Num' a) => 'Num' ($g a) instance ('Lifted' $f, 'Fractional' a) => 'Fractional' ($g a) instance ('Lifted' $f, 'Floating' a) => 'Floating' ($g a) instance ('Lifted' $f, 'RealFloat' a) => 'RealFloat' ($g a) instance ('Lifted' $f, 'RealFrac' a) => 'RealFrac' ($g a) instance ('Lifted' $f, 'Real' a) => 'Real' ($g a)
Higher-order versions of the stock numerical methods.
showsPrec1 :: Show a => Int -> t a -> ShowSSource
(==!) :: (Num a, Eq a) => t a -> t a -> BoolSource
compare1 :: (Num a, Ord a) => t a -> t a -> OrderingSource
fromInteger1 :: Num a => Integer -> t aSource
(+!) :: Num a => t a -> t a -> t aSource
(*!) :: Num a => t a -> t a -> t aSource
(-!) :: Num a => t a -> t a -> t aSource
negate1 :: Num a => t a -> t aSource
signum1 :: Num a => t a -> t aSource
abs1 :: Num a => t a -> t aSource
(/!) :: Fractional a => t a -> t a -> t aSource
recip1 :: Fractional a => t a -> t aSource
fromRational1 :: Fractional a => Rational -> t aSource
toRational1 :: Real a => t a -> RationalSource
pi1 :: Floating a => t aSource
exp1 :: Floating a => t a -> t aSource
sqrt1 :: Floating a => t a -> t aSource
log1 :: Floating a => t a -> t aSource
(**!) :: Floating a => t a -> t a -> t aSource
logBase1 :: Floating a => t a -> t a -> t aSource
sin1 :: Floating a => t a -> t aSource
atan1 :: Floating a => t a -> t aSource
acos1 :: Floating a => t a -> t aSource
asin1 :: Floating a => t a -> t aSource
tan1 :: Floating a => t a -> t aSource
cos1 :: Floating a => t a -> t aSource
sinh1 :: Floating a => t a -> t aSource
atanh1 :: Floating a => t a -> t aSource
acosh1 :: Floating a => t a -> t aSource
asinh1 :: Floating a => t a -> t aSource
tanh1 :: Floating a => t a -> t aSource
cosh1 :: Floating a => t a -> t aSource
properFraction1 :: (RealFrac a, Integral b) => t a -> (b, t a)Source
truncate1 :: (RealFrac a, Integral b) => t a -> bSource
floor1 :: (RealFrac a, Integral b) => t a -> bSource
ceiling1 :: (RealFrac a, Integral b) => t a -> bSource
round1 :: (RealFrac a, Integral b) => t a -> bSource
floatRadix1 :: RealFloat a => t a -> IntegerSource
floatDigits1 :: RealFloat a => t a -> IntSource
floatRange1 :: RealFloat a => t a -> (Int, Int)Source
decodeFloat1 :: RealFloat a => t a -> (Integer, Int)Source
encodeFloat1 :: RealFloat a => Integer -> Int -> t aSource
exponent1 :: RealFloat a => t a -> IntSource
significand1 :: RealFloat a => t a -> t aSource
scaleFloat1 :: RealFloat a => Int -> t a -> t aSource
isNaN1 :: RealFloat a => t a -> BoolSource
isIEEE1 :: RealFloat a => t a -> BoolSource
isNegativeZero1 :: RealFloat a => t a -> BoolSource
isDenormalized1 :: RealFloat a => t a -> BoolSource
isInfinite1 :: RealFloat a => t a -> BoolSource
atan21 :: RealFloat a => t a -> t a -> t aSource
succ1 :: (Num a, Enum a) => t a -> t aSource
pred1 :: (Num a, Enum a) => t a -> t aSource
toEnum1 :: (Num a, Enum a) => Int -> t aSource
fromEnum1 :: (Num a, Enum a) => t a -> IntSource
enumFrom1 :: (Num a, Enum a) => t a -> [t a]Source
enumFromThen1 :: (Num a, Enum a) => t a -> t a -> [t a]Source
enumFromTo1 :: (Num a, Enum a) => t a -> t a -> [t a]Source
enumFromThenTo1 :: (Num a, Enum a) => t a -> t a -> t a -> [t a]Source