trace

Compute the trace of a matrix, the sum of the diagonal elements.

R = trace(A)

Inputs

A
Dimension: matrix

R
The trace.

Examples

R = trace([1,2,3;4,5,6;7,8,9])
R = 15