4#include <boost/math/special_functions.hpp>
6#include "dg/algorithm.h"
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)
98 template<
class MatrixType0,
class MatrixType1,
class ContainerType0,
100 void operator()(MatrixType0&& A, MatrixType1&& wAinv,
const ContainerType0&
101 b, ContainerType1& x, std::array<value_type,2> EVs,
unsigned
114 const value_type Ks=boost::math::ellint_1(sqrt1mk2 );
116 for (
unsigned j=1; j<steps+1; j++)
118 t = (j-0.5)*Ks/steps;
120 c = 1./boost::math::jacobi_cn(sqrt1mk2, t);
121 s = boost::math::jacobi_sn(sqrt1mk2, t)*c;
122 d = boost::math::jacobi_dn(sqrt1mk2, t)*c;
143template<
class Container>
169 template<
class MatrixType>
175 std::array<value_type,2> EVs,
int exp)
179 m_iterCauchy = iterCauchy;
180 m_cauchysqrtint.construct(weights);
185 m_op = m_cauchysqrtint.make_denominator(A);
186 m_wAinv = [&, eps = epsCG, w = weights]
188 m_pcg.
solve( m_op,
y,
x, 1., w, eps);
193 template<
class ...Params>
208 m_cauchysqrtint(m_A, m_wAinv, b,
x, m_EVs, m_iterCauchy, m_exp);
212 unsigned m_iterCauchy;
216 std::array<value_type,2> m_EVs;
unsigned solve(MatrixType0 &&A, ContainerType0 &x, const ContainerType1 &b, MatrixType1 &&P, const ContainerType2 &W, double eps=1e-12, double nrmb_correction=1, int test_frequency=1)
void construct(Params &&...ps)
void copy(const ContainerTypeIn &source, ContainerTypeOut &target)
void axpby(value_type alpha, const ContainerType1 &x, value_type1 beta, ContainerType &y)
void symv(MatrixType &&M, const ContainerType1 &x, ContainerType2 &y)
typename TensorTraits< std::decay_t< Vector > >::value_type get_value_type
dg::DVec Container
Definition lanczos_b.cpp:19
Functions for optimizing Contours.
#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:145
Container container_type
Definition sqrt_cauchy.h:147
unsigned operator()(const Container &b, Container &x)
Compute via sqrt Cauchy integral solve.
Definition sqrt_cauchy.h:206
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:170
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition sqrt_cauchy.h:194
DirectSqrtCauchy()
empty object ( no memory allocation)
Definition sqrt_cauchy.h:150
dg::get_value_type< Container > value_type
Definition sqrt_cauchy.h:148
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:100
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
double value_type
Definition tridiaginv_b.cpp:6