Compute the trace of a square NumPy matrix by summing its main-diagonal elements with numeric dtype support.