From 3b8bb4b76e19f857da235759ca413a6ff8d48f71 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 26 Jan 2022 07:41:16 -0500 Subject: [PATCH] hurwitz.py: add is_skew_hermitian() method. --- mjo/hurwitz.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/mjo/hurwitz.py b/mjo/hurwitz.py index ff84b51..43ed8f2 100644 --- a/mjo/hurwitz.py +++ b/mjo/hurwitz.py @@ -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 -- 2.43.2