From f292189be8e5a79f9ae2b80ddaff76460e0d14c2 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 24 Feb 2021 14:11:13 -0500 Subject: [PATCH] eja: add subalgebra() method. --- mjo/eja/eja_algebra.py | 19 +++++++++++++------ mjo/eja/eja_element.py | 6 +----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 51ff790..8005412 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -1029,14 +1029,12 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): if not c.is_idempotent(): raise ValueError("element is not idempotent: %s" % c) - from mjo.eja.eja_subalgebra import FiniteDimensionalEJASubalgebra - # Default these to what they should be if they turn out to be # trivial, because eigenspaces_left() won't return eigenvalues # corresponding to trivial spaces (e.g. it returns only the # eigenspace corresponding to lambda=1 if you take the # decomposition relative to the identity element). - trivial = FiniteDimensionalEJASubalgebra(self, ()) + trivial = self.subalgebra(()) J0 = trivial # eigenvalue zero J5 = VectorSpace(self.base_ring(), 0) # eigenvalue one-half J1 = trivial # eigenvalue one @@ -1046,9 +1044,7 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): J5 = eigspace else: gens = tuple( self.from_vector(b) for b in eigspace.basis() ) - subalg = FiniteDimensionalEJASubalgebra(self, - gens, - check_axioms=False) + subalg = self.subalgebra(gens, check_axioms=False) if eigval == 0: J0 = subalg elif eigval == 1: @@ -1267,6 +1263,17 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): return len(self._charpoly_coefficients()) + def subalgebra(self, basis, **kwargs): + r""" + Create a subalgebra of this algebra from the given basis. + + This is a simple wrapper around a subalgebra class constructor + that can be overridden in subclasses. + """ + from mjo.eja.eja_subalgebra import FiniteDimensionalEJASubalgebra + return FiniteDimensionalEJASubalgebra(self, basis, **kwargs) + + def vector_space(self): """ Return the vector space that underlies this algebra. diff --git a/mjo/eja/eja_element.py b/mjo/eja/eja_element.py index 4c9993a..42e5782 100644 --- a/mjo/eja/eja_element.py +++ b/mjo/eja/eja_element.py @@ -1413,12 +1413,8 @@ class FiniteDimensionalEJAElement(IndexedFreeModuleElement): True """ - from mjo.eja.eja_subalgebra import FiniteDimensionalEJASubalgebra powers = tuple( self**k for k in range(self.degree()) ) - A = FiniteDimensionalEJASubalgebra(self.parent(), - powers, - associative=True, - **kwargs) + A = self.parent().subalgebra(powers, associative=True, **kwargs) A.one.set_cache(A(self.parent().one())) return A -- 2.44.2