133 static const int init_jk[] = {2,3,4,6};
135 static int init_jk[] = {2,3,4,6};
139 static const double PIo2[] = {
141 static double PIo2[] = {
143 1.57079625129699707031e+00,
144 7.54978941586159635335e-08,
145 5.39030252995776476554e-15,
146 3.28200341580791294123e-22,
147 1.27065575308067607349e-29,
148 1.22933308981111328932e-36,
149 2.73370053816464559624e-44,
150 2.16741683877804819444e-51,
160 two24 = 1.67772160000000000000e+07,
161 twon24 = 5.96046447753906250000e-08;
164 int __kernel_rem_pio2(
double *x,
double *y,
int e0,
int nx,
int prec,
const int *ipio2)
167 double x[], y[];
int e0,nx,prec;
int ipio2[];
170 int jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
171 double z,fw,f[20],fq[20],q[20];
179 jv = (e0-3)/24;
if(jv<0) jv=0;
183 j = jv-jx; m = jx+jk;
184 for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (double) ipio2[j];
187 for (i=0;i<=jk;i++) {
188 for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
194 for(i=0,j=jz,z=q[jz];j>0;i++,j--) {
195 fw = (double)((
int)(twon24* z));
196 iq[i] = (int)(z-two24*fw);
202 z -= 8.0*
floor(z*0.125);
207 i = (iq[jz-1]>>(24-q0)); n += i;
208 iq[jz-1] -= i<<(24-q0);
209 ih = iq[jz-1]>>(23-q0);
211 else if(q0==0) ih = iq[jz-1]>>23;
212 else if(z>=0.5) ih=2;
220 carry = 1; iq[i] = 0x1000000- j;
222 }
else iq[i] = 0xffffff - j;
227 iq[jz-1] &= 0x7fffff;
break;
229 iq[jz-1] &= 0x3fffff;
break;
241 for (i=jz-1;i>=jk;i--) j |= iq[i];
243 for(k=1;iq[jk-k]==0;k++);
245 for(i=jz+1;i<=jz+k;i++) {
246 f[jx+i] = (double) ipio2[jv+i];
247 for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j];
258 while(iq[jz]==0) { jz--; q0-=24;}
262 fw = (double)((
int)(twon24*z));
263 iq[jz] = (int)(z-two24*fw);
266 }
else iq[jz] = (int) z ;
272 q[i] = fw*(double)iq[i]; fw*=twon24;
277 for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k];
285 for (i=jz;i>=0;i--) fw += fq[i];
286 y[0] = (ih==0)? fw: -fw;
291 for (i=jz;i>=0;i--) fw += fq[i];
292 y[0] = (ih==0)? fw: -fw;
294 for (i=1;i<=jz;i++) fw += fq[i];
295 y[1] = (ih==0)? fw: -fw;
308 for (fw=0.0,i=jz;i>=2;i--) fw += fq[i];
310 y[0] = fq[0]; y[1] = fq[1]; y[2] = fw;
312 y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw;