%% Reorganize the preconditioning results 

load 'cgikl-d-4-p-5.mat'


%% Run through the data and build setup time and total time.
% We want a table with
% Method Setup Time Iterations Avg. Iter Total time

clear tresults;

r = all_results.nopre;
tr.type = 'no preconditioning';
tr.setup = 0;
tr.niters = length(r.resvec);
tr.avgiter = mean(diff(r.matvectimes));
tr.time = r.dt;
tresults(1) = tr;

r = all_results.maxeig_exact;
tr.type = 'largest eigenvalue';
tr.setup = r.dt_precond;
tr.niters = length(r.resvec);
tr.avgiter = mean(diff(r.matvectimes));
tr.time = r.dt;
tresults(end+1) = tr;

r = all_results.mineig_fmincon;
tr.type = 'smallest eigenvalue';
tr.setup = r.dt_precond;
tr.niters = length(r.resvec);
tr.avgiter = mean(diff(r.matvectimes));
tr.time = r.dt;
tresults(end+1) = tr;

r = all_results.random(2);
tr.type = 'random';
tr.setup = r.dt_precond;
tr.niters = length(r.resvec);
tr.avgiter = mean(diff(r.matvectimes));
tr.time = r.dt;
tresults(end+1) = tr;

r = all_results.random(3);
tr.type = 'random';
tr.setup = r.dt_precond;
tr.niters = length(r.resvec);
tr.avgiter = mean(diff(r.matvectimes));
tr.time = r.dt;
tresults(end+1) = tr;

r = all_results.mean(end);
tr.type = 'mean (5)';
tr.setup = r.dt_precond;
tr.niters = length(r.resvec);
tr.avgiter = mean(diff(r.matvectimes));
tr.time = r.dt;
tresults(end+1) = tr;

r = all_results.mean(2);
tr.type = 'mean (2)';
tr.setup = r.dt_precond;
tr.niters = length(r.resvec);
tr.avgiter = mean(diff(r.matvectimes));
tr.time = r.dt;
tresults(end+1) = tr;

r = all_results.midpoint;
tr.type = 'midpoint';
tr.setup = r.dt_precond;
tr.niters = length(r.resvec);
tr.avgiter = mean(diff(r.matvectimes));
tr.time = r.dt;
tresults(end+1) = tr;


for i=1:length(tresults)
    fprintf('%20s & %6.1f & %5i & %6.1f & %7.1f \\\\\n',...
        tresults(i).type, tresults(i).setup, ...
        tresults(i).niters, tresults(i).avgiter, ...
        tresults(i).time);
end
    
