From 2c4fdb8c5b0d70b1aafb3aed7e993c5821ee26be Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 2 Feb 2022 11:21:01 -0500 Subject: [PATCH] mjo/hurwitz.py: speed up is_hermitian() and is_skew_symmetric(). We only need to test these above and on the diagonal. --- mjo/hurwitz.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mjo/hurwitz.py b/mjo/hurwitz.py index 6767fe1..614804f 100644 --- a/mjo/hurwitz.py +++ b/mjo/hurwitz.py @@ -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,7 +390,7 @@ 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_symmetric(self): @@ -431,7 +439,7 @@ class HurwitzMatrixAlgebraElement(MatrixAlgebraElement): # 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): -- 2.44.2