namespace ietl {
template <class T>
class basic_iteration {
public:
basic_iteration(unsigned int max_iter, T reltol, T abstol = 0.);
bool finished(T residual, T lambda);
bool converged(T residual, T lambda);
void operator++();
unsigned int iterations();
unsigned int max_iterations();
T relative_tolerance();
T absolute_tolerance();
int error_code();
};
basic_iteration(unsigned int max_iter, T reltol, T abstol = 0.)The constructor takes three arguments: the maximum number of iterations to be performed and the relative and absolute tolerances
bool finished(T residual, T lambda);Both these functions take the current residual ||Av-lambda v|| and the current estimate of the eigenvalue lambda as arguments. converged returns true if the residual is smaller than either the absolute tolerance or smaller than the relative tolerance multiplied by lambda. finished is true if either converged is true or the maximum number of iterations has been exceeded.
bool converged(T residual, T lambda);
void operator++();increments the iteration counter.
unsigned int iterations();
returns the number of iterations performed.
unsigned int max_iterations();return the maximum number of iterations, and the relative and absolute tolerances respectively.
T relative_tolerance();
T absolute_tolerance();
int error_code();returns 1 if the maximum number of iterations has been exceeded and 0 otherwise.
template <class T>
class fixed_lanczos_iteration {
public:
fixed_lanczos_iteration(unsigned int max_iter);
template <class Tmatrix>
bool finished(const Tmatrix& tmatrix) const;
inline void operator++();
};
template <class T>
class lanczos_iteration_nlowest {
public:
lanczos_iteration_nlowest(unsigned int max_iter, unsigned int n= 1,
T r = 100.*std::numeric_limits<T>::epsilon(),
T a = 100.*std::numeric_limits<T>::epsilon());
template <class Tmatrix>
bool finished(const Tmatrix& tmatrix) const;
template <class Tmatrix>
inline bool converged(const Tmatrix& tmatrix);
inline void operator++();
inline int error_code() const;
inline unsigned int iterations() const;
inline unsigned int max_iterations() const;
inline T relative_tolerance() const;
inline T absolute_tolerance() const;
};
template <class T>
class lanczos_iteration_nhighest {
public:
lanczos_iteration_nhighest(unsigned int max_iter, unsigned int n= 1,
T r = 100.*std::numeric_limits<T>::epsilon(),
T a = 100.*std::numeric_limits<T>::epsilon())
template <class Tmatrix>
bool finished(const Tmatrix& tmatrix) const;
template <class Tmatrix>
inline bool converged(const Tmatrix& tmatrix);
inline void operator++();
inline int error_code() const;
inline unsigned int iterations() const;
inline unsigned int max_iterations() const;
inline T relative_tolerance() const;
inline T absolute_tolerance() const;
};
fixed_lanczos_iteration(unsigned int max_iter);
The number of iterations passed to the constructor is the number of iterations that will be performed.
template <class Tmatrix>
bool finished(const Tmatrix& tmatrix) const;
returns true after the required number of iterations has been performed.
inline void operator++();
increments the iteration count by one. This is usually only called by the
IETL algorithms.
lanczos_iteration_nlowest(unsigned int max_iter, unsigned int n= 1,
T r = 100.*std::numeric_limits<T>::epsilon(),
T a = 100.*std::numeric_limits<T>::epsilon());
lanczos_iteration_nhighest(unsigned int max_iter, unsigned int n= 1,
T r = 100.*std::numeric_limits<T>::epsilon(),
T a = 100.*std::numeric_limits<T>::epsilon());
are the constructors and take the following arguments:
template <class Tmatrix>
bool finished(const Tmatrix& tmatrix) const;
template <class Tmatrix>
inline bool converged(const Tmatrix& tmatrix);
both these functions take a T-matrix of the Lanczos algorithm as argument and check whether the
n highest or lowest eigenvalues have converged. converged returns
true if they have converged. finished returns true either if they
have converged or if the maximum number of iterations has been exceeded.
void operator++();
increments the iteration counter.
unsigned int iterations();
returns the number of iterations performed.