+def _complex_hermitian_basis(n, field=QQ):
+ """
+ Returns a basis for the space of complex Hermitian n-by-n matrices.
+
+ TESTS::
+
+ sage: set_random_seed()
+ sage: n = ZZ.random_element(1,5).abs()
+ sage: all( M.is_symmetric() for M in _complex_hermitian_basis(n) )
+ True
+
+ """
+ F = QuadraticField(-1, 'I')
+ I = F.gen()
+
+ # This is like the symmetric case, but we need to be careful:
+ #
+ # * We want conjugate-symmetry, not just symmetry.
+ # * The diagonal will (as a result) be real.
+ #
+ S = []
+ for i in xrange(n):
+ for j in xrange(i+1):
+ Eij = matrix(field, n, lambda k,l: k==i and l==j)
+ if i == j:
+ Sij = _embed_complex_matrix(Eij)
+ S.append(Sij)
+ else:
+ # Beware, orthogonal but not normalized! The second one
+ # has a minus because it's conjugated.
+ Sij_real = _embed_complex_matrix(Eij + Eij.transpose())
+ S.append(Sij_real)
+ Sij_imag = _embed_complex_matrix(I*Eij - I*Eij.transpose())
+ S.append(Sij_imag)
+ return S
+
+