srtree-2.0.0.2: A general library to work with Symbolic Regression expression trees.
Copyright(c) Fabricio Olivetti 2021 - 2024
LicenseBSD3
Maintainerfabricio.olivetti@gmail.com
Stabilityexperimental
PortabilityFlexibleInstances, DeriveFunctor, ScopedTypeVariables
Safe HaskellNone
LanguageHaskell2010

Algorithm.SRTree.AD

Description

Automatic Differentiation for Expression trees

Synopsis

Documentation

forwardMode :: Array S Ix2 Double -> Array S Ix1 Double -> SRVector -> Fix SRTree -> (Array D Ix1 Double, Array S Ix1 Double) Source #

Calculates the results of the error vector multiplied by the Jacobian of an expression using forward mode provided a vector of variable values xss, a vector of parameter values theta and a function that changes a Double value to the type of the variable values. uses unsafe operations to use mutable array instead of a tape

forwardModeUnique :: SRMatrix -> PVector -> SRVector -> Fix SRTree -> (SRVector, Array S Ix1 Double) Source #

The function forwardModeUnique calculates the numerical gradient of the tree and evaluates the tree at the same time. It assumes that each parameter has a unique occurrence in the expression. This should be significantly faster than forwardMode.

reverseModeUnique :: SRMatrix -> PVector -> SRVector -> (SRVector -> SRVector) -> Fix SRTree -> (Array D Ix1 Double, Array S Ix1 Double) Source #

Same as above, but using reverse mode, that is even faster.

reverseModeUniqueArr :: (Num a, Eq a, Manifest r1 Double, Manifest r2 Double, Source r3 Double) => Array r1 Ix2 Double -> Array r2 Int Double -> Array r3 Ix1 Double -> (Array D Ix1 Double -> Array D Ix1 Double) -> [(Key, (a, Int, Int, Double))] -> IntMap Int -> (Array D Ix1 Double, Array S Int Double) Source #

Same as above, but using reverse mode with the tree encoded as an array, that is even faster. reverseModeUniqueArr :: SRMatrix -> PVector -> SRVector -> (SRVector -> SRVector) -> Array S Ix1 (Int, Int, Int, Double) -- arity, opcode, ix, const val -> (Array D Ix1 Double, Array S Ix1 Double)

forwardModeUniqueJac :: SRMatrix -> PVector -> Fix SRTree -> [PVector] Source #

The function forwardModeUnique calculates the numerical gradient of the tree and evaluates the tree at the same time. It assumes that each parameter has a unique occurrence in the expression. This should be significantly faster than forwardMode.