next up previous
Next: Inserting diagonal elements Up: A sampling of useful Previous: Extracting part of a

Trace

The trace of a square matrix is the sum of the diagonal elements.

>>> print np.trace(C)
15



Carleton DeTar 2018-02-12