poly-laguerre-solve.cpp revision 29684a16b6c92bee28a94fdc2607bcc143950fa8
#include "poly-laguerre-solve.h"
#include <iterator>
double x0,
double tol,
bool & quad_root) {
double n = p.degree();
quad_root = false;
const unsigned shuffle_rate = 10;
unsigned shuffle_counter = 0;
//std::cout << "xk = " << xk << std::endl;
cdouble d = 0, f = 0;
for(int j = p.size()-2; j >= 0; j--) {
f = xk*f + d;
d = xk*d + b;
b = xk*b + p[j];
}
return xk;
//if(std::norm(px) < tol*tol)
// return xk;
//std::cout << "G = " << G << "H = " << H;
//assert(radicand.real() > 0);
quad_root = true;
//std::cout << "radicand = " << radicand << std::endl;
if(G.real() < 0) // here we try to maximise the denominator avoiding cancellation
else
//std::cout << "a = " << a << std::endl;
a = n / (a + G);
//std::cout << "a = " << a << std::endl;
if(shuffle_counter % shuffle_rate == 0)
;//a *= shuffle[shuffle_counter / shuffle_rate];
xk -= a;
if(shuffle_counter >= 90)
break;
}
//std::cout << "xk = " << xk << std::endl;
return xk;
}
double laguerre_internal(Poly const & p,
double x0,
double tol,
bool & quad_root) {
double a = 2*tol;
double n = p.degree();
quad_root = false;
//std::cout << "xk = " << xk << std::endl;
return xk;
//std::cout << "G = " << G << "H = " << H;
double radicand = (n - 1)*(n*H-G*G);
//std::cout << "radicand = " << radicand << std::endl;
if(G < 0) // here we try to maximise the denominator avoiding cancellation
else
//std::cout << "a = " << a << std::endl;
a = n / (a + G);
//std::cout << "a = " << a << std::endl;
xk -= a;
}
//std::cout << "xk = " << xk << std::endl;
return xk;
}
//std::cout << "p = " << p << " = ";
while(p.size() > 1)
{
double x0 = 0;
bool quad_root = false;
//if(abs(sol) > 1) break;
if(quad_root) {
//std::cout << "(" << dvs << ")";
//solutions.push_back(sol);
//solutions.push_back(conj(sol));
} else {
//std::cout << sol << std::endl;
//std::cout << "(" << dvs << ")";
}
Poly r;
//std::cout << r << std::endl;
}
return solutions;
}
const double tol) {
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :