33from PyClical cimport *
35__version__ = str(glucat_package_version,
'utf-8')
40cdef inline IndexSet toIndexSet(obj):
42 Return the C++ IndexSet instance wrapped by index_set(obj).
48 Python class index_set wraps C++
class IndexSet.
50 cdef IndexSet *instance
52 cdef inline wrap(index_set self, IndexSet other):
54 Wrap an instance of the C++ class IndexSet.
59 cdef inline IndexSet unwrap(index_set self):
61 Return the wrapped C++ IndexSet instance.
65 cpdef copy(index_set self):
67 Copy this index_set object.
76 Construct an object of type index_set.
93 error_msg_prefix = "Cannot initialize index_set object from"
94 if isinstance(other, index_set):
95 self.
instance = new IndexSet((<index_set>other).unwrap())
96 elif isinstance(other, numbers.Integral):
97 self.
instance = new IndexSet(<int>other)
98 elif isinstance(other, (set, frozenset)):
104 raise IndexError(error_msg_prefix +
" invalid " + repr(other) +
".")
105 except (RuntimeError, TypeError):
106 raise ValueError(error_msg_prefix +
" invalid " + repr(other) +
".")
107 elif isinstance(other, str):
109 bother = other.encode(
"UTF-8")
110 self.
instance = new IndexSet(<char *>bother)
112 raise ValueError(error_msg_prefix +
" invalid string " + repr(other) +
".")
114 raise TypeError(error_msg_prefix +
" " + str(type(other)) +
".")
118 Clean up by deallocating the instance of C++ class IndexSet.
143 if (lhs
is None)
or (rhs
is None):
144 eq = bool(lhs
is rhs)
159 return NotImplemented
161 eq = bool( toIndexSet(lhs) == toIndexSet(rhs) )
167 lt = bool( toIndexSet(lhs) < toIndexSet(rhs) )
173 return not (lt
or eq)
177 return NotImplemented
181 Set the value of an index_set object at index idx to value val.
183 >>> s=index_set({1}); s[2] = True; print(s)
185 >>> s=
index_set({1,2}); s[1] =
False; print(s)
193 Get the value of an index_set object at an index.
212 Check that an index_set object contains the index idx: idx in self.
231 Iterate over the indices of an index_set.
233 >>> for i
in index_set({-3,4,7}):print(i, end=
",")
236 for idx
in range(self.
min(), self.
max()+1):
244 >>> print(~
index_set({-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}))
245 {-32,-31,-30,-29,-28,-27,-26,-25,-24,-23,-22,-21,-20,-19,-18,-17,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32}
251 Symmetric set difference: exclusive or.
258 return index_set().wrap( toIndexSet(lhs) ^ toIndexSet(rhs) )
262 Symmetric set difference: exclusive or.
269 return self.wrap( self.unwrap() ^ toIndexSet(rhs) )
273 Set intersection: and.
280 return index_set().wrap( toIndexSet(lhs) & toIndexSet(rhs) )
284 Set intersection: and.
291 return self.wrap( self.unwrap() & toIndexSet(rhs) )
302 return index_set().wrap( toIndexSet(lhs) | toIndexSet(rhs) )
313 return self.wrap( self.unwrap() | toIndexSet(rhs) )
317 Cardinality: Number of indices included in set.
326 Number of negative indices included in set.
335 Number of positive indices included in set.
368 Sign of geometric product of two Clifford basis elements.
377 Sign of geometric square of a Clifford basis element.
379 >>> s = index_set({1,2}); s.sign_of_square()
386 The “official” string representation of self.
397 The “informal” string representation of self.
408 Tests for functions that Doctest cannot see.
410 For index_set.__cinit__: Construct index_set.
427 Traceback (most recent call last):
429 ValueError: Cannot initialize index_set object
from invalid string
'{'.
431 Traceback (most recent call last):
433 ValueError: Cannot initialize index_set object
from invalid string
'{1'.
435 Traceback (most recent call last):
437 ValueError: Cannot initialize index_set object
from invalid string
'{1,2,100}'.
439 Traceback (most recent call last):
441 IndexError: Cannot initialize index_set object
from invalid {1, 2, 100}.
443 Traceback (most recent call last):
445 TypeError: Cannot initialize index_set object
from <
class 'list'>.
447 For index_set.__richcmp__: Compare two objects of
class index_set.
492cpdef inline compare(lhs,rhs):
494 "lexicographic compare" eg. {3,4,5}
is less than {3,7,8};
495 -1
if a<b, +1
if a>b, 0
if a==b.
504cpdef inline min_neg(obj):
506 Minimum negative index, or 0
if none.
513cpdef inline max_pos(obj):
515 Maximum positive index, or 0
if none.
522cdef inline vector[scalar_t] list_to_vector(lst):
524 Create a C++ std:vector[scalar_t] from an iterable Python object.
526 cdef vector[scalar_t] v
528 v.push_back(<scalar_t>s)
534cdef inline Clifford toClifford(obj):
539 Python class clifford wraps C++
class Clifford.
541 cdef Clifford *instance
543 cdef inline wrap(clifford self, Clifford other):
545 Wrap an instance of the C++ class Clifford.
550 cdef inline Clifford unwrap(clifford self):
552 Return the wrapped C++ Clifford instance.
556 cpdef copy(clifford self):
558 Copy this clifford object.
560 >>> x=clifford("1{2}"); y=x.copy(); print(y)
567 Construct an object of type clifford.
588 error_msg_prefix = "Cannot initialize clifford object from"
591 if isinstance(other, clifford):
592 self.
instance = new Clifford((<clifford>other).unwrap())
593 elif isinstance(other, index_set):
594 self.
instance = new Clifford((<index_set>other).unwrap(), <scalar_t>1.0)
595 elif isinstance(other, numbers.Real):
596 self.
instance = new Clifford(<scalar_t>other)
597 elif isinstance(other, str):
599 bother = other.encode(
"UTF-8")
600 self.
instance = new Clifford(<char *>bother)
602 raise ValueError(error_msg_prefix +
" invalid string " + repr(other) +
".")
604 raise TypeError(error_msg_prefix +
" " + str(type(other)) +
".")
605 except RuntimeError
as err:
606 raise ValueError(error_msg_prefix +
" " + str(type(other))
607 +
" value " + repr(other) +
":"
609 elif isinstance(ixt, index_set):
610 if isinstance(other, numbers.Real):
611 self.
instance = new Clifford((<index_set>ixt).unwrap(), <scalar_t>other)
612 elif isinstance(other, collections.abc.Sequence):
613 self.
instance = new Clifford(list_to_vector(other), (<index_set>ixt).unwrap())
615 raise TypeError(error_msg_prefix +
" (" + str(type(other))
616 +
", " + repr(ixt) +
").")
618 raise TypeError(error_msg_prefix +
" (" + str(type(other))
619 +
", " + str(type(ixt)) +
").")
623 Clean up by deallocating the instance of C++ class Clifford.
632 Traceback (most recent call last):
634 TypeError: Not applicable.
636 raise TypeError(
"Not applicable.")
643 Traceback (most recent call last):
645 TypeError: Not applicable.
647 raise TypeError(
"Not applicable.")
651 Put self into a larger frame, containing the union of self.frame() and index set ixt.
652 This can be used to make multiplication faster, by multiplying within a common frame.
659 error_msg_prefix = "Cannot reframe"
660 if isinstance(ixt, index_set):
663 result.instance = new Clifford(self.unwrap(), (<index_set>ixt).unwrap())
664 except RuntimeError
as err:
665 raise ValueError(error_msg_prefix +
" from " + str(self) +
" to frame "
669 raise TypeError(error_msg_prefix +
" using (" + str(type(ixt)) +
").")
674 Compare objects of type clifford.
692 if (lhs
is None)
or (rhs
is None):
693 return bool(lhs
is rhs)
695 return bool( toClifford(lhs) == toClifford(rhs) )
697 if (lhs
is None)
or (rhs
is None):
698 return not bool(lhs
is rhs)
700 return bool( toClifford(lhs) != toClifford(rhs) )
701 elif isinstance(lhs, clifford)
or isinstance(rhs, clifford):
702 raise TypeError(
"This comparison operator is not implemented for "
703 + str(type(lhs)) +
", " + str(type(rhs)) +
".")
705 return NotImplemented
709 Subscripting: map from index set to scalar coordinate.
720 return self.
instance.getitem(toIndexSet(ixt))
749 return clifford().wrap( toClifford(lhs) + toClifford(rhs) )
758 return self.wrap( self.unwrap() + toClifford(rhs) )
762 Geometric difference.
769 return clifford().wrap( toClifford(lhs) - toClifford(rhs) )
773 Geometric difference.
778 return self.wrap( self.unwrap() - toClifford(rhs) )
791 return clifford().wrap( toClifford(lhs) * toClifford(rhs) )
804 return self.wrap( self.unwrap() * toClifford(rhs) )
819 return clifford().wrap( toClifford(lhs) % toClifford(rhs) )
834 return self.wrap( self.unwrap() % toClifford(rhs) )
849 return clifford().wrap( toClifford(lhs) & toClifford(rhs) )
864 return self.wrap( self.unwrap() & toClifford(rhs) )
879 return clifford().wrap( toClifford(lhs) ^ toClifford(rhs) )
894 return self.wrap( self.unwrap() ^ toClifford(rhs) )
909 return clifford().wrap( toClifford(lhs) / toClifford(rhs) )
924 return self.wrap( self.unwrap() / toClifford(rhs) )
928 Geometric multiplicative inverse.
930 >>> x = clifford("{1}"); print(x.inv())
934 >>> x =
clifford(
"{1,2}"); print(x.inv())
941 Transform left hand side, using right hand side as a transformation.
948 return clifford().wrap( toClifford(lhs) | toClifford(rhs) )
952 Transform left hand side, using right hand side as a transformation.
959 return self.wrap( self.unwrap() | toClifford(rhs) )
963 Power: self to the m.
965 >>> x=clifford("{1}"); print(x ** 2)
969 >>> x=
clifford(
"2+{1}"); print(x ** 0)
971 >>> x=
clifford(
"2+{1}"); print(x ** 1)
973 >>> x=
clifford(
"2+{1}"); print(x ** 2)
975 >>> i=
clifford(
"{1,2}"); print(exp(pi/2) * (i ** i))
982 Power: self to the m.
984 >>> x=clifford("{1}"); print(x.pow(2))
986 >>> x=
clifford(
"2"); print(x.pow(2))
988 >>> x=
clifford(
"2+{1}"); print(x.pow(0))
990 >>> x=
clifford(
"2+{1}"); print(x.pow(1))
992 >>> x=
clifford(
"2+{1}"); print(x.pow(2))
996 >>> i=
clifford(
"{1,2}"); print(exp(pi/2) * i.pow(i))
999 if isinstance(m, numbers.Integral):
1002 return exp(m * log(self))
1006 Outer product power.
1008 >>> x=clifford("2+{1}"); print(x.outer_pow(0))
1010 >>> x=
clifford(
"2+{1}"); print(x.outer_pow(1))
1012 >>> x=
clifford(
"2+{1}"); print(x.outer_pow(2))
1022 Pure grade-vector part.
1028 >>> print(
clifford(
"1+{1}+{1,2}")(0))
1030 >>> print(
clifford(
"1+{1}+{1,2}")(1))
1032 >>> print(
clifford(
"1+{1}+{1,2}")(2))
1034 >>> print(
clifford(
"1+{1}+{1,2}")(3))
1063 Even part of multivector, sum of even grade terms.
1072 Odd part of multivector, sum of odd grade terms.
1081 Vector part of multivector, as a Python list,
with respect to frm.
1088 error_msg_prefix = "Cannot take vector part of "
1089 cdef vector[scalar_t] vec
1102 except RuntimeError
as err:
1103 raise ValueError(error_msg_prefix + str(self) +
" using invalid "
1104 + repr(frm) +
" as frame:\n\t"
1109 Main involution, each {i} is replaced by -{i}
in each term,
1140 Conjugation, reverse o involute == involute o reverse.
1155 Quadratic form == (rev(x)*x)(0).
1166 Norm == sum of squares of coordinates.
1177 Absolute value: square root of norm.
1186 Maximum of absolute values of components of multivector: multivector infinity norm.
1197 Remove all terms of self with relative size smaller than limit.
1208 Check if a multivector contains any infinite values.
1217 Check if a multivector contains any IEEE NaN values.
1226 Subalgebra generated by all generators of terms of given multivector.
1231 <
class 'PyClical.index_set'>
1237 The “official” string representation of self.
1240 'clifford("1+3{-1}+2{1,2}+4{-2,7}")'
1246 The “informal” string representation of self.
1249 '1+3{-1}+2{1,2}+4{-2,7}'
1255 Tests for functions that Doctest cannot see.
1257 For clifford.__cinit__: Construct an object of type clifford.
1278 Traceback (most recent call last):
1280 TypeError: Cannot initialize clifford object
from <
class 'list'>.
1282 Traceback (most recent call last):
1284 TypeError: Cannot initialize clifford object
from <
class 'NoneType'>.
1286 Traceback (most recent call last):
1288 TypeError: Cannot initialize clifford object
from (<
class 'NoneType'>, <
class 'list'>).
1290 Traceback (most recent call last):
1292 TypeError: Cannot initialize clifford object
from (<
class 'list'>, <
class 'list'>).
1294 Traceback (most recent call last):
1296 ValueError: Cannot initialize clifford object
from invalid string
''.
1298 Traceback (most recent call last):
1300 ValueError: Cannot initialize clifford object
from invalid string
'{'.
1302 Traceback (most recent call last):
1304 ValueError: Cannot initialize clifford object
from invalid string
'{1'.
1306 Traceback (most recent call last):
1308 ValueError: Cannot initialize clifford object
from invalid string
'+'.
1310 Traceback (most recent call last):
1312 ValueError: Cannot initialize clifford object
from invalid string
'-'.
1314 Traceback (most recent call last):
1316 ValueError: Cannot initialize clifford object
from invalid string
'{1}+'.
1318 For clifford.__richcmp__: Compare objects of type clifford.
1337cpdef inline error_squared_tol(obj):
1339 Quadratic norm error tolerance relative to a specific multivector.
1341 >>> print(error_squared_tol(clifford("{1}")) * 3.0 - error_squared_tol(
clifford(
"1{1}-2{2}+3{3}")))
1346cpdef inline error_squared(lhs, rhs, threshold):
1348 Relative or absolute error using the quadratic norm.
1350 >>> err2=scalar_epsilon*scalar_epsilon
1354 >>> print(error_squared(
clifford(
"1{1}-3{2}+4{3}"),
clifford(
"{1}"), err2))
1359cpdef inline approx_equal(lhs, rhs, threshold=
None, tol=
None):
1361 Test for approximate equality of multivectors.
1363 >>> err2=scalar_epsilon*scalar_epsilon
1369 >>> print(approx_equal(
clifford(
"1{1}-3{2}+4{3}+0.001"),
clifford(
"1{1}-3{2}+4{3}"), err2, err2))
1371 >>> print(approx_equal(
clifford(
"1{1}-3{2}+4{3}+1.0e-30"),
clifford(
"1{1}-3{2}+4{3}"), err2, err2))
1374 threshold = error_squared_tol(rhs) if threshold
is None else threshold
1375 tol = error_squared_tol(rhs)
if tol
is None else tol
1376 return glucat.approx_equal(toClifford(lhs), toClifford(rhs), <scalar_t>threshold, <scalar_t>tol)
1378cpdef inline inv(obj):
1380 Geometric multiplicative inverse.
1386 >>> print(inv(
clifford(
"{-2,-1}")))
1388 >>> print(inv(
clifford(
"{-1}+{1}")))
1393cpdef inline scalar(obj):
1397 >>> scalar(clifford("1+{1}+{1,2}"))
1404cpdef inline real(obj):
1406 Real part: synonym for scalar part.
1415cpdef inline imag(obj):
1417 Imaginary part: deprecated (always 0).
1426cpdef inline pure(obj):
1430 >>> print(pure(clifford("1+{1}+{1,2}")))
1437cpdef inline even(obj):
1439 Even part of multivector, sum of even grade terms.
1441 >>> print(even(clifford("1+{1}+{1,2}")))
1446cpdef inline odd(obj):
1448 Odd part of multivector, sum of odd grade terms.
1450 >>> print(odd(clifford("1+{1}+{1,2}")))
1455cpdef inline involute(obj):
1457 Main involution, each {i} is replaced by -{i}
in each term, eg. {1}*{2} -> (-{2})*(-{1})
1459 >>> print(involute(
clifford(
"{1}")))
1465 >>> print(involute(
clifford(
"1+{1}+{1,2}")))
1470cpdef inline reverse(obj):
1472 Reversion, eg. {1}*{2} -> {2}*{1}
1474 >>> print(reverse(clifford("{1}")))
1480 >>> print(reverse(
clifford(
"1+{1}+{1,2}")))
1485cpdef inline conj(obj):
1487 Conjugation, reverse o involute == involute o reverse.
1495 >>> print(conj(
clifford(
"1+{1}+{1,2}")))
1500cpdef inline quad(obj):
1502 Quadratic form == (rev(x)*x)(0).
1504 >>> print(quad(clifford("1+{1}+{1,2}")))
1506 >>> print(quad(
clifford(
"1+{-1}+{1,2}+{1,2,3}")))
1511cpdef inline norm(obj):
1513 norm == sum of squares of coordinates.
1517 >>> norm(
clifford(
"1+{-1}+{1,2}+{1,2,3}"))
1522cpdef inline abs(obj):
1524 Absolute value of multivector: multivector 2-norm.
1526 >>> abs(clifford("1+{-1}+{1,2}+{1,2,3}"))
1531cpdef inline max_abs(obj):
1533 Maximum absolute value of coordinates multivector: multivector infinity-norm.
1535 >>> max_abs(clifford("1+{-1}+{1,2}+{1,2,3}"))
1537 >>> max_abs(
clifford(
"3+2{1}+{1,2}"))
1543cpdef inline pow(obj, m):
1545 Integer power of multivector: obj to the m.
1547 >>> x=clifford("{1}"); print(pow(x,2))
1549 >>> x=
clifford(
"2"); print(pow(x,2))
1551 >>> x=
clifford(
"2+{1}"); print(pow(x,0))
1553 >>> x=
clifford(
"2+{1}"); print(pow(x,1))
1555 >>> x=
clifford(
"2+{1}"); print(pow(x,2))
1557 >>> print(pow(
clifford(
"1+{1}+{1,2}"),3))
1559 >>> i=
clifford(
"{1,2}"); print(exp(pi/2) * pow(i, i))
1567cpdef inline outer_pow(obj, m):
1569 Outer product power of multivector.
1571 >>> print(outer_pow(clifford("1+{1}+{1,2}"),3))
1576cpdef inline complexifier(obj):
1578 Square root of -1 which commutes with all members of the frame of the given multivector.
1586 >>> print(complexifier(
index_set({-1})))
1591cpdef inline sqrt(obj, i =
None):
1593 Square root of multivector with optional complexifier.
1599 >>> j=sqrt(-1,complexifier(
index_set({1}))); print(j); print(j*j)
1602 >>> j=sqrt(-1,
"{1,2,3}"); print(j); print(j*j)
1610 return math.sqrt(obj)
1614cpdef inline exp(obj):
1616 Exponential of multivector.
1618 >>> x=clifford("{1,2}") * pi/4; print(exp(x))
1620 >>> x=
clifford(
"{1,2}") * pi/2; print(exp(x))
1624 return math.exp(obj)
1628cpdef inline log(obj,i =
None):
1630 Natural logarithm of multivector with optional complexifier.
1632 >>> x=
clifford(
"{-1}"); print((log(x,
"{-1}") * 2/pi))
1634 >>> x=
clifford(
"{1,2}"); print((log(x,
"{1,2,3}") * 2/pi))
1636 >>> x=
clifford(
"{1,2}"); print((log(x) * 2/pi))
1638 >>> x=
clifford(
"{1,2}"); print((log(x,
"{1,2}") * 2/pi))
1639 Traceback (most recent call last):
1641 RuntimeError: check_complex(val, i): i
is not a valid complexifier
for val
1647 return math.log(obj)
1651cpdef inline cos(obj,i =
None):
1653 Cosine of multivector with optional complexifier.
1655 >>> x=
clifford(
"{1,2}"); print(cos(acos(x),
"{1,2,3}"))
1657 >>> x=
clifford(
"{1,2}"); print(cos(acos(x)))
1664 return math.cos(obj)
1668cpdef inline acos(obj,i =
None):
1670 Inverse cosine of multivector with optional complexifier.
1672 >>> x=
clifford(
"{1,2}"); print(cos(acos(x),
"{1,2,3}"))
1674 >>> x=
clifford(
"{1,2}"); print(cos(acos(x),
"{-1,1,2,3,4}"))
1676 >>> print(acos(0) / pi)
1678 >>> x=
clifford(
"{1,2}"); print(cos(acos(x)))
1685 return math.acos(obj)
1689cpdef inline cosh(obj):
1691 Hyperbolic cosine of multivector.
1693 >>> x=clifford("{1,2}") * pi; print(cosh(x))
1695 >>> x=
clifford(
"{1,2,3}"); print(cosh(acosh(x)))
1697 >>> x=
clifford(
"{1,2}"); print(cosh(acosh(x)))
1701 return math.cosh(obj)
1705cpdef inline acosh(obj,i =
None):
1707 Inverse hyperbolic cosine of multivector with optional complexifier.
1709 >>> print(acosh(0,
"{-2,-1,1}"))
1711 >>> x=
clifford(
"{1,2,3}"); print(cosh(acosh(x,
"{-1,1,2,3,4}")))
1715 >>> x=
clifford(
"{1,2,3}"); print(cosh(acosh(x)))
1717 >>> x=
clifford(
"{1,2}"); print(cosh(acosh(x)))
1724 return math.acosh(obj)
1728cpdef inline sin(obj,i =
None):
1730 Sine of multivector with optional complexifier.
1732 >>> s=
"{-1}"; x=
clifford(s); print(asin(sin(x,s),s))
1734 >>> s=
"{-1}"; x=
clifford(s); print(asin(sin(x,s),
"{-2,-1,1}"))
1736 >>> x=
clifford(
"{1,2,3}"); print(asin(sin(x)))
1743 return math.sin(obj)
1747cpdef inline asin(obj,i =
None):
1749 Inverse sine of multivector with optional complexifier.
1751 >>> s=
"{-1}"; x=
clifford(s); print(asin(sin(x,s),s))
1753 >>> s=
"{-1}"; x=
clifford(s); print(asin(sin(x,s),
"{-2,-1,1}"))
1755 >>> print(asin(1) / pi)
1757 >>> x=
clifford(
"{1,2,3}"); print(asin(sin(x)))
1764 return math.asin(obj)
1768cpdef inline sinh(obj):
1770 Hyperbolic sine of multivector.
1772 >>> x=clifford("{1,2}") * pi/2; print(sinh(x))
1774 >>> x=
clifford(
"{1,2}") * pi/6; print(sinh(x))
1778 return math.sinh(obj)
1782cpdef inline asinh(obj,i =
None):
1784 Inverse hyperbolic sine of multivector with optional complexifier.
1786 >>> x=
clifford(
"{1,2}"); print(asinh(x,
"{1,2,3}") * 2/pi)
1788 >>> x=
clifford(
"{1,2}"); print(asinh(x) * 2/pi)
1790 >>> x=
clifford(
"{1,2}") / 2; print(asinh(x) * 6/pi)
1797 return math.asinh(obj)
1801cpdef inline tan(obj,i =
None):
1803 Tangent of multivector with optional complexifier.
1805 >>> x=
clifford(
"{1,2}"); print(tan(x,
"{1,2,3}"))
1807 >>> x=
clifford(
"{1,2}"); print(tan(x))
1814 return math.tan(obj)
1818cpdef inline atan(obj,i =
None):
1820 Inverse tangent of multivector with optional complexifier.
1824 >>> x=
clifford(
"{1}"); print(tan(atan(x)))
1831 return math.atan(obj)
1835cpdef inline tanh(obj):
1837 Hyperbolic tangent of multivector.
1839 >>> x=clifford("{1,2}") * pi/4; print(tanh(x))
1843 return math.tanh(obj)
1847cpdef inline atanh(obj,i =
None):
1849 Inverse hyperbolic tangent of multivector with optional complexifier.
1853 >>> x=
clifford(
"{1,2}"); print(tanh(atanh(x)))
1860 return math.atanh(obj)
1864cpdef inline random_clifford(index_set ixt, fill = 1.0):
1866 Random multivector within a frame.
1868 >>> print(random_clifford(index_set({-3,-1,2})).frame())
1871 return clifford().wrap(
clifford().instance.random(ixt.unwrap(), <scalar_t>fill) )
1873cpdef inline
cga3(obj):
1875 Convert Euclidean 3D multivector to Conformal Geometric Algebra using Doran and Lasenby definition.
1878 87{-1}+4{1}+18{2}+2{3}+85{4}
1880 return clifford().wrap( glucat.cga3(toClifford(obj)) )
1882cpdef inline cga3std(obj):
1884 Convert CGA3 null vector to standard conformal null vector using Doran and Lasenby definition.
1886 >>> x=
clifford(
"2{1}+9{2}+{3}"); print(cga3std(
cga3(x)))
1887 87{-1}+4{1}+18{2}+2{3}+85{4}
1891 return clifford().wrap( glucat.cga3std(toClifford(obj)) )
1893cpdef inline agc3(obj):
1895 Convert CGA3 null vector to Euclidean 3D vector using Doran and Lasenby definition.
1899 >>> x=
clifford(
"2{1}+9{2}+{3}"); print(agc3(
cga3(x))-x)
1902 return clifford().wrap( glucat.agc3(toClifford(obj)) )
1905scalar_epsilon = epsilon
1912Abbreviation for clifford.
1918>>> print(cl(5.0e-1))
1922>>> print(cl("2{1,2,3}"))
1924>>> print(cl(cl("2{1,2,3}")))
1930Abbreviation for index_set.
1932>>> print(ist("{1,2,3}"))
1953 >>> print(
istpq(2,3))
1963 import PyClical, doctest
1964 return doctest.testmod(PyClical)
1966if __name__ ==
"__main__":
String clifford_to_str(const Multivector_T &mv)
The "informal" string representation of Multivector_T mv.
String clifford_to_repr(const Multivector_T &mv)
The “official” string representation of Multivector_T mv.
String index_set_to_str(const Index_Set_T &ist)
The "informal" string representation of Index_Set_T ist.
String index_set_to_repr(const Index_Set_T &ist)
The “official” string representation of Index_Set_T ist.
def truncated(self, limit)
def __truediv__(lhs, rhs)
def __pow__(self, m, dummy)
def __call__(self, grade)
def __getitem__(self, ixt)
def vector_part(self, frm=None)
def __contains__(self, x)
def __richcmp__(lhs, rhs, int, op)
def __cinit__(self, other=0, ixt=None)
def __getitem__(self, idx)
def __cinit__(self, other=0)
def __setitem__(self, idx, val)
def __contains__(self, idx)
def __richcmp__(lhs, rhs, int, op)
def sign_of_mult(self, rhs)
def index_set_hidden_doctests()
def clifford_hidden_doctests()
Definitions for 3D Conformal Geometric Algebra [DL].
auto exp(const framed_multi< Scalar_T, LO, HI, Tune_P > &val) -> const framed_multi< Scalar_T, LO, HI, Tune_P >
Exponential of multivector.
auto compare(const index_set< LO, HI > &a, const index_set< LO, HI > &b) -> int
"lexicographic compare" eg. {3,4,5} is less than {3,7,8}
auto cosh(const Multivector< Scalar_T, LO, HI, Tune_P > &val) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Hyperbolic cosine of multivector.
auto tanh(const Multivector< Scalar_T, LO, HI, Tune_P > &val) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Hyperbolic tangent of multivector.
auto approx_equal(const Multivector< Scalar_T, LO, HI, Tune_P > &lhs, const RHS< Scalar_T, LO, HI, Tune_P > &rhs, const Scalar_T threshold, const Scalar_T tolerance) -> bool
Test for approximate equality of multivectors.
auto min_neg(const index_set< LO, HI > &ist) -> index_t
Minimum negative index, or 0 if none.
auto tan(const Multivector< Scalar_T, LO, HI, Tune_P > &val, const Multivector< Scalar_T, LO, HI, Tune_P > &i, const bool prechecked=false) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Tangent of multivector with specified complexifier.
auto error_squared(const Multivector< Scalar_T, LO, HI, Tune_P > &lhs, const RHS< Scalar_T, LO, HI, Tune_P > &rhs, const Scalar_T threshold) -> Scalar_T
Relative or absolute error using the quadratic norm.
auto sinh(const Multivector< Scalar_T, LO, HI, Tune_P > &val) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Hyperbolic sine of multivector.
auto sin(const Multivector< Scalar_T, LO, HI, Tune_P > &val, const Multivector< Scalar_T, LO, HI, Tune_P > &i, const bool prechecked=false) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Sine of multivector with specified complexifier.
auto abs(const Multivector< Scalar_T, LO, HI, Tune_P > &val) -> Scalar_T
Absolute value == sqrt(norm)
auto asinh(const Multivector< Scalar_T, LO, HI, Tune_P > &val, const Multivector< Scalar_T, LO, HI, Tune_P > &i, const bool prechecked=false) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Inverse hyperbolic sine of multivector with specified complexifier.
auto atanh(const Multivector< Scalar_T, LO, HI, Tune_P > &val, const Multivector< Scalar_T, LO, HI, Tune_P > &i, const bool prechecked=false) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Inverse hyperbolic tangent of multivector with specified complexifier.
auto atan(const Multivector< Scalar_T, LO, HI, Tune_P > &val, const Multivector< Scalar_T, LO, HI, Tune_P > &i, const bool prechecked=false) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Inverse tangent of multivector with specified complexifier.
auto cos(const Multivector< Scalar_T, LO, HI, Tune_P > &val, const Multivector< Scalar_T, LO, HI, Tune_P > &i, const bool prechecked=false) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Cosine of multivector with specified complexifier.
auto log(const Multivector< Scalar_T, LO, HI, Tune_P > &val, const Multivector< Scalar_T, LO, HI, Tune_P > &i, const bool prechecked=false) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Natural logarithm of multivector with specified complexifier.
auto asin(const Multivector< Scalar_T, LO, HI, Tune_P > &val, const Multivector< Scalar_T, LO, HI, Tune_P > &i, const bool prechecked=false) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Inverse sine of multivector with specified complexifier.
auto acosh(const Multivector< Scalar_T, LO, HI, Tune_P > &val, const Multivector< Scalar_T, LO, HI, Tune_P > &i, const bool prechecked=false) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Inverse hyperbolic cosine of multivector with specified complexifier.
auto error_squared_tol(const Multivector< Scalar_T, LO, HI, Tune_P > &val) -> Scalar_T
Quadratic norm error tolerance relative to a specific multivector.
auto max_abs(const Multivector< Scalar_T, LO, HI, Tune_P > &val) -> Scalar_T
Maximum of absolute values of components of multivector: multivector infinity norm.
auto sqrt(const Multivector< Scalar_T, LO, HI, Tune_P > &val, const Multivector< Scalar_T, LO, HI, Tune_P > &i, const bool prechecked=false) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Square root of multivector with specified complexifier.
auto complexifier(const Multivector< Scalar_T, LO, HI, Tune_P > &val) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Square root of -1 which commutes with all members of the frame of the given multivector.
auto acos(const Multivector< Scalar_T, LO, HI, Tune_P > &val, const Multivector< Scalar_T, LO, HI, Tune_P > &i, const bool prechecked=false) -> const Multivector< Scalar_T, LO, HI, Tune_P >
Inverse cosine of multivector with specified complexifier.
auto max_pos(const index_set< LO, HI > &ist) -> index_t
Maximum positive index, or 0 if none.