]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: make an inverse() test work in trivial algebras.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 6 Nov 2020 22:42:49 +0000 (17:42 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 6 Nov 2020 22:42:49 +0000 (17:42 -0500)
mjo/eja/eja_element.py

index c5cbef9ebca32c2789ece22b0f9c4c46e6fb34a2..de12bb10604094e9b90ffb89a335514c4811d2aa 100644 (file)
@@ -438,11 +438,11 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement):
             sage: while not x.is_invertible():
             ....:     x = J.random_element()
             sage: x_vec = x.to_vector()
-            sage: x0 = x_vec[0]
+            sage: x0 = x_vec[:1]
             sage: x_bar = x_vec[1:]
-            sage: coeff = ~(x0^2 - x_bar.inner_product(x_bar))
-            sage: inv_vec = x_vec.parent()([x0] + (-x_bar).list())
-            sage: x_inverse = coeff*inv_vec
+            sage: coeff = x0.inner_product(x0) - x_bar.inner_product(x_bar)
+            sage: x_inverse = x_vec.parent()(x0.list() + (-x_bar).list())
+            sage: if not coeff.is_zero(): x_inverse = x_inverse/coeff
             sage: x.inverse() == J.from_vector(x_inverse)
             True