clif-0.1.1.0: A Clifford algebra number type for Haskell

Copyright(c) Matti A. Eskelinen 2016-2017
LicenseMIT
Maintainermatti.a.eskelinen@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe
LanguageHaskell2010

Clif.Algebra

Contents

Description

This module provides the type Clif for representing the elements of a Clifford algebra along with some standard operations.

See The inner products of geometric algebra by Leo Dorst for a concise explanation of the different inner products.

Synopsis

The Clif type

data Clif b a Source #

A data type representing a Clif (multivector) composed of direct sum of scaled blades

Instances

Functor (Clif b) Source # 

Methods

fmap :: (a -> b) -> Clif b a -> Clif b b #

(<$) :: a -> Clif b b -> Clif b a #

(Eq b, Eq a, Basis b a) => Eq (Clif b a) Source #

The Eq instance calculates the canonical forms of the compared Clifs before comparison.

Methods

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

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

(Eq a, Basis b a, Fractional a) => Fractional (Clif b a) Source #

Inverse elements only exist for Clifs c for which c times c is scalar. For others, recip does not terminate.

Methods

(/) :: Clif b a -> Clif b a -> Clif b a #

recip :: Clif b a -> Clif b a #

fromRational :: Rational -> Clif b a #

(Eq a, Basis b a) => Num (Clif b a) Source #

Note that abs and signum are only well-defined on the scalar component of each Clif, and zero otherwise.

Methods

(+) :: Clif b a -> Clif b a -> Clif b a #

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

(*) :: Clif b a -> Clif b a -> Clif b a #

negate :: Clif b a -> Clif b a #

abs :: Clif b a -> Clif b a #

signum :: Clif b a -> Clif b a #

fromInteger :: Integer -> Clif b a #

(Show b, Show a) => Show (Clif b a) Source #

Show instance just shows the underlying Map for now

Methods

showsPrec :: Int -> Clif b a -> ShowS #

show :: Clif b a -> String #

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

Constructing and deconstructing Clifs

blade :: (Eq a, Basis b a) => [b] -> a -> Clif b a Source #

Constructor for a blade

(*:) :: (Eq a, Basis b a) => a -> [b] -> Clif b a infix 9 Source #

Infix synonym for flip blade

vec :: (Eq a, Basis b a) => b -> a -> Clif b a Source #

Constructor for basis vector values. Note that vec a s is equivalent to blade [a] s.

fromList :: (Eq a, Basis b a) => [([b], a)] -> Clif b a Source #

Constructs a Clif from a list of blades and their multipliers in canonical form.

>>> fromList [([], 42), ([E 1, E 2], 1)]
42 *: [] + 1 *: [E 1,E 2]

toList :: Clif b a -> [([b], a)] Source #

Return a list of the blades and coefficients of a Clif. Note that toList is not an inverse of fromList due to nonuniquess of zeros in the current implementation.

Geometric algebra operations

grade :: (Eq a, Basis b a) => Int -> Clif b a -> Clif b a Source #

Grade projection on the given grade. For negative values, returns zero.

Note that this always calculates the canonical form of a Clif before projecting it.

rev :: Ord b => Clif b a -> Clif b a Source #

Reverse of a Clif, i.e. the reverse of all its component blades.

Outer product

wedge :: (Eq a, Basis b a) => Clif b a -> Clif b a -> Clif b a Source #

Wedge product

(/\) :: (Eq a, Basis b a) => Clif b a -> Clif b a -> Clif b a infixl 8 Source #

Infix synonym for wedge

Inner products

(<\) :: (Eq a, Basis b a) => Clif b a -> Clif b a -> Clif b a infixl 8 Source #

Infix synonym for lContract

(/>) :: (Eq a, Basis b a) => Clif b a -> Clif b a -> Clif b a infixl 8 Source #

Infix synonym for rContract

(.|.) :: (Eq a, Basis b a) => Clif b a -> Clif b a -> Clif b a infixl 8 Source #

Infix synonym for scalarProd

(<.>) :: (Eq a, Basis b a) => Clif b a -> Clif b a -> Clif b a infixl 8 Source #

Infix synonym for dot

lContract :: (Eq a, Basis b a) => Clif b a -> Clif b a -> Clif b a Source #

Left contraction

rContract :: (Eq a, Basis b a) => Clif b a -> Clif b a -> Clif b a Source #

Right contraction

scalarProd :: (Eq a, Basis b a) => Clif b a -> Clif b a -> Clif b a Source #

Scalar product (0-grade components of the blade products)

dot :: (Eq a, Basis b a) => Clif b a -> Clif b a -> Clif b a Source #

Dot product

hestenes :: (Eq a, Basis b a) => Clif b a -> Clif b a -> Clif b a Source #

Hestenes dot product

Hodge duality

hodge :: (Eq a, Basis b a) => [b] -> Clif b a -> Clif b a Source #

Hodge dual of a Clif in a Clifford algebra specified by a given pseudoscalar (volume element):

hodge (E <$> "abc") $ blade [E 'b'] 1 == blade (E <$> "ac") 1

Projections

proj :: (Eq a, Basis b a, Fractional a) => Clif b a -> Clif b a -> Clif b a Source #

Projection of Clif x in the direction of Clif y, defined as

proj x y == (x <\ recip y) <\ y