%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Gram-Schmidt QR factorization %
% Comparison                    %
% Classical Vs. Modified        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

A = [10000 10001;10001 10002;10002 10003;10003 10004;10004 10005]



[Qc, Rc] = classicgs(A);
[Qm, Rm] = modifiedgs(A);
[Q, R] = qr(A);


Ac = Qc*Rc
Am = Qm*Rm
A2 = Q*R

%%%%%%%%%%%%%%%%%%%
B = [1 2;1.1 1.9;.9 2.1]


[Qcb, Rcb] = classicgs(B);
[Qmb, Rmb] = modifiedgs(B);
[Qb, Rb] = qr(B);


Bc = Qcb*Rcb
Bm = Qmb*Rmb
B2 = Qb*Rb


format short g
%%%%%%%%%%%%%%%%%%%%
C = [1 1; 0 0; 1 1.0001;1 0.9999]

[Qcc, Rcc] = classicgs(C);
[Qmc, Rmc] = modifiedgs(C);
[Qc, Rc] = qr(C);


Cc = Qcc*Rcc
Cm = Qmc*Rmc
C2 = Qc*Rc


