Returns the sum of the diagonal elements of a matrix.

1 | ```
tr(X)
``` |

`X` |
A matrix whose diagonal elements will be added together. |

This returns the trace of a matrix, which is just the sum of its diagonal elements.

The sum of the diagonal elements of X.

Peter Hoff.

1 2 3 |

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.