% plots 3d log log plots

clc;
clf;
close all;

% For dense nxm matrices 

% when n is fixed and m is varied
n1=100*ones(1,length(t1(1,:)));
n2=200*ones(1,length(t1(1,:)));
m=100:100:1500;

% timings
h=figure(1);
hold on
plot3(n1,m,t1(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(n1,m,t2(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(n1,m,t3(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(n1,m,t4(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(n1,m,t5(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(n1,m,t6(1,:),'m*-','MarkerFaceColor','m','LineWidth',2);
plot3(n2,m,t1(2,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(n2,m,t2(2,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(n2,m,t3(2,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(n2,m,t4(2,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(n2,m,t5(2,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(n2,m,t6(2,:),'m*-','MarkerFaceColor','m','LineWidth',2);
% Set all three axes to be log scale
set(gca, 'YScale', 'log', 'ZScale', 'log')
xlabel('n');
ylabel('m');
zlabel('Timings (s)');
title('Comparison of timings when n is fixed and m is varied');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method','Francis');
view(45,30);
grid 
% %axis tight
print(h,'-dpng');

% accuracies
h=figure(2);
hold on
plot3(n1,m,e1(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(n1,m,e2(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(n1,m,e3(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(n1,m,e4(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(n1,m,e5(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(n2,m,e1(2,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(n2,m,e2(2,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(n2,m,e3(2,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(n2,m,e4(2,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(n2,m,e5(2,:),'co-','MarkerFaceColor','c','LineWidth',2);
% Set all three axes to be log scale
set(gca, 'YScale', 'log', 'ZScale', 'log')
xlabel('n');
ylabel('m');
zlabel('Accuracies (||U\SigmaV^{T}-A||_\infty)');
title('Comparison of accuracies when n is fixed and m is varied');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
view(45,30);
grid 
%axis tight
print(h,'-dpng');

% Orthogonality checks u*u'-eye
h=figure(3);
hold on
plot3(n1,m,orth1(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(n1,m,orth3(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(n1,m,orth5(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(n1,m,orth7(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(n1,m,orth9(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(n2,m,orth1(2,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(n2,m,orth3(2,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(n2,m,orth5(2,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(n2,m,orth7(2,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(n2,m,orth9(2,:),'co-','MarkerFaceColor','c','LineWidth',2);
% Set all three axes to be log scale
set(gca,  'YScale', 'log', 'ZScale', 'log')
xlabel('n');
ylabel('m');
zlabel('Orthogonality checks (||UU^{T}-Id||_\infty)');
title('Comparison of Orthogonality checks when n is fixed and m is varied');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
view(45,30);
grid 
%axis tight
print(h,'-dpng');

% Orthogonality checks u'*u-eye
h=figure(4);
hold on
plot3(n1,m,orth1_1(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(n1,m,orth3_1(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(n1,m,orth5_1(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(n1,m,orth7_1(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(n1,m,orth9_1(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(n2,m,orth1_1(2,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(n2,m,orth3_1(2,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(n2,m,orth5_1(2,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(n2,m,orth7_1(2,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(n2,m,orth9_1(2,:),'co-','MarkerFaceColor','c','LineWidth',2);
% Set all three axes to be log scale
set(gca,'YScale', 'log', 'ZScale', 'log')
xlabel('n');
ylabel('m');
zlabel('Orthogonality checks (||U^{T}U-Id||_\infty)');
title('Comparison of Orthogonality checks when n is fixed and m is varied');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
view(45,30);
grid 
%axis tight
print(h,'-dpng');

% Orthogonality checks v*v'-eye
h=figure(5);
hold on
plot3(n1,m,orth2(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(n1,m,orth4(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(n1,m,orth6(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(n1,m,orth8(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(n1,m,orth10(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(n2,m,orth2(2,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(n2,m,orth4(2,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(n2,m,orth6(2,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(n2,m,orth8(2,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(n2,m,orth10(2,:),'co-','MarkerFaceColor','c','LineWidth',2);
% Set all three axes to be log scale
set(gca,'YScale', 'log', 'ZScale', 'log')
xlabel('n');
ylabel('m');
zlabel('Orthogonality checks (||VV^{T}-Id||_\infty)');
title('Comparison of Orthogonality checks when n is fixed and m is varied');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
view(45,30);
grid 
%axis tight
print(h,'-dpng');

% Orthogonality checks v'*v-eye
h=figure(6);
hold on
plot3(n1,m,orth2_1(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(n1,m,orth4_1(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(n1,m,orth6_1(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(n1,m,orth8_1(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(n1,m,orth10_1(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(n2,m,orth2_1(2,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(n2,m,orth4_1(2,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(n2,m,orth6_1(2,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(n2,m,orth8_1(2,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(n2,m,orth10_1(2,:),'co-','MarkerFaceColor','c','LineWidth',2);
% Set all three axes to be log scale
set(gca, 'YScale', 'log', 'ZScale', 'log')
xlabel('n');
ylabel('m');
zlabel('Orthogonality checks (||V^{T}V-Id||_\infty)');
title('Comparison of Orthogonality checks when n is fixed and m is varied');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
view(45,30);
grid 
%axis tight
print(h,'-dpng');

% errors in singular values 
h=figure(7);
hold on
plot3(n1,m,esval1(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(n1,m,esval2(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(n1,m,esval3(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(n1,m,esval4(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(n1,m,esval5(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(n1,m,esval6(1,:),'m*-','MarkerFaceColor','m','LineWidth',2);
plot3(n2,m,esval1(2,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(n2,m,esval2(2,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(n2,m,esval3(2,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(n2,m,esval4(2,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(n2,m,esval5(2,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(n2,m,esval6(2,:),'m*-','MarkerFaceColor','m','LineWidth',2);
% Set all three axes to be log scale
set(gca,  'YScale', 'log', 'ZScale', 'log')
xlabel('n');
ylabel('m');
zlabel('Errors in singular values (||Computed-Actual||_\infty)');
title('Comparison of errors in singular values when n is fixed and m is varied');
legend('Comb. Built in','Comb. Square','Indirect Method','Direct Method','Francis');
view(45,30);
grid 
%axis tight
print(h,'-dpng');

% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% 
% when m is fixed and n is varied
m1=n1;
m2=n2;
n=m;

% timingd
h=figure(8);
hold on
plot3(m1,n,t7(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(m1,n,t8(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(m1,n,t9(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(m1,n,t10(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(m1,n,t11(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(m1,n,t12(1,:),'m*-','MarkerFaceColor','m','LineWidth',2);
plot3(m2,n,t7(2,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(m2,n,t8(2,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(m2,n,t9(2,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(m2,n,t10(2,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(m2,n,t11(2,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(m2,n,t12(2,:),'m*-','MarkerFaceColor','m','LineWidth',2);
% Set all three axes to be log scale
set(gca,  'YScale', 'log', 'ZScale', 'log')
xlabel('m');
ylabel('n');
zlabel('Timings (s)');
title('Comparison of timings when m is fixed and n is varied');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method','Francis');
view(45,30);
grid 
%axis tight
print(h,'-dpng');

% accuracies
h=figure(9);
hold on
plot3(m1,n,e7(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(m1,n,e8(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(m1,n,e9(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(m1,n,e10(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(m1,n,e11(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(m2,n,e7(2,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(m2,n,e8(2,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(m2,n,e9(2,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(m2,n,e10(2,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(m2,n,e11(2,:),'co-','MarkerFaceColor','c','LineWidth',2);
% Set all three axes to be log scale
set(gca,  'YScale', 'log', 'ZScale', 'log')
xlabel('m');
ylabel('n');
zlabel('Accuracies (||U\SigmaV^{T}-A||_\infty)');
title('Comparison of accuracies when m is fixed and n is varied');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
view(45,30);
grid 
axis tight
print(h,'-dpng');

% Orthogonality checks u*u'-eye
h=figure(10);
hold on
plot3(m1,n,orth13(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(m1,n,orth15(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(m1,n,orth17(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(m1,n,orth19(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(m1,n,orth21(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(m2,n,orth13(2,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(m2,n,orth15(2,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(m2,n,orth17(2,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(m2,n,orth19(2,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(m2,n,orth21(2,:),'co-','MarkerFaceColor','c','LineWidth',2);
% Set all three axes to be log scale
set(gca,  'YScale', 'log', 'ZScale', 'log')
xlabel('m');
ylabel('n');
zlabel('Orthogonality checks (||UU^{T}-Id||_\infty)');
title('Comparison of Orthogonality checks when m is fixed and n is varied');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
view(45,30);
grid 
%axis tight
print(h,'-dpng');

% Orthogonality checks u'*u-eye
h=figure(11);
hold on
plot3(m1,n,orth13_1(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(m1,n,orth15_1(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(m1,n,orth17_1(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(m1,n,orth19_1(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(m1,n,orth21_1(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(m2,n,orth13_1(2,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(m2,n,orth15_1(2,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(m2,n,orth17_1(2,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(m2,n,orth19_1(2,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(m2,n,orth21_1(2,:),'co-','MarkerFaceColor','c','LineWidth',2);
% Set all three axes to be log scale
set(gca,  'YScale', 'log', 'ZScale', 'log')
xlabel('m');
ylabel('n');
zlabel('Orthogonality checks (||UU^{T}-Id||_\infty)');
title('Comparison of Orthogonality checks when m is fixed and n is varied');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
view(45,30);
grid 
%axis tight
print(h,'-dpng');

% Orthogonality checks v*v'-eye
h=figure(12);
hold on
plot3(m1,n,orth14(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(m1,n,orth16(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(m1,n,orth18(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(m1,n,orth20(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(m1,n,orth22(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(m2,n,orth14(2,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(m2,n,orth16(2,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(m2,n,orth18(2,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(m2,n,orth20(2,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(m2,n,orth22(2,:),'co-','MarkerFaceColor','c','LineWidth',2);
% Set all three axes to be log scale
set(gca,  'YScale', 'log', 'ZScale', 'log')
xlabel('m');
ylabel('n');
zlabel('Orthogonality checks (||VV^{T}-Id||_\infty)');
title('Comparison of Orthogonality checks when m is fixed and n is varied');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
view(45,30);
grid 
%axis tight
print(h,'-dpng');

% Orthogonality checks v*v'-eye
h=figure(13);
hold on
plot3(m1,n,orth14_1(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(m1,n,orth16_1(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(m1,n,orth18_1(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(m1,n,orth20_1(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(m1,n,orth22_1(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(m2,n,orth14_1(2,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(m2,n,orth16_1(2,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(m2,n,orth18_1(2,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(m2,n,orth20_1(2,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(m2,n,orth22_1(2,:),'co-','MarkerFaceColor','c','LineWidth',2);
% Set all three axes to be log scale
set(gca,  'YScale', 'log', 'ZScale', 'log')
xlabel('m');
ylabel('n');
zlabel('Orthogonality checks (||V^{T}V-Id||_\infty)');
title('Comparison of Orthogonality checks when m is fixed and n is varied');
legend('Built-in function', 'Comb. Built in','Comb. Square','Indirect Method','Direct Method');
view(45,30);
grid 
%axis tight
print(h,'-dpng');

% errors in singular values 
h=figure(14);
hold on
plot3(m1,n,esval7(1,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(m1,n,esval8(1,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(m1,n,esval9(1,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(m1,n,esval10(1,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(m1,n,esval11(1,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(m2,n,esval12(1,:),'m*-','MarkerFaceColor','m','LineWidth',2);
plot3(m2,n,esval7(2,:),'bv-','MarkerFaceColor','b','LineWidth',2);
plot3(m2,n,esval8(2,:),'g^-','MarkerFaceColor','g','LineWidth',2);
plot3(m2,n,esval9(2,:),'ks-','MarkerFaceColor','k','LineWidth',2);
plot3(m2,n,esval10(2,:),'rd-','MarkerFaceColor','r','LineWidth',2);
plot3(m2,n,esval11(2,:),'co-','MarkerFaceColor','c','LineWidth',2);
plot3(m2,n,esval12(2,:),'m*-','MarkerFaceColor','m','LineWidth',2);
% Set all three axes to be log scale
set(gca,  'YScale', 'log', 'ZScale', 'log')
xlabel('m');
ylabel('n');
zlabel('Errors in singular values (||Computed-Actual||_\infty)');
title('Comparison of errors in singular values when m is fixed and n is varied');
legend('Comb. Built in','Comb. Square','Indirect Method','Direct Method','Francis');
view(45,30);
grid 
%axis tight
print(h,'-dpng');