From e9cb8f877cfca9934dc67b6ab4f6ea585bba92d5 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 9 Nov 2020 11:59:21 -0500 Subject: [PATCH] eja: improve how we get the "real part" of a possibly-complex trace. --- mjo/eja/eja_algebra.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) 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] -- 2.44.2