From: Michael Orlitzky Date: Sat, 10 Aug 2019 00:00:04 +0000 (-0400) Subject: eja: fix the natural representation in trivial subalgebras. X-Git-Url: http://gitweb.michael.orlitzky.com/?p=sage.d.git;a=commitdiff_plain;h=723fd0f50c7997768c3d098c707df30197b88afd eja: fix the natural representation in trivial subalgebras. The natural representation relies on knowing a matrix space, and in a trivial subalgebra there ain't no matrices to have no spaces. To work around that, the space is now computed/stored separately, in a new natural_basis_space() method. This is then overridden in the subalgebra class to do the right thing. --- diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 06f6f53..42b2474 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -9,6 +9,7 @@ from sage.algebras.quatalg.quaternion_algebra import QuaternionAlgebra from sage.categories.magmatic_algebras import MagmaticAlgebras from sage.combinat.free_module import CombinatorialFreeModule from sage.matrix.constructor import matrix +from sage.matrix.matrix_space import MatrixSpace from sage.misc.cachefunc import cached_method from sage.misc.prandom import choice from sage.misc.table import table @@ -514,11 +515,23 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule): """ if self._natural_basis is None: - return tuple( b.to_vector().column() for b in self.basis() ) + M = self.natural_basis_space() + return tuple( M(b.to_vector()) for b in self.basis() ) else: return self._natural_basis + def natural_basis_space(self): + """ + Return the matrix space in which this algebra's natural basis + elements live. + """ + if self._natural_basis is None or len(self._natural_basis) == 0: + return MatrixSpace(self.base_ring(), self.dimension(), 1) + else: + return self._natural_basis[0].matrix_space() + + @cached_method def one(self): """ diff --git a/mjo/eja/eja_element.py b/mjo/eja/eja_element.py index e1f7563..aef1c5d 100644 --- a/mjo/eja/eja_element.py +++ b/mjo/eja/eja_element.py @@ -825,7 +825,7 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): """ B = self.parent().natural_basis() - W = B[0].matrix_space() + W = self.parent().natural_basis_space() return W.linear_combination(zip(B,self.to_vector())) diff --git a/mjo/eja/eja_subalgebra.py b/mjo/eja/eja_subalgebra.py index e39792a..2318d12 100644 --- a/mjo/eja/eja_subalgebra.py +++ b/mjo/eja/eja_subalgebra.py @@ -313,6 +313,18 @@ class FiniteDimensionalEuclideanJordanElementSubalgebra(FiniteDimensionalEuclide return self.monomial(self.one_basis()) + def natural_basis_space(self): + """ + Return the natural basis space of this algebra, which is identical + to that of its superalgebra. + + This is correct "by definition," and avoids a mismatch when the + subalgebra is trivial (with no natural basis to infer anything + from) and the parent is not. + """ + return self.superalgebra().natural_basis_space() + + def superalgebra(self): """ Return the superalgebra that this algebra was generated from.