# tr

From lasso2 v1.2-20
by Berwin Turlach

##### Trace of a Matrix

Calculates the trace of a matrix

- Keywords
- math

##### 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

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

*Documentation reproduced from package lasso2, version 1.2-20, License: GPL (>= 2)*

### Community examples

Looks like there are no examples yet.