function [xnew,gradnew,alpha,pnew] = cg(localmtd,fnhess,fngrad,fn,gradold,xold,p) % usage: [xnew,gradnew,alpha,p] = cg(localmtd,fnhess,fngrad,fn,gradold,xold,p) % description: does a single step of a CG method. Returns % new x, its gradient, step length and search direction. % Input parameters: % localhmtd: cg method % fnhess: function hessian name % fngrad: function grad name % fn: function name % gradold: gradient at starting point % xold: starting point % p: current search direction % simply call a single step of the cg iteration method [xnew,gradnew,alpha,pnew]= feval(localmtd,fnhess,fngrad,fn,gradold,xold,p);