tr: Trace of a Matrix

View source: R/tr.R

trR Documentation

Trace of a Matrix

Description

Takes the traces of a matrix by extracting the diagonal entries and then summing over.

Usage

tr(x)

Arguments

x

Square matrix (Q \times Q)

Value

Returns a single-value double.

See Also

logdet, fillout

Examples


# Identity Matrix of size 4, gives trace of 4.
tr(diag(4))

coatless/msos documentation built on Nov. 16, 2023, 5:31 a.m.