[R] SVD and spectral decompositions of a hermitian matrix
Ravi Varadhan
rvaradha at jhsph.edu
Thu Jul 3 19:09:02 CEST 2003
Hi:
I create a hermitian matrix and then perform its singular value
decomposition. But when I put it back, I don't get the original
hermitian matrix. I am having the same problem with spectral value
decomposition as well.
I am using R 1.7.0 on Windows. Here is my code:
X <- matrix(rnorm(16)+1i*rnorm(16),4)
X <- X + t(X)
X[upper.tri(X)] <- Conj(X[upper.tri(X)])
Y <- La.svd(X)
Y$u %*% diag(Y$d) %*% t(Y$v) # this doesn't give back X
Y$u %*% diag(Y$d) %*% Y$v # this works fine.
Z <- La.eigen(X) # the eigen values should be real, but are not.
Z$vec %*% diag(Z$val) %*% t(Z$vec) # this doesn't give back X
The help for "La.svd" says that the function return U, D, and V such
that X = U D V' Furthermore, the help for "La.eigen" says that if the
argument "symmetric" is not specified, the matrix is inspected for
symmetry, so I expect that I should get real eigen values to a
hermitian matrix. Are there any problems with these 2 functions, or
what is it that I am not understanding?
thanks for your help,
Ravi.
More information about the R-help
mailing list