tr: Trace of a Matrix

View source: R/convenience.R

trR Documentation

Trace of a Matrix

Description

Sum of diagonal elements of a matrix.

Usage

tr(x)

Arguments

x

A matrix.

Value

The sum of the diagonal elements of x.

Examples

tr(ones(5, 10))
x <- replicate(1000, tr(rand(25, 25)))
hist(x)

ramify documentation built on June 24, 2025, 9:07 a.m.