dvda-0.3.1: Efficient automatic differentiation and code generation

Safe HaskellNone

Dvda.Expr

Synopsis

Documentation

data Expr a whereSource

Constructors

ESym :: Sym -> Expr a 
EConst :: a -> Expr a 
ENum :: Num a => Nums (Expr a) -> Expr a 
EFractional :: Fractional a => Fractionals (Expr a) -> Expr a 
EFloating :: Floating a => Floatings (Expr a) -> Expr a 

Instances

Typeable1 Expr 
Eq a => Eq (Expr a) 
(Floating a, Ord a) => Floating (Expr a) 
(Fractional a, Ord a) => Fractional (Expr a) 
(Data a, Floating a) => Data (Expr a) 
(Num a, Ord a) => Num (Expr a) 
Show a => Show (Expr a) 
Hashable a => Hashable (Expr a) 
MuRef (Expr a) 
ToFunGraph [[Expr a]] 
ToFunGraph [Expr a] 
ToFunGraph (Expr a) 

data GExpr a b whereSource

Constructors

GSym :: Sym -> GExpr a b 
GConst :: a -> GExpr a b 
GNum :: Num a => Nums b -> GExpr a b 
GFractional :: Fractional a => Fractionals b -> GExpr a b 
GFloating :: Floating a => Floatings b -> GExpr a b 

Instances

Typeable2 GExpr 
(Eq a, Eq b) => Eq (GExpr a b) 
(Data a, Data b, Floating a) => Data (GExpr a b) 
(Ord a, Ord b) => Ord (GExpr a b) 
(Show a, Show b) => Show (GExpr a b) 
(Hashable a, Hashable b) => Hashable (GExpr a b) 

data Nums a Source

Constructors

Mul a a 
Add a a 
Sub a a 
Negate a 
Abs a 
Signum a 
FromInteger Integer 

Instances

Typeable1 Nums 
Eq a => Eq (Nums a) 
Data a => Data (Nums a) 
Ord a => Ord (Nums a) 
Show a => Show (Nums a) 
Hashable a => Hashable (Nums a) 

data Fractionals a Source

Constructors

Div a a 
FromRational Rational 

data Floatings a Source

Constructors

Pow a a 
LogBase a a 
Exp a 
Log a 
Sin a 
Cos a 
ASin a 
ATan a 
ACos a 
Sinh a 
Cosh a 
Tanh a 
ASinh a 
ATanh a 
ACosh a 

Instances

isVal :: Eq a => a -> Expr a -> BoolSource

Checks to see if an Expr is equal to a value

sym :: String -> Expr aSource

symbolic scalar

symDependent :: String -> Expr a -> Expr aSource

Symbolic scalar which is a function of some independent variable, like time. . This lets you do d(f(g(t)))/dt == f'(g(t))*g'(t)

symDependentN :: String -> Expr a -> Int -> Expr aSource

same as symDependent but it can start as the Nth derivative

const' :: a -> Expr aSource

getParents :: GExpr a b -> [b]Source

extractLinearPart :: (Num a, Ord a, Show a) => Expr a -> Expr a -> (Expr a, a)Source

getConst :: Expr a -> Maybe aSource

if the expression is a constant, a fromInteger, or a fromRational, return the constant part otherwise return nothing

substitute :: (Ord a, Hashable a, Show a) => Expr a -> [(Expr a, Expr a)] -> Expr aSource

sketchySubstitute :: (Eq a, Hashable a, Show a) => Expr a -> [(Expr a, Expr a)] -> Expr aSource

this substitute is sketchy because it doesn't perform simplifications that are often assumed to be done

foldExpr :: (Expr a -> b -> b) -> b -> Expr a -> bSource

foldr over the constants and symbols