double atan2(double y, double x) /* wrapper atan2 */ { #ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY return __ieee754_atan2(y,x); #else double z; z = __ieee754_atan2(y,x); if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE||isnan(x)||isnan(y)) return z; if(x==0.0&&y==0.0) { return __kernel_standard(y,x,3); /* atan2(+-0,+-0) */ } else return z; #endif }
double atan2(double y, double x) /* wrapper atan2 */ { #ifdef _IEEE_LIBM return __ieee754_atan2(y,x); #else double z; z = __ieee754_atan2(y,x); if(_LIB_VERSION == _IEEE_||isnan(x)||isnan(y)) return z; if(x==0.0&&y==0.0) { return __kernel_standard(y,x,3); /* atan2(+-0,+-0) */ } else return z; #endif }
__complex__ double __clog10 (__complex__ double x) { __complex__ double result; int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) { /* Real and imaginary part are 0.0. */ __imag__ result = signbit (__real__ x) ? M_PI : 0.0; __imag__ result = __copysign (__imag__ result, __imag__ x); /* Yes, the following line raises an exception. */ __real__ result = -1.0 / fabs (__real__ x); } else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1)) { /* Neither real nor imaginary part is NaN. */ __real__ result = __ieee754_log10 (__ieee754_hypot (__real__ x, __imag__ x)); __imag__ result = M_LOG10E * __ieee754_atan2 (__imag__ x, __real__ x); } else { __imag__ result = __nan (""); if (rcls == FP_INFINITE || icls == FP_INFINITE) /* Real or imaginary part is infinite. */ __real__ result = HUGE_VAL; else __real__ result = __nan (""); } return result; }
double __atan2 (double y, double x) { if (__builtin_expect (x == 0.0 && y == 0.0, 0) && _LIB_VERSION == _SVID_) return __kernel_standard (y, x, 3); /* atan2(+-0,+-0) */ return __ieee754_atan2 (y, x); }
void Math_atan2(void *fp) { F_Math_atan2 *f; f = fp; *f->ret = __ieee754_atan2(f->y, f->x); }
__complex__ double __clog (__complex__ double x) { __complex__ double result; int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) { /* Real and imaginary part are 0.0. */ __imag__ result = signbit (__real__ x) ? M_PI : 0.0; __imag__ result = __copysign (__imag__ result, __imag__ x); /* Yes, the following line raises an exception. */ __real__ result = -1.0 / fabs (__real__ x); } else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1)) { /* Neither real nor imaginary part is NaN. */ double d; int scale = 0; if (fabs (__real__ x) > DBL_MAX / 2.0 || fabs (__imag__ x) > DBL_MAX / 2.0) { scale = -1; __real__ x = __scalbn (__real__ x, scale); __imag__ x = __scalbn (__imag__ x, scale); } else if (fabs (__real__ x) < DBL_MIN && fabs (__imag__ x) < DBL_MIN) { scale = DBL_MANT_DIG; __real__ x = __scalbn (__real__ x, scale); __imag__ x = __scalbn (__imag__ x, scale); } d = __ieee754_hypot (__real__ x, __imag__ x); __real__ result = __ieee754_log (d) - scale * M_LN2; __imag__ result = __ieee754_atan2 (__imag__ x, __real__ x); } else { __imag__ result = __nan (""); if (rcls == FP_INFINITE || icls == FP_INFINITE) /* Real or imaginary part is infinite. */ __real__ result = HUGE_VAL; else __real__ result = __nan (""); } return result; }
double __atan2 (double y, double x) { double z; if (__builtin_expect (x == 0.0 && y == 0.0, 0) && _LIB_VERSION == _SVID_) return __kernel_standard (y, x, 3); /* atan2(+-0,+-0) */ z = __ieee754_atan2 (y, x); if (__glibc_unlikely (z == 0.0 && y != 0.0 && isfinite (x))) __set_errno (ERANGE); return z; }
EXPORT(sqInt) primitiveArcTan2(void) { double rcvr; double result; double arg; arg = interpreterProxy->stackFloatValue(0); rcvr = interpreterProxy->stackFloatValue(1); if (interpreterProxy->failed()) { return null; } result = __ieee754_atan2(rcvr, arg); if (isnan(result)) { return interpreterProxy->primitiveFail(); } interpreterProxy->pop((interpreterProxy->methodArgumentCount()) + 1); interpreterProxy->pushFloat(result); }
primitiveArcTan2(void) { // FloatMathPlugin>>#primitiveArcTan2 double arg; double rcvr; double result; arg = stackFloatValue(0); rcvr = stackFloatValue(1); if (failed()) { return null; } result = __ieee754_atan2(rcvr, arg); if (isnan(result)) { return primitiveFail(); } pop((methodArgumentCount()) + 1); pushFloat(result); }
Err mathlib_atan2(UInt16 refnum, double y, double x, double *result) { #pragma unused(refnum) *result = __ieee754_atan2(y, x); return mlErrNone; }
__complex__ double __kernel_casinh (__complex__ double x, int adj) { __complex__ double res; double rx, ix; __complex__ double y; /* Avoid cancellation by reducing to the first quadrant. */ rx = fabs (__real__ x); ix = fabs (__imag__ x); if (rx >= 1.0 / DBL_EPSILON || ix >= 1.0 / DBL_EPSILON) { /* For large x in the first quadrant, x + csqrt (1 + x * x) is sufficiently close to 2 * x to make no significant difference to the result; avoid possible overflow from the squaring and addition. */ __real__ y = rx; __imag__ y = ix; if (adj) { double t = __real__ y; __real__ y = __copysign (__imag__ y, __imag__ x); __imag__ y = t; } res = __clog (y); __real__ res += M_LN2; } else if (rx >= 0.5 && ix < DBL_EPSILON / 8.0) { double s = __ieee754_hypot (1.0, rx); __real__ res = __ieee754_log (rx + s); if (adj) __imag__ res = __ieee754_atan2 (s, __imag__ x); else __imag__ res = __ieee754_atan2 (ix, s); } else if (rx < DBL_EPSILON / 8.0 && ix >= 1.5) { double s = __ieee754_sqrt ((ix + 1.0) * (ix - 1.0)); __real__ res = __ieee754_log (ix + s); if (adj) __imag__ res = __ieee754_atan2 (rx, __copysign (s, __imag__ x)); else __imag__ res = __ieee754_atan2 (s, rx); } else if (ix > 1.0 && ix < 1.5 && rx < 0.5) { if (rx < DBL_EPSILON * DBL_EPSILON) { double ix2m1 = (ix + 1.0) * (ix - 1.0); double s = __ieee754_sqrt (ix2m1); __real__ res = __log1p (2.0 * (ix2m1 + ix * s)) / 2.0; if (adj) __imag__ res = __ieee754_atan2 (rx, __copysign (s, __imag__ x)); else __imag__ res = __ieee754_atan2 (s, rx); } else { double ix2m1 = (ix + 1.0) * (ix - 1.0); double rx2 = rx * rx; double f = rx2 * (2.0 + rx2 + 2.0 * ix * ix); double d = __ieee754_sqrt (ix2m1 * ix2m1 + f); double dp = d + ix2m1; double dm = f / dp; double r1 = __ieee754_sqrt ((dm + rx2) / 2.0); double r2 = rx * ix / r1; __real__ res = __log1p (rx2 + dp + 2.0 * (rx * r1 + ix * r2)) / 2.0; if (adj) __imag__ res = __ieee754_atan2 (rx + r1, __copysign (ix + r2, __imag__ x)); else __imag__ res = __ieee754_atan2 (ix + r2, rx + r1); } } else if (ix == 1.0 && rx < 0.5) { if (rx < DBL_EPSILON / 8.0) { __real__ res = __log1p (2.0 * (rx + __ieee754_sqrt (rx))) / 2.0; if (adj) __imag__ res = __ieee754_atan2 (__ieee754_sqrt (rx), __copysign (1.0, __imag__ x)); else __imag__ res = __ieee754_atan2 (1.0, __ieee754_sqrt (rx)); } else { double d = rx * __ieee754_sqrt (4.0 + rx * rx); double s1 = __ieee754_sqrt ((d + rx * rx) / 2.0); double s2 = __ieee754_sqrt ((d - rx * rx) / 2.0); __real__ res = __log1p (rx * rx + d + 2.0 * (rx * s1 + s2)) / 2.0; if (adj) __imag__ res = __ieee754_atan2 (rx + s1, __copysign (1.0 + s2, __imag__ x)); else __imag__ res = __ieee754_atan2 (1.0 + s2, rx + s1); } } else if (ix < 1.0 && rx < 0.5) { if (ix >= DBL_EPSILON) { if (rx < DBL_EPSILON * DBL_EPSILON) { double onemix2 = (1.0 + ix) * (1.0 - ix); double s = __ieee754_sqrt (onemix2); __real__ res = __log1p (2.0 * rx / s) / 2.0; if (adj) __imag__ res = __ieee754_atan2 (s, __imag__ x); else __imag__ res = __ieee754_atan2 (ix, s); } else { double onemix2 = (1.0 + ix) * (1.0 - ix); double rx2 = rx * rx; double f = rx2 * (2.0 + rx2 + 2.0 * ix * ix); double d = __ieee754_sqrt (onemix2 * onemix2 + f); double dp = d + onemix2; double dm = f / dp; double r1 = __ieee754_sqrt ((dp + rx2) / 2.0); double r2 = rx * ix / r1; __real__ res = __log1p (rx2 + dm + 2.0 * (rx * r1 + ix * r2)) / 2.0; if (adj) __imag__ res = __ieee754_atan2 (rx + r1, __copysign (ix + r2, __imag__ x)); else __imag__ res = __ieee754_atan2 (ix + r2, rx + r1); } } else { double s = __ieee754_hypot (1.0, rx); __real__ res = __log1p (2.0 * rx * (rx + s)) / 2.0; if (adj) __imag__ res = __ieee754_atan2 (s, __imag__ x); else __imag__ res = __ieee754_atan2 (ix, s); } math_check_force_underflow_nonneg (__real__ res); } else { __real__ y = (rx - ix) * (rx + ix) + 1.0; __imag__ y = 2.0 * rx * ix; y = __csqrt (y); __real__ y += rx; __imag__ y += ix; if (adj) { double t = __real__ y; __real__ y = __copysign (__imag__ y, __imag__ x); __imag__ y = t; } res = __clog (y); } /* Give results the correct sign for the original argument. */ __real__ res = __copysign (__real__ res, __real__ x); __imag__ res = __copysign (__imag__ res, (adj ? 1.0 : __imag__ x)); return res; }
__complex__ double __catanh (__complex__ double x) { __complex__ double res; int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) { if (icls == FP_INFINITE) { __real__ res = __copysign (0.0, __real__ x); __imag__ res = __copysign (M_PI_2, __imag__ x); } else if (rcls == FP_INFINITE || rcls == FP_ZERO) { __real__ res = __copysign (0.0, __real__ x); if (icls >= FP_ZERO) __imag__ res = __copysign (M_PI_2, __imag__ x); else __imag__ res = __nan (""); } else { __real__ res = __nan (""); __imag__ res = __nan (""); } } else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { res = x; } else { if (fabs (__real__ x) >= 16.0 / DBL_EPSILON || fabs (__imag__ x) >= 16.0 / DBL_EPSILON) { __imag__ res = __copysign (M_PI_2, __imag__ x); if (fabs (__imag__ x) <= 1.0) __real__ res = 1.0 / __real__ x; else if (fabs (__real__ x) <= 1.0) __real__ res = __real__ x / __imag__ x / __imag__ x; else { double h = __ieee754_hypot (__real__ x / 2.0, __imag__ x / 2.0); __real__ res = __real__ x / h / h / 4.0; } } else { if (fabs (__real__ x) == 1.0 && fabs (__imag__ x) < DBL_EPSILON * DBL_EPSILON) __real__ res = (__copysign (0.5, __real__ x) * (M_LN2 - __ieee754_log (fabs (__imag__ x)))); else { double i2 = 0.0; if (fabs (__imag__ x) >= DBL_EPSILON * DBL_EPSILON) i2 = __imag__ x * __imag__ x; double num = 1.0 + __real__ x; num = i2 + num * num; double den = 1.0 - __real__ x; den = i2 + den * den; double f = num / den; if (f < 0.5) __real__ res = 0.25 * __ieee754_log (f); else { num = 4.0 * __real__ x; __real__ res = 0.25 * __log1p (num / den); } } double absx, absy, den; absx = fabs (__real__ x); absy = fabs (__imag__ x); if (absx < absy) { double t = absx; absx = absy; absy = t; } if (absy < DBL_EPSILON / 2.0) { den = (1.0 - absx) * (1.0 + absx); if (den == -0.0) den = 0.0; } else if (absx >= 1.0) den = (1.0 - absx) * (1.0 + absx) - absy * absy; else if (absx >= 0.75 || absy >= 0.5) den = -__x2y2m1 (absx, absy); else den = (1.0 - absx) * (1.0 + absx) - absy * absy; __imag__ res = 0.5 * __ieee754_atan2 (2.0 * __imag__ x, den); } math_check_force_underflow_complex (res); } return res; }
__complex__ double __clog (__complex__ double x) { __complex__ double result; int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) { /* Real and imaginary part are 0.0. */ __imag__ result = signbit (__real__ x) ? M_PI : 0.0; __imag__ result = __copysign (__imag__ result, __imag__ x); /* Yes, the following line raises an exception. */ __real__ result = -1.0 / fabs (__real__ x); } else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN)) { /* Neither real nor imaginary part is NaN. */ double absx = fabs (__real__ x), absy = fabs (__imag__ x); int scale = 0; if (absx < absy) { double t = absx; absx = absy; absy = t; } if (absx > DBL_MAX / 2.0) { scale = -1; absx = __scalbn (absx, scale); absy = (absy >= DBL_MIN * 2.0 ? __scalbn (absy, scale) : 0.0); } else if (absx < DBL_MIN && absy < DBL_MIN) { scale = DBL_MANT_DIG; absx = __scalbn (absx, scale); absy = __scalbn (absy, scale); } if (absx == 1.0 && scale == 0) { __real__ result = __log1p (absy * absy) / 2.0; math_check_force_underflow_nonneg (__real__ result); } else if (absx > 1.0 && absx < 2.0 && absy < 1.0 && scale == 0) { double d2m1 = (absx - 1.0) * (absx + 1.0); if (absy >= DBL_EPSILON) d2m1 += absy * absy; __real__ result = __log1p (d2m1) / 2.0; } else if (absx < 1.0 && absx >= 0.5 && absy < DBL_EPSILON / 2.0 && scale == 0) { double d2m1 = (absx - 1.0) * (absx + 1.0); __real__ result = __log1p (d2m1) / 2.0; } else if (absx < 1.0 && absx >= 0.5 && scale == 0 && absx * absx + absy * absy >= 0.5) { double d2m1 = __x2y2m1 (absx, absy); __real__ result = __log1p (d2m1) / 2.0; } else { double d = __ieee754_hypot (absx, absy); __real__ result = __ieee754_log (d) - scale * M_LN2; } __imag__ result = __ieee754_atan2 (__imag__ x, __real__ x); } else { __imag__ result = __nan (""); if (rcls == FP_INFINITE || icls == FP_INFINITE) /* Real or imaginary part is infinite. */ __real__ result = HUGE_VAL; else __real__ result = __nan (""); } return result; }
__complex__ double __clog10 (__complex__ double x) { __complex__ double result; int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); if (__builtin_expect (rcls == FP_ZERO && icls == FP_ZERO, 0)) { /* Real and imaginary part are 0.0. */ __imag__ result = signbit (__real__ x) ? M_PI : 0.0; __imag__ result = __copysign (__imag__ result, __imag__ x); /* Yes, the following line raises an exception. */ __real__ result = -1.0 / fabs (__real__ x); } else if (__builtin_expect (rcls != FP_NAN && icls != FP_NAN, 1)) { /* Neither real nor imaginary part is NaN. */ double absx = fabs (__real__ x), absy = fabs (__imag__ x); int scale = 0; if (absx < absy) { double t = absx; absx = absy; absy = t; } if (absx > DBL_MAX / 2.0) { scale = -1; absx = __scalbn (absx, scale); absy = (absy >= DBL_MIN * 2.0 ? __scalbn (absy, scale) : 0.0); } else if (absx < DBL_MIN && absy < DBL_MIN) { scale = DBL_MANT_DIG; absx = __scalbn (absx, scale); absy = __scalbn (absy, scale); } if (absx == 1.0 && scale == 0) { double absy2 = absy * absy; if (absy2 <= DBL_MIN * 2.0 * M_LN10) { #if __FLT_EVAL_METHOD__ == 0 __real__ result = (absy2 / 2.0 - absy2 * absy2 / 4.0) * M_LOG10E; #else volatile double force_underflow = absy2 * absy2 / 4.0; __real__ result = (absy2 / 2.0 - force_underflow) * M_LOG10E; #endif } else __real__ result = __log1p (absy2) * (M_LOG10E / 2.0); } else if (absx > 1.0 && absx < 2.0 && absy < 1.0 && scale == 0) { double d2m1 = (absx - 1.0) * (absx + 1.0); if (absy >= DBL_EPSILON) d2m1 += absy * absy; __real__ result = __log1p (d2m1) * (M_LOG10E / 2.0); } else if (absx < 1.0 && absx >= 0.75 && absy < DBL_EPSILON / 2.0 && scale == 0) { double d2m1 = (absx - 1.0) * (absx + 1.0); __real__ result = __log1p (d2m1) * (M_LOG10E / 2.0); } else if (absx < 1.0 && (absx >= 0.75 || absy >= 0.5) && scale == 0) { double d2m1 = __x2y2m1 (absx, absy); __real__ result = __log1p (d2m1) * (M_LOG10E / 2.0); } else { double d = __ieee754_hypot (absx, absy); __real__ result = __ieee754_log10 (d) - scale * M_LOG10_2; } __imag__ result = M_LOG10E * __ieee754_atan2 (__imag__ x, __real__ x); } else { __imag__ result = __nan (""); if (rcls == FP_INFINITE || icls == FP_INFINITE) /* Real or imaginary part is infinite. */ __real__ result = HUGE_VAL; else __real__ result = __nan (""); } return result; }