tr: Matrix trace

Description

Calculates the trace of a matrix

Usage

1
tr(M)

Arguments

M

a matrix

Value

returns the sum of the diagonal elements

Author(s)

Michael Friendly

Examples

1
2
M <- matrix(sample(1:9), 3,3)
tr(M)

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.