Problem with QR method for Hessenberg matrices

조회 수: 9 (최근 30일)
Will
Will 2015년 4월 21일
In trying to implement the method, my approach is to use a reduction to Hessenberg form, and then to iterate using a QR method of Givens rotations. However, I am having trouble successfully implementing the Givens rotations, since I'm only worried about the n−1 entries of the off-diagonal, in a manner of speaking. Included is my MATLAB code:
function [H,Q,R] = hessQR(A,maxIter)
[H,P] = HHhess(A);
for k = 1:maxIter
[Q,R] = HGivQR(H);
A = R*Q;
end
end
function [Q,R] = HGivQR(A)
n = size(A,1);
Q=eye(n);
R=A;
for j=1:n-1
for i=n:(-1):j+1
x=R(:,j);
if norm([x(i-1),x(i)])>0
c=x(i-1)/norm([x(i-1),x(i)]);
s=-x(i)/norm([x(i-1),x(i)]);
G=eye(n);
G([i-1,i],[i-1,i])=[c,s;-s,c];
R=G'*R;
Q=Q*G;
end
end
end
end
The method converges, but my real Schur decomposition (which is R in my code) is not correct... nor is A==Q*R. I'm not sure what I'm doing wrong, but I think it might be in my Givens code. Please, point out mistakes you see that I have made!

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by