isSymmetric
Test if an Object is Symmetric

Description

Tests if a matrix or other object is symmetric (or, for complex values, Hermitian).

Usage

isSymmetric(object, ...)
isSymmetric.matrix(object, tol = 100 * .Machine$double.eps, ...)

Arguments

object any object, but currently only matrices are supported.
... additional arguments passed to the generic method.
tol tolerance used when comparing numeric values.

Details

isSymmetric is generic and has a method implemented for class matrix. It has no default method, so all other object types generate an error.
A matrix is considered symmetric if it is equal to its own transpose. A complex matrix is considered Herimitian if it is equal to its own conjugate transpose.
Note that the symmetry also applies to the dimnames.
Value
returns TRUE if object is a symmetric matrix. Otherwise, it returns FALSE.
See Also
matrix, diag, t, Conj
Examples
m <- diag(3)
m[1,3] <- 1e-20
isSymmetric(m) # TRUE
isSymmetric(m, tol=0) # FALSE

m <- matrix(0+0i, 3,3) m[1,3] <- 1+2i m[3,1] <- 1-2i isSymmetric(m) # TRUE

x <- rbind(c(1,2,3), c(2,2,4), c(3,4,5)) isSymmetric(x) # TRUE dimnames(x) <- list(c("r1", "r2", "r3"), c("c1", "c2", "c3")) isSymmetric(x) # FALSE

Package base version 6.0.0-69
Package Index