QR Factorization using Householder Transformation
56 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello!
I am trying to compute a function householder that taking a matrix A, returns the matrix Q R such that
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/538726/image.png)
This is my code so far but it seems that I have a mistake since
~= A:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/538731/image.png)
Any help please?
function [Q,R] = householder(A)
% Write your code here.
[m,n] = size(A);
Q = A;
for j = 1:m
z = Q(j:end,j);
v = [ -sign(z(1))*norm(z)-z(1); -z(2:end)];
P = eye(size(z,1), size(z,1)) - (2/(v'*v))*(v*v');
Q(j:end, j:end) = P* Q(j:end, j:end);
end
R = Q' * A;
end
0 comentarios
Respuestas (1)
Monisha Nalluru
el 10 de Mzo. de 2021
Refer to the following blog post which gives example and clear understanding on Household Refelection and Household QR factorization with sample code.
0 comentarios
Ver también
Categorías
Más información sobre Sparse Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!