1 //Normal version of the Ehrlich-Aberth method
2 cuDoubleComplex FirstH_EA(int i, cuDoubleComplex *Z) {
4 cuDoubleComplex result;
5 cuDoubleComplex C,F,Fp;
10 //evaluate the polynomial
12 //evaluate the derivative of the poly.
15 double mod=Cmodule(F);
18 C=Cdiv(F,Fp); //P(z)/P'(z)
20 //for all roots, compute the sum
21 //for the Ehrlich-Aberth iteration
22 for ( j=0 ; j<P.PolyDegre ; j++ )
26 sum=Cadd(sum,Cdiv(un,Csub(Z[i],Z[j])));
29 sum=Cdiv(C,Csub(un,Cmul(C,sum))); //C/(1-Csum)
30 result=Csub(Z[i], sum);
35 //Log Exp version of the Ehrlich-Aberth method
36 cuDoubleComplex NewH_EA(int i, cuDoubleComplex *Z) {
38 cuDoubleComplex result;
40 cuDoubleComplex one,denominator,sum;
46 //evaluate the polynomial with
48 Fp = LogFonctionD(Z[i]);
49 //evaluate the derivative of the polynomial
50 //with the LogExp version
51 F = LogFonction(Z[i]);
53 cuDoubleComplex FdivFp=Csub(F,Fp);
55 //for all roots, compute the sum
56 //for the Ehrlich-Aberth iteration
57 for ( j=0 ; j<P.degrePolynome ; j++ )
61 sum=Cadd(sum,Cdiv(un,Csub(Z[i],Z[j])));
65 //then terminate the computation
66 //of the Ehrlich-Aberth method
67 denominator=Cln(Csub(un,Cexp(Cadd(FdivFp,Cln(sum)))));
68 result=Csub(FdivFp,denominator);
69 result=Csub(Z[i],Cexp(res));
76 //kernels to update a root i
77 cuDoubleComplex H_EA(int i, cuDoubleComplex *Z) {
79 //if the root needs to be updated
81 //according to the module of the root
82 if (Cmodule(Z[i])<=maxRadius)
83 //selects the normal version
86 //of the Log Exp version