| -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)
+
"""
- entries = [ [ self[i,j].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,v)) for (k,v) in d.items() )
+ return self.parent().sum_of_terms(new_terms)
def conjugate_transpose(self):
r"""
(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"""
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