tr: Trace of a Matrix

View source: R/tr.R

trR Documentation

Trace of a Matrix

Description

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

Usage

tr(X)

Arguments

X

a numeric matrix

Value

a numeric value, the sum of diag(X)

Examples

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


friendly/matlib documentation built on March 3, 2024, 12:18 p.m.