Go to the documentation of this file.
10 #ifndef vtk_m_NewtonsMethod_h
11 #define vtk_m_NewtonsMethod_h
21 template <
typename ScalarType, vtkm::IdComponent Size>
62 template <
typename ScalarType,
64 typename JacobianFunctor,
65 typename FunctionFunctor>
67 JacobianFunctor jacobianEvaluator,
68 FunctionFunctor functionEvaluator,
71 ScalarType convergeDifference = ScalarType(1e-3),
77 VectorType x = initialGuess;
80 bool converged =
false;
81 for (
vtkm::IdComponent iteration = 0; !converged && (iteration < maxIterations); iteration++)
92 MatrixType jacobian = jacobianEvaluator(x);
93 VectorType currentFunctionOutput = functionEvaluator(x);
107 converged &= (vtkm::Abs(deltaX[index]) < convergeDifference);
112 return { valid, converged, x };
117 #endif //vtk_m_NewtonsMethod_h
bool Valid
True if Newton's method ran into a singularity.
Definition: NewtonsMethod.h:25
Groups connected points that have the same field value.
Definition: Atomic.h:19
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
An object returned from NewtonsMethod() that contains the result and other information about the fina...
Definition: NewtonsMethod.h:22
NewtonsMethodResult< ScalarType, Size > NewtonsMethod(JacobianFunctor jacobianEvaluator, FunctionFunctor functionEvaluator, vtkm::Vec< ScalarType, Size > desiredFunctionOutput, vtkm::Vec< ScalarType, Size > initialGuess=vtkm::Vec< ScalarType, Size >(ScalarType(0)), ScalarType convergeDifference=ScalarType(1e-3), vtkm::IdComponent maxIterations=10)
Uses Newton's method (a.k.a.
Definition: NewtonsMethod.h:66
vtkm::Vec< ScalarType, Size > Solution
The solution found by Newton's method.
Definition: NewtonsMethod.h:31
vtkm::Vec< T, Size > SolveLinearSystem(const vtkm::Matrix< T, Size, Size > &A, const vtkm::Vec< T, Size > &b, bool &valid)
Solve the linear system Ax = b for x.
Definition: Matrix.h:448
Basic Matrix type.
Definition: Matrix.h:33
bool Converged
True if Newton's method converted to below the convergence value.
Definition: NewtonsMethod.h:27
#define VTKM_SUPPRESS_EXEC_WARNINGS
Definition: ExportMacros.h:53