22 {
23 std::complex<double> zh,r[38],s,t,v;
24
25 const double z1 = 1;
26 const double hf = z1/2;
27 const double z10 = 10;
28 const double c1 = 74/z10;
29 const double c2 = 83/z10;
30 const double c3 = z10/32;
31 const double c4 = 16/z10;
32 const double c = 1.12837916709551257;
33 const double p =
Pow(2.0*c4,33);
34
35 double x=z.real();
36 double y=z.imag();
37 double xa=(x >= 0) ? x : -x;
38 double ya=(y >= 0) ? y : -y;
39 if(ya < c1 && xa < c2){
40 zh = std::complex<double>(ya+c4,xa);
41 r[37]= std::complex<double>(0,0);
42
43 for(
int n = 36;
n>0;
n--){
44 t=zh+
double(n)*std::conj(r[n+1]);
45 r[
n]=hf*t/std::norm(t);
46 }
47 double xl=p;
48 s=std::complex<double>(0,0);
49
50 for(int k=33; k>0; k--){
51 xl=c3*xl;
52 s=r[k]*(s+xl);
53 }
54 v=c*s;
55 }
56 else{
57 zh=std::complex<double>(ya,xa);
58 r[1]=std::complex<double>(0,0);
59
61 t=zh+
double(n)*std::conj(r[1]);
62 r[1]=hf*t/std::norm(t);
63 }
64 v=c*r[1];
65 }
66 if(ya == 0) v= std::complex<double>(exp(-xa*xa),v.imag());
67 if(y < 0) {
68 v=2.0*std::exp(std::complex<double>(-xa,-ya)*std::complex<double>(xa,ya))-v;
69 if(x > 0) v=std::conj(v);
70 }
71 else{
72 if(x < 0) v=std::conj(v);
73 }
74 return v;
75}
double Pow(double x, int n)