]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: add norm() and trace_norm() methods for elements.
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 20 Aug 2019 14:05:39 +0000 (10:05 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 20 Aug 2019 14:05:39 +0000 (10:05 -0400)
mjo/eja/eja_element.py

index aef1c5d2813660ced5d9fe66314b4f5fd7577a11..a681ae29652f913246033affb3db74d85b52c9c0 100644 (file)
@@ -829,6 +829,33 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement):
         return W.linear_combination(zip(B,self.to_vector()))
 
 
+    def norm(self):
+        """
+        The norm of this element with respect to :meth:`inner_product`.
+
+        SETUP::
+
+            sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
+            ....:                                  RealCartesianProductEJA)
+
+        EXAMPLES::
+
+            sage: J = RealCartesianProductEJA(2)
+            sage: x = sum(J.gens())
+            sage: x.norm()
+            sqrt(2)
+
+        ::
+
+            sage: J = JordanSpinEJA(4)
+            sage: x = sum(J.gens())
+            sage: x.norm()
+            2
+
+        """
+        return self.inner_product(self).sqrt()
+
+
     def operator(self):
         """
         Return the left-multiplication-by-this-element
@@ -1177,3 +1204,30 @@ class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement):
             raise TypeError("'other' must live in the same algebra")
 
         return (self*other).trace()
+
+
+    def trace_norm(self):
+        """
+        The norm of this element with respect to :meth:`trace_inner_product`.
+
+        SETUP::
+
+            sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
+            ....:                                  RealCartesianProductEJA)
+
+        EXAMPLES::
+
+            sage: J = RealCartesianProductEJA(2)
+            sage: x = sum(J.gens())
+            sage: x.trace_norm()
+            sqrt(2)
+
+        ::
+
+            sage: J = JordanSpinEJA(4)
+            sage: x = sum(J.gens())
+            sage: x.trace_norm()
+            2*sqrt(2)
+
+        """
+        return self.trace_inner_product(self).sqrt()