plankton-0.0.0.1: The core of a numeric prelude, taken from numhask

Safe HaskellNone
LanguageHaskell2010

Plankton.Module

Description

Algebra for Representable numbers

Synopsis

Documentation

class (Representable r, Additive a) => AdditiveModule r a where Source #

Additive Module Laws

(a + b) .+ c == a + (b .+ c)
(a + b) .+ c == (a .+ c) + b
a .+ zero == a
a .+ b == b +. a

Methods

(.+) :: r a -> a -> r a infixl 6 Source #

(+.) :: a -> r a -> r a infixl 6 Source #

Instances

(Representable r, Additive a) => AdditiveModule r a Source # 

Methods

(.+) :: r a -> a -> r a Source #

(+.) :: a -> r a -> r a Source #

class (Representable r, AdditiveGroup a) => AdditiveGroupModule r a where Source #

Subtraction Module Laws

(a + b) .- c == a + (b .- c)
(a + b) .- c == (a .- c) + b
a .- zero == a
a .- b == negate b +. a

Methods

(.-) :: r a -> a -> r a infixl 6 Source #

(-.) :: a -> r a -> r a infixl 6 Source #

Instances

(Representable r, AdditiveGroup a) => AdditiveGroupModule r a Source # 

Methods

(.-) :: r a -> a -> r a Source #

(-.) :: a -> r a -> r a Source #

class (Representable r, Multiplicative a) => MultiplicativeModule r a where Source #

Multiplicative Module Laws

a .* one == a
(a + b) .* c == (a .* c) + (b .* c)
c *. (a + b) == (c *. a) + (c *. b)
a .* zero == zero
a .* b == b *. a

Methods

(.*) :: r a -> a -> r a infixl 7 Source #

(*.) :: a -> r a -> r a infixl 7 Source #

Instances

(Representable r, Multiplicative a) => MultiplicativeModule r a Source # 

Methods

(.*) :: r a -> a -> r a Source #

(*.) :: a -> r a -> r a Source #

class (Representable r, MultiplicativeGroup a) => MultiplicativeGroupModule r a where Source #

Division Module Laws

nearZero a || a ./ one == a
b == zero || a ./ b == recip b *. a

Methods

(./) :: r a -> a -> r a infixl 7 Source #

(/.) :: a -> r a -> r a infixl 7 Source #

Instances

(Representable r, MultiplicativeGroup a) => MultiplicativeGroupModule r a Source # 

Methods

(./) :: r a -> a -> r a Source #

(/.) :: a -> r a -> r a Source #

class (Representable r, ExpField a, Normed (r a) a) => Banach r a where Source #

Banach (with Norm) laws form rules around size and direction of a number, with a potential crossing into another codomain.

a == singleton zero || normalize a *. size a == a

Methods

normalize :: r a -> r a Source #

Instances

(Normed (r a) a, ExpField a, Representable r) => Banach r a Source # 

Methods

normalize :: r a -> r a Source #

class (Semiring a, Foldable r, Representable r) => Hilbert r a where Source #

the inner product of a representable over a semiring

a <.> b == b <.> a
a <.> (b +c) == a <.> b + a <.> c
a <.> (s *. b + c) == s * (a <.> b) + a <.> c

(s0 *. a) . (s1 *. b) == s0 * s1 * (a . b)

Methods

(<.>) :: r a -> r a -> a infix 8 Source #

inner :: Hilbert r a => r a -> r a -> a Source #

synonym for (.)

type family (a :: k1) >< (b :: k2) :: * infix 8 Source #

tensorial type

Instances

type (><) * * (r a) b Source # 
type (><) * * (r a) b
type (><) * * Double Double Source # 
type (><) * * Float Float Source # 
type (><) * * Int Int Source # 
type (><) * * Int Int = Int
type (><) * * Integer Integer Source # 

class TensorProduct a where Source #

generalised outer product

a><b + c><b == (a+c) >< b
a><b + a><c == a >< (b+c)

todo: work out why these laws down't apply > a *. (b>== (a<b) .* c > (a>.* c == a *. (b<c)

Minimal complete definition

(><), timesleft, timesright

Methods

(><) :: a -> a -> a >< a infix 8 Source #

outer :: a -> a -> a >< a Source #

timesleft :: a -> (a >< a) -> a Source #

timesright :: (a >< a) -> a -> a Source #

Instances

(Hilbert r a, Multiplicative a) => TensorProduct (r a) Source # 

Methods

(><) :: r a -> r a -> (* >< *) (r a) (r a) Source #

outer :: r a -> r a -> (* >< *) (r a) (r a) Source #

timesleft :: r a -> (* >< *) (r a) (r a) -> r a Source #

timesright :: (* >< *) (r a) (r a) -> r a -> r a Source #