From: Michael Orlitzky Date: Tue, 23 Jul 2019 03:31:44 +0000 (-0400) Subject: eja: use the @cached_method decorator for characteristic_polynomial(). X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=3d7151570d57d56b6e19a3522d6415ed29a3b0d9;p=sage.d.git eja: use the @cached_method decorator for characteristic_polynomial(). --- 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):