Example #1
0
def run_fsolver():
    params = numx.array((1., 10.)) * 1.
    mysys = multiroots.gsl_multiroot_function(rosenbrock_f, params, 2)

    #solver = multiroots.hybrids(mysys, 2)
    solver = multiroots.dnewton(mysys, 2)
    #solver = multiroots.broyden(mysys, 2)
    #solver = multiroots.hybrid(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!"
Example #2
0
def run_fsolver():
    params = numx.array((1., 10.)) * 1.
    mysys = multiroots.gsl_multiroot_function(rosenbrock_f, params, 2)
    
    #solver = multiroots.hybrids(mysys, 2)
    solver = multiroots.dnewton(mysys, 2)
    #solver = multiroots.broyden(mysys, 2)
    #solver = multiroots.hybrid(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!"
Example #3
0
 def setUp(self):
     tmp = Numeric.array((1., 10.), Float)
     self.sys = multiroots.gsl_multiroot_function(rosenbrock_f, tmp,
                                                  self._getsize())
Example #4
0
 def setUp(self):
     tmp = Numeric.array((1., 10.), Float)
     self.sys = multiroots.gsl_multiroot_function(rosenbrock_f, tmp,
                                                  self._getsize())