]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/eja_algebra.py
eja: more tests/examples.
[sage.d.git] / mjo / eja / eja_algebra.py
index ad619f667a853e191f254aa32aaed3664e27f6a5..5d96a53f402f4f3343cc396049b4311d13fa3ba1 100644 (file)
@@ -3115,6 +3115,33 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct,
         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::
@@ -3200,6 +3227,9 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct,
         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
@@ -3216,15 +3246,15 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct,
             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()