matrix-tr: Trace of a matrix

trR Documentation

Trace of a matrix

Description

Computes the trace of a matrix.

Usage

tr(x)

Arguments

x

a numeric matrix.

Details

tr computes the trace of a square matrix, i.e., the sum of its diagonal elements.

If the matrix is not square, tr returns NA.

References

Golub, van Loan, (1996); Matrix Computations, 3rd edition. Johns Hopkins University Press.

Examples

## Create Pascal Matrix:
   P = pascal(3)
   P
  
## Trace:
   tr(P)                                  

fBasics documentation built on Nov. 3, 2023, 3:01 p.m.