]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: define the trace of an element in a trivial algebra.
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 15 Oct 2019 12:27:44 +0000 (08:27 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 15 Oct 2019 12:27:44 +0000 (08:27 -0400)
mjo/eja/eja_element.py

index 2eb267727235946ed94681d973c915407c5d3dc1..bd45b179541487bd82e3b06768a902a77cd0899d 100644 (file)
@@ -1248,6 +1248,12 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement):
         """
         P = self.parent()
         r = P.rank()
+
+        if r == 0:
+            # Special case for the trivial algebra where
+            # the trace is an empty sum.
+            return P.base_ring().zero()
+
         p = P._charpoly_coeff(r-1)
         # The _charpoly_coeff function already adds the factor of
         # -1 to ensure that _charpoly_coeff(r-1) is really what