Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

trace

Matrix trace


Description

Sum of the main diagonal elements.

Usage

Trace(a)

Arguments

a

a square matrix

Details

Sums the elements of the main diagonal of areal or complrx square matrix.

Value

scalar value

Note

The corresponding function in Matlab/Octave is called trace(), but this in R has a different meaning.

See Also

Examples

Trace(matrix(1:16, nrow=4, ncol=4))

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.