55template<
class ContainerType>
65 m_ax(
copyable), m_z( m_ax), m_xm1(m_ax){}
68 const ContainerType&
copyable()
const{
return m_ax;}
100 template<
class MatrixType,
class ContainerType0,
class ContainerType1>
101 void solve( MatrixType&& A, ContainerType0& x,
const ContainerType1& b,
106 assert ( min_ev < max_ev);
120 for (
unsigned k=1; k<num_iter; k++)
122 rhok = 1./(2.*theta/
delta - rhokm1);
158 template<
class MatrixType0,
class MatrixType1,
class ContainerType0,
class ContainerType1>
159 void solve( MatrixType0&& A, ContainerType0& x,
const ContainerType1& b,
161 bool x_is_zero =
false)
165 assert ( min_ev < max_ev);
179 if( num_iter == 1)
return;
183 for (
unsigned k=1; k<num_iter; k++)
185 rhok = 1./(2.*theta/
delta - rhokm1);
200 ContainerType m_ax, m_z, m_xm1;
223template<
class Matrix,
class ContainerType>
240 m_op(op), m_ch( copyable),
241 m_ev_min(ev_min), m_ev_max(ev_max), m_degree(degree){}
243 template<
class ContainerType0,
class ContainerType1>
244 void symv(
const ContainerType0& x, ContainerType1& y)
247 m_ch.solve( m_op,
y,
x, m_ev_min, m_ev_max, m_degree+1,
true);
269template<
class Matrix,
class ContainerType>
288 m_op(op), m_ax(copyable), m_z1(m_ax), m_z2(m_ax),
289 m_ev_min(ev_min), m_ev_max(ev_max), m_degree(degree){}
291 template<
class ContainerType0,
class ContainerType1>
292 void symv(
const ContainerType0& x, ContainerType1& y)
294 value_type theta = (m_ev_min+m_ev_max)/2.,
delta = (m_ev_max-m_ev_min)/2.;
297 if( m_degree == 0)
return;
300 c_k *= (sqrt( m_ev_min/m_ev_max) - 1.)/(sqrt(m_ev_min/m_ev_max)+1);
302 if( m_degree == 1)
return;
304 for(
unsigned i=1; i<m_degree; i++)
309 c_k *= (sqrt( m_ev_min/m_ev_max) - 1.)/(sqrt(m_ev_min/m_ev_max)+1);
317 ContainerType m_ax, m_z1, m_z2;
339template<
class Matrix,
class InnerPreconditioner,
class ContainerType>
355 m_ev_max( ev_max), m_degree(degree){
356 m_c = coeffs(degree);
362 template<
class ContainerType0,
class ContainerType1>
363 void symv(
const ContainerType0& x, ContainerType1& y)
367 for(
int i=m_degree-1; i>=0; i--)
378 std::vector<value_type> coeffs(
unsigned degree){
381 case 1:
return {5., -1.};
382 case 2:
return { 14., -7., 1.};
383 case 3:
return {30., -27., 9., -1.};
384 case 4:
return {55., -77., 44., -11., 1.};
385 case 5:
return {91., -182., 156., -65., 13., -1. };
386 case 6:
return {140., -378., 450., -275., 90., -15., 1. };
387 case 7:
return {204., -714.,1122., -935., 442., -119., 17., -1.};
388 case 8:
return {285.,-1254., 2508., -2717., 1729., -665., 152., -19., 1.};
389 case 9:
return {385., -2079., 5148.,-7007.,5733.,-2940.,952.,-189.,21.,-1.};
392 std::cerr <<
"WARNING: LeastSquares Case "<<degree<<
" not implemented. Taking 10 instead!\n";
393 return {506., -3289., 9867.,-16445.,16744.,-10948.,4692.,-1311.,230.,-23.,1. };
396 std::vector<value_type> m_c;
398 InnerPreconditioner m_p;
405template<
class M,
class V>
406struct TensorTraits<ChebyshevPreconditioner<M,V>>
411template<
class M,
class V>
412struct TensorTraits<ModifiedChebyshevPreconditioner<M,V>>
417template<
class M,
class P,
class V>
418struct TensorTraits<LeastSquaresPreconditioner<M,P,V>>
Preconditioned Chebyshev iteration for solving .
Definition: chebyshev.h:57
get_value_type< ContainerType > value_type
Definition: chebyshev.h:60
const ContainerType & copyable() const
Return an object of same size as the object used for construction.
Definition: chebyshev.h:68
void solve(MatrixType0 &&A, ContainerType0 &x, const ContainerType1 &b, MatrixType1 &&P, value_type min_ev, value_type max_ev, unsigned num_iter, bool x_is_zero=false)
Solve the system using num_iter Preconditioned Chebyshev iteration.
Definition: chebyshev.h:159
ChebyshevIteration(const ContainerType ©able)
Allocate memory for the pcg method.
Definition: chebyshev.h:64
ContainerType container_type
Definition: chebyshev.h:59
ChebyshevIteration()=default
Allocate nothing, Call construct method before usage.
void construct(const ContainerType ©able)
Allocate memory for the pcg method.
Definition: chebyshev.h:75
void solve(MatrixType &&A, ContainerType0 &x, const ContainerType1 &b, value_type min_ev, value_type max_ev, unsigned num_iter, bool x_is_zero=false)
Solve the system using num_iter Chebyshev iteration.
Definition: chebyshev.h:101
void copy(const ContainerTypeIn &source, ContainerTypeOut &target)
Definition: blas1.h:164
void axpbypgz(get_value_type< ContainerType > alpha, const ContainerType1 &x, get_value_type< ContainerType > beta, const ContainerType2 &y, get_value_type< ContainerType > gamma, ContainerType &z)
Definition: blas1.h:265
void axpby(get_value_type< ContainerType > alpha, const ContainerType1 &x, get_value_type< ContainerType > beta, ContainerType &y)
Definition: blas1.h:231
void scal(ContainerType &x, get_value_type< ContainerType > alpha)
Definition: blas1.h:185
void evaluate(ContainerType &y, BinarySubroutine f, Functor g, const ContainerType0 &x0, const ContainerTypes &...xs)
Definition: blas1.h:556
void symv(MatrixType &&M, const ContainerType1 &x, ContainerType2 &y)
Definition: blas2.h:287
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...
Chebyshev Polynomial Preconditioner .
Definition: chebyshev.h:225
ChebyshevPreconditioner(Matrix op, const ContainerType ©able, value_type ev_min, value_type ev_max, unsigned degree)
Construct the k-th Chebyshev Polynomial.
Definition: chebyshev.h:238
ContainerType container_type
Definition: chebyshev.h:226
void symv(const ContainerType0 &x, ContainerType1 &y)
Definition: chebyshev.h:244
get_value_type< ContainerType > value_type
value type of the ContainerType class
Definition: chebyshev.h:227
Least Squares Polynomial Preconditioner .
Definition: chebyshev.h:341
const ContainerType & copyable() const
Return an object of same size as the object used for construction.
Definition: chebyshev.h:360
get_value_type< ContainerType > value_type
value type of the ContainerType class
Definition: chebyshev.h:343
ContainerType container_type
Definition: chebyshev.h:342
void symv(const ContainerType0 &x, ContainerType1 &y)
Definition: chebyshev.h:363
LeastSquaresPreconditioner(Matrix op, InnerPreconditioner P, const ContainerType ©able, value_type ev_max, unsigned degree)
Construct k-th Least Squares Polynomial.
Definition: chebyshev.h:353
Approximate inverse Chebyshev Polynomial Preconditioner .
Definition: chebyshev.h:271
void symv(const ContainerType0 &x, ContainerType1 &y)
Definition: chebyshev.h:292
ContainerType container_type
Definition: chebyshev.h:272
get_value_type< ContainerType > value_type
value type of the ContainerType class
Definition: chebyshev.h:273
ModifiedChebyshevPreconditioner(Matrix op, const ContainerType ©able, value_type ev_min, value_type ev_max, unsigned degree)
Construct the k-th Chebyshev Polynomial approximate.
Definition: chebyshev.h:286
Definition: subroutines.h:108
NotATensorTag tensor_category
Definition: tensor_traits.h:33
void value_type
Definition: tensor_traits.h:32
Definition: subroutines.h:22