pycauset.trace
Returns the sum of the diagonal elements of a square matrix.
Parameters
- a (matrix): A square matrix.
Returns
A scalar: the trace (sum of a[i, i]).
Notes
Structural shortcuts apply when the matrix carries a properties assertion:
is_zeroreturns0.is_identityreturnsn.is_diagonalwith a knowndiagonal_valuereturnsdiagonal_value * n.
Otherwise the native trace() method is used, falling back to NumPy.