Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

matrix.trace

The trace of a matrix


Description

This function returns the trace of a given square numeric matrix.

Usage

matrix.trace(x)

Arguments

x

a matrix

Value

A numeric value which is the sum of the values on the diagonal.

Note

If the argument x is not numeric, the function presents and error message and terminates. If the argument x is not a square matrix, the function presents an error message and terminates.

Author(s)

Frederick Novomestky fnovomes@poly.edu

References

Bellman, R. (1987). Matrix Analysis, Second edition, Classics in Applied Mathematics, Society for Industrial and Applied Mathematics.

Examples

A <- matrix( seq( 1, 16, 1 ), nrow=4, byrow=TRUE )
matrix.trace( A )

matrixcalc

Collection of functions for matrix calculations

v1.0-3
GPL (>= 2)
Authors
Frederick Novomestky <fnovomes@poly.edu>
Initial release
2012-09-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.