From 8f7ecef93d07a3f969d1c944c80b75a7052a4975 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 25 Jul 2019 20:40:21 -0400 Subject: [PATCH] eja: ensure that the element inverse() always lives back in the EJA. --- mjo/eja/euclidean_jordan_algebra.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 2fa4800..a469bb0 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -699,14 +699,13 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): True """ + if not self.is_invertible(): + raise ValueError("element not invertible") + if self.parent().is_associative(): elt = FiniteDimensionalAlgebraElement(self.parent(), self) - return elt.inverse() - - # TODO: we can do better once the call to is_invertible() - # doesn't crash on irregular elements. - #if not self.is_invertible(): - # raise ValueError('element is not invertible') + # elt is in the right coordinates, but has the wrong class. + return self.parent()(elt.inverse().vector()) # We do this a little different than the usual recursive # call to a finite-dimensional algebra element, because we -- 2.44.2