From feb62ddacb7b1d772d7383de0228a3977f07fc1e Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Tue, 28 Jun 2016 14:28:04 -0500 Subject: Convert remaining complex function to generated files Convert cpow, clog, clog10, cexp, csqrt, and cproj functions into generated templates. Note, ldbl-opt still retains s_clog10l.c as the aliasing rules are non-trivial. --- math/Makefile | 5 +- math/s_cexp.c | 157 -------------------------------------------- math/s_cexp_template.c | 64 +++++++++--------- math/s_cexpf.c | 155 -------------------------------------------- math/s_cexpl.c | 153 ------------------------------------------- math/s_clog.c | 118 --------------------------------- math/s_clog10.c | 124 ----------------------------------- math/s_clog10_template.c | 90 ++++++++++++++------------ math/s_clog10f.c | 122 ----------------------------------- math/s_clog10l.c | 127 ------------------------------------ math/s_clog_template.c | 83 ++++++++++++------------ math/s_clogf.c | 116 --------------------------------- math/s_clogl.c | 121 ---------------------------------- math/s_cpow.c | 33 ---------- math/s_cpow_template.c | 18 +++--- math/s_cpowf.c | 31 --------- math/s_cpowl.c | 29 --------- math/s_cproj.c | 44 ------------- math/s_cproj_template.c | 19 +++--- math/s_cprojf.c | 42 ------------ math/s_cprojl.c | 40 ------------ math/s_csqrt.c | 165 ----------------------------------------------- math/s_csqrt_template.c | 105 +++++++++++++++--------------- math/s_csqrtf.c | 163 ---------------------------------------------- math/s_csqrtl.c | 161 --------------------------------------------- 25 files changed, 194 insertions(+), 2091 deletions(-) delete mode 100644 math/s_cexp.c delete mode 100644 math/s_cexpf.c delete mode 100644 math/s_cexpl.c delete mode 100644 math/s_clog.c delete mode 100644 math/s_clog10.c delete mode 100644 math/s_clog10f.c delete mode 100644 math/s_clog10l.c delete mode 100644 math/s_clogf.c delete mode 100644 math/s_clogl.c delete mode 100644 math/s_cpow.c delete mode 100644 math/s_cpowf.c delete mode 100644 math/s_cpowl.c delete mode 100644 math/s_cproj.c delete mode 100644 math/s_cprojf.c delete mode 100644 math/s_cprojl.c delete mode 100644 math/s_csqrt.c delete mode 100644 math/s_csqrtf.c delete mode 100644 math/s_csqrtl.c (limited to 'math') diff --git a/math/Makefile b/math/Makefile index dbc2a17..f1b7937 100644 --- a/math/Makefile +++ b/math/Makefile @@ -48,7 +48,8 @@ libm-support = s_lib_version s_matherr s_signgam \ gen-libm-calls = cargF conjF cimagF crealF cabsF s_cacosF \ s_cacoshF s_ccosF s_ccoshF s_casinF s_csinF s_casinhF \ k_casinhF s_csinhF k_casinhF s_csinhF s_catanhF s_catanF \ - s_ctanF s_ctanhF + s_ctanF s_ctanhF s_cexpF s_clogF s_cprojF s_csqrtF \ + s_cpowF s_clog10F libm-calls = \ e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \ @@ -66,8 +67,6 @@ libm-calls = \ w_ilogbF \ s_fpclassifyF s_fmaxF s_fminF s_fdimF s_nanF s_truncF \ s_remquoF e_log2F e_exp2F s_roundF s_nearbyintF s_sincosF \ - s_cexpF s_clogF \ - s_csqrtF s_cpowF s_cprojF s_clog10F \ s_fmaF s_lrintF s_llrintF s_lroundF s_llroundF e_exp10F w_log2F \ s_issignalingF $(calls:s_%=m_%) x2y2m1F \ gamma_productF lgamma_negF lgamma_productF \ diff --git a/math/s_cexp.c b/math/s_cexp.c deleted file mode 100644 index 3a476bd..0000000 --- a/math/s_cexp.c +++ /dev/null @@ -1,157 +0,0 @@ -/* Return value of complex exponential function for double complex value. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include -#include - -__complex__ double -__cexp (__complex__ double x) -{ - __complex__ double retval; - int rcls = fpclassify (__real__ x); - int icls = fpclassify (__imag__ x); - - if (__glibc_likely (rcls >= FP_ZERO)) - { - /* Real part is finite. */ - if (__glibc_likely (icls >= FP_ZERO)) - { - /* Imaginary part is finite. */ - const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2); - double sinix, cosix; - - if (__glibc_likely (fabs (__imag__ x) > DBL_MIN)) - { - __sincos (__imag__ x, &sinix, &cosix); - } - else - { - sinix = __imag__ x; - cosix = 1.0; - } - - if (__real__ x > t) - { - double exp_t = __ieee754_exp (t); - __real__ x -= t; - sinix *= exp_t; - cosix *= exp_t; - if (__real__ x > t) - { - __real__ x -= t; - sinix *= exp_t; - cosix *= exp_t; - } - } - if (__real__ x > t) - { - /* Overflow (original real part of x > 3t). */ - __real__ retval = DBL_MAX * cosix; - __imag__ retval = DBL_MAX * sinix; - } - else - { - double exp_val = __ieee754_exp (__real__ x); - __real__ retval = exp_val * cosix; - __imag__ retval = exp_val * sinix; - } - math_check_force_underflow_complex (retval); - } - else - { - /* If the imaginary part is +-inf or NaN and the real part - is not +-inf the result is NaN + iNaN. */ - __real__ retval = __nan (""); - __imag__ retval = __nan (""); - - feraiseexcept (FE_INVALID); - } - } - else if (__glibc_likely (rcls == FP_INFINITE)) - { - /* Real part is infinite. */ - if (__glibc_likely (icls >= FP_ZERO)) - { - /* Imaginary part is finite. */ - double value = signbit (__real__ x) ? 0.0 : HUGE_VAL; - - if (icls == FP_ZERO) - { - /* Imaginary part is 0.0. */ - __real__ retval = value; - __imag__ retval = __imag__ x; - } - else - { - double sinix, cosix; - - if (__glibc_likely (fabs (__imag__ x) > DBL_MIN)) - { - __sincos (__imag__ x, &sinix, &cosix); - } - else - { - sinix = __imag__ x; - cosix = 1.0; - } - - __real__ retval = __copysign (value, cosix); - __imag__ retval = __copysign (value, sinix); - } - } - else if (signbit (__real__ x) == 0) - { - __real__ retval = HUGE_VAL; - __imag__ retval = __nan (""); - - if (icls == FP_INFINITE) - feraiseexcept (FE_INVALID); - } - else - { - __real__ retval = 0.0; - __imag__ retval = __copysign (0.0, __imag__ x); - } - } - else - { - /* If the real part is NaN the result is NaN + iNaN unless the - imaginary part is zero. */ - __real__ retval = __nan (""); - if (icls == FP_ZERO) - __imag__ retval = __imag__ x; - else - { - __imag__ retval = __nan (""); - - if (rcls != FP_NAN || icls != FP_NAN) - feraiseexcept (FE_INVALID); - } - } - - return retval; -} -weak_alias (__cexp, cexp) -#ifdef NO_LONG_DOUBLE -strong_alias (__cexp, __cexpl) -weak_alias (__cexp, cexpl) -#endif diff --git a/math/s_cexp_template.c b/math/s_cexp_template.c index 3a476bd..a60afe0 100644 --- a/math/s_cexp_template.c +++ b/math/s_cexp_template.c @@ -1,4 +1,4 @@ -/* Return value of complex exponential function for double complex value. +/* Return value of complex exponential function for a float type. Copyright (C) 1997-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -23,10 +23,10 @@ #include #include -__complex__ double -__cexp (__complex__ double x) +CFLOAT +M_DECL_FUNC (__cexp) (CFLOAT x) { - __complex__ double retval; + CFLOAT retval; int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); @@ -36,22 +36,22 @@ __cexp (__complex__ double x) if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ - const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2); - double sinix, cosix; + const int t = (int) ((M_MAX_EXP - 1) * M_MLIT (M_LN2)); + FLOAT sinix, cosix; - if (__glibc_likely (fabs (__imag__ x) > DBL_MIN)) + if (__glibc_likely (M_FABS (__imag__ x) > M_MIN)) { - __sincos (__imag__ x, &sinix, &cosix); + M_SINCOS (__imag__ x, &sinix, &cosix); } else { sinix = __imag__ x; - cosix = 1.0; + cosix = 1; } if (__real__ x > t) { - double exp_t = __ieee754_exp (t); + FLOAT exp_t = M_EXP (t); __real__ x -= t; sinix *= exp_t; cosix *= exp_t; @@ -65,12 +65,12 @@ __cexp (__complex__ double x) if (__real__ x > t) { /* Overflow (original real part of x > 3t). */ - __real__ retval = DBL_MAX * cosix; - __imag__ retval = DBL_MAX * sinix; + __real__ retval = M_MAX * cosix; + __imag__ retval = M_MAX * sinix; } else { - double exp_val = __ieee754_exp (__real__ x); + FLOAT exp_val = M_EXP (__real__ x); __real__ retval = exp_val * cosix; __imag__ retval = exp_val * sinix; } @@ -80,8 +80,8 @@ __cexp (__complex__ double x) { /* If the imaginary part is +-inf or NaN and the real part is not +-inf the result is NaN + iNaN. */ - __real__ retval = __nan (""); - __imag__ retval = __nan (""); + __real__ retval = M_NAN; + __imag__ retval = M_NAN; feraiseexcept (FE_INVALID); } @@ -92,7 +92,7 @@ __cexp (__complex__ double x) if (__glibc_likely (icls >= FP_ZERO)) { /* Imaginary part is finite. */ - double value = signbit (__real__ x) ? 0.0 : HUGE_VAL; + FLOAT value = signbit (__real__ x) ? 0 : M_HUGE_VAL; if (icls == FP_ZERO) { @@ -102,46 +102,46 @@ __cexp (__complex__ double x) } else { - double sinix, cosix; + FLOAT sinix, cosix; - if (__glibc_likely (fabs (__imag__ x) > DBL_MIN)) + if (__glibc_likely (M_FABS (__imag__ x) > M_MIN)) { - __sincos (__imag__ x, &sinix, &cosix); + M_SINCOS (__imag__ x, &sinix, &cosix); } else { sinix = __imag__ x; - cosix = 1.0; + cosix = 1; } - __real__ retval = __copysign (value, cosix); - __imag__ retval = __copysign (value, sinix); + __real__ retval = M_COPYSIGN (value, cosix); + __imag__ retval = M_COPYSIGN (value, sinix); } } else if (signbit (__real__ x) == 0) { - __real__ retval = HUGE_VAL; - __imag__ retval = __nan (""); + __real__ retval = M_HUGE_VAL; + __imag__ retval = M_NAN; if (icls == FP_INFINITE) feraiseexcept (FE_INVALID); } else { - __real__ retval = 0.0; - __imag__ retval = __copysign (0.0, __imag__ x); + __real__ retval = 0; + __imag__ retval = M_COPYSIGN (0, __imag__ x); } } else { /* If the real part is NaN the result is NaN + iNaN unless the imaginary part is zero. */ - __real__ retval = __nan (""); + __real__ retval = M_NAN; if (icls == FP_ZERO) __imag__ retval = __imag__ x; else { - __imag__ retval = __nan (""); + __imag__ retval = M_NAN; if (rcls != FP_NAN || icls != FP_NAN) feraiseexcept (FE_INVALID); @@ -150,8 +150,8 @@ __cexp (__complex__ double x) return retval; } -weak_alias (__cexp, cexp) -#ifdef NO_LONG_DOUBLE -strong_alias (__cexp, __cexpl) -weak_alias (__cexp, cexpl) +declare_mgen_alias (__cexp, cexp) + +#if M_LIBM_NEED_COMPAT (cexp) +declare_mgen_libm_compat (__cexp, cexp) #endif diff --git a/math/s_cexpf.c b/math/s_cexpf.c deleted file mode 100644 index 001fec2..0000000 --- a/math/s_cexpf.c +++ /dev/null @@ -1,155 +0,0 @@ -/* Return value of complex exponential function for float complex value. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include -#include - -__complex__ float -__cexpf (__complex__ float x) -{ - __complex__ float retval; - int rcls = fpclassify (__real__ x); - int icls = fpclassify (__imag__ x); - - if (__glibc_likely (rcls >= FP_ZERO)) - { - /* Real part is finite. */ - if (__glibc_likely (icls >= FP_ZERO)) - { - /* Imaginary part is finite. */ - const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2); - float sinix, cosix; - - if (__glibc_likely (fabsf (__imag__ x) > FLT_MIN)) - { - __sincosf (__imag__ x, &sinix, &cosix); - } - else - { - sinix = __imag__ x; - cosix = 1.0f; - } - - if (__real__ x > t) - { - float exp_t = __ieee754_expf (t); - __real__ x -= t; - sinix *= exp_t; - cosix *= exp_t; - if (__real__ x > t) - { - __real__ x -= t; - sinix *= exp_t; - cosix *= exp_t; - } - } - if (__real__ x > t) - { - /* Overflow (original real part of x > 3t). */ - __real__ retval = FLT_MAX * cosix; - __imag__ retval = FLT_MAX * sinix; - } - else - { - float exp_val = __ieee754_expf (__real__ x); - __real__ retval = exp_val * cosix; - __imag__ retval = exp_val * sinix; - } - math_check_force_underflow_complex (retval); - } - else - { - /* If the imaginary part is +-inf or NaN and the real part - is not +-inf the result is NaN + iNaN. */ - __real__ retval = __nanf (""); - __imag__ retval = __nanf (""); - - feraiseexcept (FE_INVALID); - } - } - else if (__glibc_likely (rcls == FP_INFINITE)) - { - /* Real part is infinite. */ - if (__glibc_likely (icls >= FP_ZERO)) - { - /* Imaginary part is finite. */ - float value = signbit (__real__ x) ? 0.0 : HUGE_VALF; - - if (icls == FP_ZERO) - { - /* Imaginary part is 0.0. */ - __real__ retval = value; - __imag__ retval = __imag__ x; - } - else - { - float sinix, cosix; - - if (__glibc_likely (fabsf (__imag__ x) > FLT_MIN)) - { - __sincosf (__imag__ x, &sinix, &cosix); - } - else - { - sinix = __imag__ x; - cosix = 1.0f; - } - - __real__ retval = __copysignf (value, cosix); - __imag__ retval = __copysignf (value, sinix); - } - } - else if (signbit (__real__ x) == 0) - { - __real__ retval = HUGE_VALF; - __imag__ retval = __nanf (""); - - if (icls == FP_INFINITE) - feraiseexcept (FE_INVALID); - } - else - { - __real__ retval = 0.0; - __imag__ retval = __copysignf (0.0, __imag__ x); - } - } - else - { - /* If the real part is NaN the result is NaN + iNaN unless the - imaginary part is zero. */ - __real__ retval = __nanf (""); - if (icls == FP_ZERO) - __imag__ retval = __imag__ x; - else - { - __imag__ retval = __nanf (""); - - if (rcls != FP_NAN || icls != FP_NAN) - feraiseexcept (FE_INVALID); - } - } - - return retval; -} -#ifndef __cexpf -weak_alias (__cexpf, cexpf) -#endif diff --git a/math/s_cexpl.c b/math/s_cexpl.c deleted file mode 100644 index 9ab566c..0000000 --- a/math/s_cexpl.c +++ /dev/null @@ -1,153 +0,0 @@ -/* Return value of complex exponential function for long double complex value. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include -#include - -__complex__ long double -__cexpl (__complex__ long double x) -{ - __complex__ long double retval; - int rcls = fpclassify (__real__ x); - int icls = fpclassify (__imag__ x); - - if (__glibc_likely (rcls >= FP_ZERO)) - { - /* Real part is finite. */ - if (__glibc_likely (icls >= FP_ZERO)) - { - /* Imaginary part is finite. */ - const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l); - long double sinix, cosix; - - if (__glibc_likely (fabsl (__imag__ x) > LDBL_MIN)) - { - __sincosl (__imag__ x, &sinix, &cosix); - } - else - { - sinix = __imag__ x; - cosix = 1.0; - } - - if (__real__ x > t) - { - long double exp_t = __ieee754_expl (t); - __real__ x -= t; - sinix *= exp_t; - cosix *= exp_t; - if (__real__ x > t) - { - __real__ x -= t; - sinix *= exp_t; - cosix *= exp_t; - } - } - if (__real__ x > t) - { - /* Overflow (original real part of x > 3t). */ - __real__ retval = LDBL_MAX * cosix; - __imag__ retval = LDBL_MAX * sinix; - } - else - { - long double exp_val = __ieee754_expl (__real__ x); - __real__ retval = exp_val * cosix; - __imag__ retval = exp_val * sinix; - } - math_check_force_underflow_complex (retval); - } - else - { - /* If the imaginary part is +-inf or NaN and the real part - is not +-inf the result is NaN + iNaN. */ - __real__ retval = __nanl (""); - __imag__ retval = __nanl (""); - - feraiseexcept (FE_INVALID); - } - } - else if (__glibc_likely (rcls == FP_INFINITE)) - { - /* Real part is infinite. */ - if (__glibc_likely (icls >= FP_ZERO)) - { - /* Imaginary part is finite. */ - long double value = signbit (__real__ x) ? 0.0 : HUGE_VALL; - - if (icls == FP_ZERO) - { - /* Imaginary part is 0.0. */ - __real__ retval = value; - __imag__ retval = __imag__ x; - } - else - { - long double sinix, cosix; - - if (__glibc_likely (fabsl (__imag__ x) > LDBL_MIN)) - { - __sincosl (__imag__ x, &sinix, &cosix); - } - else - { - sinix = __imag__ x; - cosix = 1.0; - } - - __real__ retval = __copysignl (value, cosix); - __imag__ retval = __copysignl (value, sinix); - } - } - else if (signbit (__real__ x) == 0) - { - __real__ retval = HUGE_VALL; - __imag__ retval = __nanl (""); - - if (icls == FP_INFINITE) - feraiseexcept (FE_INVALID); - } - else - { - __real__ retval = 0.0; - __imag__ retval = __copysignl (0.0, __imag__ x); - } - } - else - { - /* If the real part is NaN the result is NaN + iNaN unless the - imaginary part is zero. */ - __real__ retval = __nanl (""); - if (icls == FP_ZERO) - __imag__ retval = __imag__ x; - else - { - __imag__ retval = __nanl (""); - - if (rcls != FP_NAN || icls != FP_NAN) - feraiseexcept (FE_INVALID); - } - } - - return retval; -} -weak_alias (__cexpl, cexpl) diff --git a/math/s_clog.c b/math/s_clog.c deleted file mode 100644 index b546030..0000000 --- a/math/s_clog.c +++ /dev/null @@ -1,118 +0,0 @@ -/* Compute complex natural logarithm. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include - -__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; -} -weak_alias (__clog, clog) -#ifdef NO_LONG_DOUBLE -strong_alias (__clog, __clogl) -weak_alias (__clog, clogl) -#endif diff --git a/math/s_clog10.c b/math/s_clog10.c deleted file mode 100644 index 8d9245b..0000000 --- a/math/s_clog10.c +++ /dev/null @@ -1,124 +0,0 @@ -/* Compute complex base 10 logarithm. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include - -/* log_10 (2). */ -#define M_LOG10_2 0.3010299956639811952137388947244930267682 - -/* pi * log10 (e). */ -#define M_PI_LOG10E 1.364376353841841347485783625431355770210 - -__complex__ double -__clog10 (__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_LOG10E : 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) * (M_LOG10E / 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) * (M_LOG10E / 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) * (M_LOG10E / 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) * (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; -} -weak_alias (__clog10, clog10) -#ifdef NO_LONG_DOUBLE -strong_alias (__clog10, __clog10l) -weak_alias (__clog10, clog10l) -#endif diff --git a/math/s_clog10_template.c b/math/s_clog10_template.c index 8d9245b..82624e3 100644 --- a/math/s_clog10_template.c +++ b/math/s_clog10_template.c @@ -23,102 +23,106 @@ #include /* log_10 (2). */ -#define M_LOG10_2 0.3010299956639811952137388947244930267682 +#define LOG10_2 M_LIT (0.3010299956639811952137388947244930267682) /* pi * log10 (e). */ -#define M_PI_LOG10E 1.364376353841841347485783625431355770210 +#define PI_LOG10E M_LIT (1.364376353841841347485783625431355770210) -__complex__ double -__clog10 (__complex__ double x) +CFLOAT +M_DECL_FUNC (__clog10) (CFLOAT x) { - __complex__ double result; + CFLOAT 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_LOG10E : 0.0; - __imag__ result = __copysign (__imag__ result, __imag__ x); + __imag__ result = signbit (__real__ x) ? PI_LOG10E : 0; + __imag__ result = M_COPYSIGN (__imag__ result, __imag__ x); /* Yes, the following line raises an exception. */ - __real__ result = -1.0 / fabs (__real__ x); + __real__ result = -1 / M_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); + FLOAT absx = M_FABS (__real__ x), absy = M_FABS (__imag__ x); int scale = 0; if (absx < absy) { - double t = absx; + FLOAT t = absx; absx = absy; absy = t; } - if (absx > DBL_MAX / 2.0) + if (absx > M_MAX / 2) { scale = -1; - absx = __scalbn (absx, scale); - absy = (absy >= DBL_MIN * 2.0 ? __scalbn (absy, scale) : 0.0); + absx = M_SCALBN (absx, scale); + absy = (absy >= M_MIN * 2 ? M_SCALBN (absy, scale) : 0); } - else if (absx < DBL_MIN && absy < DBL_MIN) + else if (absx < M_MIN && absy < M_MIN) { - scale = DBL_MANT_DIG; - absx = __scalbn (absx, scale); - absy = __scalbn (absy, scale); + scale = M_MANT_DIG; + absx = M_SCALBN (absx, scale); + absy = M_SCALBN (absy, scale); } - if (absx == 1.0 && scale == 0) + if (absx == 1 && scale == 0) { - __real__ result = __log1p (absy * absy) * (M_LOG10E / 2.0); + __real__ result = (M_LOG1P (absy * absy) + * ((FLOAT) M_MLIT (M_LOG10E) / 2)); math_check_force_underflow_nonneg (__real__ result); } - else if (absx > 1.0 && absx < 2.0 && absy < 1.0 && scale == 0) + else if (absx > 1 && absx < 2 && absy < 1 && scale == 0) { - double d2m1 = (absx - 1.0) * (absx + 1.0); - if (absy >= DBL_EPSILON) + FLOAT d2m1 = (absx - 1) * (absx + 1); + if (absy >= M_EPSILON) d2m1 += absy * absy; - __real__ result = __log1p (d2m1) * (M_LOG10E / 2.0); + __real__ result = M_LOG1P (d2m1) * ((FLOAT) M_MLIT (M_LOG10E) / 2); } - else if (absx < 1.0 - && absx >= 0.5 - && absy < DBL_EPSILON / 2.0 + else if (absx < 1 + && absx >= M_LIT (0.5) + && absy < M_EPSILON / 2 && scale == 0) { - double d2m1 = (absx - 1.0) * (absx + 1.0); - __real__ result = __log1p (d2m1) * (M_LOG10E / 2.0); + FLOAT d2m1 = (absx - 1) * (absx + 1); + __real__ result = M_LOG1P (d2m1) * ((FLOAT) M_MLIT (M_LOG10E) / 2); } - else if (absx < 1.0 - && absx >= 0.5 + else if (absx < 1 + && absx >= M_LIT (0.5) && scale == 0 - && absx * absx + absy * absy >= 0.5) + && absx * absx + absy * absy >= M_LIT (0.5)) { - double d2m1 = __x2y2m1 (absx, absy); - __real__ result = __log1p (d2m1) * (M_LOG10E / 2.0); + FLOAT d2m1 = M_SUF (__x2y2m1) (absx, absy); + __real__ result = M_LOG1P (d2m1) * ((FLOAT) M_MLIT (M_LOG10E) / 2); } else { - double d = __ieee754_hypot (absx, absy); - __real__ result = __ieee754_log10 (d) - scale * M_LOG10_2; + FLOAT d = M_HYPOT (absx, absy); + __real__ result = M_SUF (__ieee754_log10) (d) - scale * LOG10_2; } - __imag__ result = M_LOG10E * __ieee754_atan2 (__imag__ x, __real__ x); + __imag__ result = M_MLIT (M_LOG10E) * M_ATAN2 (__imag__ x, __real__ x); } else { - __imag__ result = __nan (""); + __imag__ result = M_NAN; if (rcls == FP_INFINITE || icls == FP_INFINITE) /* Real or imaginary part is infinite. */ - __real__ result = HUGE_VAL; + __real__ result = M_HUGE_VAL; else - __real__ result = __nan (""); + __real__ result = M_NAN; } return result; } -weak_alias (__clog10, clog10) -#ifdef NO_LONG_DOUBLE -strong_alias (__clog10, __clog10l) -weak_alias (__clog10, clog10l) + +declare_mgen_alias (__clog10, clog10) + +#if M_LIBM_NEED_COMPAT (clog10) +/* __clog10 is also a public symbol. */ +declare_mgen_libm_compat (__clog10, __clog10) +declare_mgen_libm_compat (clog10, clog10) #endif diff --git a/math/s_clog10f.c b/math/s_clog10f.c deleted file mode 100644 index 485625e..0000000 --- a/math/s_clog10f.c +++ /dev/null @@ -1,122 +0,0 @@ -/* Compute complex base 10 logarithm. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include - -/* log_10 (2). */ -#define M_LOG10_2f 0.3010299956639811952137388947244930267682f - -/* pi * log10 (e). */ -#define M_PI_LOG10Ef 1.364376353841841347485783625431355770210f - -__complex__ float -__clog10f (__complex__ float x) -{ - __complex__ float 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_LOG10Ef : 0.0; - __imag__ result = __copysignf (__imag__ result, __imag__ x); - /* Yes, the following line raises an exception. */ - __real__ result = -1.0 / fabsf (__real__ x); - } - else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN)) - { - /* Neither real nor imaginary part is NaN. */ - float absx = fabsf (__real__ x), absy = fabsf (__imag__ x); - int scale = 0; - - if (absx < absy) - { - float t = absx; - absx = absy; - absy = t; - } - - if (absx > FLT_MAX / 2.0f) - { - scale = -1; - absx = __scalbnf (absx, scale); - absy = (absy >= FLT_MIN * 2.0f ? __scalbnf (absy, scale) : 0.0f); - } - else if (absx < FLT_MIN && absy < FLT_MIN) - { - scale = FLT_MANT_DIG; - absx = __scalbnf (absx, scale); - absy = __scalbnf (absy, scale); - } - - if (absx == 1.0f && scale == 0) - { - __real__ result = __log1pf (absy * absy) * ((float) M_LOG10E / 2.0f); - math_check_force_underflow_nonneg (__real__ result); - } - else if (absx > 1.0f && absx < 2.0f && absy < 1.0f && scale == 0) - { - float d2m1 = (absx - 1.0f) * (absx + 1.0f); - if (absy >= FLT_EPSILON) - d2m1 += absy * absy; - __real__ result = __log1pf (d2m1) * ((float) M_LOG10E / 2.0f); - } - else if (absx < 1.0f - && absx >= 0.5f - && absy < FLT_EPSILON / 2.0f - && scale == 0) - { - float d2m1 = (absx - 1.0f) * (absx + 1.0f); - __real__ result = __log1pf (d2m1) * ((float) M_LOG10E / 2.0f); - } - else if (absx < 1.0f - && absx >= 0.5f - && scale == 0 - && absx * absx + absy * absy >= 0.5f) - { - float d2m1 = __x2y2m1f (absx, absy); - __real__ result = __log1pf (d2m1) * ((float) M_LOG10E / 2.0f); - } - else - { - float d = __ieee754_hypotf (absx, absy); - __real__ result = __ieee754_log10f (d) - scale * M_LOG10_2f; - } - - __imag__ result = M_LOG10E * __ieee754_atan2f (__imag__ x, __real__ x); - } - else - { - __imag__ result = __nanf (""); - if (rcls == FP_INFINITE || icls == FP_INFINITE) - /* Real or imaginary part is infinite. */ - __real__ result = HUGE_VALF; - else - __real__ result = __nanf (""); - } - - return result; -} -#ifndef __clog10f -weak_alias (__clog10f, clog10f) -#endif diff --git a/math/s_clog10l.c b/math/s_clog10l.c deleted file mode 100644 index da40477..0000000 --- a/math/s_clog10l.c +++ /dev/null @@ -1,127 +0,0 @@ -/* Compute complex base 10 logarithm. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include - -/* To avoid spurious underflows, use this definition to treat IBM long - double as approximating an IEEE-style format. */ -#if LDBL_MANT_DIG == 106 -# undef LDBL_EPSILON -# define LDBL_EPSILON 0x1p-106L -#endif - -/* log_10 (2). */ -#define M_LOG10_2l 0.3010299956639811952137388947244930267682L - -/* pi * log10 (e). */ -#define M_PI_LOG10El 1.364376353841841347485783625431355770210L - -__complex__ long double -__clog10l (__complex__ long double x) -{ - __complex__ long 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_LOG10El : 0.0; - __imag__ result = __copysignl (__imag__ result, __imag__ x); - /* Yes, the following line raises an exception. */ - __real__ result = -1.0 / fabsl (__real__ x); - } - else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN)) - { - /* Neither real nor imaginary part is NaN. */ - long double absx = fabsl (__real__ x), absy = fabsl (__imag__ x); - int scale = 0; - - if (absx < absy) - { - long double t = absx; - absx = absy; - absy = t; - } - - if (absx > LDBL_MAX / 2.0L) - { - scale = -1; - absx = __scalbnl (absx, scale); - absy = (absy >= LDBL_MIN * 2.0L ? __scalbnl (absy, scale) : 0.0L); - } - else if (absx < LDBL_MIN && absy < LDBL_MIN) - { - scale = LDBL_MANT_DIG; - absx = __scalbnl (absx, scale); - absy = __scalbnl (absy, scale); - } - - if (absx == 1.0L && scale == 0) - { - __real__ result = __log1pl (absy * absy) * (M_LOG10El / 2.0L); - math_check_force_underflow_nonneg (__real__ result); - } - else if (absx > 1.0L && absx < 2.0L && absy < 1.0L && scale == 0) - { - long double d2m1 = (absx - 1.0L) * (absx + 1.0L); - if (absy >= LDBL_EPSILON) - d2m1 += absy * absy; - __real__ result = __log1pl (d2m1) * (M_LOG10El / 2.0L); - } - else if (absx < 1.0L - && absx >= 0.5L - && absy < LDBL_EPSILON / 2.0L - && scale == 0) - { - long double d2m1 = (absx - 1.0L) * (absx + 1.0L); - __real__ result = __log1pl (d2m1) * (M_LOG10El / 2.0L); - } - else if (absx < 1.0L - && absx >= 0.5L - && scale == 0 - && absx * absx + absy * absy >= 0.5L) - { - long double d2m1 = __x2y2m1l (absx, absy); - __real__ result = __log1pl (d2m1) * (M_LOG10El / 2.0L); - } - else - { - long double d = __ieee754_hypotl (absx, absy); - __real__ result = __ieee754_log10l (d) - scale * M_LOG10_2l; - } - - __imag__ result = M_LOG10El * __ieee754_atan2l (__imag__ x, __real__ x); - } - else - { - __imag__ result = __nanl (""); - if (rcls == FP_INFINITE || icls == FP_INFINITE) - /* Real or imaginary part is infinite. */ - __real__ result = HUGE_VALL; - else - __real__ result = __nanl (""); - } - - return result; -} -weak_alias (__clog10l, clog10l) diff --git a/math/s_clog_template.c b/math/s_clog_template.c index b546030..047ac03 100644 --- a/math/s_clog_template.c +++ b/math/s_clog_template.c @@ -22,97 +22,98 @@ #include #include -__complex__ double -__clog (__complex__ double x) +CFLOAT +M_DECL_FUNC (__clog) (CFLOAT x) { - __complex__ double result; + CFLOAT 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); + __imag__ result = signbit (__real__ x) ? (FLOAT) M_MLIT (M_PI) : 0; + __imag__ result = M_COPYSIGN (__imag__ result, __imag__ x); /* Yes, the following line raises an exception. */ - __real__ result = -1.0 / fabs (__real__ x); + __real__ result = -1 / M_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); + FLOAT absx = M_FABS (__real__ x), absy = M_FABS (__imag__ x); int scale = 0; if (absx < absy) { - double t = absx; + FLOAT t = absx; absx = absy; absy = t; } - if (absx > DBL_MAX / 2.0) + if (absx > M_MAX / 2) { scale = -1; - absx = __scalbn (absx, scale); - absy = (absy >= DBL_MIN * 2.0 ? __scalbn (absy, scale) : 0.0); + absx = M_SCALBN (absx, scale); + absy = (absy >= M_MIN * 2 ? M_SCALBN (absy, scale) : 0); } - else if (absx < DBL_MIN && absy < DBL_MIN) + else if (absx < M_MIN && absy < M_MIN) { - scale = DBL_MANT_DIG; - absx = __scalbn (absx, scale); - absy = __scalbn (absy, scale); + scale = M_MANT_DIG; + absx = M_SCALBN (absx, scale); + absy = M_SCALBN (absy, scale); } - if (absx == 1.0 && scale == 0) + if (absx == 1 && scale == 0) { - __real__ result = __log1p (absy * absy) / 2.0; + __real__ result = M_LOG1P (absy * absy) / 2; math_check_force_underflow_nonneg (__real__ result); } - else if (absx > 1.0 && absx < 2.0 && absy < 1.0 && scale == 0) + else if (absx > 1 && absx < 2 && absy < 1 && scale == 0) { - double d2m1 = (absx - 1.0) * (absx + 1.0); - if (absy >= DBL_EPSILON) + FLOAT d2m1 = (absx - 1) * (absx + 1); + if (absy >= M_EPSILON) d2m1 += absy * absy; - __real__ result = __log1p (d2m1) / 2.0; + __real__ result = M_LOG1P (d2m1) / 2; } - else if (absx < 1.0 - && absx >= 0.5 - && absy < DBL_EPSILON / 2.0 + else if (absx < 1 + && absx >= M_LIT (0.5) + && absy < M_EPSILON / 2 && scale == 0) { - double d2m1 = (absx - 1.0) * (absx + 1.0); - __real__ result = __log1p (d2m1) / 2.0; + FLOAT d2m1 = (absx - 1) * (absx + 1); + __real__ result = M_LOG1P (d2m1) / 2; } - else if (absx < 1.0 - && absx >= 0.5 + else if (absx < 1 + && absx >= M_LIT (0.5) && scale == 0 - && absx * absx + absy * absy >= 0.5) + && absx * absx + absy * absy >= M_LIT (0.5)) { - double d2m1 = __x2y2m1 (absx, absy); - __real__ result = __log1p (d2m1) / 2.0; + FLOAT d2m1 = M_SUF (__x2y2m1) (absx, absy); + __real__ result = M_LOG1P (d2m1) / 2; } else { - double d = __ieee754_hypot (absx, absy); - __real__ result = __ieee754_log (d) - scale * M_LN2; + FLOAT d = M_HYPOT (absx, absy); + __real__ result = M_LOG (d) - scale * (FLOAT) M_MLIT (M_LN2); } - __imag__ result = __ieee754_atan2 (__imag__ x, __real__ x); + __imag__ result = M_ATAN2 (__imag__ x, __real__ x); } else { - __imag__ result = __nan (""); + __imag__ result = M_NAN; if (rcls == FP_INFINITE || icls == FP_INFINITE) /* Real or imaginary part is infinite. */ - __real__ result = HUGE_VAL; + __real__ result = M_HUGE_VAL; else - __real__ result = __nan (""); + __real__ result = M_NAN; } return result; } -weak_alias (__clog, clog) -#ifdef NO_LONG_DOUBLE -strong_alias (__clog, __clogl) -weak_alias (__clog, clogl) + +declare_mgen_alias (__clog, clog) + +#if M_LIBM_NEED_COMPAT (clog) +declare_mgen_libm_compat (__clog, clog) #endif diff --git a/math/s_clogf.c b/math/s_clogf.c deleted file mode 100644 index cc56539..0000000 --- a/math/s_clogf.c +++ /dev/null @@ -1,116 +0,0 @@ -/* Compute complex natural logarithm. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include - -__complex__ float -__clogf (__complex__ float x) -{ - __complex__ float 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 = __copysignf (__imag__ result, __imag__ x); - /* Yes, the following line raises an exception. */ - __real__ result = -1.0 / fabsf (__real__ x); - } - else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN)) - { - /* Neither real nor imaginary part is NaN. */ - float absx = fabsf (__real__ x), absy = fabsf (__imag__ x); - int scale = 0; - - if (absx < absy) - { - float t = absx; - absx = absy; - absy = t; - } - - if (absx > FLT_MAX / 2.0f) - { - scale = -1; - absx = __scalbnf (absx, scale); - absy = (absy >= FLT_MIN * 2.0f ? __scalbnf (absy, scale) : 0.0f); - } - else if (absx < FLT_MIN && absy < FLT_MIN) - { - scale = FLT_MANT_DIG; - absx = __scalbnf (absx, scale); - absy = __scalbnf (absy, scale); - } - - if (absx == 1.0f && scale == 0) - { - __real__ result = __log1pf (absy * absy) / 2.0f; - math_check_force_underflow_nonneg (__real__ result); - } - else if (absx > 1.0f && absx < 2.0f && absy < 1.0f && scale == 0) - { - float d2m1 = (absx - 1.0f) * (absx + 1.0f); - if (absy >= FLT_EPSILON) - d2m1 += absy * absy; - __real__ result = __log1pf (d2m1) / 2.0f; - } - else if (absx < 1.0f - && absx >= 0.5f - && absy < FLT_EPSILON / 2.0f - && scale == 0) - { - float d2m1 = (absx - 1.0f) * (absx + 1.0f); - __real__ result = __log1pf (d2m1) / 2.0f; - } - else if (absx < 1.0f - && absx >= 0.5f - && scale == 0 - && absx * absx + absy * absy >= 0.5f) - { - float d2m1 = __x2y2m1f (absx, absy); - __real__ result = __log1pf (d2m1) / 2.0f; - } - else - { - float d = __ieee754_hypotf (absx, absy); - __real__ result = __ieee754_logf (d) - scale * (float) M_LN2; - } - - __imag__ result = __ieee754_atan2f (__imag__ x, __real__ x); - } - else - { - __imag__ result = __nanf (""); - if (rcls == FP_INFINITE || icls == FP_INFINITE) - /* Real or imaginary part is infinite. */ - __real__ result = HUGE_VALF; - else - __real__ result = __nanf (""); - } - - return result; -} -#ifndef __clogf -weak_alias (__clogf, clogf) -#endif diff --git a/math/s_clogl.c b/math/s_clogl.c deleted file mode 100644 index 6db59b7..0000000 --- a/math/s_clogl.c +++ /dev/null @@ -1,121 +0,0 @@ -/* Compute complex natural logarithm. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include - -/* To avoid spurious underflows, use this definition to treat IBM long - double as approximating an IEEE-style format. */ -#if LDBL_MANT_DIG == 106 -# undef LDBL_EPSILON -# define LDBL_EPSILON 0x1p-106L -#endif - -__complex__ long double -__clogl (__complex__ long double x) -{ - __complex__ long 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_PIl : 0.0; - __imag__ result = __copysignl (__imag__ result, __imag__ x); - /* Yes, the following line raises an exception. */ - __real__ result = -1.0 / fabsl (__real__ x); - } - else if (__glibc_likely (rcls != FP_NAN && icls != FP_NAN)) - { - /* Neither real nor imaginary part is NaN. */ - long double absx = fabsl (__real__ x), absy = fabsl (__imag__ x); - int scale = 0; - - if (absx < absy) - { - long double t = absx; - absx = absy; - absy = t; - } - - if (absx > LDBL_MAX / 2.0L) - { - scale = -1; - absx = __scalbnl (absx, scale); - absy = (absy >= LDBL_MIN * 2.0L ? __scalbnl (absy, scale) : 0.0L); - } - else if (absx < LDBL_MIN && absy < LDBL_MIN) - { - scale = LDBL_MANT_DIG; - absx = __scalbnl (absx, scale); - absy = __scalbnl (absy, scale); - } - - if (absx == 1.0L && scale == 0) - { - __real__ result = __log1pl (absy * absy) / 2.0L; - math_check_force_underflow_nonneg (__real__ result); - } - else if (absx > 1.0L && absx < 2.0L && absy < 1.0L && scale == 0) - { - long double d2m1 = (absx - 1.0L) * (absx + 1.0L); - if (absy >= LDBL_EPSILON) - d2m1 += absy * absy; - __real__ result = __log1pl (d2m1) / 2.0L; - } - else if (absx < 1.0L - && absx >= 0.5L - && absy < LDBL_EPSILON / 2.0L - && scale == 0) - { - long double d2m1 = (absx - 1.0L) * (absx + 1.0L); - __real__ result = __log1pl (d2m1) / 2.0L; - } - else if (absx < 1.0L - && absx >= 0.5L - && scale == 0 - && absx * absx + absy * absy >= 0.5L) - { - long double d2m1 = __x2y2m1l (absx, absy); - __real__ result = __log1pl (d2m1) / 2.0L; - } - else - { - long double d = __ieee754_hypotl (absx, absy); - __real__ result = __ieee754_logl (d) - scale * M_LN2l; - } - - __imag__ result = __ieee754_atan2l (__imag__ x, __real__ x); - } - else - { - __imag__ result = __nanl (""); - if (rcls == FP_INFINITE || icls == FP_INFINITE) - /* Real or imaginary part is infinite. */ - __real__ result = HUGE_VALL; - else - __real__ result = __nanl (""); - } - - return result; -} -weak_alias (__clogl, clogl) diff --git a/math/s_cpow.c b/math/s_cpow.c deleted file mode 100644 index 037e575..0000000 --- a/math/s_cpow.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Complex power of double values. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - - -__complex__ double -__cpow (__complex__ double x, __complex__ double c) -{ - return __cexp (c * __clog (x)); -} -weak_alias (__cpow, cpow) -#ifdef NO_LONG_DOUBLE -strong_alias (__cpow, __cpowl) -weak_alias (__cpow, cpowl) -#endif diff --git a/math/s_cpow_template.c b/math/s_cpow_template.c index 037e575..12dfc92 100644 --- a/math/s_cpow_template.c +++ b/math/s_cpow_template.c @@ -1,4 +1,4 @@ -/* Complex power of double values. +/* Complex power of float type. Copyright (C) 1997-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -20,14 +20,14 @@ #include #include - -__complex__ double -__cpow (__complex__ double x, __complex__ double c) +CFLOAT +M_DECL_FUNC (__cpow) (CFLOAT x, CFLOAT c) { - return __cexp (c * __clog (x)); + return M_SUF (__cexp) (c * M_SUF (__clog) (x)); } -weak_alias (__cpow, cpow) -#ifdef NO_LONG_DOUBLE -strong_alias (__cpow, __cpowl) -weak_alias (__cpow, cpowl) + +declare_mgen_alias (__cpow, cpow) + +#if M_LIBM_NEED_COMPAT (cpow) +declare_mgen_libm_compat (__cpow, cpow) #endif diff --git a/math/s_cpowf.c b/math/s_cpowf.c deleted file mode 100644 index 2b0b5b2..0000000 --- a/math/s_cpowf.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Complex power of float values. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - - -__complex__ float -__cpowf (__complex__ float x, __complex__ float c) -{ - return __cexpf (c * __clogf (x)); -} -#ifndef __cpowf -weak_alias (__cpowf, cpowf) -#endif diff --git a/math/s_cpowl.c b/math/s_cpowl.c deleted file mode 100644 index 963e03a..0000000 --- a/math/s_cpowl.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Complex power of long double values. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - - -__complex__ long double -__cpowl (__complex__ long double x, __complex__ long double c) -{ - return __cexpl (c * __clogl (x)); -} -weak_alias (__cpowl, cpowl) diff --git a/math/s_cproj.c b/math/s_cproj.c deleted file mode 100644 index d47f009..0000000 --- a/math/s_cproj.c +++ /dev/null @@ -1,44 +0,0 @@ -/* Compute projection of complex double value to Riemann sphere. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include - - -__complex__ double -__cproj (__complex__ double x) -{ - if (isinf (__real__ x) || isinf (__imag__ x)) - { - __complex__ double res; - - __real__ res = INFINITY; - __imag__ res = __copysign (0.0, __imag__ x); - - return res; - } - - return x; -} -weak_alias (__cproj, cproj) -#ifdef NO_LONG_DOUBLE -strong_alias (__cproj, __cprojl) -weak_alias (__cproj, cprojl) -#endif diff --git a/math/s_cproj_template.c b/math/s_cproj_template.c index d47f009..e274e4c 100644 --- a/math/s_cproj_template.c +++ b/math/s_cproj_template.c @@ -1,4 +1,4 @@ -/* Compute projection of complex double value to Riemann sphere. +/* Compute projection of complex float type value to Riemann sphere. Copyright (C) 1997-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -22,23 +22,24 @@ #include -__complex__ double -__cproj (__complex__ double x) +CFLOAT +M_DECL_FUNC (__cproj) (CFLOAT x) { if (isinf (__real__ x) || isinf (__imag__ x)) { - __complex__ double res; + CFLOAT res; __real__ res = INFINITY; - __imag__ res = __copysign (0.0, __imag__ x); + __imag__ res = M_COPYSIGN (0, __imag__ x); return res; } return x; } -weak_alias (__cproj, cproj) -#ifdef NO_LONG_DOUBLE -strong_alias (__cproj, __cprojl) -weak_alias (__cproj, cprojl) + +declare_mgen_alias (__cproj, cproj) + +#if M_LIBM_NEED_COMPAT (cproj) +declare_mgen_libm_compat (__cproj, cproj) #endif diff --git a/math/s_cprojf.c b/math/s_cprojf.c deleted file mode 100644 index 8a0d873..0000000 --- a/math/s_cprojf.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Compute projection of complex float value to Riemann sphere. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include - - -__complex__ float -__cprojf (__complex__ float x) -{ - if (isinf (__real__ x) || isinf (__imag__ x)) - { - __complex__ float res; - - __real__ res = INFINITY; - __imag__ res = __copysignf (0.0, __imag__ x); - - return res; - } - - return x; -} -#ifndef __cprojf -weak_alias (__cprojf, cprojf) -#endif diff --git a/math/s_cprojl.c b/math/s_cprojl.c deleted file mode 100644 index 213b733..0000000 --- a/math/s_cprojl.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Compute projection of complex long double value to Riemann sphere. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include - - -__complex__ long double -__cprojl (__complex__ long double x) -{ - if (isinf (__real__ x) || isinf (__imag__ x)) - { - __complex__ long double res; - - __real__ res = INFINITY; - __imag__ res = __copysignl (0.0, __imag__ x); - - return res; - } - - return x; -} -weak_alias (__cprojl, cprojl) diff --git a/math/s_csqrt.c b/math/s_csqrt.c deleted file mode 100644 index 1f073e7..0000000 --- a/math/s_csqrt.c +++ /dev/null @@ -1,165 +0,0 @@ -/* Complex square root of double value. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Based on an algorithm by Stephen L. Moshier . - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include - -__complex__ double -__csqrt (__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 = HUGE_VAL; - __imag__ res = __imag__ x; - } - else if (rcls == FP_INFINITE) - { - if (__real__ x < 0.0) - { - __real__ res = icls == FP_NAN ? __nan ("") : 0; - __imag__ res = __copysign (HUGE_VAL, __imag__ x); - } - else - { - __real__ res = __real__ x; - __imag__ res = (icls == FP_NAN - ? __nan ("") : __copysign (0.0, __imag__ x)); - } - } - else - { - __real__ res = __nan (""); - __imag__ res = __nan (""); - } - } - else - { - if (__glibc_unlikely (icls == FP_ZERO)) - { - if (__real__ x < 0.0) - { - __real__ res = 0.0; - __imag__ res = __copysign (__ieee754_sqrt (-__real__ x), - __imag__ x); - } - else - { - __real__ res = fabs (__ieee754_sqrt (__real__ x)); - __imag__ res = __copysign (0.0, __imag__ x); - } - } - else if (__glibc_unlikely (rcls == FP_ZERO)) - { - double r; - if (fabs (__imag__ x) >= 2.0 * DBL_MIN) - r = __ieee754_sqrt (0.5 * fabs (__imag__ x)); - else - r = 0.5 * __ieee754_sqrt (2.0 * fabs (__imag__ x)); - - __real__ res = r; - __imag__ res = __copysign (r, __imag__ x); - } - else - { - double d, r, s; - int scale = 0; - - if (fabs (__real__ x) > DBL_MAX / 4.0) - { - scale = 1; - __real__ x = __scalbn (__real__ x, -2 * scale); - __imag__ x = __scalbn (__imag__ x, -2 * scale); - } - else if (fabs (__imag__ x) > DBL_MAX / 4.0) - { - scale = 1; - if (fabs (__real__ x) >= 4.0 * DBL_MIN) - __real__ x = __scalbn (__real__ x, -2 * scale); - else - __real__ x = 0.0; - __imag__ x = __scalbn (__imag__ x, -2 * scale); - } - else if (fabs (__real__ x) < 2.0 * DBL_MIN - && fabs (__imag__ x) < 2.0 * DBL_MIN) - { - scale = -((DBL_MANT_DIG + 1) / 2); - __real__ x = __scalbn (__real__ x, -2 * scale); - __imag__ x = __scalbn (__imag__ x, -2 * scale); - } - - d = __ieee754_hypot (__real__ x, __imag__ x); - /* Use the identity 2 Re res Im res = Im x - to avoid cancellation error in d +/- Re x. */ - if (__real__ x > 0) - { - r = __ieee754_sqrt (0.5 * (d + __real__ x)); - if (scale == 1 && fabs (__imag__ x) < 1.0) - { - /* Avoid possible intermediate underflow. */ - s = __imag__ x / r; - r = __scalbn (r, scale); - scale = 0; - } - else - s = 0.5 * (__imag__ x / r); - } - else - { - s = __ieee754_sqrt (0.5 * (d - __real__ x)); - if (scale == 1 && fabs (__imag__ x) < 1.0) - { - /* Avoid possible intermediate underflow. */ - r = fabs (__imag__ x / s); - s = __scalbn (s, scale); - scale = 0; - } - else - r = fabs (0.5 * (__imag__ x / s)); - } - - if (scale) - { - r = __scalbn (r, scale); - s = __scalbn (s, scale); - } - - math_check_force_underflow (r); - math_check_force_underflow (s); - - __real__ res = r; - __imag__ res = __copysign (s, __imag__ x); - } - } - - return res; -} -weak_alias (__csqrt, csqrt) -#ifdef NO_LONG_DOUBLE -strong_alias (__csqrt, __csqrtl) -weak_alias (__csqrt, csqrtl) -#endif diff --git a/math/s_csqrt_template.c b/math/s_csqrt_template.c index 1f073e7..22af083 100644 --- a/math/s_csqrt_template.c +++ b/math/s_csqrt_template.c @@ -1,4 +1,4 @@ -/* Complex square root of double value. +/* Complex square root of a float type. Copyright (C) 1997-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Based on an algorithm by Stephen L. Moshier . @@ -23,10 +23,10 @@ #include #include -__complex__ double -__csqrt (__complex__ double x) +CFLOAT +M_DECL_FUNC (__csqrt) (CFLOAT x) { - __complex__ double res; + CFLOAT res; int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); @@ -34,132 +34,131 @@ __csqrt (__complex__ double x) { if (icls == FP_INFINITE) { - __real__ res = HUGE_VAL; + __real__ res = M_HUGE_VAL; __imag__ res = __imag__ x; } else if (rcls == FP_INFINITE) { - if (__real__ x < 0.0) + if (__real__ x < 0) { - __real__ res = icls == FP_NAN ? __nan ("") : 0; - __imag__ res = __copysign (HUGE_VAL, __imag__ x); + __real__ res = icls == FP_NAN ? M_NAN : 0; + __imag__ res = M_COPYSIGN (M_HUGE_VAL, __imag__ x); } else { __real__ res = __real__ x; __imag__ res = (icls == FP_NAN - ? __nan ("") : __copysign (0.0, __imag__ x)); + ? M_NAN : M_COPYSIGN (0, __imag__ x)); } } else { - __real__ res = __nan (""); - __imag__ res = __nan (""); + __real__ res = M_NAN; + __imag__ res = M_NAN; } } else { if (__glibc_unlikely (icls == FP_ZERO)) { - if (__real__ x < 0.0) + if (__real__ x < 0) { - __real__ res = 0.0; - __imag__ res = __copysign (__ieee754_sqrt (-__real__ x), - __imag__ x); + __real__ res = 0; + __imag__ res = M_COPYSIGN (M_SQRT (-__real__ x), __imag__ x); } else { - __real__ res = fabs (__ieee754_sqrt (__real__ x)); - __imag__ res = __copysign (0.0, __imag__ x); + __real__ res = M_FABS (M_SQRT (__real__ x)); + __imag__ res = M_COPYSIGN (0, __imag__ x); } } else if (__glibc_unlikely (rcls == FP_ZERO)) { - double r; - if (fabs (__imag__ x) >= 2.0 * DBL_MIN) - r = __ieee754_sqrt (0.5 * fabs (__imag__ x)); + FLOAT r; + if (M_FABS (__imag__ x) >= 2 * M_MIN) + r = M_SQRT (M_LIT (0.5) * M_FABS (__imag__ x)); else - r = 0.5 * __ieee754_sqrt (2.0 * fabs (__imag__ x)); + r = M_LIT (0.5) * M_SQRT (2 * M_FABS (__imag__ x)); __real__ res = r; - __imag__ res = __copysign (r, __imag__ x); + __imag__ res = M_COPYSIGN (r, __imag__ x); } else { - double d, r, s; + FLOAT d, r, s; int scale = 0; - if (fabs (__real__ x) > DBL_MAX / 4.0) + if (M_FABS (__real__ x) > M_MAX / 4) { scale = 1; - __real__ x = __scalbn (__real__ x, -2 * scale); - __imag__ x = __scalbn (__imag__ x, -2 * scale); + __real__ x = M_SCALBN (__real__ x, -2 * scale); + __imag__ x = M_SCALBN (__imag__ x, -2 * scale); } - else if (fabs (__imag__ x) > DBL_MAX / 4.0) + else if (M_FABS (__imag__ x) > M_MAX / 4) { scale = 1; - if (fabs (__real__ x) >= 4.0 * DBL_MIN) - __real__ x = __scalbn (__real__ x, -2 * scale); + if (M_FABS (__real__ x) >= 4 * M_MIN) + __real__ x = M_SCALBN (__real__ x, -2 * scale); else - __real__ x = 0.0; - __imag__ x = __scalbn (__imag__ x, -2 * scale); + __real__ x = 0; + __imag__ x = M_SCALBN (__imag__ x, -2 * scale); } - else if (fabs (__real__ x) < 2.0 * DBL_MIN - && fabs (__imag__ x) < 2.0 * DBL_MIN) + else if (M_FABS (__real__ x) < 2 * M_MIN + && M_FABS (__imag__ x) < 2 * M_MIN) { - scale = -((DBL_MANT_DIG + 1) / 2); - __real__ x = __scalbn (__real__ x, -2 * scale); - __imag__ x = __scalbn (__imag__ x, -2 * scale); + scale = -((M_MANT_DIG + 1) / 2); + __real__ x = M_SCALBN (__real__ x, -2 * scale); + __imag__ x = M_SCALBN (__imag__ x, -2 * scale); } - d = __ieee754_hypot (__real__ x, __imag__ x); + d = M_HYPOT (__real__ x, __imag__ x); /* Use the identity 2 Re res Im res = Im x to avoid cancellation error in d +/- Re x. */ if (__real__ x > 0) { - r = __ieee754_sqrt (0.5 * (d + __real__ x)); - if (scale == 1 && fabs (__imag__ x) < 1.0) + r = M_SQRT (M_LIT (0.5) * (d + __real__ x)); + if (scale == 1 && M_FABS (__imag__ x) < 1) { /* Avoid possible intermediate underflow. */ s = __imag__ x / r; - r = __scalbn (r, scale); + r = M_SCALBN (r, scale); scale = 0; } else - s = 0.5 * (__imag__ x / r); + s = M_LIT (0.5) * (__imag__ x / r); } else { - s = __ieee754_sqrt (0.5 * (d - __real__ x)); - if (scale == 1 && fabs (__imag__ x) < 1.0) + s = M_SQRT (M_LIT (0.5) * (d - __real__ x)); + if (scale == 1 && M_FABS (__imag__ x) < 1) { /* Avoid possible intermediate underflow. */ - r = fabs (__imag__ x / s); - s = __scalbn (s, scale); + r = M_FABS (__imag__ x / s); + s = M_SCALBN (s, scale); scale = 0; } else - r = fabs (0.5 * (__imag__ x / s)); + r = M_FABS (M_LIT (0.5) * (__imag__ x / s)); } if (scale) { - r = __scalbn (r, scale); - s = __scalbn (s, scale); + r = M_SCALBN (r, scale); + s = M_SCALBN (s, scale); } math_check_force_underflow (r); math_check_force_underflow (s); __real__ res = r; - __imag__ res = __copysign (s, __imag__ x); + __imag__ res = M_COPYSIGN (s, __imag__ x); } } return res; } -weak_alias (__csqrt, csqrt) -#ifdef NO_LONG_DOUBLE -strong_alias (__csqrt, __csqrtl) -weak_alias (__csqrt, csqrtl) +declare_mgen_alias (__csqrt, csqrt) + +#if M_LIBM_NEED_COMPAT (csqrt) +declare_mgen_libm_compat (__csqrt, csqrt) #endif diff --git a/math/s_csqrtf.c b/math/s_csqrtf.c deleted file mode 100644 index b30af06..0000000 --- a/math/s_csqrtf.c +++ /dev/null @@ -1,163 +0,0 @@ -/* Complex square root of float value. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Based on an algorithm by Stephen L. Moshier . - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include - -__complex__ float -__csqrtf (__complex__ float x) -{ - __complex__ float 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 = HUGE_VALF; - __imag__ res = __imag__ x; - } - else if (rcls == FP_INFINITE) - { - if (__real__ x < 0.0) - { - __real__ res = icls == FP_NAN ? __nanf ("") : 0; - __imag__ res = __copysignf (HUGE_VALF, __imag__ x); - } - else - { - __real__ res = __real__ x; - __imag__ res = (icls == FP_NAN - ? __nanf ("") : __copysignf (0.0, __imag__ x)); - } - } - else - { - __real__ res = __nanf (""); - __imag__ res = __nanf (""); - } - } - else - { - if (__glibc_unlikely (icls == FP_ZERO)) - { - if (__real__ x < 0.0) - { - __real__ res = 0.0; - __imag__ res = __copysignf (__ieee754_sqrtf (-__real__ x), - __imag__ x); - } - else - { - __real__ res = fabsf (__ieee754_sqrtf (__real__ x)); - __imag__ res = __copysignf (0.0, __imag__ x); - } - } - else if (__glibc_unlikely (rcls == FP_ZERO)) - { - float r; - if (fabsf (__imag__ x) >= 2.0f * FLT_MIN) - r = __ieee754_sqrtf (0.5f * fabsf (__imag__ x)); - else - r = 0.5f * __ieee754_sqrtf (2.0f * fabsf (__imag__ x)); - - __real__ res = r; - __imag__ res = __copysignf (r, __imag__ x); - } - else - { - float d, r, s; - int scale = 0; - - if (fabsf (__real__ x) > FLT_MAX / 4.0f) - { - scale = 1; - __real__ x = __scalbnf (__real__ x, -2 * scale); - __imag__ x = __scalbnf (__imag__ x, -2 * scale); - } - else if (fabsf (__imag__ x) > FLT_MAX / 4.0f) - { - scale = 1; - if (fabsf (__real__ x) >= 4.0f * FLT_MIN) - __real__ x = __scalbnf (__real__ x, -2 * scale); - else - __real__ x = 0.0f; - __imag__ x = __scalbnf (__imag__ x, -2 * scale); - } - else if (fabsf (__real__ x) < 2.0f * FLT_MIN - && fabsf (__imag__ x) < 2.0f * FLT_MIN) - { - scale = -((FLT_MANT_DIG + 1) / 2); - __real__ x = __scalbnf (__real__ x, -2 * scale); - __imag__ x = __scalbnf (__imag__ x, -2 * scale); - } - - d = __ieee754_hypotf (__real__ x, __imag__ x); - /* Use the identity 2 Re res Im res = Im x - to avoid cancellation error in d +/- Re x. */ - if (__real__ x > 0) - { - r = __ieee754_sqrtf (0.5f * (d + __real__ x)); - if (scale == 1 && fabsf (__imag__ x) < 1.0f) - { - /* Avoid possible intermediate underflow. */ - s = __imag__ x / r; - r = __scalbnf (r, scale); - scale = 0; - } - else - s = 0.5f * (__imag__ x / r); - } - else - { - s = __ieee754_sqrtf (0.5f * (d - __real__ x)); - if (scale == 1 && fabsf (__imag__ x) < 1.0f) - { - /* Avoid possible intermediate underflow. */ - r = fabsf (__imag__ x / s); - s = __scalbnf (s, scale); - scale = 0; - } - else - r = fabsf (0.5f * (__imag__ x / s)); - } - - if (scale) - { - r = __scalbnf (r, scale); - s = __scalbnf (s, scale); - } - - math_check_force_underflow (r); - math_check_force_underflow (s); - - __real__ res = r; - __imag__ res = __copysignf (s, __imag__ x); - } - } - - return res; -} -#ifndef __csqrtf -weak_alias (__csqrtf, csqrtf) -#endif diff --git a/math/s_csqrtl.c b/math/s_csqrtl.c deleted file mode 100644 index b0b52a5..0000000 --- a/math/s_csqrtl.c +++ /dev/null @@ -1,161 +0,0 @@ -/* Complex square root of long double value. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Based on an algorithm by Stephen L. Moshier . - Contributed by Ulrich Drepper , 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include -#include - -__complex__ long double -__csqrtl (__complex__ long double x) -{ - __complex__ long 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 = HUGE_VALL; - __imag__ res = __imag__ x; - } - else if (rcls == FP_INFINITE) - { - if (__real__ x < 0.0) - { - __real__ res = icls == FP_NAN ? __nanl ("") : 0; - __imag__ res = __copysignl (HUGE_VALL, __imag__ x); - } - else - { - __real__ res = __real__ x; - __imag__ res = (icls == FP_NAN - ? __nanl ("") : __copysignl (0.0, __imag__ x)); - } - } - else - { - __real__ res = __nanl (""); - __imag__ res = __nanl (""); - } - } - else - { - if (__glibc_unlikely (icls == FP_ZERO)) - { - if (__real__ x < 0.0) - { - __real__ res = 0.0; - __imag__ res = __copysignl (__ieee754_sqrtl (-__real__ x), - __imag__ x); - } - else - { - __real__ res = fabsl (__ieee754_sqrtl (__real__ x)); - __imag__ res = __copysignl (0.0, __imag__ x); - } - } - else if (__glibc_unlikely (rcls == FP_ZERO)) - { - long double r; - if (fabsl (__imag__ x) >= 2.0L * LDBL_MIN) - r = __ieee754_sqrtl (0.5L * fabsl (__imag__ x)); - else - r = 0.5L * __ieee754_sqrtl (2.0L * fabsl (__imag__ x)); - - __real__ res = r; - __imag__ res = __copysignl (r, __imag__ x); - } - else - { - long double d, r, s; - int scale = 0; - - if (fabsl (__real__ x) > LDBL_MAX / 4.0L) - { - scale = 1; - __real__ x = __scalbnl (__real__ x, -2 * scale); - __imag__ x = __scalbnl (__imag__ x, -2 * scale); - } - else if (fabsl (__imag__ x) > LDBL_MAX / 4.0L) - { - scale = 1; - if (fabsl (__real__ x) >= 4.0L * LDBL_MIN) - __real__ x = __scalbnl (__real__ x, -2 * scale); - else - __real__ x = 0.0L; - __imag__ x = __scalbnl (__imag__ x, -2 * scale); - } - else if (fabsl (__real__ x) < 2.0L * LDBL_MIN - && fabsl (__imag__ x) < 2.0L * LDBL_MIN) - { - scale = -((LDBL_MANT_DIG + 1) / 2); - __real__ x = __scalbnl (__real__ x, -2 * scale); - __imag__ x = __scalbnl (__imag__ x, -2 * scale); - } - - d = __ieee754_hypotl (__real__ x, __imag__ x); - /* Use the identity 2 Re res Im res = Im x - to avoid cancellation error in d +/- Re x. */ - if (__real__ x > 0) - { - r = __ieee754_sqrtl (0.5L * (d + __real__ x)); - if (scale == 1 && fabsl (__imag__ x) < 1.0L) - { - /* Avoid possible intermediate underflow. */ - s = __imag__ x / r; - r = __scalbnl (r, scale); - scale = 0; - } - else - s = 0.5L * (__imag__ x / r); - } - else - { - s = __ieee754_sqrtl (0.5L * (d - __real__ x)); - if (scale == 1 && fabsl (__imag__ x) < 1.0L) - { - /* Avoid possible intermediate underflow. */ - r = fabsl (__imag__ x / s); - s = __scalbnl (s, scale); - scale = 0; - } - else - r = fabsl (0.5L * (__imag__ x / s)); - } - - if (scale) - { - r = __scalbnl (r, scale); - s = __scalbnl (s, scale); - } - - math_check_force_underflow (r); - math_check_force_underflow (s); - - __real__ res = r; - __imag__ res = __copysignl (s, __imag__ x); - } - } - - return res; -} -weak_alias (__csqrtl, csqrtl) -- cgit v1.1