glucat  0.12.0
Public Member Functions | Public Attributes | List of all members
PyClical.clifford Class Reference
Inheritance diagram for PyClical.clifford:
Inheritance graph
[legend]
Collaboration diagram for PyClical.clifford:
Collaboration graph
[legend]

Public Member Functions

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

Public Attributes

 instance
 

Detailed Description

Python class clifford wraps C++ class Clifford.

Definition at line 534 of file PyClical.pyx.

Member Function Documentation

◆ __add__()

def 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__()

def 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__()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ __cinit__()

def 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__()

def 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__()

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

Definition at line 621 of file PyClical.pyx.

References PyClical.index_set.instance, and PyClical.clifford.instance.

◆ __getitem__()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ __iadd__()

def 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__()

def 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__()

def 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__()

def 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__()

def 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__()

def 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__()

def 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__()

def 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__()

def 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__()

def 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__()

def 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__()

def PyClical.clifford.__neg__ (   self)
Unary -.

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

Definition at line 722 of file PyClical.pyx.

References PyClical.index_set.instance, and PyClical.clifford.instance.

◆ __or__()

def 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__()

def PyClical.clifford.__pos__ (   self)
Unary +.

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

Definition at line 731 of file PyClical.pyx.

◆ __pow__()

def 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 PyClical.clifford.pow().

◆ __repr__()

def 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__()

def 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__()

def 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__()

def 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__()

def 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__()

def 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()

def 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()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ even()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ frame()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ inv()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ involute()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ isinf()

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

>>> clifford().isinf()
False

Definition at line 1206 of file PyClical.pyx.

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

◆ isnan()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

Referenced by PyClical.clifford.isinf().

◆ max_abs()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ norm()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ odd()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ outer_pow()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ pow()

def 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 glucat.exp(), PyClical.index_set.instance, PyClical.clifford.instance, and glucat.log().

Referenced by PyClical.clifford.__pow__().

◆ pure()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ quad()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ reframe()

def 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()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ scalar()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ truncated()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

◆ vector_part()

def 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 PyClical.index_set.instance, and PyClical.clifford.instance.

Member Data Documentation

◆ instance

PyClical.clifford.instance

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