Esempio n. 1
0
double jvm_fplib_acos(double x) {
  double z,p,q,r,w,s,c,df;
  int hx,ix;
  hx = __JHI(x);
  ix = hx&0x7fffffff;
  if(ix>=0x3ff00000) {	/* |x| >= 1 */
    if(((ix-0x3ff00000)|__JLO(x))==0) {	/* |x|==1 */
      if(hx>0) return 0.0;		/* acos(1) = 0  */
      else return ac_pi+2.0*ac_pio2_lo;	/* acos(-1)= pi */
    }
    return jvm_ddiv(jvm_dsub(x, x), jvm_dsub(x, x));		/* acos(|x|>1) is NaN */
  }
  if(ix<0x3fe00000) {	/* |x| < 0.5 */
    if(ix<=0x3c600000) return ac_pio2_hi+ac_pio2_lo;/*if|x|<2**-57*/
    z = jvm_dmul(x, x);
    p = jvm_dmul(z, jvm_dadd(ac_pS0, jvm_dmul(z, jvm_dadd(ac_pS1, jvm_dmul(z, jvm_dadd(ac_pS2, jvm_dmul(z, jvm_dadd(ac_pS3, jvm_dmul(z, jvm_dadd(ac_pS4, jvm_dmul(z, ac_pS5)))))))))));
    q = jvm_dadd(ac_one, jvm_dmul(z, jvm_dadd(ac_qS1, jvm_dmul(z, jvm_dadd(ac_qS2, jvm_dmul(z, jvm_dadd(ac_qS3, jvm_dmul(z, ac_qS4))))))));
    r = jvm_ddiv(p, q);
    return jvm_dsub(ac_pio2_hi, jvm_dsub(x, jvm_dsub(ac_pio2_lo, jvm_dmul(x, r))));
  } else  if (hx<0) {		/* x < -0.5 */
    z = jvm_dmul(jvm_dadd(ac_one, x), 0.5);
    p = jvm_dmul(z, jvm_dadd(ac_pS0, jvm_dmul(z, jvm_dadd(ac_pS1, jvm_dmul(z, jvm_dadd(ac_pS2, jvm_dmul(z, jvm_dadd(ac_pS3, jvm_dmul(z, jvm_dadd(ac_pS4, jvm_dmul(z, ac_pS5)))))))))));
    q = jvm_dadd(ac_one, jvm_dmul(z, jvm_dadd(ac_qS1, jvm_dmul(z, jvm_dadd(ac_qS2, jvm_dmul(z, jvm_dadd(ac_qS3, jvm_dmul(z, ac_qS4))))))));
    s = ieee754_sqrt(z);
    r = jvm_ddiv(p, q);
    w = jvm_dsub(jvm_dmul(r, s), ac_pio2_lo);
    return jvm_dsub(ac_pi, jvm_dmul(2.0, jvm_dadd(s, w)));
  } else {			/* x > 0.5 */
    z = jvm_dmul(jvm_dsub(ac_one, x), 0.5);
    s = ieee754_sqrt(z);
    df = s;
    __JLO(df) = 0;
    c  = jvm_ddiv(jvm_dsub(z, jvm_dmul(df, df)), jvm_dadd(s, df));
    p = jvm_dmul(z, jvm_dadd(ac_pS0, jvm_dmul(z, jvm_dadd(ac_pS1, jvm_dmul(z, jvm_dadd(ac_pS2, jvm_dmul(z, jvm_dadd(ac_pS3, jvm_dmul(z, jvm_dadd(ac_pS4, jvm_dmul(z, ac_pS5)))))))))));
    q = jvm_dadd(ac_one, jvm_dmul(z, jvm_dadd(ac_qS1, jvm_dmul(z, jvm_dadd(ac_qS2, jvm_dmul(z, jvm_dadd(ac_qS3, jvm_dmul(z, ac_qS4))))))));
    r = jvm_ddiv(p, q);
    w = jvm_dadd(jvm_dmul(r, s), c);
    return jvm_dmul(2.0, jvm_dadd(df, w));
  }
}
double tangent_kernel(double x, double y, int iy) {
  double z, r, v, w, s;
  int ix, hx;
  hx = __JHI(x);   /* high word of x */
  ix = hx & 0x7fffffff; /* high word of |x| */
  if (ix < 0x3e300000) {           /* x < 2**-28 */
    if (jvm_d2i(x) == 0) {            /* generate inexact */
      if (((ix | __JLO(x)) | (iy + 1)) == 0) {
        return jvm_ddiv(one_t, jvm_fplib_fabs(x));
      } else {
        return (iy == 1)? x: jvm_ddiv(jvm_dneg(one_t), x);
      }
    }
  }
  if (ix >= 0x3FE59428) {            /* |x|>=0.6744 */
    if (hx < 0) {
      x = jvm_dneg(x);
      y = jvm_dneg(y);
    }
    z = jvm_dsub(pio4, x);
    w = jvm_dsub(pio4lo, y);
    x = jvm_dadd(z, w);
    y = 0.0;
  }
  z =  jvm_dmul(x, x);
  w =  jvm_dmul(z, z);
  /* Break x^5*(T[1]+x^2*T[2]+...) into
   *    x^5(T[1]+x^4*T[3]+...+x^20*T[11]) +
   *    x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12]))
   */
  //r = T[1]+w*(T[3]+w*(T[5]+w*(T[7]+w*(T[9]+w*T[11]))));
  r = jvm_dadd(T[1], jvm_dmul(w, jvm_dadd(T[3], jvm_dmul(w, jvm_dadd(T[5], jvm_dmul(w, jvm_dadd(T[7], jvm_dmul(w, jvm_dadd(T[9], jvm_dmul(w, T[11]))))))))));
  //v = z*(T[2]+w*(T[4]+w*(T[6]+w*(T[8]+w*(T[10]+w*T[12])))));
  v = jvm_dmul(z, jvm_dadd(T[2], jvm_dmul(w, jvm_dadd(T[4], jvm_dmul(w, jvm_dadd(T[6], jvm_dmul(w, jvm_dadd(T[8], jvm_dmul(w, jvm_dadd(T[10], jvm_dmul(w, T[12])))))))))));
  s = jvm_dmul(z, x);
  r = jvm_dadd(y, jvm_dmul(z, jvm_dmul(s, jvm_dadd(jvm_dadd(r, v), y))));
  r = jvm_dadd(r, jvm_dmul(T[0], s));
  w = jvm_dadd(x, r);
  if(ix >= 0x3FE59428) {
    v = jvm_i2d(iy);
    return jvm_dmul(jvm_i2d((1 - ((hx >> 30) & 2))),
     jvm_dsub(v, jvm_dmul(2.0, jvm_dsub(x, jvm_dsub(jvm_dmul(w, jvm_ddiv( w, jvm_dadd(w, v))), r)))));
  }