vector-space-0.11: Vector & affine spaces, linear maps, and derivatives

Copyright(c) Conal Elliott 2008
LicenseBSD3
Maintainerconal@conal.net
Stabilityexperimental
Safe HaskellNone
LanguageHaskell98

Data.Maclaurin

Contents

Description

Infinite derivative towers via linear maps, using the Maclaurin representation. See blog posts http://conal.net/blog/tag/derivative/.

Synopsis

Documentation

data a :> b Source #

Tower of derivatives.

Constructors

D infixr 9 

Fields

Instances

(VectorSpace s, HasBasis s, HasTrie (Basis s), HasNormal ((:>) (Two s) (Three s))) => HasNormal (Three ((:>) (Two s) s)) Source # 

Methods

normalVec :: Three (Two s :> s) -> Three (Two s :> s) Source #

(VectorSpace s, HasBasis s, HasTrie (Basis s), (~) * (Basis s) ()) => HasNormal (Two ((:>) (One s) s)) Source # 

Methods

normalVec :: Two (One s :> s) -> Two (One s :> s) Source #

Eq ((:>) a b) Source # 

Methods

(==) :: (a :> b) -> (a :> b) -> Bool #

(/=) :: (a :> b) -> (a :> b) -> Bool #

(HasBasis a, (~) * s (Scalar a), HasTrie (Basis a), Floating s, VectorSpace s, (~) * (Scalar s) s) => Floating ((:>) a s) Source # 

Methods

pi :: a :> s #

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

(HasBasis a, (~) * s (Scalar a), HasTrie (Basis a), Fractional s, VectorSpace s, (~) * (Scalar s) s) => Fractional ((:>) a s) Source # 

Methods

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

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

fromRational :: Rational -> a :> s #

(HasBasis a, (~) * s (Scalar a), HasTrie (Basis a), Num s, VectorSpace s, (~) * (Scalar s) s) => Num ((:>) a s) Source # 

Methods

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

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

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

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

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

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

fromInteger :: Integer -> a :> s #

(AdditiveGroup b, HasBasis a, HasTrie (Basis a), OrdB b, IfB b, Ord b) => Ord ((:>) a b) Source # 

Methods

compare :: (a :> b) -> (a :> b) -> Ordering #

(<) :: (a :> b) -> (a :> b) -> Bool #

(<=) :: (a :> b) -> (a :> b) -> Bool #

(>) :: (a :> b) -> (a :> b) -> Bool #

(>=) :: (a :> b) -> (a :> b) -> Bool #

max :: (a :> b) -> (a :> b) -> a :> b #

min :: (a :> b) -> (a :> b) -> a :> b #

Show b => Show ((:>) a b) Source # 

Methods

showsPrec :: Int -> (a :> b) -> ShowS #

show :: (a :> b) -> String #

showList :: [a :> b] -> ShowS #

(AdditiveGroup v, HasBasis u, HasTrie (Basis u), IfB v) => IfB ((:>) u v) Source # 

Methods

ifB :: (* ~ bool) (BooleanOf (u :> v)) => bool -> (u :> v) -> (u :> v) -> u :> v #

OrdB v => OrdB ((:>) u v) Source # 

Methods

(<*) :: (* ~ bool) (BooleanOf (u :> v)) => (u :> v) -> (u :> v) -> bool #

(<=*) :: (* ~ bool) (BooleanOf (u :> v)) => (u :> v) -> (u :> v) -> bool #

(>*) :: (* ~ bool) (BooleanOf (u :> v)) => (u :> v) -> (u :> v) -> bool #

(>=*) :: (* ~ bool) (BooleanOf (u :> v)) => (u :> v) -> (u :> v) -> bool #

(HasBasis a, HasTrie (Basis a), AdditiveGroup u) => AdditiveGroup ((:>) a u) Source # 

Methods

zeroV :: a :> u Source #

(^+^) :: (a :> u) -> (a :> u) -> a :> u Source #

negateV :: (a :> u) -> a :> u Source #

(^-^) :: (a :> u) -> (a :> u) -> a :> u Source #

(InnerSpace u, (~) * s (Scalar u), AdditiveGroup s, HasBasis a, HasTrie (Basis a)) => InnerSpace ((:>) a u) Source # 

Methods

(<.>) :: (a :> u) -> (a :> u) -> Scalar (a :> u) Source #

(HasBasis a, HasTrie (Basis a), VectorSpace u) => VectorSpace ((:>) a u) Source # 

Associated Types

type Scalar ((:>) a u) :: * Source #

Methods

(*^) :: Scalar (a :> u) -> (a :> u) -> a :> u Source #

(HasBasis a, HasTrie (Basis a), VectorSpace v, HasCross3 v) => HasCross3 ((:>) a v) Source # 

Methods

cross3 :: (a :> v) -> (a :> v) -> a :> v Source #

(HasTrie (Basis a), HasCross2 v) => HasCross2 ((:>) a v) Source # 

Methods

cross2 :: (a :> v) -> a :> v Source #

(Num s, HasTrie (Basis (s, s)), HasBasis s, (~) * (Basis s) ()) => HasNormal ((:>) (Two s) (Three s)) Source # 

Methods

normalVec :: (Two s :> Three s) -> Two s :> Three s Source #

(HasBasis s, HasTrie (Basis s), (~) * (Basis s) ()) => HasNormal ((:>) (One s) (Two s)) Source # 

Methods

normalVec :: (One s :> Two s) -> One s :> Two s Source #

type BooleanOf ((:>) a b) Source # 
type BooleanOf ((:>) a b) = BooleanOf b
type Scalar ((:>) a u) Source # 
type Scalar ((:>) a u) = (:>) a (Scalar u)

derivAtBasis :: (HasTrie (Basis a), HasBasis a, AdditiveGroup b) => (a :> b) -> Basis a -> a :> b Source #

Sample the derivative at a basis element. Optimized for partial application to save work for non-scalar derivatives.

type (:~>) a b = a -> a :> b Source #

Infinitely differentiable functions

pureD :: (AdditiveGroup b, HasBasis a, HasTrie (Basis a)) => b -> a :> b Source #

Constant derivative tower.

fmapD :: HasTrie (Basis a) => (b -> c) -> (a :> b) -> a :> c Source #

Map a linear function over a derivative tower.

(<$>>) :: HasTrie (Basis a) => (b -> c) -> (a :> b) -> a :> c infixl 4 Source #

Map a linear function over a derivative tower.

liftD2 :: (HasBasis a, HasTrie (Basis a), AdditiveGroup b, AdditiveGroup c) => (b -> c -> d) -> (a :> b) -> (a :> c) -> a :> d Source #

Apply a linear binary function over derivative towers.

liftD3 :: (HasBasis a, HasTrie (Basis a), AdditiveGroup b, AdditiveGroup c, AdditiveGroup d) => (b -> c -> d -> e) -> (a :> b) -> (a :> c) -> (a :> d) -> a :> e Source #

Apply a linear ternary function over derivative towers.

idD :: (VectorSpace u, HasBasis u, HasTrie (Basis u)) => u :~> u Source #

Differentiable identity function. Sometimes called "the derivation variable" or similar, but it's not really a variable.

fstD :: (HasBasis a, HasTrie (Basis a), HasBasis b, HasTrie (Basis b), Scalar a ~ Scalar b) => (a, b) :~> a Source #

Differentiable version of fst

sndD :: (HasBasis a, HasTrie (Basis a), HasBasis b, HasTrie (Basis b), Scalar a ~ Scalar b) => (a, b) :~> b Source #

Differentiable version of snd

linearD :: (HasBasis u, HasTrie (Basis u), AdditiveGroup v) => (u -> v) -> u :~> v Source #

Every linear function has a constant derivative equal to the function itself (as a linear map).

distrib :: forall a b c u. (HasBasis a, HasTrie (Basis a), AdditiveGroup u) => (b -> c -> u) -> (a :> b) -> (a :> c) -> a :> u Source #

Derivative tower for applying a binary function that distributes over addition, such as multiplication. A bit weaker assumption than bilinearity. Is bilinearity necessary for correctness here?

(>-<) :: (HasBasis a, HasTrie (Basis a), VectorSpace u) => (u -> u) -> ((a :> u) -> a :> Scalar u) -> (a :> u) -> a :> u infix 0 Source #

Specialized chain rule. See also '(@.)'

Misc

pairD :: (HasBasis a, HasTrie (Basis a), VectorSpace b, VectorSpace c) => (a :> b, a :> c) -> a :> (b, c) Source #

unpairD :: HasTrie (Basis a) => (a :> (b, c)) -> (a :> b, a :> c) Source #

tripleD :: (HasBasis a, HasTrie (Basis a), VectorSpace b, VectorSpace c, VectorSpace d) => (a :> b, a :> c, a :> d) -> a :> (b, c, d) Source #

untripleD :: HasTrie (Basis a) => (a :> (b, c, d)) -> (a :> b, a :> c, a :> d) Source #