lasso2 (version 1.2-19)

tr: Trace of a Matrix

Description

Calculates the trace of a matrix

Usage

tr(mat)

Arguments

mat

a square matrix.

Value

The trace of the matrix, i.e. the sum of its diagonal elements, is returned.

Examples

Run this code
# NOT RUN {
tr(cbind(1,1:3,4:2)) # 5
# }

Run the code above in your browser using DataCamp Workspace