]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: speed up construction of JordanSpinEJA and HadamardEJA.
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 2 Dec 2020 14:46:47 +0000 (09:46 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 2 Dec 2020 14:46:47 +0000 (09:46 -0500)
mjo/eja/eja_algebra.py

index 70be6ed43bb8d091d6f2b4565400f368bd75b741..e9f971f42164b2fc960b82724aa1cf29466c29d9 100644 (file)
@@ -1355,9 +1355,11 @@ class RationalBasisEuclideanJordanAlgebra(FiniteDimensionalEuclideanJordanAlgebr
             Algebraic Real Field
 
         """
-        if self.base_ring() is QQ:
+        if self.base_ring() is QQ or self._rational_algebra is None:
             # There's no need to construct *another* algebra over the
-            # rationals if this one is already over the rationals.
+            # rationals if this one is already over the
+            # rationals. Likewise, if we never orthonormalized our
+            # basis, we might as well just use the given one.
             superclass = super(RationalBasisEuclideanJordanAlgebra, self)
             return superclass._charpoly_coefficients()
 
@@ -2273,10 +2275,15 @@ class HadamardEJA(ConcreteEuclideanJordanAlgebra):
         def inner_product(x,y):
             return x.inner_product(y)
 
+        # Don't orthonormalize because our basis is already orthonormal
+        # with respect to our inner-product.
         super(HadamardEJA, self).__init__(field,
                                           basis,
                                           jordan_product,
                                           inner_product,
+                                          orthonormalize=False,
+                                          check_field=False,
+                                          check_axioms=False,
                                           **kwargs)
         self.rank.set_cache(n)
 
@@ -2500,10 +2507,18 @@ class JordanSpinEJA(BilinearFormEJA):
 
     """
     def __init__(self, n, field=AA, **kwargs):
-        # This is a special case of the BilinearFormEJA with the identity
-        # matrix as its bilinear form.
+        # This is a special case of the BilinearFormEJA with the
+        # identity matrix as its bilinear form.
         B = matrix.identity(field, n)
-        super(JordanSpinEJA, self).__init__(B, field, **kwargs)
+
+        # Don't orthonormalize because our basis is already
+        # orthonormal with respect to our inner-product.
+        super(JordanSpinEJA, self).__init__(B,
+                                            field,
+                                            orthonormalize=False,
+                                            check_field=False,
+                                            check_axioms=False,
+                                            **kwargs)
 
     @staticmethod
     def _max_random_instance_size():