]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: fix the determinant in trivial algebras.
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 4 Nov 2020 15:14:52 +0000 (10:14 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 4 Nov 2020 15:14:52 +0000 (10:14 -0500)
mjo/eja/eja_element.py

index 926f2bf57a612c71eab53b693daa1e3f559ad6bc..0953b2f27d67d059e88588fc9adb1f3081fdecc6 100644 (file)
@@ -346,6 +346,7 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement):
         SETUP::
 
             sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
+            ....:                                  TrivialEJA,
             ....:                                  random_eja)
 
         EXAMPLES::
@@ -364,6 +365,17 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement):
             sage: x.det()
             -1
 
+        The determinant of the sole element in the rank-zero trivial
+        algebra is ``1``, by three paths of reasoning. First, its
+        characteristic polynomial is a constant ``1``, so the constant
+        term in that polynomial is ``1``. Second, the characteristic
+        polynomial evaluated at zero is again ``1``. And finally, the
+        (empty) product of its eigenvalues is likewise just unity::
+
+            sage: J = TrivialEJA()
+            sage: J.zero().det()
+            1
+
         TESTS:
 
         An element is invertible if and only if its determinant is
@@ -382,10 +394,16 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement):
             sage: x,y = J.random_elements(2)
             sage: (x*y).det() == x.det()*y.det()
             True
-
         """
         P = self.parent()
         r = P.rank()
+
+        if r == 0:
+            # Special case, since we don't get the a0=1
+            # coefficient when the rank of the algebra
+            # is zero.
+            return P.base_ring().one()
+
         p = P._charpoly_coefficients()[0]
         # The _charpoly_coeff function already adds the factor of -1
         # to ensure that _charpoly_coefficients()[0] is really what