]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/eja_algebra.py
eja: use the basis space ring instead of the element's during construction.
[sage.d.git] / mjo / eja / eja_algebra.py
index 204a537df12d2ab4d3d27764c20c830ec324a68a..1f6112ca188124b114da9892d6a8aed283681161 100644 (file)
@@ -135,13 +135,17 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
             return self.zero()
 
         natural_basis = self.natural_basis()
-        if elt not in natural_basis[0].matrix_space():
+        basis_space = natural_basis[0].matrix_space()
+        if elt not in basis_space:
             raise ValueError("not a naturally-represented algebra element")
 
-        # Thanks for nothing! Matrix spaces aren't vector
-        # spaces in Sage, so we have to figure out its
-        # natural-basis coordinates ourselves.
-        V = VectorSpace(elt.base_ring(), elt.nrows()*elt.ncols())
+        # Thanks for nothing! Matrix spaces aren't vector spaces in
+        # Sage, so we have to figure out its natural-basis coordinates
+        # ourselves. We use the basis space's ring instead of the
+        # element's ring because the basis space might be an algebraic
+        # closure whereas the base ring of the 3-by-3 identity matrix
+        # could be QQ instead of QQbar.
+        V = VectorSpace(basis_space.base_ring(), elt.nrows()*elt.ncols())
         W = V.span_of_basis( _mat2vec(s) for s in natural_basis )
         coords =  W.coordinate_vector(_mat2vec(elt))
         return self.from_vector(coords)