From 1c7418a9b9a3f6f41c95b785c9e4ec18c168d962 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 20 Aug 2019 11:11:32 -0400 Subject: [PATCH] eja: use the basis space ring instead of the element's during construction. Basically, when we're constructing an element, we're trying to fit some given representation into a pre-existing space. Thus it makes sense to build that space out of the pre-existing stuff, and not from the element's base ring. This makes sense in general. --- mjo/eja/eja_algebra.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 204a537..1f6112c 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -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) -- 2.44.2