R: Matrix trace

Trace {pracma} | R Documentation

## Matrix trace

### Description

Sum of the main diagonal elements.

### Usage

    Trace(a)

### Arguments

`a` | a square matrix

### Details

Sums the elements of the main diagonal of areal or complrx square matrix.

### Value

scalar value

### Note

The corresponding function in Matlab/Octave is called trace(), but this in R has a different meaning.

### See Also

`Diag`, `diag`

### Examples

    Trace(matrix(1:16, nrow=4, ncol=4))

[Package pracma version 2.0.4 Index]