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

is.diagonal.matrix

Test for diagonal square matrix


Description

This function returns TRUE if the given matrix argument x is a square numeric matrix and that the off-diagonal elements are close to zero in absolute value to within the given tolerance level. Otherwise, a FALSE value is returned.

Usage

is.diagonal.matrix(x, tol = 1e-08)

Arguments

x

a numeric square matrix

tol

a numeric tolerance level usually left out

Value

A TRUE or FALSE value.

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.

Horn, R. A. and C. R. Johnson (1990). Matrix Analysis, Cambridge University Press.

Examples

A <- diag( 1, 3 )
is.diagonal.matrix( A )
B <- matrix( c( 1, 2, 3, 4 ), nrow=2, byrow=TRUE )
is.diagonal.matrix( B )
C <- matrix( c( 1, 0, 0, 0 ), nrow=2, byrow=TRUE )
is.diagonal.matrix( C )

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.