X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feja_algebra.py;h=cbe5c08a344a95248e0b7c15e94de80b0c662816;hb=c49406021cb8496ead26ef89865f8afbdc96ea6c;hp=40b4bcac6583e75f6877260f633d752b6693d8d7;hpb=86ec96a9ff510b4b3d178998d63b0ce9a374c444;p=sage.d.git diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 40b4bca..cbe5c08 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -460,9 +460,7 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): this algebra was constructed with ``check_axioms=False`` and passed an invalid multiplication table. """ - return all( self.product_on_basis(i,j) == self.product_on_basis(i,j) - for i in range(self.dimension()) - for j in range(self.dimension()) ) + return all( x*y == y*x for x in self.gens() for y in self.gens() ) def _is_jordanian(self): r""" @@ -931,7 +929,7 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): # And to each subsequent row, prepend an entry that belongs to # the left-side "header column." - M += [ [self.gens()[i]] + [ self.product_on_basis(i,j) + M += [ [self.gens()[i]] + [ self.gens()[i]*self.gens()[j] for j in range(n) ] for i in range(n) ] @@ -1994,11 +1992,11 @@ class RealSymmetricEJA(ConcreteEJA, RealMatrixEJA): if n <= 1: associative = True - super(RealSymmetricEJA, self).__init__(self._denormalized_basis(n), - self.jordan_product, - self.trace_inner_product, - associative=associative, - **kwargs) + super().__init__(self._denormalized_basis(n), + self.jordan_product, + self.trace_inner_product, + associative=associative, + **kwargs) # TODO: this could be factored out somehow, but is left here # because the MatrixEJA is not presently a subclass of the @@ -2088,7 +2086,7 @@ class ComplexMatrixEJA(MatrixEJA): True """ - super(ComplexMatrixEJA,cls).real_embed(M) + super().real_embed(M) n = M.nrows() # We don't need any adjoined elements... @@ -2135,7 +2133,7 @@ class ComplexMatrixEJA(MatrixEJA): True """ - super(ComplexMatrixEJA,cls).real_unembed(M) + super().real_unembed(M) n = ZZ(M.nrows()) d = cls.dimension_over_reals() F = cls.complex_extension(M.base_ring()) @@ -2287,11 +2285,11 @@ class ComplexHermitianEJA(ConcreteEJA, ComplexMatrixEJA): if n <= 1: associative = True - super(ComplexHermitianEJA, self).__init__(self._denormalized_basis(n), - self.jordan_product, - self.trace_inner_product, - associative=associative, - **kwargs) + super().__init__(self._denormalized_basis(n), + self.jordan_product, + self.trace_inner_product, + associative=associative, + **kwargs) # TODO: this could be factored out somehow, but is left here # because the MatrixEJA is not presently a subclass of the # FDEJA class that defines rank() and one(). @@ -2374,7 +2372,7 @@ class QuaternionMatrixEJA(MatrixEJA): True """ - super(QuaternionMatrixEJA,cls).real_embed(M) + super().real_embed(M) quaternions = M.base_ring() n = M.nrows() @@ -2429,7 +2427,7 @@ class QuaternionMatrixEJA(MatrixEJA): True """ - super(QuaternionMatrixEJA,cls).real_unembed(M) + super().real_unembed(M) n = ZZ(M.nrows()) d = cls.dimension_over_reals() @@ -2598,11 +2596,11 @@ class QuaternionHermitianEJA(ConcreteEJA, QuaternionMatrixEJA): if n <= 1: associative = True - super(QuaternionHermitianEJA, self).__init__(self._denormalized_basis(n), - self.jordan_product, - self.trace_inner_product, - associative=associative, - **kwargs) + super().__init__(self._denormalized_basis(n), + self.jordan_product, + self.trace_inner_product, + associative=associative, + **kwargs) # TODO: this could be factored out somehow, but is left here # because the MatrixEJA is not presently a subclass of the @@ -2835,11 +2833,11 @@ class BilinearFormEJA(ConcreteEJA): if n <= 2: associative = True - super(BilinearFormEJA, self).__init__(column_basis, - jordan_product, - inner_product, - associative=associative, - **kwargs) + super().__init__(column_basis, + jordan_product, + inner_product, + associative=associative, + **kwargs) # The rank of this algebra is two, unless we're in a # one-dimensional ambient space (because the rank is bounded @@ -2944,7 +2942,7 @@ class JordanSpinEJA(BilinearFormEJA): # But also don't pass check_field=False here, because the user # can pass in a field! - super(JordanSpinEJA, self).__init__(B, **kwargs) + super().__init__(B, **kwargs) @staticmethod def _max_random_instance_size(): @@ -3002,11 +3000,11 @@ class TrivialEJA(ConcreteEJA): if "orthonormalize" not in kwargs: kwargs["orthonormalize"] = False if "check_axioms" not in kwargs: kwargs["check_axioms"] = False - super(TrivialEJA, self).__init__(basis, - jordan_product, - inner_product, - associative=True, - **kwargs) + super().__init__(basis, + jordan_product, + inner_product, + associative=True, + **kwargs) # The rank is zero using my definition, namely the dimension of the # largest subalgebra generated by any element. @@ -3198,6 +3196,65 @@ 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() ) + + """ + # 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. + factor = mon[0] + idx_in_factor = 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``. + + This overrides the superclass method because here, both ``i`` + and ``j`` will be ordered pairs. + + SETUP:: + + sage: from mjo.eja.eja_algebra import (QuaternionHermitianEJA, + ....: RealSymmetricEJA) + + TESTS:: + + 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() + True + sage: x*x == x + True + + """ + 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""" Return the space that our matrix basis lives in as a Cartesian