]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: fix the natural representation in trivial subalgebras.
authorMichael Orlitzky <michael@orlitzky.com>
Sat, 10 Aug 2019 00:00:04 +0000 (20:00 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sat, 10 Aug 2019 00:00:04 +0000 (20:00 -0400)
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.

mjo/eja/eja_algebra.py
mjo/eja/eja_element.py
mjo/eja/eja_subalgebra.py

index 06f6f531ac46305da59ec2b4290ba808602cea50..42b2474d6971d81c8a1fcda67b079892a3e8af25 100644 (file)
@@ -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):
         """
index e1f75630bf5b3fc33292e4c84fa657fed715828a..aef1c5d2813660ced5d9fe66314b4f5fd7577a11 100644 (file)
@@ -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()))
 
 
index e39792a91732724b5fc7bc8b352e8fd977c80940..2318d12bfd0ebbfc765ca74766af9ab0e73ce02c 100644 (file)
@@ -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.