From: Michael Orlitzky Date: Mon, 23 Nov 2020 03:39:59 +0000 (-0500) Subject: eja: use cached charpoly for element inverse when available. X-Git-Url: http://gitweb.michael.orlitzky.com/?p=sage.d.git;a=commitdiff_plain;h=f02d09e53017ba3b3b5592a45be84487c580379d eja: use cached charpoly for element inverse when available. --- diff --git a/mjo/eja/TODO b/mjo/eja/TODO index 220a701..94fb172 100644 --- a/mjo/eja/TODO +++ b/mjo/eja/TODO @@ -21,9 +21,7 @@ This may require supporting "basis" as a list of basis vectors (as opposed to superalgebra elements) in the subalgebra constructor. -7. Use charpoly for inverse stuff if it's cached. - -8. The inner product should be an *argument* to the main EJA +7. The inner product should be an *argument* to the main EJA constructor. Afterwards, the basis normalization step should be optional (and enabled by default) for ALL algebras, since any algebra can have a nonstandard inner-product and its basis can be diff --git a/mjo/eja/eja_element.py b/mjo/eja/eja_element.py index a5880c4..739bff3 100644 --- a/mjo/eja/eja_element.py +++ b/mjo/eja/eja_element.py @@ -523,6 +523,11 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): whether or not the paren't algebra's zero element is a root of this element's minimal polynomial. + That is... unless the coefficients of our algebra's + "characteristic polynomial of" function are already cached! + In that case, we just use the determinant (which will be fast + as a result). + Beware that we can't use the superclass method, because it relies on the algebra being associative. @@ -553,6 +558,11 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement): else: return False + if self.parent()._charpoly_coefficients.is_in_cache(): + # The determinant will be quicker than computing the minimal + # polynomial from scratch, most likely. + return (not self.det().is_zero()) + # In fact, we only need to know if the constant term is non-zero, # so we can pass in the field's zero element instead. zero = self.base_ring().zero()