From 985862996b2f6017a8e1f09a789f6670b2e9337f Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 3 Dec 2020 17:39:49 -0500 Subject: [PATCH] eja: fix the Hadamard/JordanSpinEJA fast path for charpoly_coefficients. --- mjo/eja/eja_algebra.py | 49 ++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 52e27de..3d49005 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -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 -- 2.44.2