tr: Trace of a matrix.

Description Usage Arguments Details Value Author(s) Examples

Description

Returns the sum of the diagonal elements of a matrix.

Usage

1
tr(X)

Arguments

X

A matrix whose diagonal elements will be added together.

Details

This returns the trace of a matrix, which is just the sum of its diagonal elements.

Value

The sum of the diagonal elements of X.

Author(s)

Peter Hoff.

Examples

1
2
3
X <- matrix(1:4, nrow = 2, ncol = 2)
X
tr(X)


Search within the tensr package
Search all R packages, documentation and source code

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

Please suggest features or report bugs with the GitHub issue tracker.

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