def _linesearch_powell(func, p, xi, tol=1e-3, maxiter=500): # line-search algorithm using fminbound # find the minimium of the function # func(x0+ alpha*direc) def myfunc(alpha): return func(p + alpha * xi) settings = numpy.seterr(all='ignore') alpha_min, fret, iter, num = brent(myfunc, full_output=1, tol=tol, maxiter=maxiter) numpy.seterr(**settings) xi = alpha_min*xi return squeeze(fret), p+xi, xi