Learn R Programming

tester (version 0.2.0)

is_diagonal: Is diagonal matrix

Description

Test if an object is a diagonal matrix (or not) (i.e. square matrix with zeros above and below the diagonal)

Usage

is_diagonal(x)

Arguments

x

an R object

See Also

is_matrix, is_square_matrix

Examples

Run this code
m1 = diag(1:3, 3, 3)
m2 = matrix(1:9, 3, 3)

is_diagonal(m1) # TRUE
is_diagonal(m2) # FALSE
is_not_diagonal(m2) # TRUE

Run the code above in your browser using DataLab