1
#include "poly-dk-solve.h"
4
/*** implementation of the Durand-Kerner method. seems buggy*/
6
std::complex<double> evalu(Poly const & p, std::complex<double> x) {
7
std::complex<double> result = 0;
8
std::complex<double> xx = 1;
10
for(unsigned i = 0; i < p.size(); i++) {
17
std::vector<std::complex<double> > DK(Poly const & ply, const double tol) {
18
std::vector<std::complex<double> > roots;
19
const int N = ply.degree();
21
std::complex<double> b(0.4, 0.9);
22
std::complex<double> p = 1;
23
for(int i = 0; i < N; i++) {
27
assert(roots.size() == ply.degree());
31
for( i = 0; i < 30; i++) {
33
for(int r_i = 0; r_i < N; r_i++) {
34
std::complex<double> denom = 1;
35
std::complex<double> R = roots[r_i];
36
for(int d_i = 0; d_i < N; d_i++) {
38
denom *= R-roots[d_i];
40
assert(norm(denom) != 0);
41
std::complex<double> dr = evalu(ply, R)/denom;
45
/*std::copy(roots.begin(), roots.end(), std::ostream_iterator<std::complex<double> >(std::cout, ",\t"));
46
std::cout << std::endl;*/
50
//std::cout << error << ", " << i<< std::endl;
58
c-file-style:"stroustrup"
59
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
64
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :