]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: add subalgebra() method for algebras.
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 24 Feb 2021 21:26:00 +0000 (16:26 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 24 Feb 2021 21:26:00 +0000 (16:26 -0500)
mjo/eja/eja_algebra.py
mjo/eja/eja_subalgebra.py

index 8005412e65da8b6192072420dffe794c7975b5d0..9ba146bc6e8fd6dc97dcf1f7d70058cd046528a4 100644 (file)
@@ -119,11 +119,12 @@ class FiniteDimensionalEJA(CombinatorialFreeModule):
         # Call the superclass constructor so that we can use its from_vector()
         # method to build our multiplication table.
         n = len(basis)
-        super().__init__(field,
-                         range(n),
-                         prefix=prefix,
-                         category=category,
-                         bracket=False)
+        CombinatorialFreeModule.__init__(self,
+                                         field,
+                                         range(n),
+                                         prefix=prefix,
+                                         category=category,
+                                         bracket=False)
 
         # Now comes all of the hard work. We'll be constructing an
         # ambient vector space V that our (vectorized) basis lives in,
@@ -3134,6 +3135,16 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct,
         except:
             raise ValueError("not an element of this algebra")
 
+    def subalgebra(self, basis, **kwargs):
+        r"""
+        Create a subalgebra of this algebra from the given basis.
+
+        This overrides the superclass method to use a special class
+        for Cartesian products.
+        """
+        from mjo.eja.eja_subalgebra import CartesianProductEJASubalgebra
+        return CartesianProductEJASubalgebra(self, basis, **kwargs)
+
     Element = CartesianProductEJAElement
 
 
index 3b8c67d6176320485ab30549d7cfdbbdc9a48ffa..e2d12d26b01a0deaedeb190d450dfd14ede3c262 100644 (file)
@@ -1,7 +1,11 @@
 from sage.matrix.constructor import matrix
 
-from mjo.eja.eja_algebra import FiniteDimensionalEJA
-from mjo.eja.eja_element import FiniteDimensionalEJAElement
+from sage.combinat.free_module import CombinatorialFreeModule_CartesianProduct
+
+from mjo.eja.eja_algebra import (CartesianProductEJA,
+                                 FiniteDimensionalEJA)
+from mjo.eja.eja_element import (CartesianProductEJAElement,
+                                 FiniteDimensionalEJAElement)
 
 class FiniteDimensionalEJASubalgebraElement(FiniteDimensionalEJAElement):
     """
@@ -230,3 +234,24 @@ class FiniteDimensionalEJASubalgebra(FiniteDimensionalEJA):
 
 
     Element = FiniteDimensionalEJASubalgebraElement
+
+
+
+class CartesianProductEJASubalgebraElement(CartesianProductEJAElement,
+                                           FiniteDimensionalEJASubalgebraElement):
+    pass
+
+class CartesianProductEJASubalgebra(CartesianProductEJA,
+                                    FiniteDimensionalEJASubalgebra):
+
+    def __init__(self, superalgebra, basis, **kwargs):
+        CombinatorialFreeModule_CartesianProduct.__init__(self,
+                                                          superalgebra.cartesian_factors())
+        FiniteDimensionalEJASubalgebra.__init__(self,
+                                                superalgebra,
+                                                basis,
+                                                cartesian_product=True,
+                                                **kwargs)
+
+
+    Element = CartesianProductEJASubalgebraElement