function R = household(A)%输入QR分解的矩阵A
R = A;
n = size(A);for i =1:n
H = eye(i-1);
x = R(i:n,i);
s = sign(x(1));
a = norm(x,2)* s;
k = zeros(5-i,1);
k(1)=1;
X = x + a*k;
Ho = eye(5-i)-2*X*X'/norm(X,2)^2;
H = blkdiag(H,Ho);
R = H*R;
end
Given法
function R = rotation(A)%输入QR分解的矩阵A
R = A;n = size(R);
c =0;s =0;k =0;for i =1:n-1for j = i+1:n
T = eye(n);
c = R(i,i)/sqrt(R(i,i)^2+R(j,i)^2),8;
s = R(j,i)/sqrt(R(i,i)^2+R(j,i)^2),8;
T(i,i)= c;T(i,j)= s;
T(j,i)=-s;T(j,j)= c;
R = T*R;
end
end
方阵的QR分解Household法function R = household(A) %输入QR分解的矩阵AR = A;n = size(A);for i = 1:n H = eye(i-1); x = R(i:n,i); s = sign(x(1)); a = norm(x,2) * s; k = zero...