tr: Trace of a square matrix

Description Usage Arguments Value Author(s) Examples

View source: R/tr.R

Description

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

Usage

1
tr(X)

Arguments

X

Matrix to calculate the trace of.

Value

Returns the trace of X as a scalar value.

Author(s)

Theo Pepler

Examples

1
2
3
4
5
6
7
8
9
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (X)
{
    return(sum(diag(X)))
  }

tpepler/theolib documentation built on Aug. 10, 2021, 9:53 a.m.