From: Michael Orlitzky Date: Mon, 22 Feb 2021 18:04:43 +0000 (-0500) Subject: eja: define matrix basis/space for Cartesian product algebras. X-Git-Url: http://gitweb.michael.orlitzky.com/?p=sage.d.git;a=commitdiff_plain;h=0f9127108539899f95e7e645eeab0d0b956af7f9 eja: define matrix basis/space for Cartesian product algebras. --- diff --git a/mjo/eja/TODO b/mjo/eja/TODO index 03bf404..93aa9fb 100644 --- a/mjo/eja/TODO +++ b/mjo/eja/TODO @@ -1,10 +1,7 @@ -1. Finish CartesianProductEJA: add to_matrix(), - random_instance(),... methods. This will require rethinking what a - "matrix representation" and "matrix space" means for a cartesian - product algebra. Do we want our matrix basis to consist of ordered - pairs (or triples, or...)? Should the matrix_space() of the algebra - be the cartesian product of the factors' matrix spaces? Can we just - fix the matrix basis/space after we call the FDEJA initializer? +1. Finish CartesianProductEJA: add to_matrix(), random_instance(),... + methods. I guess we should create a separate class hierarchy for + Cartesian products of RationalBasisEJA? That way we get fast + charpoly and random_instance() defined... 2. Add references and start citing them. diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 850447b..0653396 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -2836,6 +2836,45 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct, self.one.set_cache(self._cartesian_product_of_elements(ones)) self.rank.set_cache(sum(J.rank() for J in modules)) + # Now that everything else is ready, we clobber our computed + # matrix basis with the "correct" one consisting of ordered + # tuples. Since we didn't orthonormalize our basis, we can + # create these from the basis that was handed to us; that is, + # we don't need to use the one that the earlier __init__() + # method came up with. + m = len(self.cartesian_factors()) + MS = self.matrix_space() + self._matrix_basis = tuple( + MS(tuple( self.cartesian_projection(i)(b).to_matrix() + for i in range(m) )) + for b in self.basis() + ) + + def matrix_space(self): + r""" + Return the space that our matrix basis lives in as a Cartesian + product. + + SETUP:: + + sage: from mjo.eja.eja_algebra import (HadamardEJA, + ....: RealSymmetricEJA) + + EXAMPLES:: + + sage: J1 = HadamardEJA(1) + sage: J2 = RealSymmetricEJA(2) + sage: J = cartesian_product([J1,J2]) + sage: J.matrix_space() + The Cartesian product of (Full MatrixSpace of 1 by 1 dense + matrices over Algebraic Real Field, Full MatrixSpace of 2 + by 2 dense matrices over Algebraic Real Field) + + """ + from sage.categories.cartesian_product import cartesian_product + return cartesian_product( [J.matrix_space() + for J in self.cartesian_factors()] ) + @cached_method def cartesian_projection(self, i): r""" @@ -3096,6 +3135,31 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct, return sum( P(x).inner_product(P(y)) for P in projections ) + def _element_constructor_(self, elt): + r""" + Construct an element of this algebra from an ordered tuple. + + We just apply the element constructor from each of our factors + to the corresponding component of the tuple, and package up + the result. + + SETUP:: + + sage: from mjo.eja.eja_algebra import (HadamardEJA, + ....: RealSymmetricEJA) + + EXAMPLES:: + + sage: J1 = HadamardEJA(3) + sage: J2 = RealSymmetricEJA(2) + sage: J = cartesian_product([J1,J2]) + sage: J( (J1.matrix_basis()[1], J2.matrix_basis()[2]) ) + e(0, 1) + e(1, 2) + """ + m = len(self.cartesian_factors()) + z = tuple( self.cartesian_factors()[i](elt[i]) for i in range(m) ) + return self._cartesian_product_of_elements(z) + Element = FiniteDimensionalEJAElement