56 #include "../../../../Eigen/src/Core/util/NonMPL2.h"
58 #ifndef EIGEN_ITERATION_CONTROLLER_H
59 #define EIGEN_ITERATION_CONTROLLER_H
78 double m_resminreach, m_resadd;
88 m_resminreach = 1E50; m_resadd = 0.0;
95 void operator ++(
int) {
m_nit++; m_written =
false; m_resadd +=
m_res; }
96 void operator ++() { (*this)++; }
98 bool first() {
return m_nit == 0; }
101 int noiseLevel()
const {
return m_noise; }
102 void setNoiseLevel(
int n) {
m_noise = n; }
105 double maxResidual()
const {
return m_resmax; }
106 void setMaxResidual(
double r) {
m_resmax = r; }
108 double residual()
const {
return m_res; }
111 void setCallback(
void (*t)(
const IterationController&))
116 size_t iteration()
const {
return m_nit; }
117 void setIteration(
size_t i) {
m_nit = i; }
119 size_t maxIterarions()
const {
return m_maxiter; }
120 void setMaxIterations(
size_t i) {
m_maxiter = i; }
122 double rhsNorm()
const {
return m_rhsn; }
123 void setRhsNorm(
double r) {
m_rhsn = r; }
126 bool converged(
double nr)
130 m_resminreach = (std::min)(m_resminreach,
m_res);
133 template<
typename VectorType>
bool converged(
const VectorType &v)
134 {
return converged(v.squaredNorm()); }
136 bool finished(
double nr)
138 if (m_callback) m_callback(*
this);
146 template <
typename VectorType>
147 bool finished(
const MatrixBase<VectorType> &v)
148 {
return finished(
double(v.squaredNorm())); }
154 #endif // EIGEN_ITERATION_CONTROLLER_H
double m_res
last computed residual
Definition: IterationController.h:80
size_t m_nit
iteration number
Definition: IterationController.h:79
double m_resmax
maximum residual
Definition: IterationController.h:77
double m_rhsn
Right hand side norm.
Definition: IterationController.h:74
size_t m_maxiter
Max. number of iterations.
Definition: IterationController.h:75
Controls the iterations of the iterative solvers.
Definition: IterationController.h:71
int m_noise
if noise > 0 iterations are printed
Definition: IterationController.h:76