]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja/euclidean_jordan_algebra.py: add span_of_powers() method.
authorMichael Orlitzky <michael@orlitzky.com>
Mon, 24 Jun 2019 16:05:47 +0000 (12:05 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 24 Jun 2019 16:05:47 +0000 (12:05 -0400)
mjo/eja/euclidean_jordan_algebra.py

index 08bce5f7c7b24a96d9fa982bb1ec0c77dc01807a..ce6f6e55e18b28aabea82c9118758c1dab061c28 100644 (file)
@@ -57,6 +57,18 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra):
                 return A.element_class(A, self.vector()*(self.matrix()**(n-1)))
 
 
+        def span_of_powers(self):
+            """
+            Return the vector space spanned by successive powers of
+            this element.
+            """
+            # The dimension of the subalgebra can't be greater than
+            # the big algebra, so just put everything into a list
+            # and let span() get rid of the excess.
+            V = self.vector().parent()
+            return V.span( (self**d).vector() for d in xrange(V.dimension()) )
+
+
         def degree(self):
             """
             Compute the degree of this element the straightforward way
@@ -74,13 +86,8 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra):
                 2
 
             """
-            d = 0
-            V = self.vector().parent()
-            vectors = [(self**d).vector()]
-            while V.span(vectors).dimension() > d:
-                d += 1
-                vectors.append((self**d).vector())
-            return d
+            return self.span_of_powers().dimension()
+
 
         def minimal_polynomial(self):
             return self.matrix().minimal_polynomial()