rings-0.0.3: Ring-like objects.

Safe HaskellSafe
LanguageHaskell2010

Data.Algebra

Synopsis

Documentation

type FreeAlgebra a f = (Free f, (Additive - Group) (f a), Algebra a (Rep f)) Source #

An algebra over a free semimodule. type FreeAlgebra a f = (FreeSemimodule a f, Algebra a (Rep f))

type FreeUnital a f = (FreeAlgebra a f, Unital a (Rep f)) Source #

A unital algebra over a free semimodule.

type FreeClifford a f = (FreeUnital a f, Clifford a (Rep f)) Source #

A unital algebra over a free semimodule.

class Semiring a => Algebra a b where Source #

Algebra over a semiring.

Needn't be associative or unital.

Methods

aappend :: (b -> b -> a) -> b -> a Source #

Instances
Semiring r => Algebra r IntSet Source # 
Instance details

Defined in Data.Algebra

Methods

aappend :: (IntSet -> IntSet -> r) -> IntSet -> r Source #

Semiring a => Algebra a () Source # 
Instance details

Defined in Data.Algebra

Methods

aappend :: (() -> () -> a) -> () -> a Source #

Ring r => Algebra r Bool Source # 
Instance details

Defined in Data.Algebra

Methods

aappend :: (Bool -> Bool -> r) -> Bool -> r Source #

(Semiring r, Ord a) => Algebra r (Set a) Source # 
Instance details

Defined in Data.Algebra

Methods

aappend :: (Set a -> Set a -> r) -> Set a -> r Source #

Semiring r => Algebra r (Seq a) Source #

The tensor algebra

Instance details

Defined in Data.Algebra

Methods

aappend :: (Seq a -> Seq a -> r) -> Seq a -> r Source #

Semiring a => Algebra a [a] Source #

Tensor algebra

>>> aappend (<>) [1..3 :: Int]
[1,2,3,1,2,3,1,2,3,1,2,3]
>>> aappend (\f g -> fold (f ++ g)) [1..3] :: Int
24
Instance details

Defined in Data.Algebra

Methods

aappend :: ([a] -> [a] -> a) -> [a] -> a Source #

(Algebra a b, Algebra a c) => Algebra a (b, c) Source # 
Instance details

Defined in Data.Algebra

Methods

aappend :: ((b, c) -> (b, c) -> a) -> (b, c) -> a Source #

(Algebra a b, Algebra a c, Algebra a d) => Algebra a (b, c, d) Source # 
Instance details

Defined in Data.Algebra

Methods

aappend :: ((b, c, d) -> (b, c, d) -> a) -> (b, c, d) -> a Source #

(.*.) :: FreeAlgebra a f => f a -> f a -> f a infixl 7 Source #

Multiplication operator on a free algebra.

In particular this is cross product on the standard basis in R^3:

>>> V3 1 0 0 .*. V3 0 1 0 .*. V3 0 1 0 :: V3 Int
V3 (-1) 0 0
>>> V3 1 0 0 .*. (V3 0 1 0 .*. V3 0 1 0) :: V3 Int
V3 0 0 0

For Lie algebras like one above, .*. satisfies the following properties:

a .*. a = zero
a .*. b = negate ( b .*. a ) , 
a .*. ( b <> c ) = ( a .*. b ) <> ( a .*. c ) , 
( r a ) .*. b = a .*. ( r b ) = r ( a .*. b ) . 
a .*. ( b .*. c ) <> b .*. ( c .*. a ) <> c .*. ( a .*. b ) = mempty . 

See Jacobi identity.

Caution in general (.*.) needn't be commutative, nor even associative.

For associative algebras, consider implementing Multiplicative-Semigroup as well for clarity:

>>> (1 :+ 2) .*. (3 :+ 4) :: Complex Int
(-5) :+ 10
>>> (1 :+ 2) * (3 :+ 4) :: Complex Int
(-5) :+ 10
>>> qi .*. qj :: QuatM
Quaternion 0.000000 (V3 0.000000 0.000000 1.000000)
>>> qi * qj :: QuatM
Quaternion 0.000000 (V3 0.000000 0.000000 1.000000)

class (Semiring a, Algebra a b) => Unital a b where Source #

Methods

aempty :: a -> b -> a Source #

Instances
Semiring r => Unital r IntSet Source # 
Instance details

Defined in Data.Algebra

Methods

aempty :: r -> IntSet -> r Source #

Semiring a => Unital a () Source # 
Instance details

Defined in Data.Algebra

Methods

aempty :: a -> () -> a Source #

Ring r => Unital r Bool Source # 
Instance details

Defined in Data.Algebra

Methods

aempty :: r -> Bool -> r Source #

(Semiring r, Ord a) => Unital r (Set a) Source # 
Instance details

Defined in Data.Algebra

Methods

aempty :: r -> Set a -> r Source #

Semiring r => Unital r (Seq a) Source # 
Instance details

Defined in Data.Algebra

Methods

aempty :: r -> Seq a -> r Source #

Semiring a => Unital a [a] Source # 
Instance details

Defined in Data.Algebra

Methods

aempty :: a -> [a] -> a Source #

(Unital a b, Unital a c) => Unital a (b, c) Source # 
Instance details

Defined in Data.Algebra

Methods

aempty :: a -> (b, c) -> a Source #

(Unital a b, Unital a c, Unital a d) => Unital a (b, c, d) Source # 
Instance details

Defined in Data.Algebra

Methods

aempty :: a -> (b, c, d) -> a Source #

unit :: FreeUnital a f => f a Source #

Unital element of a free unital algebra.

>>> aaempty :: Complex Int
1 :+ 0
>>> aaempty :: QuatD
Quaternion 1.0 (V3 0.0 0.0 0.0)

class (Semifield a, FreeUnital a f) => Division a f where Source #

A (not necessarily associative) division algebra.

Minimal complete definition

Nothing

Methods

arecip :: f a -> f a Source #

Reciprocal operator.

When f is a composition algebra we must have:

@ arecip x = (recip $ norm f) *. conj f

See Property.

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

Division operator.

>>> (1 :+ 0) ./. (0 :+ 1)
0.0 :+ (-1.0)
>>> qe ./. qi :: QuatD
Quat 0.0 (V3 (-1.0) 0.0 0.0)

(.\.) :: f a -> f a -> f a infixl 7 Source #

Left division operator.

>>> (1 :+ 0) .\. (0 :+ 1)
0.0 :+ 1.0
>>> qe .\. qi :: QuatD
Quat 0.0 (V3 1.0 0.0 0.0)
Instances
Real a => Division a Complex Source # 
Instance details

Defined in Data.Algebra

class (Ring a, Unital a b) => Clifford a b where Source #

Bilinear form on a free composition algebra.

See Property.

>>> V2 1 2 .@. V2 1 2
5.0
>>> V2 1 2 .@. V2 2 (-1)
0.0
>>> V3 1 1 1 .@. V3 1 1 (-2)
0.0
>>> (1 :+ 2) .@. (2 :+ (-1)) :: Double
0.0
>>> qi .@. qj :: Double
0.0
>>> qj .@. qk :: Double
0.0
>>> qk .@. qi :: Double
0.0
>>> qk .@. qk :: Double
1.0

foldcomp :: Composition a f => f a -> f a -> a foldcomp = symmetric norm

Methods

metric :: (b -> b -> a) -> a Source #

x .*. x = metric x x *. unit
x .*. y + y .*. x = (two * x .@. y) *. unit

quad :: (b -> a) -> a

Instances
Field a => Clifford a Bool Source # 
Instance details

Defined in Data.Algebra

Methods

metric :: (Bool -> Bool -> a) -> a Source #

symmetric :: Field a => (Additive - Semigroup) b => (b -> a) -> b -> b -> a Source #

foldc :: FreeClifford a f => f a -> f a -> a Source #

class FreeClifford a f => Composition a f where Source #

Methods

conj :: f a -> f a Source #

Conjugation operator.

 conj a * conj b = conj (b * a)

norm :: f a -> a Source #

Norm operator on a composition algebra.

norm x * norm y = norm (x * y)
norm x * norm x = norm $ x * conj x
Instances
Real a => Composition a Complex Source # 
Instance details

Defined in Data.Algebra

Methods

conj :: Complex a -> Complex a Source #

norm :: Complex a -> a Source #