53template<
class ContainerType>
63 m_ax(
copyable), m_z( m_ax), m_xm1(m_ax){}
66 const ContainerType&
copyable()
const{
return m_ax;}
97 template<
class MatrixType,
class ContainerType0,
class ContainerType1>
98 void solve( MatrixType&& A, ContainerType0& x,
const ContainerType1& b,
103 assert ( min_ev < max_ev);
104 value_type theta = (min_ev+max_ev)/2., delta = (max_ev-min_ev)/2.;
117 for (
unsigned k=1; k<num_iter; k++)
119 rhok = 1./(2.*theta/delta - rhokm1);
154 template<
class MatrixType0,
class MatrixType1,
class ContainerType0,
class ContainerType1>
155 void solve( MatrixType0&& A, ContainerType0& x,
const ContainerType1& b,
157 bool x_is_zero =
false)
161 assert ( min_ev < max_ev);
162 value_type theta = (min_ev+max_ev)/2., delta = (max_ev-min_ev)/2.;
175 if( num_iter == 1)
return;
179 for (
unsigned k=1; k<num_iter; k++)
181 rhok = 1./(2.*theta/delta - rhokm1);
196 ContainerType m_ax, m_z, m_xm1;
219template<
class Matrix,
class ContainerType>
235 m_op(op), m_ch( copyable),
236 m_ev_min(ev_min), m_ev_max(ev_max), m_degree(degree){}
238 template<
class ContainerType0,
class ContainerType1>
239 void symv(
const ContainerType0& x, ContainerType1&
y)
242 m_ch.solve( m_op,
y,
x, m_ev_min, m_ev_max, m_degree+1,
true);
264template<
class Matrix,
class ContainerType>
282 m_op(op), m_ax(copyable), m_z1(m_ax), m_z2(m_ax),
283 m_ev_min(ev_min), m_ev_max(ev_max), m_degree(degree){}
285 template<
class ContainerType0,
class ContainerType1>
286 void symv(
const ContainerType0& x, ContainerType1&
y)
288 value_type theta = (m_ev_min+m_ev_max)/2., delta = (m_ev_max-m_ev_min)/2.;
291 if( m_degree == 0)
return;
294 c_k *= (sqrt( m_ev_min/m_ev_max) - 1.)/(sqrt(m_ev_min/m_ev_max)+1);
296 if( m_degree == 1)
return;
298 for(
unsigned i=1; i<m_degree; i++)
303 c_k *= (sqrt( m_ev_min/m_ev_max) - 1.)/(sqrt(m_ev_min/m_ev_max)+1);
311 ContainerType m_ax, m_z1, m_z2;
333template<
class Matrix,
class InnerPreconditioner,
class ContainerType>
349 m_ev_max( ev_max), m_degree(degree){
350 m_c = coeffs(degree);
356 template<
class ContainerType0,
class ContainerType1>
357 void symv(
const ContainerType0& x, ContainerType1&
y)
361 for(
int i=m_degree-1; i>=0; i--)
372 std::vector<value_type> coeffs(
unsigned degree){
375 case 1:
return {5., -1.};
376 case 2:
return { 14., -7., 1.};
377 case 3:
return {30., -27., 9., -1.};
378 case 4:
return {55., -77., 44., -11., 1.};
379 case 5:
return {91., -182., 156., -65., 13., -1. };
380 case 6:
return {140., -378., 450., -275., 90., -15., 1. };
381 case 7:
return {204., -714.,1122., -935., 442., -119., 17., -1.};
382 case 8:
return {285.,-1254., 2508., -2717., 1729., -665., 152., -19., 1.};
383 case 9:
return {385., -2079., 5148.,-7007.,5733.,-2940.,952.,-189.,21.,-1.};
386 std::cerr <<
"WARNING: LeastSquares Case "<<degree<<
" not implemented. Taking 10 instead!\n";
387 return {506., -3289., 9867.,-16445.,16744.,-10948.,4692.,-1311.,230.,-23.,1. };
390 std::vector<value_type> m_c;
392 InnerPreconditioner m_p;
399template<
class M,
class V>
400struct TensorTraits<ChebyshevPreconditioner<M,V>>
405template<
class M,
class V>
406struct TensorTraits<ModifiedChebyshevPreconditioner<M,V>>
411template<
class M,
class P,
class V>
412struct TensorTraits<LeastSquaresPreconditioner<M,P,V>>
Preconditioned Chebyshev iteration for solving .
Definition chebyshev.h:55
get_value_type< ContainerType > value_type
Definition chebyshev.h:58
const ContainerType & copyable() const
Return an object of same size as the object used for construction.
Definition chebyshev.h:66
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:155
ChebyshevIteration(const ContainerType ©able)
Allocate memory for the pcg method.
Definition chebyshev.h:62
ContainerType container_type
Definition chebyshev.h:57
ChebyshevIteration()=default
Allocate nothing, Call construct method before usage.
void construct(const ContainerType ©able)
Allocate memory for the pcg method.
Definition chebyshev.h:73
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:98
void copy(const ContainerTypeIn &source, ContainerTypeOut &target)
Definition blas1.h:243
void axpbypgz(value_type alpha, const ContainerType1 &x, value_type1 beta, const ContainerType2 &y, value_type2 gamma, ContainerType &z)
Definition blas1.h:337
void axpby(value_type alpha, const ContainerType1 &x, value_type1 beta, ContainerType &y)
Definition blas1.h:306
void evaluate(ContainerType &y, BinarySubroutine f, Functor g, const ContainerType0 &x0, const ContainerTypes &...xs)
Definition blas1.h:612
void scal(ContainerType &x, value_type alpha)
Definition blas1.h:263
void symv(MatrixType &&M, const ContainerType1 &x, ContainerType2 &y)
Definition blas2.h:331
typename TensorTraits< std::decay_t< Vector > >::value_type get_value_type
Definition tensor_traits.h:45
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
Chebyshev Polynomial Preconditioner .
Definition chebyshev.h:221
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:233
ContainerType container_type
Definition chebyshev.h:222
void symv(const ContainerType0 &x, ContainerType1 &y)
Definition chebyshev.h:239
get_value_type< ContainerType > value_type
value type of the ContainerType class
Definition chebyshev.h:223
Ell Sparse Block Matrix format.
Definition sparseblockmat.h:46
Least Squares Polynomial Preconditioner .
Definition chebyshev.h:335
const ContainerType & copyable() const
Return an object of same size as the object used for construction.
Definition chebyshev.h:354
get_value_type< ContainerType > value_type
value type of the ContainerType class
Definition chebyshev.h:337
ContainerType container_type
Definition chebyshev.h:336
void symv(const ContainerType0 &x, ContainerType1 &y)
Definition chebyshev.h:357
LeastSquaresPreconditioner(Matrix op, InnerPreconditioner P, const ContainerType ©able, value_type ev_max, unsigned degree)
Construct k-th Least Squares Polynomial.
Definition chebyshev.h:347
Approximate inverse Chebyshev Polynomial Preconditioner .
Definition chebyshev.h:266
void symv(const ContainerType0 &x, ContainerType1 &y)
Definition chebyshev.h:286
ContainerType container_type
Definition chebyshev.h:267
get_value_type< ContainerType > value_type
value type of the ContainerType class
Definition chebyshev.h:268
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:280
Definition subroutines.h:124
NotATensorTag tensor_category
Definition tensor_traits.h:40
Definition subroutines.h:22