5 //Normal version of the Ehrlich-Aberth method
6 cuDoubleComplex FirstH_EA(int i, cuDoubleComplex *Z) {
8 cuDoubleComplex result;
9 cuDoubleComplex C,F,Fp;
14 //evaluate the polynomial
16 //evaluate the derivative of the poly.
19 double mod=Cmodule(F);
22 C=Cdiv(F,Fp); //P(z)/P'(z)
24 //for all roots, compute the sum
25 //for the Ehrlich-Aberth iteration
26 for ( j=0 ; j<P.PolyDegre ; j++ )
30 sum=Cadd(sum,Cdiv(un,Csub(Z[i],Z[j])));
33 sum=Cdiv(C,Csub(un,Cmul(C,sum))); //C/(1-Csum)
34 result=Csub(Z[i], sum);
39 //Log Exp version of the Ehrlich-Aberth method
40 cuDoubleComplex NewH_EA(int i, cuDoubleComplex *Z) {
42 cuDoubleComplex result;
44 cuDoubleComplex one,denominator,sum;
50 //evaluate the polynomial with
52 Fp = LogFonctionD(Z[i]);
53 //evaluate the derivative of the polynomial
54 //with the LogExp version
55 F = LogFonction(Z[i]);
57 cuDoubleComplex FdivFp=Csub(F,Fp);
59 //for all roots, compute the sum
60 //for the Ehrlich-Aberth iteration
61 for ( j=0 ; j<P.degrePolynome ; j++ )
65 sum=Cadd(sum,Cdiv(un,Csub(Z[i],Z[j])));
69 //then terminate the computation
70 //of the Ehrlich-Aberth method
71 denominator=Cln(Csub(un,Cexp(Cadd(FdivFp,Cln(sum)))));
72 result=Csub(FdivFp,denominator);
73 result=Csub(Z[i],Cexp(res));
80 //kernels to update a root i
81 cuDoubleComplex H_EA(int i, cuDoubleComplex *Z) {
83 //if the root needs to be updated
85 //according to the module of the root
86 if (Cmodule(Z[i])<=maxRadius)
87 //selects the normal version
90 //of the Log Exp version