X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feja_algebra.py;h=2bad32c2f500193e4126b7c5e209c0acb3116ede;hb=f0cabe7c6e37781e4f92c9ba0e0c7413a5f6b939;hp=6fb4baa5f87ca09d3deef5bf3e4d9eb9a241188a;hpb=83d376d66655871201e89b17b2cbc6fba8210d56;p=sage.d.git diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 6fb4baa..2bad32c 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -166,9 +166,10 @@ from sage.modules.free_module import FreeModule, VectorSpace from sage.rings.all import (ZZ, QQ, AA, QQbar, RR, RLF, CLF, PolynomialRing, QuadraticField) -from mjo.eja.eja_element import FiniteDimensionalEJAElement +from mjo.eja.eja_element import (CartesianProductEJAElement, + FiniteDimensionalEJAElement) from mjo.eja.eja_operator import FiniteDimensionalEJAOperator -from mjo.eja.eja_utils import _all2list, _mat2vec +from mjo.eja.eja_utils import _all2list def EuclideanJordanAlgebras(field): r""" @@ -1281,7 +1282,9 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): # # Of course, matrices aren't vectors in sage, so we have to # appeal to the "long vectors" isometry. - oper_vecs = [ _mat2vec(g.operator().matrix()) for g in self.gens() ] + + V = VectorSpace(self.base_ring(), self.dimension()**2) + oper_vecs = [ V(g.operator().matrix().list()) for g in self.gens() ] # Now we use basic linear algebra to find the coefficients, # of the matrices-as-vectors-linear-combination, which should @@ -1291,7 +1294,7 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): # We used the isometry on the left-hand side already, but we # still need to do it for the right-hand side. Recall that we # wanted something that summed to the identity matrix. - b = _mat2vec( matrix.identity(self.base_ring(), self.dimension()) ) + b = V( matrix.identity(self.base_ring(), self.dimension()).list() ) # Now if there's an identity element in the algebra, this # should work. We solve on the left to avoid having to @@ -3087,6 +3090,7 @@ class CartesianProductEJA(FiniteDimensionalEJA): sage: actual == expected # long time True """ + Element = CartesianProductEJAElement def __init__(self, factors, **kwargs): m = len(factors) if m == 0: @@ -3190,6 +3194,34 @@ class CartesianProductEJA(FiniteDimensionalEJA): ones = tuple(J.one().to_matrix() for J in factors) self.one.set_cache(self(ones)) + def _sets_keys(self): + r""" + + SETUP:: + + sage: from mjo.eja.eja_algebra import (ComplexHermitianEJA, + ....: RealSymmetricEJA) + + TESTS: + + The superclass uses ``_sets_keys()`` to implement its + ``cartesian_factors()`` method:: + + sage: J1 = RealSymmetricEJA(2, + ....: field=QQ, + ....: orthonormalize=False, + ....: prefix="a") + sage: J2 = ComplexHermitianEJA(2,field=QQ,orthonormalize=False) + sage: J = cartesian_product([J1,J2]) + sage: x = sum(i*J.gens()[i] for i in range(len(J.gens()))) + sage: x.cartesian_factors() + (a1 + 2*a2, 3*b0 + 4*b1 + 5*b2 + 6*b3) + + """ + # Copy/pasted from CombinatorialFreeModule_CartesianProduct, + # but returning a tuple instead of a list. + return tuple(range(len(self.cartesian_factors()))) + def cartesian_factors(self): # Copy/pasted from CombinatorialFreeModule_CartesianProduct. return self._sets