]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: fix parent of empty sum in element inverse().
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 2 Feb 2022 05:11:38 +0000 (00:11 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 2 Feb 2022 05:11:38 +0000 (00:11 -0500)
mjo/eja/eja_element.py

index 6997766319798e5188683972c303ce450f0303e3..85ec494e53beaf05c788dbd5b04a23a18c0952d6 100644 (file)
@@ -506,15 +506,18 @@ class FiniteDimensionalEJAElement(IndexedFreeModuleElement):
             True
         """
         not_invertible_msg = "element is not invertible"
-        if self.parent()._charpoly_coefficients.is_in_cache():
+
+        algebra = self.parent()
+        if algebra._charpoly_coefficients.is_in_cache():
             # We can invert using our charpoly if it will be fast to
             # compute. If the coefficients are cached, our rank had
             # better be too!
             if self.det().is_zero():
                 raise ZeroDivisionError(not_invertible_msg)
-            r = self.parent().rank()
+            r = algebra.rank()
             a = self.characteristic_polynomial().coefficients(sparse=False)
-            return (-1)**(r+1)*sum(a[i+1]*self**i for i in range(r))/self.det()
+            return (-1)**(r+1)*algebra.sum(a[i+1]*self**i
+                                           for i in range(r))/self.det()
 
         try:
             inv = (~self.quadratic_representation())(self)