]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: use cached charpoly for element inverse when available.
authorMichael Orlitzky <michael@orlitzky.com>
Mon, 23 Nov 2020 03:39:59 +0000 (22:39 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 23 Nov 2020 03:39:59 +0000 (22:39 -0500)
mjo/eja/TODO
mjo/eja/eja_element.py

index 220a70193014f215b25758fe39f42c82e1fbfbc4..94fb172aba0dda1d601e7c70ccf4f991749a6fcc 100644 (file)
@@ -21,9 +21,7 @@
    This may require supporting "basis" as a list of basis vectors
    (as opposed to superalgebra elements) in the subalgebra constructor.
 
    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
    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
index a5880c4c4c3fc083726fbf2adcef6ee071e7cd63..739bff334c5aa2069dbf09244e7a7fa39ceaccb3 100644 (file)
@@ -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.
 
         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.
 
         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
 
             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()
         # 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()