]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/eja_algebra.py
eja: add another Cartesian product test.
[sage.d.git] / mjo / eja / eja_algebra.py
index 1302ca18bf9988f57048cdd9035e79212aa7ca3d..ccc5006f3d79397d81ad98bbf45a7262e36dd6e9 100644 (file)
@@ -2690,7 +2690,8 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct,
 
     SETUP::
 
-        sage: from mjo.eja.eja_algebra import (CartesianProductEJA,
+        sage: from mjo.eja.eja_algebra import (random_eja,
+        ....:                                  CartesianProductEJA,
         ....:                                  HadamardEJA,
         ....:                                  JordanSpinEJA,
         ....:                                  RealSymmetricEJA)
@@ -2740,9 +2741,24 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct,
         ...
         ValueError: all factors must share the same base field
 
+    The "cached" Jordan and inner products are the componentwise
+    ones::
+
+        sage: set_random_seed()
+        sage: J1 = random_eja()
+        sage: J2 = random_eja()
+        sage: J = cartesian_product([J1,J2])
+        sage: x,y = J.random_elements(2)
+        sage: x*y == J.cartesian_jordan_product(x,y)
+        True
+        sage: x.inner_product(y) == J.cartesian_inner_product(x,y)
+        True
+
     """
     def __init__(self, modules, **kwargs):
-        CombinatorialFreeModule_CartesianProduct.__init__(self, modules)
+        CombinatorialFreeModule_CartesianProduct.__init__(self,
+                                                          modules,
+                                                          **kwargs)
         field = modules[0].base_ring()
         if not all( J.base_ring() == field for J in modules ):
             raise ValueError("all factors must share the same base field")
@@ -2763,17 +2779,19 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct,
         # Use whatever category the superclass came up with. Usually
         # some join of the EJA and Cartesian product
         # categories. There's no need to check the field since it
-        # already came from an EJA. Likewise the axioms are guaranteed
-        # to be satisfied.
+        # already came from an EJA.
+        #
+        # If you want the basis to be orthonormalized, orthonormalize
+        # the factors.
         FiniteDimensionalEJA.__init__(self,
                                       basis,
                                       jordan_product,
                                       inner_product,
                                       field=field,
+                                      orthonormalize=False,
                                       check_field=False,
                                       check_axioms=False,
-                                      category=self.category(),
-                                      **kwargs)
+                                      category=self.category())
 
         self.rank.set_cache(sum(J.rank() for J in modules))
 
@@ -3040,23 +3058,5 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct,
     Element = FiniteDimensionalEJAElement
 
 
-class FiniteDimensionalEJA_CartesianProduct(CartesianProductEJA):
-    r"""
-    A wrapper around the :class:`CartesianProductEJA` class that gets
-    used by the ``cartesian_product`` functor. Its one job is to set
-    ``orthonormalize=False``, since ``cartesian_product()`` can't be
-    made to pass that option through. And if we try to orthonormalize
-    over the rationals, we get conversion errors. If you want a non-
-    standard Jordan product or inner product, or if you want to
-    orthonormalize the basis, use :class:`CartesianProductEJA`
-    directly.
-    """
-    def __init__(self, modules, **options):
-        CombinatorialFreeModule_CartesianProduct.__init__(self,
-                                                          modules,
-                                                          **options)
-        CartesianProductEJA.__init__(self, modules, orthonormalize=False)
-
-
-FiniteDimensionalEJA.CartesianProduct = FiniteDimensionalEJA_CartesianProduct
+FiniteDimensionalEJA.CartesianProduct = CartesianProductEJA
 random_eja = ConcreteEJA.random_instance