Learn R Programming

pracma (version 0.7.5)

mtrace: Matrix trace

Description

Sum of the main diagonal elements.

Usage

mtrace(a)

Arguments

a
a square matrix

Value

  • scalar value

Details

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

See Also

mdiag, diag

Examples

Run this code
mtrace(matrix(1:16, nrow=4, ncol=4))

Run the code above in your browser using DataLab