|
glucat
0.8.2
|


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 | __div__ (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 | isnan (self) |
| def | frame (self) |
| def | __repr__ (self) |
| def | __str__ (self) |
Public Attributes | |
| instance | |
Python class clifford wraps C++ class Clifford.
Definition at line 532 of file PyClical.pyx.
| 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 739 of file PyClical.pyx.
| 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 835 of file PyClical.pyx.
| 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 1019 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| def PyClical.clifford.__cinit__ | ( | self, | |
other = 0, |
|||
ixt = None |
|||
| ) |
Construct an object of type clifford.
>>> print clifford(2)
2
>>> print clifford(2L)
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 563 of file PyClical.pyx.
| 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 626 of file PyClical.pyx.
| def PyClical.clifford.__dealloc__ | ( | self | ) |
Clean up by deallocating the instance of C++ class Clifford.
Definition at line 620 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| def PyClical.clifford.__div__ | ( | 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 895 of file PyClical.pyx.
| 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 706 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| def PyClical.clifford.__iadd__ | ( | self, | |
| rhs | |||
| ) |
Geometric sum.
>>> x = clifford(1); x += clifford("{2}"); print x
1+{2}
Definition at line 750 of file PyClical.pyx.
| 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 850 of file PyClical.pyx.
| 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 910 of file PyClical.pyx.
| 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 820 of file PyClical.pyx.
| 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 792 of file PyClical.pyx.
| 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 949 of file PyClical.pyx.
| def PyClical.clifford.__isub__ | ( | self, | |
| rhs | |||
| ) |
Geometric difference.
>>> x = clifford(1); x -= clifford("{2}"); print x
1-{2}
Definition at line 770 of file PyClical.pyx.
| def PyClical.clifford.__iter__ | ( | self | ) |
Not applicable.
>>> for a in clifford(index_set({-3,4,7})): print a,
Traceback (most recent call last):
...
TypeError: Not applicable.
Definition at line 637 of file PyClical.pyx.
| 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 880 of file PyClical.pyx.
| 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 805 of file PyClical.pyx.
| 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 779 of file PyClical.pyx.
| def PyClical.clifford.__neg__ | ( | self | ) |
Unary -.
>>> print -clifford("{1}")
-{1}
Definition at line 721 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| 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 938 of file PyClical.pyx.
| def PyClical.clifford.__pos__ | ( | self | ) |
Unary +.
>>> print +clifford("{1}")
{1}
Definition at line 730 of file PyClical.pyx.
| 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 960 of file PyClical.pyx.
References PyClical.clifford.pow().
| 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 1225 of file PyClical.pyx.
References clifford_to_repr().
| 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 671 of file PyClical.pyx.
| 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 1234 of file PyClical.pyx.
References clifford_to_str().
| 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 759 of file PyClical.pyx.
| 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 865 of file PyClical.pyx.
| 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 1174 of file PyClical.pyx.
References glucat.abs().
| 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 1137 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| 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 1060 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| 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)
<type 'PyClical.index_set'>
Definition at line 1214 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| 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 925 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| 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 1106 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| def PyClical.clifford.isnan | ( | self | ) |
Check if a multivector contains any IEEE NaN values. >>> clifford().isnan() False
Definition at line 1205 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| 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 1183 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| 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 1163 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| 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 1069 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| 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 1003 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| 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 979 of file PyClical.pyx.
References glucat.exp(), PyClical.index_set.instance, PyClical.clifford.instance, and glucat.log().
Referenced by PyClical.clifford.__pow__().
| 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 1049 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| 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 1152 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| 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 648 of file PyClical.pyx.
| 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 1122 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| def PyClical.clifford.scalar | ( | self | ) |
Scalar part.
>>> clifford("1+{1}+{1,2}").scalar()
1.0
>>> clifford("{1,2}").scalar()
0.0
Definition at line 1038 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| 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 1194 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| 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 1078 of file PyClical.pyx.
References PyClical.index_set.instance, and PyClical.clifford.instance.
| PyClical.clifford.instance |
Definition at line 592 of file PyClical.pyx.
Referenced by PyClical.clifford.__call__(), PyClical.clifford.__dealloc__(), PyClical.clifford.__getitem__(), PyClical.clifford.__neg__(), PyClical.clifford.conj(), PyClical.clifford.even(), PyClical.clifford.frame(), PyClical.clifford.inv(), PyClical.clifford.involute(), PyClical.clifford.isnan(), PyClical.clifford.max_abs(), PyClical.clifford.norm(), PyClical.clifford.odd(), PyClical.clifford.outer_pow(), PyClical.clifford.pow(), PyClical.clifford.pure(), PyClical.clifford.quad(), PyClical.clifford.reverse(), PyClical.clifford.scalar(), PyClical.clifford.truncated(), and PyClical.clifford.vector_part().
1.8.14