def run_fdfsolver(): params = numx.array((1., 10.), ) mysys = multiroots.gsl_multiroot_function_fdf(rosenbrock_f, rosenbrock_df, rosenbrock_fdf, params, 2) #solver = multiroots.newton(mysys, 2) solver = multiroots.gnewton(mysys, 2) #solver = multiroots.hybridj(mysys, 2) #solver = multiroots.hybridsj(mysys, 2) tmp = numx.array((-10., -5.), ) solver.set(tmp) print "# Testing solver ", solver.name() print "# %5s %9s %9s %9s %10s" % ("iter", "x[0]", "x[1]", "f[0]", "f[1]") for iter in range(100): status = solver.iterate() r = solver.root() x = solver.getx() f = solver.getf() status = multiroots.test_residual(f, 1e-7) if status == errno.GSL_SUCCESS: print "# Converged :" print " %5d % .7f % .7f % .7f % .7f" % (iter, x[0], x[1], f[0], f[1]) if status == errno.GSL_SUCCESS: break else: raise ValueError, "Number of Iterations exceeded!"
def run_fdfsolver(): params = numx.array((1., 10.),) mysys = multiroots.gsl_multiroot_function_fdf(rosenbrock_f, rosenbrock_df, rosenbrock_fdf, params, 2) #solver = multiroots.newton(mysys, 2) solver = multiroots.gnewton(mysys, 2) #solver = multiroots.hybridj(mysys, 2) #solver = multiroots.hybridsj(mysys, 2) tmp = numx.array((-10., -5.), ) solver.set(tmp) print "# Testing solver ", solver.name() print "# %5s %9s %9s %9s %10s" % ("iter", "x[0]", "x[1]", "f[0]", "f[1]") for iter in range(100): status = solver.iterate() r = solver.root() x = solver.getx() f = solver.getf() status = multiroots.test_residual(f, 1e-7) if status == errno.GSL_SUCCESS: print "# Converged :" print " %5d % .7f % .7f % .7f % .7f" %(iter, x[0], x[1], f[0], f[1]) if status == errno.GSL_SUCCESS: break else: raise ValueError, "Number of Iterations exceeded!"
def test_gnewton(self): solver = multiroots.gnewton(self.sys, self._getsize()) self._run(solver)