]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/eja_subalgebra.py
eja: fix trivial subalgebra element constructor.
[sage.d.git] / mjo / eja / eja_subalgebra.py
index 68f1ce4cf8b5f07087e4474069ad4ebe5c6a4998..c8bf548e2264edf8d2ee53d82f1dbf5e78ead8f7 100644 (file)
@@ -210,7 +210,17 @@ class FiniteDimensionalEJASubalgebra(FiniteDimensionalEJA):
 
         """
         if elt in self.superalgebra():
-            return super()._element_constructor_(elt.to_matrix())
+            # If the subalgebra is trivial, its _matrix_span will be empty
+            # but we still want to be able convert the superalgebra's zero()
+            # element into the subalgebra's zero() element. There's no great
+            # workaround for this because sage checks that your basis is
+            # linearly-independent everywhere, so we can't just give it a
+            # basis consisting of the zero element.
+            m = elt.to_matrix()
+            if self.is_trivial() and m.is_zero():
+                return self.zero()
+            else:
+                return super()._element_constructor_(m)
         else:
             return super()._element_constructor_(elt)
 
@@ -227,6 +237,10 @@ class FiniteDimensionalEJASubalgebra(FiniteDimensionalEJA):
         r"""
         Return the embedding from this subalgebra into the superalgebra.
 
+        SETUP::
+
+            sage: from mjo.eja.eja_algebra import HadamardEJA
+
         EXAMPLES::
 
             sage: J = HadamardEJA(4)