From cd902de2b1956ec808d084941b503ba7b08677d5 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 29 Jun 2019 13:26:13 -0400 Subject: [PATCH] eja: add det() and trace() for regular elements. --- mjo/eja/euclidean_jordan_algebra.py | 47 ++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index a55b7e3..2404af0 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -138,7 +138,33 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): if self.is_regular(): return self.minimal_polynomial() else: - return NotImplementedError('irregular element') + raise NotImplementedError('irregular element') + + + def det(self): + """ + Return my determinant, the product of my eigenvalues. + + EXAMPLES:: + + sage: J = eja_ln(2) + sage: e0,e1 = J.gens() + sage: x = e0 + e1 + sage: x.det() + 0 + sage: J = eja_ln(3) + sage: e0,e1,e2 = J.gens() + sage: x = e0 + e1 + e2 + sage: x.det() + -1 + + """ + cs = self.characteristic_polynomial().coefficients(sparse=False) + r = len(cs) - 1 + if r >= 0: + return cs[0] * (-1)**r + else: + raise ValueError('charpoly had no coefficients') def is_nilpotent(self): @@ -462,6 +488,25 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): return self.parent().linear_combination(zip(c_coordinates, basis)) + def trace(self): + """ + Return my trace, the sum of my eigenvalues. + + EXAMPLES:: + + sage: J = eja_ln(3) + sage: e0,e1,e2 = J.gens() + sage: x = e0 + e1 + e2 + sage: x.trace() + 2 + + """ + cs = self.characteristic_polynomial().coefficients(sparse=False) + if len(cs) >= 2: + return -1*cs[-2] + else: + raise ValueError('charpoly had fewer than 2 coefficients') + def eja_rn(dimension, field=QQ): """ -- 2.44.2