glucat 0.12.0
PyClical.clifford Class Reference
Inheritance diagram for PyClical.clifford:
Collaboration diagram for PyClical.clifford:

Public Member Functions

 __cinit__ (self, other=0, ixt=None)
 
 __dealloc__ (self)
 
 __contains__ (self, x)
 
 __iter__ (self)
 
 reframe (self, ixt)
 
 __richcmp__ (lhs, rhs, int, op)
 
 __getitem__ (self, ixt)
 
 __neg__ (self)
 
 __pos__ (self)
 
 __add__ (lhs, rhs)
 
 __iadd__ (self, rhs)
 
 __sub__ (lhs, rhs)
 
 __isub__ (self, rhs)
 
 __mul__ (lhs, rhs)
 
 __imul__ (self, rhs)
 
 __mod__ (lhs, rhs)
 
 __imod__ (self, rhs)
 
 __and__ (lhs, rhs)
 
 __iand__ (self, rhs)
 
 __xor__ (lhs, rhs)
 
 __ixor__ (self, rhs)
 
 __truediv__ (lhs, rhs)
 
 __idiv__ (self, rhs)
 
 inv (self)
 
 __or__ (lhs, rhs)
 
 __ior__ (self, rhs)
 
 __pow__ (self, m, dummy)
 
 pow (self, m)
 
 outer_pow (self, m)
 
 __call__ (self, grade)
 
 scalar (self)
 
 pure (self)
 
 even (self)
 
 odd (self)
 
 vector_part (self, frm=None)
 
 involute (self)
 
 reverse (self)
 
 conj (self)
 
 quad (self)
 
 norm (self)
 
 abs (self)
 
 max_abs (self)
 
 truncated (self, limit)
 
 isinf (self)
 
 isnan (self)
 
 frame (self)
 
 __repr__ (self)
 
 __str__ (self)
 

Public Attributes

 instance = new Clifford((<clifford>other).unwrap())
 

Detailed Description

Python class clifford wraps C++ class Clifford.

Definition at line 532 of file PyClical.pyx.

Member Function Documentation

◆ __add__()

PyClical.clifford.__add__ ( lhs,
rhs )
Geometric sum.

>>> print(clifford(1) + clifford("{2}"))
1+{2}
>>> print(clifford("{1}") + clifford("{2}"))
{1}+{2}

Definition at line 740 of file PyClical.pyx.

◆ __and__()

PyClical.clifford.__and__ ( lhs,
rhs )
Inner product.

>>> print(clifford("{1}") & clifford("{2}"))
0
>>> print(clifford(2) & clifford("{2}"))
0
>>> print(clifford("{1}") & clifford("{1}"))
1
>>> print(clifford("{1}") & clifford("{1,2}"))
{2}

Definition at line 836 of file PyClical.pyx.

◆ __call__()

PyClical.clifford.__call__ ( self,
grade )
Pure grade-vector part.

>>> print(clifford("{1}")(1))
{1}
>>> print(clifford("{1}")(0))
0
>>> print(clifford("1+{1}+{1,2}")(0))
1
>>> print(clifford("1+{1}+{1,2}")(1))
{1}
>>> print(clifford("1+{1}+{1,2}")(2))
{1,2}
>>> print(clifford("1+{1}+{1,2}")(3))
0

Definition at line 1020 of file PyClical.pyx.

References instance, and PyClical.index_set.instance.

◆ __cinit__()

PyClical.clifford.__cinit__ ( self,
other = 0,
ixt = None )
Construct an object of type clifford.

>>> print(clifford(2))
2
>>> print(clifford(2.0))
2
>>> print(clifford(1.0e-1))
0.1
>>> print(clifford("2"))
2
>>> print(clifford("2{1,2,3}"))
2{1,2,3}
>>> print(clifford(clifford("2{1,2,3}")))
2{1,2,3}
>>> print(clifford("-{1}"))
-{1}
>>> print(clifford(2,index_set({1,2})))
2{1,2}
>>> print(clifford([2,3],index_set({1,2})))
2{1}+3{2}

Definition at line 565 of file PyClical.pyx.

◆ __contains__()

PyClical.clifford.__contains__ ( self,
x )
Not applicable.

>>> x=clifford(index_set({-3,4,7})); -3 in x
Traceback (most recent call last):
  ...
TypeError: Not applicable.

Definition at line 627 of file PyClical.pyx.

◆ __dealloc__()

PyClical.clifford.__dealloc__ ( self)
Clean up by deallocating the instance of C++ class Clifford.

Definition at line 621 of file PyClical.pyx.

References instance, and PyClical.index_set.instance.

◆ __getitem__()

PyClical.clifford.__getitem__ ( self,
ixt )
Subscripting: map from index set to scalar coordinate.

>>> clifford("{1}")[index_set(1)]
1.0
>>> clifford("{1}")[index_set({1})]
1.0
>>> clifford("{1}")[index_set({1,2})]
0.0
>>> clifford("2{1,2}")[index_set({1,2})]
2.0

Definition at line 707 of file PyClical.pyx.

References instance, and PyClical.index_set.instance.

◆ __iadd__()

PyClical.clifford.__iadd__ ( self,
rhs )
Geometric sum.

>>> x = clifford(1); x += clifford("{2}"); print(x)
1+{2}

Definition at line 751 of file PyClical.pyx.

◆ __iand__()

PyClical.clifford.__iand__ ( self,
rhs )
Inner product.

>>> x = clifford("{1}"); x &= clifford("{2}"); print(x)
0
>>> x = clifford(2); x &= clifford("{2}"); print(x)
0
>>> x = clifford("{1}"); x &= clifford("{1}"); print(x)
1
>>> x = clifford("{1}"); x &= clifford("{1,2}"); print(x)
{2}

Definition at line 851 of file PyClical.pyx.

◆ __idiv__()

PyClical.clifford.__idiv__ ( self,
rhs )
Geometric quotient.

>>> x = clifford("{1}"); x /= clifford("{2}"); print(x)
{1,2}
>>> x = clifford(2); x /= clifford("{2}"); print(x)
2{2}
>>> x = clifford("{1}"); x /= clifford("{1}"); print(x)
1
>>> x = clifford("{1}"); x /= clifford("{1,2}"); print(x)
-{2}

Definition at line 911 of file PyClical.pyx.

◆ __imod__()

PyClical.clifford.__imod__ ( self,
rhs )
Contraction.

>>> x = clifford("{1}"); x %= clifford("{2}"); print(x)
0
>>> x = clifford(2); x %= clifford("{2}"); print(x)
2{2}
>>> x = clifford("{1}"); x %= clifford("{1}"); print(x)
1
>>> x = clifford("{1}"); x %= clifford("{1,2}"); print(x)
{2}

Definition at line 821 of file PyClical.pyx.

◆ __imul__()

PyClical.clifford.__imul__ ( self,
rhs )
Geometric product.

>>> x = clifford(2); x *= clifford("{2}"); print(x)
2{2}
>>> x = clifford("{1}"); x *= clifford("{2}"); print(x)
{1,2}
>>> x = clifford("{1}"); x *= clifford("{1,2}"); print(x)
{2}

Definition at line 793 of file PyClical.pyx.

◆ __ior__()

PyClical.clifford.__ior__ ( self,
rhs )
Transform left hand side, using right hand side as a transformation.

>>> x=clifford("{1,2}") * pi/2; y=clifford("{1}"); y|=x; print(y)
-{1}
>>> x=clifford("{1,2}") * pi/2; y=clifford("{1}"); y|=exp(x); print(y)
-{1}

Definition at line 950 of file PyClical.pyx.

◆ __isub__()

PyClical.clifford.__isub__ ( self,
rhs )
Geometric difference.

>>> x = clifford(1); x -= clifford("{2}"); print(x)
1-{2}

Definition at line 771 of file PyClical.pyx.

◆ __iter__()

PyClical.clifford.__iter__ ( self)
Not applicable.

>>> for a in clifford(index_set({-3,4,7})):print(a, end=",")
Traceback (most recent call last):
  ...
TypeError: Not applicable.

Definition at line 638 of file PyClical.pyx.

◆ __ixor__()

PyClical.clifford.__ixor__ ( self,
rhs )
Outer product.

>>> x = clifford("{1}"); x ^= clifford("{2}"); print(x)
{1,2}
>>> x = clifford(2); x ^= clifford("{2}"); print(x)
2{2}
>>> x = clifford("{1}"); x ^= clifford("{1}"); print(x)
0
>>> x = clifford("{1}"); x ^= clifford("{1,2}"); print(x)
0

Definition at line 881 of file PyClical.pyx.

◆ __mod__()

PyClical.clifford.__mod__ ( lhs,
rhs )
Contraction.

>>> print(clifford("{1}") % clifford("{2}"))
0
>>> print(clifford(2) % clifford("{2}"))
2{2}
>>> print(clifford("{1}") % clifford("{1}"))
1
>>> print(clifford("{1}") % clifford("{1,2}"))
{2}

Definition at line 806 of file PyClical.pyx.

◆ __mul__()

PyClical.clifford.__mul__ ( lhs,
rhs )
Geometric product.

>>> print(clifford("{1}") * clifford("{2}"))
{1,2}
>>> print(clifford(2) * clifford("{2}"))
2{2}
>>> print(clifford("{1}") * clifford("{1,2}"))
{2}

Definition at line 780 of file PyClical.pyx.

◆ __neg__()

PyClical.clifford.__neg__ ( self)
Unary -.

>>> print(-clifford("{1}"))
-{1}

Definition at line 722 of file PyClical.pyx.

References instance, and PyClical.index_set.instance.

◆ __or__()

PyClical.clifford.__or__ ( lhs,
rhs )
Transform left hand side, using right hand side as a transformation.

>>> x=clifford("{1,2}") * pi/2; y=clifford("{1}"); print(y|x)
-{1}
>>> x=clifford("{1,2}") * pi/2; y=clifford("{1}"); print(y|exp(x))
-{1}

Definition at line 939 of file PyClical.pyx.

◆ __pos__()

PyClical.clifford.__pos__ ( self)
Unary +.

>>> print(+clifford("{1}"))
{1}

Definition at line 731 of file PyClical.pyx.

◆ __pow__()

PyClical.clifford.__pow__ ( self,
m,
dummy )
Power: self to the m.

>>> x=clifford("{1}"); print(x ** 2)
1
>>> x=clifford("2"); print(x ** 2)
4
>>> x=clifford("2+{1}"); print(x ** 0)
1
>>> x=clifford("2+{1}"); print(x ** 1)
2+{1}
>>> x=clifford("2+{1}"); print(x ** 2)
5+4{1}
>>> i=clifford("{1,2}"); print(exp(pi/2) * (i ** i))
1

Definition at line 961 of file PyClical.pyx.

References pow().

◆ __repr__()

PyClical.clifford.__repr__ ( self)
The “official” string representation of self.

>>> clifford("1+3{-1}+2{1,2}+4{-2,7}").__repr__()
'clifford("1+3{-1}+2{1,2}+4{-2,7}")'

Definition at line 1235 of file PyClical.pyx.

References clifford_to_repr().

◆ __richcmp__()

PyClical.clifford.__richcmp__ ( lhs,
rhs,
int,
op )
Compare objects of type clifford.

>>> clifford("{1}") == clifford("1{1}")
True
>>> clifford("{1}") != clifford("1.0{1}")
False
>>> clifford("{1}") != clifford("1.0")
True
>>> clifford("{1,2}") == None
False
>>> clifford("{1,2}") != None
True
>>> None == clifford("{1,2}")
False
>>> None != clifford("{1,2}")
True

Definition at line 672 of file PyClical.pyx.

◆ __str__()

PyClical.clifford.__str__ ( self)
The “informal” string representation of self.

>>> clifford("1+3{-1}+2{1,2}+4{-2,7}").__str__()
'1+3{-1}+2{1,2}+4{-2,7}'

Definition at line 1244 of file PyClical.pyx.

References clifford_to_str().

◆ __sub__()

PyClical.clifford.__sub__ ( lhs,
rhs )
Geometric difference.

>>> print(clifford(1) - clifford("{2}"))
1-{2}
>>> print(clifford("{1}") - clifford("{2}"))
{1}-{2}

Definition at line 760 of file PyClical.pyx.

◆ __truediv__()

PyClical.clifford.__truediv__ ( lhs,
rhs )
Geometric quotient.

>>> print(clifford("{1}") / clifford("{2}"))
{1,2}
>>> print(clifford(2) / clifford("{2}"))
2{2}
>>> print(clifford("{1}") / clifford("{1}"))
1
>>> print(clifford("{1}") / clifford("{1,2}"))
-{2}

Definition at line 896 of file PyClical.pyx.

◆ __xor__()

PyClical.clifford.__xor__ ( lhs,
rhs )
Outer product.

>>> print(clifford("{1}") ^ clifford("{2}"))
{1,2}
>>> print(clifford(2) ^ clifford("{2}"))
2{2}
>>> print(clifford("{1}") ^ clifford("{1}"))
0
>>> print(clifford("{1}") ^ clifford("{1,2}"))
0

Definition at line 866 of file PyClical.pyx.

◆ abs()

PyClical.clifford.abs ( self)
Absolute value: square root of norm.

>>> clifford("1+{-1}+{1,2}+{1,2,3}").abs()
2.0

Definition at line 1175 of file PyClical.pyx.

References glucat.abs().

◆ conj()

PyClical.clifford.conj ( self)
Conjugation, reverse o involute == involute o reverse.

>>> print((clifford("{1}")).conj())
-{1}
>>> print((clifford("{2}") * clifford("{1}")).conj())
{1,2}
>>> print((clifford("{1}") * clifford("{2}")).conj())
-{1,2}
>>> print(clifford("1+{1}+{1,2}").conj())
1-{1}-{1,2}

Definition at line 1138 of file PyClical.pyx.

References conj(), instance, and PyClical.index_set.instance.

Referenced by conj().

◆ even()

PyClical.clifford.even ( self)
Even part of multivector, sum of even grade terms.

>>> print(clifford("1+{1}+{1,2}").even())
1+{1,2}

Definition at line 1061 of file PyClical.pyx.

References even(), instance, and PyClical.index_set.instance.

Referenced by even().

◆ frame()

PyClical.clifford.frame ( self)
Subalgebra generated by all generators of terms of given multivector.

>>> print(clifford("1+3{-1}+2{1,2}+4{-2,7}").frame())
{-2,-1,1,2,7}
>>> s=clifford("1+3{-1}+2{1,2}+4{-2,7}").frame(); type(s)
<class 'PyClical.index_set'>

Definition at line 1224 of file PyClical.pyx.

References frame(), instance, and PyClical.index_set.instance.

Referenced by frame().

◆ inv()

PyClical.clifford.inv ( self)
Geometric multiplicative inverse.

>>> x = clifford("{1}"); print(x.inv())
{1}
>>> x = clifford(2); print(x.inv())
0.5
>>> x = clifford("{1,2}"); print(x.inv())
-{1,2}

Definition at line 926 of file PyClical.pyx.

References instance, PyClical.index_set.instance, and inv().

Referenced by inv().

◆ involute()

PyClical.clifford.involute ( self)
Main involution, each {i} is replaced by -{i} in each term,
eg. clifford("{1}") -> -clifford("{1}").

>>> print(clifford("{1}").involute())
-{1}
>>> print((clifford("{2}") * clifford("{1}")).involute())
-{1,2}
>>> print((clifford("{1}") * clifford("{2}")).involute())
{1,2}
>>> print(clifford("1+{1}+{1,2}").involute())
1-{1}+{1,2}

Definition at line 1107 of file PyClical.pyx.

References instance, PyClical.index_set.instance, and involute().

Referenced by involute().

◆ isinf()

PyClical.clifford.isinf ( self)
Check if a multivector contains any infinite values.

>>> clifford().isinf()
False

Definition at line 1206 of file PyClical.pyx.

References instance, PyClical.index_set.instance, and isnan().

◆ isnan()

PyClical.clifford.isnan ( self)
Check if a multivector contains any IEEE NaN values.

>>> clifford().isnan()
False

Definition at line 1215 of file PyClical.pyx.

References instance, PyClical.index_set.instance, and isnan().

Referenced by isinf(), and isnan().

◆ max_abs()

PyClical.clifford.max_abs ( self)
Maximum of absolute values of components of multivector: multivector infinity norm.

>>> clifford("1+{-1}+{1,2}+{1,2,3}").max_abs()
1.0
>>> clifford("3+2{1}+{1,2}").max_abs()
3.0

Definition at line 1184 of file PyClical.pyx.

References instance, PyClical.index_set.instance, and max_abs().

Referenced by max_abs().

◆ norm()

PyClical.clifford.norm ( self)
Norm == sum of squares of coordinates.

>>> clifford("1+{1}+{1,2}").norm()
3.0
>>> clifford("1+{-1}+{1,2}+{1,2,3}").norm()
4.0

Definition at line 1164 of file PyClical.pyx.

References instance, PyClical.index_set.instance, and norm().

Referenced by norm().

◆ odd()

PyClical.clifford.odd ( self)
Odd part of multivector, sum of odd grade terms.

>>> print(clifford("1+{1}+{1,2}").odd())
{1}

Definition at line 1070 of file PyClical.pyx.

References instance, PyClical.index_set.instance, and odd().

Referenced by odd().

◆ outer_pow()

PyClical.clifford.outer_pow ( self,
m )
Outer product power.

>>> x=clifford("2+{1}"); print(x.outer_pow(0))
1
>>> x=clifford("2+{1}"); print(x.outer_pow(1))
2+{1}
>>> x=clifford("2+{1}"); print(x.outer_pow(2))
4+4{1}
>>> print(clifford("1+{1}+{1,2}").outer_pow(3))
1+3{1}+3{1,2}

Definition at line 1004 of file PyClical.pyx.

References instance, PyClical.index_set.instance, and outer_pow().

Referenced by outer_pow().

◆ pow()

PyClical.clifford.pow ( self,
m )
Power: self to the m.

>>> x=clifford("{1}"); print(x.pow(2))
1
>>> x=clifford("2"); print(x.pow(2))
4
>>> x=clifford("2+{1}"); print(x.pow(0))
1
>>> x=clifford("2+{1}"); print(x.pow(1))
2+{1}
>>> x=clifford("2+{1}"); print(x.pow(2))
5+4{1}
>>> print(clifford("1+{1}+{1,2}").pow(3))
1+3{1}+3{1,2}
>>> i=clifford("{1,2}"); print(exp(pi/2) * i.pow(i))
1

Definition at line 980 of file PyClical.pyx.

References instance, PyClical.index_set.instance, and pow().

Referenced by __pow__(), and pow().

◆ pure()

PyClical.clifford.pure ( self)
Pure part.

>>> print(clifford("1+{1}+{1,2}").pure())
{1}+{1,2}
>>> print(clifford("{1,2}").pure())
{1,2}

Definition at line 1050 of file PyClical.pyx.

References instance, PyClical.index_set.instance, and pure().

Referenced by pure().

◆ quad()

PyClical.clifford.quad ( self)
Quadratic form == (rev(x)*x)(0).

>>> print(clifford("1+{1}+{1,2}").quad())
3.0
>>> print(clifford("1+{-1}+{1,2}+{1,2,3}").quad())
2.0

Definition at line 1153 of file PyClical.pyx.

References instance, PyClical.index_set.instance, and quad().

Referenced by quad().

◆ reframe()

PyClical.clifford.reframe ( self,
ixt )
Put self into a larger frame, containing the union of self.frame() and index set ixt.
This can be used to make multiplication faster, by multiplying within a common frame.

>>> clifford("2+3{1}").reframe(index_set({1,2,3}))
clifford("2+3{1}")
>>> s=index_set({1,2,3});t=index_set({-3,-2,-1});x=random_clifford(s); x.reframe(t).frame() == (s|t);
True

Definition at line 649 of file PyClical.pyx.

◆ reverse()

PyClical.clifford.reverse ( self)
Reversion, eg. clifford("{1}")*clifford("{2}") -> clifford("{2}")*clifford("{1}").

>>> print(clifford("{1}").reverse())
{1}
>>> print((clifford("{2}") * clifford("{1}")).reverse())
{1,2}
>>> print((clifford("{1}") * clifford("{2}")).reverse())
-{1,2}
>>> print(clifford("1+{1}+{1,2}").reverse())
1+{1}-{1,2}

Definition at line 1123 of file PyClical.pyx.

References instance, PyClical.index_set.instance, and reverse().

Referenced by reverse().

◆ scalar()

PyClical.clifford.scalar ( self)
Scalar part.

>>> clifford("1+{1}+{1,2}").scalar()
1.0
>>> clifford("{1,2}").scalar()
0.0

Definition at line 1039 of file PyClical.pyx.

References instance, PyClical.index_set.instance, and scalar().

Referenced by scalar().

◆ truncated()

PyClical.clifford.truncated ( self,
limit )
Remove all terms of self with relative size smaller than limit.

>>> clifford("1e8+{1}+1e-8{1,2}").truncated(1.0e-6)
clifford("100000000")
>>> clifford("1e4+{1}+1e-4{1,2}").truncated(1.0e-6)
clifford("10000+{1}")

Definition at line 1195 of file PyClical.pyx.

References instance, PyClical.index_set.instance, and truncated().

Referenced by truncated().

◆ vector_part()

PyClical.clifford.vector_part ( self,
frm = None )
Vector part of multivector, as a Python list, with respect to frm.

>>> print(clifford("1+2{1}+3{2}+4{1,2}").vector_part())
[2.0, 3.0]
>>> print(clifford("1+2{1}+3{2}+4{1,2}").vector_part(index_set({-1,1,2})))
[0.0, 2.0, 3.0]

Definition at line 1079 of file PyClical.pyx.

References instance, PyClical.index_set.instance, and vector_part().

Referenced by vector_part().

Member Data Documentation

◆ instance

PyClical.clifford.instance = new Clifford((<clifford>other).unwrap())

The documentation for this class was generated from the following file: