
Last chance! 50% off unlimited learning
Sale ends in
object
is symmetric or not.
Currently only a matrix method is implemented, where a
complex
matrix Z
must be “Hermitian” for
isSymmetric(Z)
to be true.
isSymmetric(object, ...)
"isSymmetric"(object, tol = 100 * .Machine$double.eps, ...)
matrix
for the matrix method.all.equal.numeric
.all.equal
.object
is symmetric or not.
matrix
method is used inside eigen
by
default to test symmetry of matrices up to rounding error, using
all.equal
. It might not be appropriate in all
situations. Note that a matrix m
is only symmetric if its rownames
and
colnames
are identical. Consider using unname(m)
.
eigen
which calls isSymmetric
when its
symmetric
argument is missing.
isSymmetric(D3 <- diag(3)) # -> TRUE
D3[2, 1] <- 1e-100
D3
isSymmetric(D3) # TRUE
isSymmetric(D3, tol = 0) # FALSE for zero-tolerance
## Complex Matrizes - Hermitian or not
Z <- sqrt(matrix(-1:2 + 0i, 2)); Z <- t(Conj(Z)) %*% Z
Z
isSymmetric(Z) # TRUE
isSymmetric(Z + 1) # TRUE
isSymmetric(Z + 1i) # FALSE -- a Hermitian matrix has a *real* diagonal
Run the code above in your browser using DataLab