
%-------------------------------------------------------------------
% Second Order Wolfe Conditions
%
% func and grad is the strings that hold the name files

function [hstep, FEs] = swolfe(Xold, func, grad, h0, F )
iter=1;
FEs=0;
c2= 0.9; % from wiki Wolfe conditions
hstep=h0;
pk=feval(grad,Xold);

while ( (hstep>=eps) && ( feval(func, Xold - hstep*pk) - F > -0.5*hstep*norm(pk)^2) &&... 
        (abs(pk'*feval(grad,Xold - hstep*pk)) > c2*abs(pk'*pk)) )
       hstep = hstep*0.5;
       FEs=FEs+2;
       iter=iter+1;

end