Exemplo n.º 1
0
 def test_NewtonRoot(self):
     fun = lambda x, return_g=True: np.sin(x) if not return_g else ( np.sin(x), sdiag( np.cos(x) ) )
     x = np.array([np.pi-0.3, np.pi+0.1, 0])
     xopt = Optimization.NewtonRoot(comments=False).root(fun,x)
     x_true = np.array([np.pi,np.pi,0])
     print('Newton Root Finding')
     print('xopt: ', xopt)
     print('x_true: ', x_true)
     self.assertTrue(np.linalg.norm(xopt-x_true,2) < TOL, True)
Exemplo n.º 2
0
 def rootFinder(self):
     """Root-finding Algorithm"""
     if getattr(self, '_rootFinder', None) is None:
         self._rootFinder = Optimization.NewtonRoot(
             doLS=self.doNewton,
             maxIter=self.maxIterRootFinder,
             tol=self.tolRootFinder,
             Solver=self.Solver)
     return self._rootFinder
Exemplo n.º 3
0
 def root_finder(self):
     """Root-finding Algorithm"""
     if getattr(self, '_root_finder', None) is None:
         self._root_finder = Optimization.NewtonRoot(
             doLS=self.do_newton,
             maxIter=self.root_finder_max_iter,
             tol=self.root_finder_tol,
             Solver=self.Solver
         )
     return self._root_finder