]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
hurwitz.py: add is_skew_hermitian() method.
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 26 Jan 2022 12:41:16 +0000 (07:41 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 26 Jan 2022 12:41:16 +0000 (07:41 -0500)
mjo/hurwitz.py

index ff84b51f8e3923ef7a8a93cb7d42ea1cfe6e3d32..43ed8f20782c074022a3a0f46f68c7dad00dae5f 100644 (file)
@@ -359,6 +359,46 @@ class HurwitzMatrixAlgebraElement(MatrixAlgebraElement):
                     for j in range(self.ncols()) )
 
 
+    def is_skew_hermitian(self):
+        r"""
+
+        SETUP::
+
+            sage: from mjo.hurwitz import (ComplexMatrixAlgebra,
+            ....:                          HurwitzMatrixAlgebra)
+
+        EXAMPLES::
+
+            sage: A = ComplexMatrixAlgebra(2, QQbar, ZZ)
+            sage: M = A([ [ 0,I],
+            ....:         [-I,1] ])
+            sage: M.is_skew_hermitian()
+            False
+
+        ::
+
+            sage: A = HurwitzMatrixAlgebra(2, AA, QQ)
+            sage: M = A([ [1, 1],
+            ....:         [1, 1] ])
+            sage: M.is_skew_hermitian()
+            False
+
+        ::
+
+            sage: A = ComplexMatrixAlgebra(2, QQbar, ZZ)
+            sage: M = A([ [2*I   ,  1 + I],
+            ....:         [-1 + I, -2*I] ])
+            sage: M.is_skew_hermitian()
+            True
+
+        """
+        # A tiny bit faster than checking equality with the conjugate
+        # transpose.
+        return all( self[i,j] == -self[j,i].conjugate()
+                    for i in range(self.nrows())
+                    for j in range(self.ncols()) )
+
+
 class HurwitzMatrixAlgebra(MatrixAlgebra):
     r"""
     A class of matrix algebras whose entries come from a Hurwitz