From 3d7151570d57d56b6e19a3522d6415ed29a3b0d9 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 22 Jul 2019 23:31:44 -0400 Subject: [PATCH] eja: use the @cached_method decorator for characteristic_polynomial(). --- mjo/eja/euclidean_jordan_algebra.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 2c496cd..4fb5f9b 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -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): -- 2.44.2