35template<
class ContainerType>
44 EVE(
const ContainerType& copyable,
unsigned max_iter = 100):r( copyable), p( r), ap( r), m_max_iter( max_iter) {}
51 void construct(
const ContainerType& copyable,
unsigned max_iter = 100) {
52 ap = p = r = copyable;
53 m_max_iter = max_iter;
60 unsigned get_max()
const {
return m_max_iter; }
63 m_throw_on_fail = throw_on_fail;
86 template<
class MatrixType0,
class ContainerType0,
class ContainerType1,
class MatrixType1,
class ContainerType2>
87 unsigned solve( MatrixType0&& A, ContainerType0& x,
const ContainerType1& b, MatrixType1&& P,
const ContainerType2& W,
value_type& ev_max,
value_type eps_ev = 1e-12);
89 ContainerType r, p, ap;
91 bool m_throw_on_fail =
true;
96template<
class ContainerType>
97template<
class Matrix,
class ContainerType0,
class ContainerType1,
class Preconditioner,
class ContainerType2>
98unsigned EVE< ContainerType>::solve( Matrix&& A, ContainerType0& x,
const ContainerType1& b, Preconditioner&& P,
const ContainerType2& W, value_type& ev_max, value_type eps_ev )
102 blas2::symv( std::forward<Preconditioner>(P), r, p );
104 value_type nrmzr_new, nrmAp;
105 value_type alpha = 1., alpha_inv = 1.,
delta = 0.;
106 value_type evdash, gamma = 0., lambda, omega, beta = 0.;
107 value_type ev_est = 0.;
109 for(
unsigned i=1; i<m_max_iter; i++)
111 lambda =
delta*alpha_inv;
114 alpha = nrmzr_old/nrmAp;
115 alpha_inv = nrmAp/nrmzr_old;
121 delta = nrmzr_new /nrmzr_old;
122 evdash = ev_est -lambda;
123 omega = sqrt( evdash*evdash +4.*beta*gamma);
124 gamma = 0.5 *(1. -evdash /omega);
125 ev_max += omega*gamma;
126 beta =
delta*alpha_inv*alpha_inv;
127 if( fabs( ev_est - ev_max) < eps_ev*ev_max)
136 <<
"After "<<m_max_iter<<
" EVE iterations");
The Eigen-Value-Estimator (EVE) finds largest Eigenvalue of .
Definition: eve.h:37
EVE(const ContainerType ©able, unsigned max_iter=100)
Allocate memory for the pcg method.
Definition: eve.h:44
void set_max(unsigned new_max)
Set maximum number of iterations.
Definition: eve.h:56
void construct(const ContainerType ©able, unsigned max_iter=100)
Allocate memory for the pcg method.
Definition: eve.h:51
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 .
get_value_type< ContainerType > value_type
Definition: eve.h:40
EVE()=default
Allocate nothing, Call construct method before usage.
unsigned get_max() const
Get maximum number of iterations.
Definition: eve.h:60
ContainerType container_type
Definition: eve.h:39
void set_throw_on_fail(bool throw_on_fail)
Set or unset a throw on failure-to-converge.
Definition: eve.h:62
#define _ping_
Definition: exceptions.h:12
void axpby(get_value_type< ContainerType > alpha, const ContainerType1 &x, get_value_type< ContainerType > beta, ContainerType &y)
Definition: blas1.h:231
void symv(MatrixType &&M, const ContainerType1 &x, ContainerType2 &y)
Definition: blas2.h:287
get_value_type< MatrixType > dot(const ContainerType1 &x, const MatrixType &m, const ContainerType2 &y)
; Binary reproducible general dot product
Definition: blas2.h:85
Operator< real_type > delta(unsigned n)
Create the unit matrix.
Definition: operator.h:514
typename TensorTraits< std::decay_t< Vector > >::value_type get_value_type
Definition: tensor_traits.h:38
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
Indicate failure to converge.
Definition: exceptions.h:126