2021-03-14 15:34:25 +01:00
|
|
|
function [Q R] = Alg11(A)
|
2021-03-21 19:45:18 +01:00
|
|
|
% Algorithm 11: QR factorization via Householder transformation.
|
2021-03-14 15:34:25 +01:00
|
|
|
|
|
|
|
[m, n] = size(A);
|
|
|
|
|
|
|
|
if ~ (m>=n)
|
|
|
|
error("m has to be greater or equal n!")
|
|
|
|
end
|
|
|
|
|
|
|
|
for j = 1:n
|
|
|
|
[v, beta] = householder(A(j:m, j))
|
|
|
|
A(j:m, j:n) = (eye(m-j+1)-beta*(v*v.'))*A(j:m, j:n)
|
|
|
|
if j < m
|
|
|
|
A(j+1:m, j) = v(2:m-j+1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
R = triu(A)
|
|
|
|
|
2021-03-14 18:40:53 +01:00
|
|
|
H = tril(A, -1)
|
|
|
|
|
|
|
|
|
2021-03-14 15:34:25 +01:00
|
|
|
end
|
|
|
|
|