From: Michael Orlitzky Date: Mon, 9 Nov 2020 16:59:21 +0000 (-0500) Subject: eja: improve how we get the "real part" of a possibly-complex trace. X-Git-Url: http://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=e9cb8f877cfca9934dc67b6ab4f6ea585bba92d5;p=sage.d.git eja: improve how we get the "real part" of a possibly-complex trace. --- diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 10b8eb3..4bef201 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -1258,16 +1258,11 @@ class MatrixEuclideanJordanAlgebra(FiniteDimensionalEuclideanJordanAlgebra): Yu = cls.real_unembed(Y) tr = (Xu*Yu).trace() - if tr in RLF: - # It's real already. - return tr - - # Otherwise, try the thing that works for complex numbers; and - # if that doesn't work, the thing that works for quaternions. try: - return tr.vector()[0] # real part, imag part is index 1 + # Works in QQ, AA, RDF, et cetera. + return tr.real() except AttributeError: - # A quaternions doesn't have a vector() method, but does + # A quaternion doesn't have a real() method, but does # have coefficient_tuple() method that returns the # coefficients of 1, i, j, and k -- in that order. return tr.coefficient_tuple()[0]