SETUP::
sage: from mjo.eja.eja_operator import EJAOperator
- sage: from mjo.eja.eja_algebra import RealSymmetricEJA
+ sage: from mjo.eja.eja_algebra import (HadamardEJA,
+ ....: JordanSpinEJA,
+ ....: RealSymmetricEJA)
TESTS:
Domain: Euclidean Jordan algebra of dimension 3 over...
Codomain: Euclidean Jordan algebra of dimension 3 over...
+ TESTS:
+
+ Exponentiation doesn't work when the domain and codomain
+ differ, even if their dimensions are compatible::
+
+ sage: J1 = HadamardEJA(3)
+ sage: J2 = JordanSpinEJA(3)
+ sage: I = J1.one().operator().matrix()
+ sage: L = EJAOperator(J1, J2, I)
+ sage: L^2
+ Traceback (most recent call last):
+ ...
+ TypeError: ...domain must equal right...
+
"""
if (n == 1):
return self
rows = self.codomain().dimension()
cols = self.domain().dimension()
mat = matrix.identity(self.base_ring(), rows, cols)
- else:
- mat = self.matrix()**n
+ return EJAOperator(self.domain(), self.codomain(), mat)
- return EJAOperator(
- self.domain(),
- self.codomain(),
- mat)
+ # Actually multiply them for n >= 2 so that the domain and
+ # codomain checks in __mul__ aren't skipped (as they would be
+ # if we simply exponentiated the matrix).
+ from functools import reduce
+ from itertools import repeat
+ from operator import mul
+ return reduce(mul, repeat(self, n))
def _repr_(self):
True
sage: L.inverse().is_isomorphism()
True
- sage: (L^2).is_isomorphism()
+ sage: (L.domain() != L.codomain()) or (L^2).is_isomorphism()
True
The identity operator is always a Jordan isomorphism::