]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: add cartesian_inner_product() method for CartesianProductEJA.
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 21 Feb 2021 04:14:53 +0000 (23:14 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 21 Feb 2021 04:14:53 +0000 (23:14 -0500)
mjo/eja/eja_algebra.py

index 08ad700d77938c2bacaab4e337088ee1efc81afa..99d89c4ab461de5b33861737499e3afca0a51d90 100644 (file)
@@ -2894,6 +2894,43 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct,
         return FiniteDimensionalEJAOperator(Ji,self,Ei.matrix())
 
 
+    def cartesian_inner_product(self, x, y):
+        r"""
+        The standard componentwise Cartesian inner-product.
+
+        We project ``x`` and ``y`` onto our factors, and add up the
+        inner-products from the subalgebras.
+
+        SETUP::
+
+
+            sage: from mjo.eja.eja_algebra import (HadamardEJA,
+            ....:                                  QuaternionHermitianEJA)
+
+        EXAMPLE::
+
+            sage: J1 = HadamardEJA(3,field=QQ)
+            sage: J2 = QuaternionHermitianEJA(2,field=QQ,orthonormalize=False)
+            sage: J = cartesian_product([J1,J2])
+            sage: x1 = J1.one()
+            sage: x2 = x1
+            sage: y1 = J2.one()
+            sage: y2 = y1
+            sage: x1.inner_product(x2)
+            3
+            sage: y1.inner_product(y2)
+            2
+            sage: z1 = J._cartesian_product_of_elements((x1,y1))
+            sage: z2 = J._cartesian_product_of_elements((x2,y2))
+            sage: J.cartesian_inner_product(z1,z2)
+            5
+
+        """
+        m = len(self.cartesian_factors())
+        projections = ( self.cartesian_projection(i) for i in range(m) )
+        return sum( P(x).inner_product(P(y)) for P in projections )
+
+
 FiniteDimensionalEJA.CartesianProduct = CartesianProductEJA
 
 
@@ -3001,44 +3038,6 @@ FiniteDimensionalEJA.CartesianProduct = CartesianProductEJA
 #         iota_right = FiniteDimensionalEJAOperator(J2,self,I2)
 #         return (iota_left, iota_right)
 
-#     def inner_product(self, x, y):
-#         r"""
-#         The standard Cartesian inner-product.
-
-#         We project ``x`` and ``y`` onto our factors, and add up the
-#         inner-products from the subalgebras.
-
-#         SETUP::
-
-
-#             sage: from mjo.eja.eja_algebra import (HadamardEJA,
-#             ....:                                  QuaternionHermitianEJA,
-#             ....:                                  DirectSumEJA)
-
-#         EXAMPLE::
-
-#             sage: J1 = HadamardEJA(3,field=QQ)
-#             sage: J2 = QuaternionHermitianEJA(2,field=QQ,orthonormalize=False)
-#             sage: J = DirectSumEJA(J1,J2)
-#             sage: x1 = J1.one()
-#             sage: x2 = x1
-#             sage: y1 = J2.one()
-#             sage: y2 = y1
-#             sage: x1.inner_product(x2)
-#             3
-#             sage: y1.inner_product(y2)
-#             2
-#             sage: J.one().inner_product(J.one())
-#             5
-
-#         """
-#         (pi_left, pi_right) = self.projections()
-#         x1 = pi_left(x)
-#         x2 = pi_right(x)
-#         y1 = pi_left(y)
-#         y2 = pi_right(y)
-
-#         return (x1.inner_product(y1) + x2.inner_product(y2))