# orthit2.s J F Monahan, June 2001 # orthogonal iteration for a few eigenvalues and vectors # third problem n <- 6 # dimension of matrix p <- 2 # of cols or eigenvals to get A <- c(8, -3, -2, 0, 6, 5, -3, 6, 1, -6, 0, -2, -2, 1, 5, -5, 2, 0, 0, -6, -5, 8, -3, -2, 6, 0, 2, -3, 6, 1, 5, -2, 0, -2, 1, 5) A <- matrix(A,n,n) "matrix" A I <- diag(1,n)[,1:p] # just p columns Z <- I for( i in 1:50) { V <- A %*% Z Z <- qr.qy(qr(V),I) R <- t(Z) %*% V if( (i %% 5) == 0 ) { # every fifth iteration print("iteration"); print(i) print("Z matrix"); print(Z) print("R matrix"); print(R) } } rm(list=ls())