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 |
+ +------+----------+
+
+ ::
+
+ sage: A = ComplexMatrixAlgebra(2, QQbar, QQ)
+ sage: M = A([ [ 1, 2],
+ ....: [ 3, 4] ])
+ sage: M.conjugate() == M
+ True
+ sage: M.to_vector()
+ (1, 0, 2, 0, 3, 0, 4, 0)
+
+ """
+ d = self.monomial_coefficients()
+ A = self.parent()
+ new_terms = ( A._conjugate_term((k,v)) for (k,v) in d.items() )
+ return self.parent().sum_of_terms(new_terms)
+
def conjugate_transpose(self):
r"""
Return the conjugate-transpose of this matrix.
(0, -1, 0, -3, 0, -2, 0, -4)
"""
- entries = [ [ self[j,i].conjugate()
- for j in range(self.ncols())]
- for i in range(self.nrows()) ]
- return self.parent()._element_constructor_(entries)
+ d = self.monomial_coefficients()
+ A = self.parent()
+ new_terms = ( A._conjugate_term( ((k[1],k[0],k[2]), v) )
+ for (k,v) in d.items() )
+ return self.parent().sum_of_terms(new_terms)
def is_hermitian(self):
r"""
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)
# 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):
+ r"""
+ Return whether or not this matrix is skew-symmetric.
+
+ 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_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_symmetric()
+ False
+
+ ::
+
+ sage: A = ComplexMatrixAlgebra(2, QQbar, ZZ)
+ sage: M = A([ [2*I , 1 + I],
+ ....: [-1 + I, -2*I] ])
+ sage: M.is_skew_symmetric()
+ False
+
+ """
+ # 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(i+1) )
class HurwitzMatrixAlgebra(MatrixAlgebra):
super().__init__(n, entry_algebra, scalars, **kwargs)
+
+ @staticmethod
+ def _conjugate_term(t):
+ r"""
+ Conjugate the given ``(index, coefficient)`` term, returning
+ another such term.
+
+ Given a term ``((i,j,e), c)``, it's straightforward to
+ conjugate the entry ``e``, but if ``e``-conjugate is ``-e``,
+ then the resulting ``((i,j,-e), c)`` is not a term, since
+ ``(i,j,-e)`` is not a monomial index! So when we build a sum
+ of these conjugates we can wind up with a nonsense object.
+
+ This function handles the case where ``e``-conjugate is
+ ``-e``, but nothing more complicated. Thus it makes sense in
+ Hurwitz matrix algebras, but not more generally.
+
+ 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: t = list(M.monomial_coefficients().items())[1]
+ sage: t
+ ((1, 0, I), 3)
+ sage: A._conjugate_term(t)
+ ((1, 0, I), -3)
+
+ """
+ if t[0][2].conjugate() == t[0][2]:
+ return t
+ else:
+ return (t[0], -t[1])
+
+
def entry_algebra_gens(self):
r"""
Return a tuple of the generators of (that is, a basis for) the