]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: fix the Hadamard/JordanSpinEJA fast path for charpoly_coefficients.
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 3 Dec 2020 22:39:49 +0000 (17:39 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 3 Dec 2020 22:39:49 +0000 (17:39 -0500)
mjo/eja/eja_algebra.py

index 52e27de8c0bb1a9bc69bdb433bd9641b07b2bb90..3d49005bda1ad3c987c654b11be1ea901da5af7b 100644 (file)
@@ -1200,36 +1200,29 @@ class RationalBasisEuclideanJordanAlgebra(FiniteDimensionalEuclideanJordanAlgebr
 
         V = VectorSpace(field, degree)
 
-        # If we were asked to orthonormalize, and if the orthonormal
-        # basis is different from the given one, then we also want to
-        # compute multiplication and inner-product tables for the
-        # deorthonormalized basis. These can be used later to
-        # construct a deorthonormalized copy of this algebra over QQ
-        # in which several operations are much faster.
+        # Save a copy of an algebra with the original, rational basis
+        # and over QQ where computations are fast.
         self._rational_algebra = None
 
-        if orthonormalize:
-            if self.base_ring() is not QQ:
-                # There's no point in constructing the extra algebra if this
-                # one is already rational. If the original basis is rational
-                # but normalization would make it irrational, then this whole
-                # constructor will just fail anyway as it tries to stick an
-                # irrational number into a rational algebra.
-                #
-                # Note: the same Jordan and inner-products work here,
-                # because they are necessarily defined with respect to
-                # ambient coordinates and not any particular basis.
-                self._rational_algebra = RationalBasisEuclideanJordanAlgebra(
-                                          basis,
-                                          jordan_product,
-                                          inner_product,
-                                          field=QQ,
-                                          orthonormalize=False,
-                                          prefix=prefix,
-                                          category=category,
-                                          check_field=False,
-                                          check_axioms=False)
+        if field is not QQ:
+            # There's no point in constructing the extra algebra if this
+            # one is already rational.
+            #
+            # Note: the same Jordan and inner-products work here,
+            # because they are necessarily defined with respect to
+            # ambient coordinates and not any particular basis.
+            self._rational_algebra = RationalBasisEuclideanJordanAlgebra(
+                                       basis,
+                                       jordan_product,
+                                       inner_product,
+                                       field=QQ,
+                                       orthonormalize=False,
+                                       prefix=prefix,
+                                       category=category,
+                                       check_field=False,
+                                       check_axioms=False)
 
+        if orthonormalize:
             # Compute the deorthonormalized tables before we orthonormalize
             # the given basis. The "check" parameter here guarantees that
             # the basis is linearly-independent.
@@ -1365,7 +1358,7 @@ class RationalBasisEuclideanJordanAlgebra(FiniteDimensionalEuclideanJordanAlgebr
             Algebraic Real Field
 
         """
-        if self.base_ring() is QQ or self._rational_algebra is None:
+        if self._rational_algebra is None:
             # There's no need to construct *another* algebra over the
             # rationals if this one is already over the
             # rationals. Likewise, if we never orthonormalized our