%-------------------------------------------------------------------
% First Order Wolfe Conditions

function [hstep, FEs] = wolfe(Xold, func, grad, h0, F) 
iter=1;
FEs=0;
hstep=h0;

F1 = feval(func, Xold - hstep*grad);
FEs=FEs+1;

while ( hstep>=eps && (F1-F) > -0.5*hstep*norm(grad)^2 )
       hstep = hstep*0.5;
       FEs=FEs+1;
       iter=iter+1;
       F1 = feval(func, Xold - hstep*grad);
end

