cmatrix.Matrix.trace

Matrix.trace()

Trace the current matrix

Returns
double

The computed trace of the matrix

See also

size_r()
get_ij()

Examples

>>> m=rand(4)
>>> print(m)
| +0.000 | +6.000 | +8.000 | +4.000 |
| +8.000 | +11.000 | +13.000 | +0.000 |
| +15.000 | +10.000 | +15.000 | +4.000 |
| +11.000 | +2.000 | +1.000 | +10.000 |
printed
>>> print(m.trace())
36.0