From 3baadd6fb5c765caab2bd57d1d6ed764b03d53b3 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 24 Feb 2021 16:26:00 -0500 Subject: [PATCH] eja: add subalgebra() method for algebras. --- mjo/eja/eja_algebra.py | 21 ++++++++++++++++----- mjo/eja/eja_subalgebra.py | 29 +++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 8005412..9ba146b 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -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 diff --git a/mjo/eja/eja_subalgebra.py b/mjo/eja/eja_subalgebra.py index 3b8c67d..e2d12d2 100644 --- a/mjo/eja/eja_subalgebra.py +++ b/mjo/eja/eja_subalgebra.py @@ -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 -- 2.44.2