% plots 2d log log plots
clc;
clf;
close all;
f=0;

% n fixed and m is varied
m=100:100:1500;

% timing
h=figure(f+1);
hold on
loglog(m,t1(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
loglog(m,t2(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
loglog(m,t3(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
loglog(m,t4(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
loglog(m,t5(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
loglog(m,t6(1,:),'m*-','MarkerFaceColor','m','LineWidth',2);
xlabel('m');
ylabel('Timings (s)');
title('Comparison of timings ')
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method','Francis');
grid
axis tight
print(h,'-dpng');

% accuracy
h=figure(f+2);
hold on
loglog(m,e1(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
loglog(m,e2(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
loglog(m,e3(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
loglog(m,e4(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
loglog(m,e5(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
xlabel('m');
ylabel('Accuracies (||U\SigmaV^{T}-A||_\infty)');
title('Comparison of accuracies')
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
grid
axis tight
print(h,'-dpng');

% uu'-eye
h=figure(f+3);
hold on
loglog(m,orth1(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
loglog(m,orth3(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
loglog(m,orth5(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
loglog(m,orth7(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
loglog(m,orth9(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
xlabel('m');
ylabel('Orthogonality checks (||UU^{T}-Id||_\infty)');
title('Comparison of Orthogonality checks');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
grid
axis tight
print(h,'-dpng');

% u'u-eye
h=figure(f+4);
hold on
loglog(m,orth1_1(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
loglog(m,orth3_1(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
loglog(m,orth5_1(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
loglog(m,orth7_1(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
loglog(m,orth9_1(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
xlabel('m');
ylabel('Orthogonality checks (||U^{T}U-Id||_\infty)');
title('Comparison of Orthogonality checks');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
grid
axis tight
print(h,'-dpng');

% vv'-eye
h=figure(f+5);
hold on
loglog(m,orth2(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
loglog(m,orth4(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
loglog(m,orth6(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
loglog(m,orth8(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
loglog(m,orth10(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
title('Comparison of Orthogonality checks ');
xlabel('m');
ylabel('Orthogonality checks (||VV^{T}-Id||_\infty)');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
grid
axis tight
print(h,'-dpng');

% v'v-eye
h=figure(f+6);
hold on
loglog(m,orth2_1(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
loglog(m,orth4_1(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
loglog(m,orth6_1(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
loglog(m,orth8_1(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
loglog(m,orth10_1(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
title('Comparison of Orthogonality checks ');
xlabel('m');
ylabel('Orthogonality checks (||V^{T}V-Id||_\infty)');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
grid
axis tight
print(h,'-dpng');

% error in singular values
h=figure(f+7);
hold on
loglog(m,esval1(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
loglog(m,esval2(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
loglog(m,esval3(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
loglog(m,esval4(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
loglog(m,esval5(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
title('Comparison of errors in singular values');
xlabel('m');
ylabel('Errors in singular values (||Computed-Actual||_\infty)');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
grid
axis tight
print(h,'-dpng');