# 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.
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
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()) )
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:
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:
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:
# 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) ]
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)
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 |
# 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
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
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())
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())