24 static constexpr T
eps = std::numeric_limits<T>::epsilon();
32 inline void laguer13(
const std::vector<std::complex<T>>& a, std::complex<T>& x,
int& lam){
33 std::complex<T> dx, x1,
b, d, f, g, h, sq, gp, gm, g2;
37 b = std::complex<T>(1.0, 0.0);
39 d = f = std::complex<T>(0.0, 0.0);
42 for (
int j = m - 1;
j >= 0;
j--) {
52 g =
static_cast<T
>(lam)*
b / d;
53 h =
static_cast<T
>(2)*f / d;
54 sq = std::sqrt(
fma(-g, h,
static_cast<T
>(lam - 1)));
55 dx = g/std::abs(
static_cast<T
>(1) + sq);
74 void operator()(std::vector<T>& poly, std::vector<std::complex<T>>& roots, std::vector<int>& conv,
int itmax=80)
override{
75 std::complex<T> x, _b, _c;
76 int m = poly.size() - 1;
77 std::vector<std::complex<T>> ad(m + 1);
78 std::vector<std::complex<T>> ad_v;
83 for (
int i = 0; i <= m; i++)
87 std::vector<T> remainder;
90 bool zeros = std::all_of(remainder.begin(), remainder.end(), [](
int i) { return i==0; });
98 std::vector<T> remainder1;
100 zeros = std::all_of(remainder1.begin(), remainder1.end(), [](
int i) { return i==0; });
102 m1 = m - remainder.size() + 1;
108 for (
int i = 0; i < m1; ++i){
109 x = std::complex<T>(0.0, 0.0);
112 ad_v = std::vector<std::complex<T>>(ad.cbegin(), ad.cbegin() +
j + 2);
114 if (std::abs(imag(x)) <= std::abs(real(x)) *
eps)
115 x.imag(
static_cast<T
>(0));
117 for (
int k = 0;
k < lambda/2; ++
k){
121 for (
int jj =
j; jj >= 0; jj--) {
std::vector< double > err(double q, double x)
Definition Laguerre15m.h:96
p2 de j *z j
Definition Laguerre15m_or.h:23
cohn_schur ra local b
Definition Laguerre15m_or.h:3
cohn_schur ra local k
Definition Laguerre15m_or.h:3
Definition BaseSolver.h:7
Definition Laguerre13m.h:21
void laguer13(const std::vector< std::complex< T > > &a, std::complex< T > &x, int &lam)
Laguerre's method to find a root of a polynomial.
Definition Laguerre13m.h:32
static constexpr T eps
Definition Laguerre13m.h:24
void operator()(std::vector< T > &poly, std::vector< std::complex< T > > &roots, std::vector< int > &conv, int itmax=80) override
Find the roots of a polynomial using Laguerre's method.
Definition Laguerre13m.h:74
ModifiedLaguerre13()
Definition Laguerre13m.h:63
Definition ExtendedFunctions.h:14
void getRemainder(vector< T > dividend, vector< T > divisor, vector< T > &remainder)
Divide vectors (coefficients of polynomials)
Definition ExtendedFunctions.h:194
complex< number > fma(complex< number > a, complex< number > b, complex< number > c)
Fused multiply-add for complex numbers.
Definition ExtendedFunctions.h:82
vector< T > diff(vector< T > coeffs, int deg=1)
Diff vector.
Definition ExtendedFunctions.h:143