From d96de12813f0403a0ca7ca1c57c75c732cf13612 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 22 Nov 2020 08:53:01 -0500 Subject: [PATCH] eja: simplify the element-subalgebra one() method. --- mjo/eja/eja_element_subalgebra.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/mjo/eja/eja_element_subalgebra.py b/mjo/eja/eja_element_subalgebra.py index 3936ac1..7bc4b3a 100644 --- a/mjo/eja/eja_element_subalgebra.py +++ b/mjo/eja/eja_element_subalgebra.py @@ -1,4 +1,5 @@ from sage.matrix.constructor import matrix +from sage.misc.cachefunc import cached_method from sage.rings.all import QQ from mjo.eja.eja_subalgebra import FiniteDimensionalEuclideanJordanSubalgebra @@ -71,6 +72,7 @@ class FiniteDimensionalEuclideanJordanElementSubalgebra(FiniteDimensionalEuclide self.rank.set_cache(self.dimension()) + @cached_method def one(self): """ Return the multiplicative identity element of this algebra. @@ -78,7 +80,7 @@ class FiniteDimensionalEuclideanJordanElementSubalgebra(FiniteDimensionalEuclide The superclass method computes the identity element, which is beyond overkill in this case: the superalgebra identity restricted to this algebra is its identity. Note that we can't - count on the first basis element being the identity -- it migth + count on the first basis element being the identity -- it might have been scaled if we orthonormalized the basis. SETUP:: @@ -144,12 +146,6 @@ class FiniteDimensionalEuclideanJordanElementSubalgebra(FiniteDimensionalEuclide """ if self.dimension() == 0: return self.zero() - else: - sa_one = self.superalgebra().one().to_vector() - # The extra hackery is because foo.to_vector() might not - # live in foo.parent().vector_space()! - coords = sum( a*b for (a,b) - in zip(sa_one, - self.superalgebra().vector_space().basis()) ) - return self.from_vector(self.vector_space().coordinate_vector(coords)) + + return self(self.superalgebra().one()) -- 2.44.2