]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/hurwitz.py
mjo/hurwitz.py: speed up is_hermitian() and is_skew_symmetric().
[sage.d.git] / mjo / hurwitz.py
index c213283099c2464316994a9d0fec7fef1f31c284..614804f21fb831aae04ff97be31413e84c1b61f8 100644 (file)
@@ -369,6 +369,14 @@ class HurwitzMatrixAlgebraElement(MatrixAlgebraElement):
             sage: M.is_hermitian()
             True
 
+        ::
+
+            sage: A = ComplexMatrixAlgebra(2, QQbar, ZZ)
+            sage: M = A([ [ 0,0],
+            ....:         [-I,0] ])
+            sage: M.is_hermitian()
+            False
+
         ::
 
             sage: A = HurwitzMatrixAlgebra(2, AA, QQ)
@@ -382,11 +390,12 @@ class HurwitzMatrixAlgebraElement(MatrixAlgebraElement):
         # transpose.
         return all( self[i,j] == self[j,i].conjugate()
                     for i in range(self.nrows())
-                    for j in range(self.ncols()) )
+                    for j in range(i+1) )
 
 
-    def is_skew_hermitian(self):
+    def is_skew_symmetric(self):
         r"""
+        Return whether or not this matrix is skew-symmetric.
 
         SETUP::
 
@@ -398,15 +407,23 @@ class HurwitzMatrixAlgebraElement(MatrixAlgebraElement):
             sage: A = ComplexMatrixAlgebra(2, QQbar, ZZ)
             sage: M = A([ [ 0,I],
             ....:         [-I,1] ])
-            sage: M.is_skew_hermitian()
+            sage: M.is_skew_symmetric()
             False
 
+        ::
+
+            sage: A = ComplexMatrixAlgebra(2, QQbar, ZZ)
+            sage: M = A([ [   0, 1+I],
+            ....:         [-1-I,   0] ])
+            sage: M.is_skew_symmetric()
+            True
+
         ::
 
             sage: A = HurwitzMatrixAlgebra(2, AA, QQ)
             sage: M = A([ [1, 1],
             ....:         [1, 1] ])
-            sage: M.is_skew_hermitian()
+            sage: M.is_skew_symmetric()
             False
 
         ::
@@ -414,15 +431,15 @@ class HurwitzMatrixAlgebraElement(MatrixAlgebraElement):
             sage: A = ComplexMatrixAlgebra(2, QQbar, ZZ)
             sage: M = A([ [2*I   ,  1 + I],
             ....:         [-1 + I, -2*I] ])
-            sage: M.is_skew_hermitian()
-            True
+            sage: M.is_skew_symmetric()
+            False
 
         """
-        # A tiny bit faster than checking equality with the conjugate
-        # transpose.
-        return all( self[i,j] == -self[j,i].conjugate()
+        # A tiny bit faster than checking equality with the negation
+        # of the transpose.
+        return all( self[i,j] == -self[j,i]
                     for i in range(self.nrows())
-                    for j in range(self.ncols()) )
+                    for j in range(i+1) )
 
 
 class HurwitzMatrixAlgebra(MatrixAlgebra):