Aliases: isSymmetric isSymmetric.matrix
### ** Examples isSymmetric(D3 <- diag(3)) # -> TRUE
[1] TRUE
D3[2, 1] <- 1e-100 D3
[,1] [,2] [,3] [1,] 1e+00 0 0 [2,] 1e-100 1 0 [3,] 0e+00 0 1
isSymmetric(D3) # TRUE
[1] TRUE
isSymmetric(D3, tol = 0) # FALSE for zero-tolerance
[1] FALSE
## Complex Matrices - Hermitian or not Z <- sqrt(matrix(-1:2 + 0i, 2)); Z <- t(Conj(Z)) %*% Z Z
[,1] [,2] [1,] 1+0i 0-1i [2,] 0+1i 3+0i
isSymmetric(Z) # TRUE
[1] TRUE
isSymmetric(Z + 1) # TRUE
[1] TRUE
isSymmetric(Z + 1i) # FALSE -- a Hermitian matrix has a *real* diagonal
[1] FALSE
colnames(D3) <- c("X", "Y", "Z") isSymmetric(D3) # FALSE (as row and column names differ)
[1] FALSE
isSymmetric(D3, check.attributes=FALSE) # TRUE (as names are not checked)
[1] TRUE