Trace of Hermitian Matrices #
While the trace of a Hermitian matrix is, in informal math, typically just "the same as" a trace of
a matrix that happens to be Hermitian - it is a real number, not a complex number. Or more generally,
it is a self-adjoint element of the base StarAddMonoid.
Working directly with Matrix.trace then means that there would be constant casts between rings,
chasing imaginary parts and inequalities and so on. By defining HermitianMat.trace as its own
operation, we encapsulate the mess and give a clean interface.
The IsMaximalSelfAdjoint class is used so that (for example) for matrices over ℤ or ℝ,
HermitianMat.trace works as well and is in fact defeq to Matrix.trace. For ℂ or RCLike,
it uses the real part.
The trace of the matrix. This requires a IsMaximalSelfAdjoint R α instance, and then maps from
HermitianMat n α to R. This means that the trace of (say) a HermitianMat n ℤ gives values in ℤ,
but that the trace of a HermitianMat n ℂ gives values in ℝ. The fact that traces are "automatically"
real reduces coercions down the line.
Equations
Instances For
HermitianMat.trace reduces to Matrix.trace in the algebra.
HermitianMat.trace reduces to Matrix.trace when the elements are a TrivialStar.
HermitianMat.trace reduces to Matrix.trace when the elements are RCLike.