]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: use the @cached_method decorator for characteristic_polynomial().
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 23 Jul 2019 03:31:44 +0000 (23:31 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 29 Jul 2019 03:19:01 +0000 (23:19 -0400)
mjo/eja/euclidean_jordan_algebra.py

index 2c496cd3ed893b3fd34f82f6e3ce730c757e0926..4fb5f9b4a22b9e0184ca6d2e4640717321c1efc2 100644 (file)
@@ -69,7 +69,6 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra):
             True
 
         """
-        self._charpoly = None # for caching
         self._rank = rank
         self._natural_basis = natural_basis
         self._multiplication_table = mult_table
@@ -89,6 +88,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra):
 
 
 
+    @cached_method
     def characteristic_polynomial(self):
         """
         EXAMPLES:
@@ -104,9 +104,6 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra):
             t^2 - 2*t + 1
 
         """
-        if self._charpoly is not None:
-            return self._charpoly
-
         r = self.rank()
         n = self.dimension()
 
@@ -162,8 +159,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra):
             # assign a[r] goes out-of-bounds.
             a.append(1) # corresponds to x^r
 
-        self._charpoly = sum( a[k]*(t**k) for k in range(len(a)) )
-        return self._charpoly
+        return sum( a[k]*(t**k) for k in range(len(a)) )
 
 
     def inner_product(self, x, y):