![]() |
User Guide
|
Solver implementation details. More...
Solver implementation details.
Implementation of Newton method for solving system of non-linear equations using Eigen
Functions | |
| template<int N> | |
| EIGEN_DEVICE_FUNC bool | nmodl::newton::is_converged (const Eigen::Matrix< double, N, 1 > &X, const Eigen::Matrix< double, N, N > &J, const Eigen::Matrix< double, N, 1 > &F, double eps) |
| template<int N, typename FUNC > | |
| EIGEN_DEVICE_FUNC int | nmodl::newton::newton_solver (Eigen::Matrix< double, N, 1 > &X, FUNC functor, double eps=EPS, int max_iter=MAX_ITER) |
| Newton method with user-provided Jacobian. More... | |
| template<typename FUNC , int N> | |
| EIGEN_DEVICE_FUNC int | nmodl::newton::newton_solver_small_N (Eigen::Matrix< double, N, 1 > &X, FUNC functor, double eps, int max_iter) |
Newton method template specializations for \(N <= 4\) Use explicit inverse of F instead of LU decomposition. More... | |
| template<typename FUNC > | |
| EIGEN_DEVICE_FUNC int | nmodl::newton::newton_solver (Eigen::Matrix< double, 1, 1 > &X, FUNC functor, double eps=EPS, int max_iter=MAX_ITER) |
| template<typename FUNC > | |
| EIGEN_DEVICE_FUNC int | nmodl::newton::newton_solver (Eigen::Matrix< double, 2, 1 > &X, FUNC functor, double eps=EPS, int max_iter=MAX_ITER) |
| template<typename FUNC > | |
| EIGEN_DEVICE_FUNC int | nmodl::newton::newton_solver (Eigen::Matrix< double, 3, 1 > &X, FUNC functor, double eps=EPS, int max_iter=MAX_ITER) |
| template<typename FUNC > | |
| EIGEN_DEVICE_FUNC int | nmodl::newton::newton_solver (Eigen::Matrix< double, 4, 1 > &X, FUNC functor, double eps=EPS, int max_iter=MAX_ITER) |
Variables | |
| static constexpr int | nmodl::newton::MAX_ITER = 50 |
| static constexpr double | nmodl::newton::EPS = 1e-13 |
| EIGEN_DEVICE_FUNC bool nmodl::newton::is_converged | ( | const Eigen::Matrix< double, N, 1 > & | X, |
| const Eigen::Matrix< double, N, N > & | J, | ||
| const Eigen::Matrix< double, N, 1 > & | F, | ||
| double | eps | ||
| ) |
Definition at line 41 of file newton.hpp.
| EIGEN_DEVICE_FUNC int nmodl::newton::newton_solver | ( | Eigen::Matrix< double, 1, 1 > & | X, |
| FUNC | functor, | ||
| double | eps = EPS, |
||
| int | max_iter = MAX_ITER |
||
| ) |
Definition at line 153 of file newton.hpp.
| EIGEN_DEVICE_FUNC int nmodl::newton::newton_solver | ( | Eigen::Matrix< double, 2, 1 > & | X, |
| FUNC | functor, | ||
| double | eps = EPS, |
||
| int | max_iter = MAX_ITER |
||
| ) |
Definition at line 161 of file newton.hpp.
| EIGEN_DEVICE_FUNC int nmodl::newton::newton_solver | ( | Eigen::Matrix< double, 3, 1 > & | X, |
| FUNC | functor, | ||
| double | eps = EPS, |
||
| int | max_iter = MAX_ITER |
||
| ) |
Definition at line 169 of file newton.hpp.
| EIGEN_DEVICE_FUNC int nmodl::newton::newton_solver | ( | Eigen::Matrix< double, 4, 1 > & | X, |
| FUNC | functor, | ||
| double | eps = EPS, |
||
| int | max_iter = MAX_ITER |
||
| ) |
Definition at line 177 of file newton.hpp.
| EIGEN_DEVICE_FUNC int nmodl::newton::newton_solver | ( | Eigen::Matrix< double, N, 1 > & | X, |
| FUNC | functor, | ||
| double | eps = EPS, |
||
| int | max_iter = MAX_ITER |
||
| ) |
Newton method with user-provided Jacobian.
Newton method with user-provided Jacobian: given initial vector X and a functor that calculates F(X), J(X) where J(X) is the Jacobian of F(X), solves for \(F(X) = 0\), starting with initial value of X by iterating:
\[ X_{n+1} = X_n - J(X_n)^{-1} F(X_n) \]
when \(|F|^2 < eps^2\), solution has converged.
Definition at line 80 of file newton.hpp.
| EIGEN_DEVICE_FUNC int nmodl::newton::newton_solver_small_N | ( | Eigen::Matrix< double, N, 1 > & | X, |
| FUNC | functor, | ||
| double | eps, | ||
| int | max_iter | ||
| ) |
Newton method template specializations for \(N <= 4\) Use explicit inverse of F instead of LU decomposition.
This is faster, as there is no pivoting and therefore no branches, but it is not numerically safe for \(N > 4\).
Definition at line 126 of file newton.hpp.
|
staticconstexpr |
Definition at line 38 of file newton.hpp.
|
staticconstexpr |
Definition at line 37 of file newton.hpp.