% Form test problem
tic; 
n = 4000;
m = 4000;
[A,B, L,U,P,Q] = dense_test(n,m, 1);
B = eye(n);
tfactor = toc;

% Time a linear system solve
y = rand(n,1);
tic; x = Q*(U\(L\(P*y))); tsolve1 = toc;
tic; xp = (((y'*Q)/U)/L)*P; tsolve2 = toc;
tsolve = tsolve1 + tsolve2;

% Print times
fprintf('---------------\n');
fprintf('Form and factor:       %g\n', tfactor);
fprintf('Time for column solve: %g\n', tsolve1);
fprintf('Time for row solve:    %g\n', tsolve2);
fprintf('Both solves times:     %g\n', tsolve);
fprintf('---------------\n');

% Check cost of routines
delta = 1e-2;
i = 3;
k = 4;
new_wp_ik = rand(1);

tic; z = influence(L,U,P,Q, B); t1 = toc;
tic; mu = mean_opinion(z, y, n); t2 = toc;
tic; [abserr_1norm, relerr_mu] = sensitivity_bound(z, y, delta, n); t3 = toc;
tic; condA = laplace_cond1(A, L,U,P,Q); t4 = toc;
tic; znew = update_influence(z, L,U,P,Q, B, i,k, new_wp_ik); t5 = toc;

fprintf('influence / solves:    %f\n', t1/tsolve);
fprintf('mean_opinion / solves: %f\n', t2/tsolve);
fprintf('sensitivity / solves:  %f\n', t3/tsolve);
fprintf('cond / solves:         %f\n', t4/tsolve);
fprintf('update / solves:       %f\n', t5/tsolve);