X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feja_algebra.py;h=ad619f667a853e191f254aa32aaed3664e27f6a5;hb=f85bca2ff71a537c82fae3736944ce8896c30251;hp=00de418a36cca4ecdf7bd6c6e70daf7cc8531344;hpb=429dda48b69d960fb71a3e321b07097d2eae6965;p=sage.d.git diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 00de418..ad619f6 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -3196,6 +3196,41 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct, self.one.set_cache(self._cartesian_product_of_elements(ones)) self.rank.set_cache(sum(J.rank() for J in algebras)) + def _monomial_to_generator(self, mon): + r""" + Convert a monomial index into a generator index. + + SETUP:: + + sage: from mjo.eja.eja_algebra import random_eja + + TESTS:: + + sage: J1 = random_eja(field=QQ, orthonormalize=False) + sage: J2 = random_eja(field=QQ, orthonormalize=False) + sage: J = cartesian_product([J1,J2]) + sage: all( J.monomial(m) + ....: == + ....: J.gens()[J._monomial_to_generator(m)] + ....: for m in J.basis().keys() ) + True + + """ + # The superclass method indexes into a matrix, so we have to + # turn the tuples i and j into integers. This is easy enough + # given that the first coordinate of i and j corresponds to + # the factor, and the second coordinate corresponds to the + # index of the generator within that factor. + try: + factor = mon[0] + except TypeError: # 'int' object is not subscriptable + return mon + idx_in_factor = self._monomial_to_generator(mon[1]) + + offset = sum( f.dimension() + for f in self.cartesian_factors()[:factor] ) + return offset + idx_in_factor + def product_on_basis(self, i, j): r""" Return the product of the monomials indexed by ``i`` and ``j``. @@ -3205,37 +3240,40 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct, SETUP:: - sage: from mjo.eja.eja_algebra import (ComplexHermitianEJA, + sage: from mjo.eja.eja_algebra import (HadamardEJA, ....: JordanSpinEJA, - ....: RealSymmetricEJA) + ....: QuaternionHermitianEJA, + ....: RealSymmetricEJA,) + + EXAMPLES:: + + sage: J1 = JordanSpinEJA(2, field=QQ) + sage: J2 = RealSymmetricEJA(2, field=QQ, orthonormalize=False) + sage: J3 = HadamardEJA(1, field=QQ) + sage: K1 = cartesian_product([J1,J2]) + sage: K2 = cartesian_product([K1,J3]) + sage: list(K2.basis()) + [e(0, (0, 0)), e(0, (0, 1)), e(0, (1, 0)), e(0, (1, 1)), + e(0, (1, 2)), e(1, 0)] + sage: g = K2.gens() + sage: (g[0] + 2*g[3]) * (g[1] - 4*g[2]) + e(0, (0, 1)) - 4*e(0, (1, 1)) TESTS:: - sage: J1 = RealSymmetricEJA(2,field=QQ,orthonormalize=False) - sage: J2 = ComplexHermitianEJA(0,field=QQ,orthonormalize=False) - sage: J3 = JordanSpinEJA(2,field=QQ,orthonormalize=False) - sage: J = cartesian_product([J1,J2,J3]) + sage: J1 = RealSymmetricEJA(1,field=QQ) + sage: J2 = QuaternionHermitianEJA(1,field=QQ) + sage: J = cartesian_product([J1,J2]) sage: x = sum(J.gens()) - sage: x*J.one() - e(0, 0) + e(0, 1) + e(0, 2) + e(2, 0) + e(2, 1) - sage: x*x - 2*e(0, 0) + 2*e(0, 1) + 2*e(0, 2) + 2*e(2, 0) + 2*e(2, 1) + sage: x == J.one() + True + sage: x*x == x + True """ - factor = i[0] - assert(j[0] == i[0]) - n = self.cartesian_factors()[factor].dimension() - - # The superclass method indexes into a matrix, so we have to - # turn the tuples i and j into integers. This is easy enough - # given that the first coordinate of i and j corresponds to - # the factor, and the second coordinate corresponds to the - # index of the generator within that factor. And of course - # we should never be multiplying two elements from different - # factors. - l = n*factor + i[1] - m = n*factor + j[1] - super().product_on_basis(l, m) + l = self._monomial_to_generator(i) + m = self._monomial_to_generator(j) + return FiniteDimensionalEJA.product_on_basis(self, l, m) def matrix_space(self): r""" @@ -3488,3 +3526,16 @@ class RationalBasisCartesianProductEJA(CartesianProductEJA, RationalBasisEJA.CartesianProduct = RationalBasisCartesianProductEJA random_eja = ConcreteEJA.random_instance + +# def random_eja(*args, **kwargs): +# J1 = ConcreteEJA.random_instance(*args, **kwargs) + +# # This might make Cartesian products appear roughly as often as +# # any other ConcreteEJA. +# if ZZ.random_element(len(ConcreteEJA.__subclasses__()) + 1) == 0: +# # Use random_eja() again so we can get more than two factors. +# J2 = random_eja(*args, **kwargs) +# J = cartesian_product([J1,J2]) +# return J +# else: +# return J1