Learn R Programming

fBasics (version 4021.93)

tr: Trace of a matrix

Description

Returns trace of a matrix.

Usage

tr(x)

Arguments

x

a numeric matrix.

Details

The function tr computes the trace of a square matrix which is the sum of the diagonal elements of the matrix under consideration.

References

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

Examples

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

Run the code above in your browser using DataLab