function [He Xx] = GQR(A)
% param A : 是一个可逆矩阵
% return He : 是一个满足每两个不同列向量的内积为0的矩阵
% return Xx : 是一个主对角线全为1的上三角矩阵
% function : 分解 A = He * Xx
% CopyRight : edu.nust.cs726.JunH(111060881)
[H L] = size(A);
if H ~= L
error('hehehe');
end
if det(A) == 0
error('hahaha');
end
BIJ = eye(H);
B = zeros(H, L);
B(:, 1) = A(:, 1);
for R = 2:L
ar = A(:, R);
br = ar;
for K = 1:R-1
% disp(ar)
% disp(B(:, K));
% disp(' ');
% disp(' ');
bij = Gb(ar, B(:, K));
BIJ(K, R) = bij;
br = br - bij*B(:, K);
end
B(:, R) = br;
end
He = B;
Xx = BIJ;
function bij = Gb(aierfa, beita)
if 1 == size(aierfa, 1) && 1 == size(beita, 1)
bij = (aierfa*beita') / (beita*beita');
else
bij = (aierfa'*beita) / (beita'*beita);
end