| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Data.Algebra
Synopsis
- type FreeAlgebra a f = (Free f, (Additive - Group) (f a), Algebra a (Rep f))
- type FreeUnital a f = (FreeAlgebra a f, Unital a (Rep f))
- type FreeClifford a f = (FreeUnital a f, Clifford a (Rep f))
- class Semiring a => Algebra a b where
- aappend :: (b -> b -> a) -> b -> a
- (.*.) :: FreeAlgebra a f => f a -> f a -> f a
- class (Semiring a, Algebra a b) => Unital a b where
- aempty :: a -> b -> a
- unit :: FreeUnital a f => f a
- class (Semifield a, FreeUnital a f) => Division a f where
- class (Ring a, Unital a b) => Clifford a b where
- metric :: (b -> b -> a) -> a
- symmetric :: Field a => (Additive - Semigroup) b => (b -> a) -> b -> b -> a
- foldc :: FreeClifford a f => f a -> f a -> a
- class FreeClifford a f => Composition a f where
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.
Instances
| Semiring r => Algebra r IntSet Source # | |
| Semiring a => Algebra a () Source # | |
Defined in Data.Algebra | |
| Ring r => Algebra r Bool Source # | |
| (Semiring r, Ord a) => Algebra r (Set a) Source # | |
| Semiring r => Algebra r (Seq a) Source # | The tensor algebra |
| Semiring a => Algebra a [a] Source # | Tensor algebra
|
Defined in Data.Algebra | |
| (Algebra a b, Algebra a c) => Algebra a (b, c) Source # | |
Defined in Data.Algebra | |
| (Algebra a b, Algebra a c, Algebra a d) => Algebra a (b, c, d) Source # | |
Defined in Data.Algebra | |
(.*.) :: 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 IntV3 (-1) 0 0>>>V3 1 0 0 .*. (V3 0 1 0 .*. V3 0 1 0) :: V3 IntV3 0 0 0
For Lie algebras like one above, .*. satisfies the following properties:
a.*.a =zeroa.*.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 :: QuatMQuaternion 0.000000 (V3 0.000000 0.000000 1.000000)>>>qi * qj :: QuatMQuaternion 0.000000 (V3 0.000000 0.000000 1.000000)
class (Semiring a, Algebra a b) => Unital a b where Source #
Instances
| Semiring r => Unital r IntSet Source # | |
Defined in Data.Algebra | |
| Semiring a => Unital a () Source # | |
Defined in Data.Algebra | |
| Ring r => Unital r Bool Source # | |
Defined in Data.Algebra | |
| (Semiring r, Ord a) => Unital r (Set a) Source # | |
Defined in Data.Algebra | |
| Semiring r => Unital r (Seq a) Source # | |
Defined in Data.Algebra | |
| Semiring a => Unital a [a] Source # | |
Defined in Data.Algebra | |
| (Unital a b, Unital a c) => Unital a (b, c) Source # | |
Defined in Data.Algebra | |
| (Unital a b, Unital a c, Unital a d) => Unital a (b, c, d) Source # | |
Defined in Data.Algebra | |
unit :: FreeUnital a f => f a Source #
Unital element of a free unital algebra.
>>>aaempty :: Complex Int1 :+ 0>>>aaempty :: QuatDQuaternion 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
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 :: QuatDQuat 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 :: QuatDQuat 0.0 (V3 1.0 0.0 0.0)
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 25.0>>>V2 1 2 .@. V2 2 (-1)0.0>>>V3 1 1 1 .@. V3 1 1 (-2)0.0
>>>(1 :+ 2) .@. (2 :+ (-1)) :: Double0.0
>>>qi .@. qj :: Double0.0>>>qj .@. qk :: Double0.0>>>qk .@. qi :: Double0.0>>>qk .@. qk :: Double1.0
foldcomp :: Composition a f => f a -> f a -> a foldcomp = symmetric norm
Methods
foldc :: FreeClifford a f => f a -> f a -> a Source #
class FreeClifford a f => Composition a f where Source #
Methods