tr: Trace of a Matrix

Description Usage Arguments Value Examples

View source: R/tr.R

Description

Calculates the trace of a square numeric matrix, i.e., the sum of its diagonal elements

Usage

1
tr(X)

Arguments

X

a numeric matrix

Value

a numeric value, the sum of diag(X)

Examples

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

matlib documentation built on May 30, 2017, 1:49 a.m.