X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Fhurwitz.py;h=c213283099c2464316994a9d0fec7fef1f31c284;hb=e0e9c70961b93516c9423e370aab735aa8ab90c1;hp=ff84b51f8e3923ef7a8a93cb7d42ea1cfe6e3d32;hpb=928b7d49fda98ff105c92293b5797bb7a2b9873a;p=sage.d.git diff --git a/mjo/hurwitz.py b/mjo/hurwitz.py index ff84b51..c213283 100644 --- a/mjo/hurwitz.py +++ b/mjo/hurwitz.py @@ -299,6 +299,32 @@ class Octonions(CombinatorialFreeModule): class HurwitzMatrixAlgebraElement(MatrixAlgebraElement): + def conjugate(self): + r""" + Return the entrywise conjugate of this matrix. + + SETUP:: + + sage: from mjo.hurwitz import ComplexMatrixAlgebra + + EXAMPLES:: + + sage: A = ComplexMatrixAlgebra(2, QQbar, ZZ) + sage: M = A([ [ I, 1 + 2*I], + ....: [ 3*I, 4*I] ]) + sage: M.conjugate() + +------+----------+ + | -I | -2*I + 1 | + +------+----------+ + | -3*I | -4*I | + +------+----------+ + + """ + entries = [ [ self[i,j].conjugate() + for j in range(self.ncols())] + for i in range(self.nrows()) ] + return self.parent()._element_constructor_(entries) + def conjugate_transpose(self): r""" Return the conjugate-transpose of this matrix. @@ -359,6 +385,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