Householder Algorithm finding Q
31 ビュー (過去 30 日間)
Hi, i have this algorithm:
function [Q,R] = householder(A)
% Write your code here.
z = -sign(A(k,k))*norm(A(k:m,k));
v = [zeros(k-1,1); A(k,k)-z; A(k+1:m,k)];
f = v'*v;
if f == 0, continue; end
for j = k:n
c = v'*A(:,j);
A(:,j) = A(:,j)-(2*c/f)*v;
I get the correct R matrix, but I can't seem to find Q correctly. Please let me know ASAP
回答 (1 件)
Athul Prakash 2021 年 3 月 12 日
You may prefer the MATLAB built-in qr() function.
[Q,R] = qr(M);
See this documentation:
Alternately, you may search the Mathworks File Exchange for alternate implementations of Householder algorithm. For example:
These are submissions by other MATLAB users, and not part of the MATLAB product. It is not tested or qualified by Mathworks, so use at your own responsibility.