]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/eja_algebra.py
eja: factor out a separate class used by cartesian_product().
[sage.d.git] / mjo / eja / eja_algebra.py
index 9815ae48de66ebcb50fbc236d09875cc87cefb3a..1302ca18bf9988f57048cdd9035e79212aa7ca3d 100644 (file)
@@ -2742,9 +2742,7 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct,
 
     """
     def __init__(self, modules, **kwargs):
-        CombinatorialFreeModule_CartesianProduct.__init__(self,
-                                                          modules,
-                                                          **kwargs)
+        CombinatorialFreeModule_CartesianProduct.__init__(self, modules)
         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")
@@ -2762,25 +2760,20 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct,
             y = self.from_vector(_mat2vec(y_mat))
             return self.cartesian_inner_product(x,y)
 
+        # 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.
         FiniteDimensionalEJA.__init__(self,
                                       basis,
                                       jordan_product,
                                       inner_product,
                                       field=field,
-                                      orthonormalize=False,
                                       check_field=False,
                                       check_axioms=False,
-                                      category=self.category())
-        # TODO:
-        #
-        # Initialize the FDEJA class, too. Does this override the
-        # initialization that we did for the
-        # CombinatorialFreeModule_CartesianProduct class? If not, we
-        # will probably have to duplicate some of the work (i.e. one
-        # of the constructors).  Since the CartesianProduct one is
-        # smaller, that makes the most sense to copy/paste if it comes
-        # down to that.
-        #
+                                      category=self.category(),
+                                      **kwargs)
 
         self.rank.set_cache(sum(J.rank() for J in modules))
 
@@ -3047,5 +3040,23 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct,
     Element = FiniteDimensionalEJAElement
 
 
-FiniteDimensionalEJA.CartesianProduct = CartesianProductEJA
+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
 random_eja = ConcreteEJA.random_instance