function [err,tim] = driver_fde12( fun, hh, mu, last )
%
%  [err,tim] = driver_fde12( fun, hh, mu[, last] )
%
%  Driver for fde12 for the problem defined by the function fun:
%      fun  = string with the function identifier;
%      hh   = timesteps used;
%      mu   = number of correction iterations;
%      last = flag to check the accuracy in the last point only.
%
%  In output:
%      err  = mescd obtained;
%      tim  = elapsed time.
%
last = nargin<4;
if nargin==2, mu = 1; end
disp(['FDE12 on ' fun])
if mu==1
   disp('PECE implementation')
else
   fprintf('PE(CE)^%i implementation\n',mu)
end    
if last
   disp('error check on the whole solution')
else
   disp('error check in the last point')
end   
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f = @(t,y) feval(fun,t,y);
[alpha,T,y0] = feval(fun);
y0  = y0.';
lh  = length(hh);
err = zeros(lh,1);
tim = err;
for i = 1:lh
    tic
    [t,y]  = fde12(alpha,f,0,T,y0,hh(i),[],mu);
    tim(i) = toc;
    if last
        yt = feval(fun,t.');
    else
        yt = feval(fun,T);
        y  = y(:,end);
    end
    err(i) = mescd(y.',yt);
end
eval(sprintf(['save ' fun '_fde12-%i err tim hh'],mu))
return