]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/eja_element.py
eja: use peirce_decomposition() method to get the Peirce decomposition.
[sage.d.git] / mjo / eja / eja_element.py
index 575c2a4754ae261f284c53de4d423011c9bf5418..4d3b071923b2c275ecb559c8d60d183696c729ac 100644 (file)
@@ -9,7 +9,7 @@ from sage.modules.with_basis.indexed_element import IndexedFreeModuleElement
 # TODO: make this unnecessary somehow.
 from sage.misc.lazy_import import lazy_import
 lazy_import('mjo.eja.eja_algebra', 'FiniteDimensionalEuclideanJordanAlgebra')
-lazy_import('mjo.eja.eja_subalgebra',
+lazy_import('mjo.eja.eja_element_subalgebra',
             'FiniteDimensionalEuclideanJordanElementSubalgebra')
 from mjo.eja.eja_operator import FiniteDimensionalEuclideanJordanAlgebraOperator
 from mjo.eja.eja_utils import _mat2vec
@@ -620,19 +620,10 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement):
             True
 
         """
-        # TODO: when the Peirce decomposition is implemented for real,
-        # we can use that instead of finding this eigenspace manually.
-        #
-        # Trivial eigenspaces don't appear in the list, so we default to the
-        # trivial one and override it if there's a nontrivial space in the
-        # list.
         if not self.is_idempotent():
             return False
 
-        J1 = VectorSpace(self.parent().base_ring(), 0)
-        for (eigval, eigspace) in self.operator().matrix().left_eigenspaces():
-            if eigval == 1:
-                J1 = eigspace
+        (_,_,J1) = self.parent().peirce_decomposition(self)
         return (J1.dimension() == 1)
 
 
@@ -1270,10 +1261,13 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement):
 
             sage: from mjo.eja.eja_algebra import random_eja
 
-        TESTS::
+        TESTS:
+
+        Ensure that we can find an idempotent in a non-trivial algebra
+        where there are non-nilpotent elements::
 
             sage: set_random_seed()
-            sage: J = random_eja()
+            sage: J = random_eja(nontrivial=True)
             sage: x = J.random_element()
             sage: while x.is_nilpotent():
             ....:     x = J.random_element()
@@ -1282,6 +1276,9 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement):
             True
 
         """
+        if self.parent().is_trivial():
+            return self
+
         if self.is_nilpotent():
             raise ValueError("this only works with non-nilpotent elements!")