]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: unbreak the trace_inner_product() for MatrixEJAs.
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 4 Mar 2021 15:20:46 +0000 (10:20 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 4 Mar 2021 15:20:46 +0000 (10:20 -0500)
mjo/eja/eja_algebra.py

index afe0a677aaafd9ddf67355ed979d5ef023beb9c0..abf2aa36879abf97905bb749783c158a9aba5600 100644 (file)
@@ -1733,11 +1733,9 @@ class MatrixEJA:
     def trace_inner_product(X,Y):
         r"""
         A trace inner-product for matrices that aren't embedded in the
-        reals.
+        reals. It takes MATRICES as arguments, not EJA elements.
         """
-        # We take the norm (absolute value) because Octonions() isn't
-        # smart enough yet to coerce its one() into the base field.
-        return (X*Y).trace().real().abs()
+        return (X*Y).trace().real()
 
 class RealEmbeddedMatrixEJA(MatrixEJA):
     @staticmethod
@@ -2735,6 +2733,25 @@ class OctonionHermitianEJA(FiniteDimensionalEJA, MatrixEJA):
 
         return tuple( basis )
 
+    @staticmethod
+    def trace_inner_product(X,Y):
+        r"""
+        The octonions don't know that the reals are embedded in them,
+        so we have to take the e0 component ourselves.
+
+        SETUP::
+
+            sage: from mjo.eja.eja_algebra import OctonionHermitianEJA
+
+        TESTS::
+
+            sage: J = OctonionHermitianEJA(2,field=QQ,orthonormalize=False)
+            sage: I = J.one().to_matrix()
+            sage: J.trace_inner_product(I, -I)
+            -2
+
+        """
+        return (X*Y).trace().real().coefficient(0)
 
 class HadamardEJA(ConcreteEJA):
     """