コード例 #1
0
 def CG_Jacobi(self):
     solution = doublevec.DoubleVec(0)
     pc = preconditioner.JacobiPreconditioner()
     solver = matrixmethod.ConjugateGradient(pc, self.tolerance,
                                             self.max_iterations)
     solver.solveMatrix(self.matrix, self.rhs, solution)
     self.assertAlmostEqual(self.ref.norm(), solution.norm(), 9)
コード例 #2
0
 def resolve_asymmetric(self, subproblemcontext, existingSolver):
     if (isinstance(existingSolver, StabilizedConjugateGradient)
             and existingSolver.tolerance == self.tolerance
             and existingSolver.max_iterations == self.max_iterations
             and isinstance(existingSolver.preconditioner,
                            preconditioner.JacobiPreconditioner)):
         return existingSolver
     return StabilizedConjugateGradient(
         preconditioner=preconditioner.JacobiPreconditioner(),
         tolerance=self.tolerance,
         max_iterations=self.max_iterations)
コード例 #3
0
 def resolve_symmetric(self, existingSolver):
     if (isinstance(existingSolver, ConjugateGradient)
             and existingSolver.tolerance == self.tolerance
             and existingSolver.max_iterations == self.max_iterations
             and isinstance(existingSolver.preconditioner,
                            preconditioner.JacobiPreconditioner)):
         return existingSolver
     return ConjugateGradient(
         preconditioner=preconditioner.JacobiPreconditioner(),
         tolerance=self.tolerance,
         max_iterations=self.max_iterations)