4#include <boost/math/special_functions.hpp>
10#define M_PI 3.14159265358979323846
35template<
class Container>
49 m_helper = m_temp = m_helper3 = copyable;
52 template<
class ...Params>
60 const double&
w()
const{
return m_w;}
65 template<
class MatrixType>
67 return [&A=A, &
w = m_w] (
const auto&
x,
auto&
y)
97 template<
class MatrixType0,
class MatrixType1,
class ContainerType0,
99 void operator()(MatrixType0&& A, MatrixType1&& wAinv,
const ContainerType0&
100 b, ContainerType1& x, std::array<value_type,2> EVs,
unsigned
113 const value_type Ks=boost::math::ellint_1(sqrt1mk2 );
115 for (
unsigned j=1; j<steps+1; j++)
117 t = (j-0.5)*Ks/steps;
119 c = 1./boost::math::jacobi_cn(sqrt1mk2, t);
120 s = boost::math::jacobi_sn(sqrt1mk2, t)*c;
121 d = boost::math::jacobi_dn(sqrt1mk2, t)*c;
135 Container m_helper, m_temp, m_helper3;
142template<
class Container>
167 template<
class MatrixType>
173 std::array<value_type,2> EVs,
int exp)
177 m_iterCauchy = iterCauchy;
178 m_cauchysqrtint.construct(
weights);
180 m_A = [&](
const Container&
x, Container&
y){
183 m_op = m_cauchysqrtint.make_denominator(A);
184 m_wAinv = [&, eps = epsCG, w =
weights]
185 (
const Container&
x, Container&
y){
186 m_pcg.
solve( m_op,
y,
x, 1., w, eps);
191 template<
class ...Params>
206 m_cauchysqrtint(m_A, m_wAinv, b,
x, m_EVs, m_iterCauchy, m_exp);
210 unsigned m_iterCauchy;
211 std::function<void (
const Container&, Container&)> m_A, m_wAinv, m_op;
214 std::array<value_type,2> m_EVs;
void construct(Params &&...ps)
unsigned solve(MatrixType0 &&A, ContainerType0 &x, const ContainerType1 &b, MatrixType1 &&P, const ContainerType2 &W, value_type eps=1e-12, value_type nrmb_correction=1, int test_frequency=1)
void copy(const ContainerTypeIn &source, ContainerTypeOut &target)
void axpby(get_value_type< ContainerType > alpha, const ContainerType1 &x, get_value_type< ContainerType > beta, ContainerType &y)
void symv(MatrixType &&M, const ContainerType1 &x, ContainerType2 &y)
MPI_Vector< thrust::host_vector< real_type > > weights(const aRealMPITopology2d< real_type > &g)
typename TensorTraits< std::decay_t< Vector > >::value_type get_value_type
Classes for Krylov space approximations of a Matrix-Vector product.
#define M_PI
M_PI is non-standard ... so MSVC complains.
Definition: sqrt_cauchy.h:10
Shortcut for solve directly via sqrt Cauchy combined with PCG inversions.
Definition: sqrt_cauchy.h:144
Container container_type
Definition: sqrt_cauchy.h:146
unsigned operator()(const Container &b, Container &x)
Compute via sqrt Cauchy integral solve.
Definition: sqrt_cauchy.h:204
DirectSqrtCauchy(MatrixType &A, const Container &weights, value_type epsCG, unsigned iterCauchy, std::array< value_type, 2 > EVs, int exp)
Construct DirectSqrtCauchy.
Definition: sqrt_cauchy.h:168
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition: sqrt_cauchy.h:192
DirectSqrtCauchy()
empty object ( no memory allocation)
Definition: sqrt_cauchy.h:149
dg::get_value_type< Container > value_type
Definition: sqrt_cauchy.h:147
Cauchy integral
Definition: sqrt_cauchy.h:37
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition: sqrt_cauchy.h:53
dg::get_value_type< Container > value_type
Definition: sqrt_cauchy.h:40
void operator()(MatrixType0 &&A, MatrixType1 &&wAinv, const ContainerType0 &b, ContainerType1 &x, std::array< value_type, 2 > EVs, unsigned steps, int exp=+1)
Cauchy integral
Definition: sqrt_cauchy.h:99
auto make_denominator(MatrixType &A) const
Definition: sqrt_cauchy.h:66
SqrtCauchyInt(const Container ©able)
Construct Rhs operator.
Definition: sqrt_cauchy.h:47
SqrtCauchyInt()
Definition: sqrt_cauchy.h:41
const double & w() const
The in .
Definition: sqrt_cauchy.h:60
Container container_type
Definition: sqrt_cauchy.h:39