tr {fBasics} | R 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)
[Package fBasics version 4032.96 Index]