1 //Normal version of the Ehrlich-Aberth method
3 cuDoubleComplex FirstH_EA(int i, cuDoubleComplex *Z) {
5 cuDoubleComplex result;
6 cuDoubleComplex C,F,Fp;
11 //evaluate the polynomial
13 //evaluate the derivative of the poly.
16 double mod=Cmodule(F);
19 C=Cdiv(F,Fp); //P(z)/P'(z)
21 //for all roots, compute the sum
22 //for the Ehrlich-Aberth iteration
23 for ( j=0 ; j<P.PolyDegre ; j++ )
27 sum=Cadd(sum,Cdiv(un,Csub(Z[i],Z[j])));
30 sum=Cdiv(C,Csub(un,Cmul(C,sum))); //C/(1-Csum)
31 result=Csub(Z[i], sum);
36 //Log Exp version of the Ehrlich-Aberth method
38 cuDoubleComplex NewH_EA(int i, cuDoubleComplex *Z) {
40 cuDoubleComplex result;
42 cuDoubleComplex one,denominator,sum;
48 //evaluate the polynomial with
50 Fp = LogFonctionD(Z[i]);
51 //evaluate the derivative of the polynomial
52 //with the LogExp version
53 F = LogFonction(Z[i]);
55 cuDoubleComplex FdivFp=Csub(F,Fp);
57 //for all roots, compute the sum
58 //for the Ehrlich-Aberth iteration
59 for ( j=0 ; j<P.degrePolynome ; j++ )
63 sum=Cadd(sum,Cdiv(un,Csub(Z[i],Z[j])));
67 //then terminate the computation
68 //of the Ehrlich-Aberth method
69 denominator=Cln(Csub(un,Cexp(Cadd(FdivFp,Cln(sum)))));
70 result=Csub(FdivFp,denominator);
71 result=Csub(Z[i],Cexp(res));
78 //kernels to update a root i
80 void Dev_EA(int i, cuDoubleComplex *Z, int* finished,
82 int i= blockIdx.x*blockDim.x+ threadIdx.x;
84 //if the root needs to be updated
86 //according to the module of the root
87 if (Cmodule(Z[i])<=maxRadius)
88 //selects the normal version
89 Z[i] = FirstH_EA(i,Z);
91 //of the Log Exp version