|
| EVE ()=default |
| Allocate nothing, Call construct method before usage. More...
|
|
| EVE (const ContainerType ©able, unsigned max_iter=100) |
| Allocate memory for the pcg method. More...
|
|
void | construct (const ContainerType ©able, unsigned max_iter=100) |
| Allocate memory for the pcg method. More...
|
|
void | set_max (unsigned new_max) |
| Set maximum number of iterations. More...
|
|
unsigned | get_max () const |
| Get maximum number of iterations. More...
|
|
void | set_throw_on_fail (bool throw_on_fail) |
| Set or unset a throw on failure-to-converge. More...
|
|
template<class MatrixType0 , class ContainerType0 , class ContainerType1 , class MatrixType1 , class ContainerType2 > |
unsigned | solve (MatrixType0 &&A, ContainerType0 &x, const ContainerType1 &b, MatrixType1 &&P, const ContainerType2 &W, value_type &ev_max, value_type eps_ev=1e-12) |
| Preconditioned CG to estimate maximum Eigenvalue of the generalized problem \( PAx = \lambda x\). More...
|
|
template<class ContainerType>
class dg::EVE< ContainerType >
The Eigen-Value-Estimator (EVE) finds largest Eigenvalue of \( M^{-1}Ax = \lambda_\max x\).
Estimate largest Eigenvalue of a symmetric positive definite matrix \( A\) with possible preconditioner \( M^{-1}\) using the conjugate gradient (CG) method. The unpreconditioned version is the algorithm suggested in Tichy, On error estimation in the conjugate gradient method: Normwise backward error, Proceedings of the Conference Algoritmy, 323-332, 2016 . The reason this works also for the preconditioned CG method is because preconditioned CG is equivalent to applying the unpreconditioned CG method to \( \bar A\bar x = \bar b\) with \( \bar A := {E^{-1}}^\mathrm{T} A E^{-1} \), \( \bar x := Ex\) and \( \bar b := {E^{-1}}^\mathrm{T}\), where \( M^{-1} = {E^{-1}}^\mathrm{T} E^{-1}\) is the preconditioner. The maximum Eigenvalue of \( M^{-1} A\) is the same as the maximum EV of \( {E^{-1}}^\mathrm{T} A E^{-1} \)
- Attention
- beware the sign: a negative definite matrix does not work in Conjugate gradient
- Template Parameters
-
ContainerType | Any class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag . Among others
dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them |
- See also
- See The dg dispatch system for a detailed explanation of our type dispatch system
template<class ContainerType >
template<class MatrixType0 , class ContainerType0 , class ContainerType1 , class MatrixType1 , class ContainerType2 >
unsigned dg::EVE< ContainerType >::solve |
( |
MatrixType0 && |
A, |
|
|
ContainerType0 & |
x, |
|
|
const ContainerType1 & |
b, |
|
|
MatrixType1 && |
P, |
|
|
const ContainerType2 & |
W, |
|
|
value_type & |
ev_max, |
|
|
value_type |
eps_ev = 1e-12 |
|
) |
| |
Preconditioned CG to estimate maximum Eigenvalue of the generalized problem \( PAx = \lambda x\).
where \( P\) is the preconditioner.
- Note
- This is just a regular PCG algorithm which updates an estimate for the largest Eigenvalue in each iteration and returns once the change is marginal. This means on output
x
is the same as after the same number of iterations of a regular PCG method. The original algorithm is suggested in Tichy, On error estimation in the conjugate gradient method: Normwise backward error, Proceedings of the Conference Algorithmy, 323-332, 2016
- Parameters
-
A | A symmetric, positive definit matrix |
x | Contains an initial value on input and the solution on output. |
b | The right hand side vector. x and b may be the same vector. |
P | The preconditioner ( \( M^{-1}\) in the above notation) |
W | The weights in which A and P are self-adjoint |
ev_max | (output) maximum Eigenvalue on output |
eps_ev | The desired accuracy of the largest Eigenvalue |
- Returns
- Number of iterations used to achieve desired precision or max_iterations
- Note
- The method will throw
dg::Fail
if the desired accuracy is not reached within max_iterations
You can unset this behaviour with the set_throw_on_fail
member
- Template Parameters
-
MatrixType | Any class for which a specialization of TensorTraits exists and defines a tensor_category derived from AnyMatrixTag . Furthermore, any functor/lambda type with signature void operator()( const ContainerType0&, ContainerType1&) . For example
In case of SelfMadeMatrixTag only those blas2 functions that have a corresponding member function in the Matrix class (e.g. symv( const ContainerType0&, ContainerType1&); ) can be called. If a Container has the RecursiveVectorTag , then the matrix is applied to each of the elements unless the type has the SelfMadeMatrixTag or is a Functor type. |
ContainerType | Any class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag . Among others
dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them |
- See also
- See The dg dispatch system for a detailed explanation of our type dispatch system