lasso2 (version 1.0-1)

tr: Trace of a Matrix

Description

Calculates the trace of a matrix

Usage

tr(mat)

Arguments

Value

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

Examples

Run this code
tr(cbind(1,1:3,4:2)) # 5

Run the code above in your browser using DataCamp Workspace