Chi-Tech
serial_newton_iteration.h
Go to the documentation of this file.
1#ifndef CHI_MATH_SERIAL_NEWTON_ITERATION_H
2#define CHI_MATH_SERIAL_NEWTON_ITERATION_H
3
4#include <vector>
5#include <cassert>
6
7#include "math/chi_math.h"
8
9
10namespace chi_math
11{
12 /**A simple base class for the evaluation of a non-linear function
13 * and its Jacobian-matrix.*/
15 {
16 public:
17 /**Function evaluation at vector-x.*/
18 virtual VecDbl F(const VecDbl& x) const
19 {
20 VecDbl result(x.size(), 0.0);
21 return result;
22 }
23 /**Jacobian evaluation at vector-x.*/
24 virtual MatDbl J(const VecDbl& x) const
25 {
26 MatDbl result(x.size(), VecDbl(x.size(), 0.0));
27 return result;
28 }
29
30 virtual ~NonLinearFunction() = default;
31 };
32
33 VecDbl NewtonIteration(const NonLinearFunction& non_linear_function,
34 const VecDbl& x_0,
35 unsigned int max_iters,
36 double epsilon,
37 bool verbose=false);
38
39}//namespace chi_math
40
41#endif //CHI_MATH_SERIAL_NEWTON_ITERATION_H
std::vector< VecDbl > MatDbl
Definition: chi_math.h:13
std::vector< double > VecDbl
Definition: chi_math.h:12
virtual MatDbl J(const VecDbl &x) const
virtual VecDbl F(const VecDbl &x) const
virtual ~NonLinearFunction()=default
VecDbl NewtonIteration(const NonLinearFunction &non_linear_function, const VecDbl &x_0, unsigned int max_iters, double epsilon, bool verbose=false)