From: Michael Orlitzky Date: Sat, 27 Feb 2021 16:23:50 +0000 (-0500) Subject: eja: complete the CFM_CartesianProduct purge. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=45f207f28a8396426469fedb026b4da82e30fbf5;p=sage.d.git eja: complete the CFM_CartesianProduct purge. --- diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 1040d37..558ff6b 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -213,7 +213,10 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): # Element subalgebras can take advantage of this. category = category.Associative() if cartesian_product: - category = category.CartesianProducts() + # Use join() here because otherwise we only get the + # "Cartesian product of..." and not the things themselves. + category = category.join([category, + category.CartesianProducts()]) # Call the superclass constructor so that we can use its from_vector() # method to build our multiplication table. @@ -361,8 +364,8 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): sage: if n > 0: ....: i = ZZ.random_element(n) ....: j = ZZ.random_element(n) - ....: ei = J.gens()[i] - ....: ej = J.gens()[j] + ....: ei = J.monomial(i) + ....: ej = J.monomial(j) ....: ei_ej = J.product_on_basis(i,j) sage: ei*ej == ei_ej True @@ -473,9 +476,9 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): return ``True``, unless this algebra was constructed with ``check_axioms=False`` and passed an invalid multiplication table. """ - return all( (self.gens()[i]**2)*(self.gens()[i]*self.gens()[j]) + return all( (self.monomial(i)**2)*(self.monomial(i)*self.monomial(j)) == - (self.gens()[i])*((self.gens()[i]**2)*self.gens()[j]) + (self.monomial(i))*((self.monomial(i)**2)*self.monomial(j)) for i in range(self.dimension()) for j in range(self.dimension()) ) @@ -555,9 +558,9 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): for i in range(self.dimension()): for j in range(self.dimension()): for k in range(self.dimension()): - x = self.gens()[i] - y = self.gens()[j] - z = self.gens()[k] + x = self.monomial(i) + y = self.monomial(j) + z = self.monomial(k) diff = (x*y)*z - x*(y*z) if diff.norm() > epsilon: @@ -586,9 +589,9 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): for i in range(self.dimension()): for j in range(self.dimension()): for k in range(self.dimension()): - x = self.gens()[i] - y = self.gens()[j] - z = self.gens()[k] + x = self.monomial(i) + y = self.monomial(j) + z = self.monomial(k) diff = (x*y).inner_product(z) - x.inner_product(y*z) if diff.abs() > epsilon: @@ -636,7 +639,7 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): 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) + e1 + e5 TESTS: @@ -929,7 +932,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.gens()[i]*self.gens()[j] + M += [ [self.monomial(i)] + [ self.monomial(i)*self.monomial(j) for j in range(n) ] for i in range(n) ] @@ -1431,7 +1434,7 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): def L_x_i_j(i,j): # From a result in my book, these are the entries of the # basis representation of L_x. - return sum( vars[k]*self.gens()[k].operator().matrix()[i,j] + return sum( vars[k]*self.monomial(k).operator().matrix()[i,j] for k in range(n) ) L_x = matrix(F, n, n, L_x_i_j) @@ -3121,15 +3124,15 @@ class CartesianProductEJA(FiniteDimensionalEJA): sage: J3 = JordanSpinEJA(1) sage: J = cartesian_product([J1,cartesian_product([J2,J3])]) sage: J.multiplication_table() - +--------------++---------+--------------+--------------+ - | * || e(0, 0) | e(1, (0, 0)) | e(1, (1, 0)) | - +==============++=========+==============+==============+ - | e(0, 0) || e(0, 0) | 0 | 0 | - +--------------++---------+--------------+--------------+ - | e(1, (0, 0)) || 0 | e(1, (0, 0)) | 0 | - +--------------++---------+--------------+--------------+ - | e(1, (1, 0)) || 0 | 0 | e(1, (1, 0)) | - +--------------++---------+--------------+--------------+ + +----++----+----+----+ + | * || e0 | e1 | e2 | + +====++====+====+====+ + | e0 || e0 | 0 | 0 | + +----++----+----+----+ + | e1 || 0 | e1 | 0 | + +----++----+----+----+ + | e2 || 0 | 0 | e2 | + +----++----+----+----+ sage: HadamardEJA(3).multiplication_table() +----++----+----+----+ | * || e0 | e1 | e2 | @@ -3195,12 +3198,14 @@ class CartesianProductEJA(FiniteDimensionalEJA): # Define jordan/inner products that operate on that matrix_basis. def jordan_product(x,y): return MS(tuple( - (factors[i](x[i])*factors[i](y[i])).to_matrix() for i in range(m) + (factors[i](x[i])*factors[i](y[i])).to_matrix() + for i in range(m) )) def inner_product(x, y): return sum( - factors[i](x[i]).inner_product(factors[i](y[i])) for i in range(m) + factors[i](x[i]).inner_product(factors[i](y[i])) + for i in range(m) ) # There's no need to check the field since it already came @@ -3225,8 +3230,21 @@ class CartesianProductEJA(FiniteDimensionalEJA): self.rank.set_cache(sum(J.rank() for J in factors)) def cartesian_factors(self): + # Copy/pasted from CombinatorialFreeModule_CartesianProduct. return self._sets + def cartesian_factor(self, i): + r""" + Return the ``i``th factor of this algebra. + """ + return self._sets[i] + + def _repr_(self): + # Copy/pasted from CombinatorialFreeModule_CartesianProduct. + from sage.categories.cartesian_product import cartesian_product + return cartesian_product.symbol.join("%s" % factor + for factor in self._sets) + def matrix_space(self): r""" Return the space that our matrix basis lives in as a Cartesian @@ -3322,10 +3340,10 @@ class CartesianProductEJA(FiniteDimensionalEJA): True """ - Ji = self.cartesian_factors()[i] - - Pi = self._module_morphism(lambda j_t: Ji.monomial(j_t[1]) - if i == j_t[0] else Ji.zero(), + offset = sum( self.cartesian_factor(k).dimension() + for k in range(i) ) + Ji = self.cartesian_factor(i) + Pi = self._module_morphism(lambda j: Ji.monomial(j - offset), codomain=Ji) return FiniteDimensionalEJAOperator(self,Ji,Pi.matrix()) @@ -3433,8 +3451,10 @@ class CartesianProductEJA(FiniteDimensionalEJA): True """ - Ji = self.cartesian_factors()[i] - Ei = Ji._module_morphism(lambda t: self.monomial((i, t)), + offset = sum( self.cartesian_factor(k).dimension() + for k in range(i) ) + Ji = self.cartesian_factor(i) + Ei = Ji._module_morphism(lambda j: self.monomial(j + offset), codomain=self) return FiniteDimensionalEJAOperator(Ji,self,Ei.matrix()) diff --git a/mjo/eja/eja_element.py b/mjo/eja/eja_element.py index 9a770ae..e8c183b 100644 --- a/mjo/eja/eja_element.py +++ b/mjo/eja/eja_element.py @@ -664,7 +664,7 @@ class FiniteDimensionalEJAElement(IndexedFreeModuleElement): element should always be in terms of minimal idempotents:: sage: J = JordanSpinEJA(4) - sage: x = sum( i*J.gens()[i] for i in range(len(J.gens())) ) + sage: x = sum( i*J.monomial(i) for i in range(len(J.gens())) ) sage: x.is_regular() True sage: [ c.is_primitive_idempotent()