]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: ensure that the element inverse() always lives back in the EJA.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 26 Jul 2019 00:40:21 +0000 (20:40 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 29 Jul 2019 03:19:01 +0000 (23:19 -0400)
mjo/eja/euclidean_jordan_algebra.py

index 2fa4800b09f4f26ca784532e154cde1665ed7b84..a469bb0d7ba1302ccf30289c9b1c0c5518ed527f 100644 (file)
@@ -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