Learn R Programming

ramify (version 0.4.0)

tr: Trace of a Matrix

Description

Sum of diagonal elements of a matrix.

Usage

tr(x)

Value

The sum of the diagonal elements of x.

Arguments

x

A matrix.

Examples

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

Run the code above in your browser using DataLab