function [err,tim] = driver_fhbvm2( fun, NN, nn, nnu, last )
%
%  [err,tim] = driver_fhbvm2( fun, NN, nn, nnu [, last] )
%
%  Driver for fhbvm2 for the problem defined by the function fun:
%      fun   = string with the function identifier;
%      NN    = vectors with the N parameters;
%      nn    = vectors with the n parameters;
%      nnu   = vectors with the nu parameters;
%      last  = flag to check the accuracy in the last point only.
%
%  In output:
%      err  = mescd obtained;
%      tim  = elapsed time.
%
last = nargin<5;
disp(['FHBVM2 on ' fun])
if last
   disp('error check on the whole solution')
else
   disp('error check in the last point')
end   
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[alpha,T,y0] = feval(fun);
y0  = y0;
lh  = length(NN);
if lh~=length(nn) || lh~=length(nnu), error('N,n,nu?'), end
err = zeros(lh,1);
tim = err;
for i = 1:lh
    [t,y,etim]  = fhbvm2( fun, y0, T, NN(i), nn(i), nnu(i) );
    tim(i) = etim;
    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 '_fhbvm2 err tim NN nn nnu']))
return