Skip to contents

Computes the trace of a matrix A.

Usage

tr(A)

Arguments

A

a square matrix.

Value

If \(A\) has order \(n\), then \(tr(A) = \sum_{i=1}^{n}a_{ii}\).

See also

Examples

A <- rbind(1:5, 2:6, 3:7)

# Calculate the trace of A
tr(A)
#> [1] 9