[ad_1]
So I'm trying to get a proper QR-decomposition using Householder reflectors. So far I got this:
function [Q,R] = House(A)
[m,n] = size(A);
Q_ster = eye(m);
for k = 1:n
A_sub = A(k:m,k);
e = zeros(1,length(A_sub)); e(1) = 1;
vk = sign(A_sub(1))*norm(A_sub)*e' + A_sub;
vk = vk / norm(vk);
A(k:m,k:n) = A(k:m,k:n) - 2*vk*(vk'*A(k:m,k:n));
Q_ster(k:m,k:n) = Q_ster(k:m,k:n) - 2*vk*(vk'*A(k:m,k:n));
end
R = A
Q = Q_ster'
A_check = Q*R
The exercize being "Implement QR-decomposition using Householder reflections as [Q,R]=House(A). Compute the unitary matrix Q by having each reflection act on both A and I until A has been triangularized. Indeed, at that moment, I has been transformed into Q'. "
But I'm not getting Q_ster right. It is supposed to start as being the identity matrix on which the reflections work s.t. this becomes Q'. Does anyone see how to solve this and want to help me?
[ad_2]
لینک منبع