sage: CP2.is_associative()
False
+ Cartesian products of Cartesian products work::
+
+ sage: J1 = JordanSpinEJA(1)
+ sage: J2 = JordanSpinEJA(1)
+ 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)) |
+ +--------------++---------+--------------+--------------+
+ sage: HadamardEJA(3).multiplication_table()
+ +----++----+----+----+
+ | * || e0 | e1 | e2 |
+ +====++====+====+====+
+ | e0 || e0 | 0 | 0 |
+ +----++----+----+----+
+ | e1 || 0 | e1 | 0 |
+ +----++----+----+----+
+ | e2 || 0 | 0 | e2 |
+ +----++----+----+----+
+
TESTS:
All factors must share the same base field::
r"""
Convert a monomial index into a generator index.
+ This is needed in product algebras because the multiplication
+ table is in terms of the generator indices.
+
SETUP::
sage: from mjo.eja.eja_algebra import random_eja
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.
+ # This works recursively so that we can handle Cartesian
+ # products of Cartesian products.
try:
+ # monomial is an ordered pair
factor = mon[0]
except TypeError: # 'int' object is not subscriptable
+ # base case where the monomials are integers
return mon
+
idx_in_factor = self._monomial_to_generator(mon[1])
offset = sum( f.dimension()
r"""
Scale the vector, matrix, or cartesian-product-of-those-things
``x`` by ``alpha``.
+
+ This works around the inability to scale certain elements of
+ Cartesian product spaces, as reported in
+
+ https://trac.sagemath.org/ticket/31435
+
+ ..WARNING:
+
+ This will do the wrong thing if you feed it a tuple or list.
+
+ SETUP::
+
+ sage: from mjo.eja.eja_utils import _scale
+
+ EXAMPLES::
+
+ sage: v = vector(QQ, (1,2,3))
+ sage: _scale(v,2)
+ (2, 4, 6)
+ sage: m = matrix(QQ, [[1,2],[3,4]])
+ sage: M = cartesian_product([m.parent(), m.parent()])
+ sage: _scale(M((m,m)), 2)
+ ([2 4]
+ [6 8], [2 4]
+ [6 8])
+
"""
if hasattr(x, 'cartesian_factors'):
P = x.parent()
else:
return x*alpha
+
def _all2list(x):
r"""
Flatten a vector, matrix, or cartesian product of those things