backprop-0.2.4.0: Heterogeneous automatic differentation

Copyright(c) Justin Le 2018
LicenseBSD3
Maintainerjustin@jle.im
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Prelude.Backprop.Explicit

Contents

Description

Provides "explicit" versions of all of the functions in Prelude.Backprop. Instead of relying on a Backprop instance, allows you to manually provide zero, add, and one on a per-value basis.

WARNING: API of this module can be considered only "semi-stable"; while the API of Prelude.Backprop and Prelude.Backprop.Num" are kept consistent, some argument order changes might happen in this module to reflect changes in underlying implementation.

Since: 0.2.0.0

Synopsis

Foldable and Traversable

sum :: (Foldable t, Functor t, Num a, Reifies s W) => AddFunc (t a) -> BVar s (t a) -> BVar s a Source #

sum, but taking explicit add and zero.

product :: (Foldable t, Functor t, Fractional a, Reifies s W) => AddFunc (t a) -> BVar s (t a) -> BVar s a Source #

product, but taking explicit add and zero.

length :: (Foldable t, Num b, Reifies s W) => AddFunc (t a) -> ZeroFunc (t a) -> BVar s (t a) -> BVar s b Source #

length, but taking explicit add and zero.

minimum :: (Foldable t, Functor t, Ord a, Reifies s W) => AddFunc (t a) -> ZeroFunc a -> BVar s (t a) -> BVar s a Source #

minimum, but taking explicit add and zero.

maximum :: (Foldable t, Functor t, Ord a, Reifies s W) => AddFunc (t a) -> ZeroFunc a -> BVar s (t a) -> BVar s a Source #

maximum, but taking explicit add and zero.

traverse :: (Traversable t, Applicative f, Foldable f, Reifies s W) => AddFunc a -> AddFunc b -> AddFunc (t b) -> ZeroFunc a -> ZeroFunc b -> (BVar s a -> f (BVar s b)) -> BVar s (t a) -> BVar s (f (t b)) Source #

traverse, but taking explicit add and zero.

toList :: (Traversable t, Reifies s W) => AddFunc a -> ZeroFunc a -> BVar s (t a) -> [BVar s a] Source #

length, but taking explicit add and zero.

Since: 0.2.2.0

mapAccumL :: (Traversable t, Reifies s W) => AddFunc b -> AddFunc c -> ZeroFunc b -> ZeroFunc c -> (BVar s a -> BVar s b -> (BVar s a, BVar s c)) -> BVar s a -> BVar s (t b) -> (BVar s a, BVar s (t c)) Source #

mapAccumL, but taking explicit add and zero.

Since: 0.2.2.0

mapAccumR :: (Traversable t, Reifies s W) => AddFunc b -> AddFunc c -> ZeroFunc b -> ZeroFunc c -> (BVar s a -> BVar s b -> (BVar s a, BVar s c)) -> BVar s a -> BVar s (t b) -> (BVar s a, BVar s (t c)) Source #

mapAccumR, but taking explicit add and zero.

Since: 0.2.2.0

foldr :: (Traversable t, Reifies s W) => AddFunc a -> ZeroFunc a -> (BVar s a -> BVar s b -> BVar s b) -> BVar s b -> BVar s (t a) -> BVar s b Source #

foldr, but taking explicit add and zero.

Since: 0.2.3.0

foldl' :: (Traversable t, Reifies s W) => AddFunc a -> ZeroFunc a -> (BVar s b -> BVar s a -> BVar s b) -> BVar s b -> BVar s (t a) -> BVar s b Source #

foldl', but taking explicit add and zero.

Since: 0.2.3.0

Functor and Applicative

fmap :: (Traversable f, Reifies s W) => AddFunc a -> AddFunc b -> ZeroFunc a -> ZeroFunc b -> (BVar s a -> BVar s b) -> BVar s (f a) -> BVar s (f b) Source #

fmap, but taking explicit add and zero.

fmapConst :: (Functor f, Foldable f, Reifies s W) => AddFunc (f a) -> AddFunc b -> ZeroFunc (f a) -> ZeroFunc b -> BVar s b -> BVar s (f a) -> BVar s (f b) Source #

fmapConst, but taking explicit add and zero.

Since: 0.2.4.0

pure :: (Foldable t, Applicative t, Reifies s W) => AddFunc a -> ZeroFunc a -> BVar s a -> BVar s (t a) Source #

pure, but taking explicit add and zero.

liftA2 :: (Traversable f, Applicative f, Reifies s W) => AddFunc a -> AddFunc b -> AddFunc c -> ZeroFunc a -> ZeroFunc b -> ZeroFunc c -> (BVar s a -> BVar s b -> BVar s c) -> BVar s (f a) -> BVar s (f b) -> BVar s (f c) Source #

liftA2, but taking explicit add and zero.

liftA3 :: (Traversable f, Applicative f, Reifies s W) => AddFunc a -> AddFunc b -> AddFunc c -> AddFunc d -> ZeroFunc a -> ZeroFunc b -> ZeroFunc c -> ZeroFunc d -> (BVar s a -> BVar s b -> BVar s c -> BVar s d) -> BVar s (f a) -> BVar s (f b) -> BVar s (f c) -> BVar s (f d) Source #

liftA3, but taking explicit add and zero.

Numeric

fromIntegral :: (Integral a, Integral b, Reifies s W) => AddFunc a -> BVar s a -> BVar s b Source #

fromIntegral, but taking explicit add and zero.

Since: 0.2.1.0

realToFrac :: (Fractional a, Real a, Fractional b, Real b, Reifies s W) => AddFunc a -> BVar s a -> BVar s b Source #

realToFrac, but taking explicit add and zero.

Since: 0.2.1.0

round :: (RealFrac a, Integral b, Reifies s W) => AddFunc a -> BVar s a -> BVar s b Source #

round, but taking explicit add and zero.

Since: 0.2.3.0

fromIntegral' :: (Integral a, RealFrac b, Reifies s W) => AddFunc a -> BVar s a -> BVar s b Source #

fromIntegral', but taking explicit add and zero.

Since: 0.2.3.0

Misc

coerce :: Coercible a b => BVar s a -> BVar s b Source #

Coerce items inside a BVar.