From: Michael Orlitzky Date: Wed, 2 Feb 2022 05:11:38 +0000 (-0500) Subject: eja: fix parent of empty sum in element inverse(). X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=1a8af0a2d9398932b8e4ac2b35a7fb4d7094654c;p=sage.d.git eja: fix parent of empty sum in element inverse(). --- diff --git a/mjo/eja/eja_element.py b/mjo/eja/eja_element.py index 6997766..85ec494 100644 --- a/mjo/eja/eja_element.py +++ b/mjo/eja/eja_element.py @@ -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)