From 1a8af0a2d9398932b8e4ac2b35a7fb4d7094654c Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 2 Feb 2022 00:11:38 -0500 Subject: [PATCH] eja: fix parent of empty sum in element inverse(). --- mjo/eja/eja_element.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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) -- 2.43.2