]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: add rational-basis subclass for Cartesian products.
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 25 Feb 2021 16:51:38 +0000 (11:51 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 25 Feb 2021 16:51:38 +0000 (11:51 -0500)
mjo/eja/TODO
mjo/eja/eja_algebra.py

index 103e8d1017eb5589b6bc5eedcc91655eb13d8c0d..90a49d3a120d4914c8b0664f2d2405f6a5b8b8ab 100644 (file)
@@ -1,7 +1,4 @@
-1. Finish CartesianProductEJA: add random_instance() method and
-   optimize. I guess I should create a separate class hierarchy for
-   Cartesian products of RationalBasisEJA? That way we get fast
-   charpoly and random_instance() defined...
+1. Add cartesian products to random_eja().
 
 2. Add references and start citing them.
 
index d38ba87d37d3e6bdb01e23c7a9631bf98ee2c96c..6048363d64402b91326ea599b109c238574f7cf8 100644 (file)
@@ -3210,4 +3210,42 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct,
 
 FiniteDimensionalEJA.CartesianProduct = CartesianProductEJA
 
+class RationalBasisCartesianProductEJA(CartesianProductEJA,
+                                       RationalBasisEJA):
+    r"""
+    A separate class for products of algebras for which we know a
+    rational basis.
+
+    SETUP::
+
+        sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
+        ....:                                  RealSymmetricEJA)
+
+    EXAMPLES:
+
+    This gives us fast characteristic polynomial computations in
+    product algebras, too::
+
+
+        sage: J1 = JordanSpinEJA(2)
+        sage: J2 = RealSymmetricEJA(3)
+        sage: J = cartesian_product([J1,J2])
+        sage: J.characteristic_polynomial_of().degree()
+        5
+        sage: J.rank()
+        5
+
+    """
+    def __init__(self, algebras, **kwargs):
+        CartesianProductEJA.__init__(self, algebras, **kwargs)
+
+        self._rational_algebra = None
+        if self.vector_space().base_field() is not QQ:
+            self._rational_algebra = cartesian_product([
+                r._rational_algebra for r in algebras
+            ])
+
+
+RationalBasisEJA.CartesianProduct = RationalBasisCartesianProductEJA
+
 random_eja = ConcreteEJA.random_instance