Contents Previous Next Subchapters

Computing The Trace Of A Matrix
Syntax trace(x)
See Also diag , cond , det , cond

Description
Returns the sum of the diagonal elements of x, where x is an integer, real, complex or double-precision matrix. The return value is a scalar with the same type as x.

Example
     x = {[1, 2, 3], [4, 5, 6], [7, 8, 9]}
     trace(x)
returns
     15