From: Michael Orlitzky Date: Thu, 3 Dec 2020 22:39:49 +0000 (-0500) Subject: eja: fix the Hadamard/JordanSpinEJA fast path for charpoly_coefficients. X-Git-Url: http://gitweb.michael.orlitzky.com/?p=sage.d.git;a=commitdiff_plain;h=985862996b2f6017a8e1f09a789f6670b2e9337f eja: fix the Hadamard/JordanSpinEJA fast path for charpoly_coefficients. --- 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