Go to the documentation of this file.
18 #ifndef viskores_NewtonsMethod_h
19 #define viskores_NewtonsMethod_h
29 template <
typename ScalarType, viskores::IdComponent Size>
70 template <
typename ScalarType,
72 typename JacobianFunctor,
73 typename FunctionFunctor>
75 JacobianFunctor jacobianEvaluator,
76 FunctionFunctor functionEvaluator,
79 ScalarType convergeDifference = ScalarType(1e-3),
85 VectorType x = initialGuess;
88 bool converged =
false;
100 MatrixType jacobian = jacobianEvaluator(x);
101 VectorType currentFunctionOutput = functionEvaluator(x);
115 converged &= (viskores::Abs(deltaX[index]) < convergeDifference);
120 return { valid, converged, x };
125 #endif //viskores_NewtonsMethod_h
viskores::Vec< T, Size > SolveLinearSystem(const viskores::Matrix< T, Size, Size > &A, const viskores::Vec< T, Size > &b, bool &valid)
Solve the linear system Ax = b for x.
Definition: Matrix.h:460
#define VISKORES_SUPPRESS_EXEC_WARNINGS
Definition: ExportMacros.h:61
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
#define VISKORES_EXEC_CONT
Definition: ExportMacros.h:60
bool Valid
True if Newton's method ran into a singularity.
Definition: NewtonsMethod.h:33
Groups connected points that have the same field value.
Definition: Atomic.h:27
Basic Matrix type.
Definition: Matrix.h:41
bool Converged
True if Newton's method converted to below the convergence value.
Definition: NewtonsMethod.h:35
NewtonsMethodResult< ScalarType, Size > NewtonsMethod(JacobianFunctor jacobianEvaluator, FunctionFunctor functionEvaluator, viskores::Vec< ScalarType, Size > desiredFunctionOutput, viskores::Vec< ScalarType, Size > initialGuess=viskores::Vec< ScalarType, Size >(ScalarType(0)), ScalarType convergeDifference=ScalarType(1e-3), viskores::IdComponent maxIterations=10)
Uses Newton's method (a.k.a.
Definition: NewtonsMethod.h:74
viskores::Vec< ScalarType, Size > Solution
The solution found by Newton's method.
Definition: NewtonsMethod.h:39
An object returned from NewtonsMethod() that contains the result and other information about the fina...
Definition: NewtonsMethod.h:30