mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-25 22:40:05 +00:00
fd3b4e7c8a
This patch makes ldbl-128 functions use libm_alias_ldouble to define function aliases. float128_private.h is updated accordingly. Most of the ldbl-64-128 wrappers are removed as no longer needed with this change (leaving those that involve versioning for functions in libc or that shouldn't be exported from libm for _Float128 / _Float64x types with the same format as long double). Tested for x86_64, and tested with build-many-glibcs.py that installed stripped shared libraries are unchanged by this patch. * sysdeps/ieee754/float128/float128_private.h: Include <libm-alias-ldouble.h> and <libm-alias-float128.h>. (libm_alias_ldouble_r): Undefine and redefine. * sysdeps/ieee754/ldbl-128/s_asinhl.c: Include <libm-alias-ldouble.h>. (asinhl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_atanl.c: Include <libm-alias-ldouble.h>. (atanl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_cbrtl.c: Include <libm-alias-ldouble.h>. (cbrtl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_ceill.c: Include <libm-alias-ldouble.h>. (ceill): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_copysignl.c: Include <libm-alias-ldouble.h>. (copysignl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_cosl.c: Include <libm-alias-ldouble.h>. (cosl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_erfl.c: Include <libm-alias-ldouble.h>. (erfl): Define using libm_alias_ldouble. (erfcl): Likewise. * sysdeps/ieee754/ldbl-128/s_expm1l.c: Include <libm-alias-ldouble.h>. (expm1l): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_fabsl.c: Include <libm-alias-ldouble.h>. (fabsl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_floorl.c: Include <libm-alias-ldouble.h>. (floorl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_fmal.c: Include <libm-alias-ldouble.h>. (fmal): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_frexpl.c: Include <libm-alias-ldouble.h>. (frexpl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_fromfpl.c (fromfpl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_fromfpl_main.c: Include <libm-alias-ldouble.h>. * sysdeps/ieee754/ldbl-128/s_fromfpxl.c (fromfpxl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_getpayloadl.c: Include <libm-alias-ldouble.h>. (getpayloadl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_llrintl.c: Include <libm-alias-ldouble.h>. (llrintl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_llroundl.c: Include <libm-alias-ldouble.h>. (llroundl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_logbl.c: Include <libm-alias-ldouble.h>. (logbl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_lrintl.c: Include <libm-alias-ldouble.h>. (lrintl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_lroundl.c: Include <libm-alias-ldouble.h>. (lroundl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_modfl.c: Include <libm-alias-ldouble.h>. (modfl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_nearbyintl.c: Include <libm-alias-ldouble.h>. (nearbyintl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_nextafterl.c: Include <libm-alias-ldouble.h>. (nextafterl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_nextupl.c: Include <libm-alias-ldouble.h>. (nextupl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_remquol.c: Include <libm-alias-ldouble.h>. (remquol): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_rintl.c: Include <libm-alias-ldouble.h>. (rintl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_roundevenl.c: Include <libm-alias-ldouble.h>. (roundevenl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_roundl.c: Include <libm-alias-ldouble.h>. (roundl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_setpayloadl.c (setpayloadl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_setpayloadl_main.c: Include <libm-alias-ldouble.h>. * sysdeps/ieee754/ldbl-128/s_setpayloadsigl.c (setpayloadsigl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_sincosl.c: Include <libm-alias-ldouble.h>. (sincosl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_sinl.c: Include <libm-alias-ldouble.h>. (sinl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_tanhl.c: Include <libm-alias-ldouble.h>. (tanhl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_tanl.c: Include <libm-alias-ldouble.h>. (tanl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_totalorderl.c: Include <libm-alias-ldouble.h>. (totalorderl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_totalordermagl.c: Include <libm-alias-ldouble.h>. (totalordermagl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_truncl.c: Include <libm-alias-ldouble.h>. (truncl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_ufromfpl.c (ufromfpl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-128/s_ufromfpxl.c (ufromfpxl): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-64-128/s_copysignl.c: Include <libm-alias-ldouble.h>. (weak_alias): Do not undefine and redefine. [IS_IN (libc)] (libm_alias_ldouble): Undefine and redefine. (copysignl): Define with long_double_symbol only if [IS_IN (libc)]. * sysdeps/ieee754/ldbl-64-128/s_frexpl.c: Include <libm-alias-ldouble.h>. (weak_alias): Do not undefine and redefine. [IS_IN (libc)] (libm_alias_ldouble): Undefine and redefine. (frexpl): Define with long_double_symbol only if [IS_IN (libc)]. * sysdeps/ieee754/ldbl-64-128/s_modfl.c: Include <libm-alias-ldouble.h>. (weak_alias): Do not undefine and redefine. [IS_IN (libc)] (libm_alias_ldouble): Undefine and redefine. (modfl): Define with long_double_symbol only if [IS_IN (libc)]. * sysdeps/ieee754/ldbl-64-128/s_asinhl.c: Remove file. * sysdeps/ieee754/ldbl-64-128/s_atanl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_cbrtl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_ceill.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_cosl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_erfl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_expm1l.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_fabsl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_floorl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_fmal.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_llrintl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_llroundl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_logbl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_lrintl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_lroundl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_nearbyintl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_remquol.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_rintl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_roundl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_sincosl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_sinl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_tanhl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_tanl.c: Likewise. * sysdeps/ieee754/ldbl-64-128/s_truncl.c: Likewise.
137 lines
3.3 KiB
C
137 lines
3.3 KiB
C
/* cbrtl.c
|
|
*
|
|
* Cube root, long double precision
|
|
*
|
|
*
|
|
*
|
|
* SYNOPSIS:
|
|
*
|
|
* long double x, y, cbrtl();
|
|
*
|
|
* y = cbrtl( x );
|
|
*
|
|
*
|
|
*
|
|
* DESCRIPTION:
|
|
*
|
|
* Returns the cube root of the argument, which may be negative.
|
|
*
|
|
* Range reduction involves determining the power of 2 of
|
|
* the argument. A polynomial of degree 2 applied to the
|
|
* mantissa, and multiplication by the cube root of 1, 2, or 4
|
|
* approximates the root to within about 0.1%. Then Newton's
|
|
* iteration is used three times to converge to an accurate
|
|
* result.
|
|
*
|
|
*
|
|
*
|
|
* ACCURACY:
|
|
*
|
|
* Relative error:
|
|
* arithmetic domain # trials peak rms
|
|
* IEEE -8,8 100000 1.3e-34 3.9e-35
|
|
* IEEE exp(+-707) 100000 1.3e-34 4.3e-35
|
|
*
|
|
*/
|
|
|
|
/*
|
|
Cephes Math Library Release 2.2: January, 1991
|
|
Copyright 1984, 1991 by Stephen L. Moshier
|
|
Adapted for glibc October, 2001.
|
|
|
|
This 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.
|
|
|
|
This 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 this library; if not, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
#include <math.h>
|
|
#include <math_private.h>
|
|
#include <libm-alias-ldouble.h>
|
|
|
|
static const _Float128 CBRT2 = L(1.259921049894873164767210607278228350570251);
|
|
static const _Float128 CBRT4 = L(1.587401051968199474751705639272308260391493);
|
|
static const _Float128 CBRT2I = L(0.7937005259840997373758528196361541301957467);
|
|
static const _Float128 CBRT4I = L(0.6299605249474365823836053036391141752851257);
|
|
|
|
|
|
_Float128
|
|
__cbrtl (_Float128 x)
|
|
{
|
|
int e, rem, sign;
|
|
_Float128 z;
|
|
|
|
if (!isfinite (x))
|
|
return x + x;
|
|
|
|
if (x == 0)
|
|
return (x);
|
|
|
|
if (x > 0)
|
|
sign = 1;
|
|
else
|
|
{
|
|
sign = -1;
|
|
x = -x;
|
|
}
|
|
|
|
z = x;
|
|
/* extract power of 2, leaving mantissa between 0.5 and 1 */
|
|
x = __frexpl (x, &e);
|
|
|
|
/* Approximate cube root of number between .5 and 1,
|
|
peak relative error = 1.2e-6 */
|
|
x = ((((L(1.3584464340920900529734e-1) * x
|
|
- L(6.3986917220457538402318e-1)) * x
|
|
+ L(1.2875551670318751538055e0)) * x
|
|
- L(1.4897083391357284957891e0)) * x
|
|
+ L(1.3304961236013647092521e0)) * x + L(3.7568280825958912391243e-1);
|
|
|
|
/* exponent divided by 3 */
|
|
if (e >= 0)
|
|
{
|
|
rem = e;
|
|
e /= 3;
|
|
rem -= 3 * e;
|
|
if (rem == 1)
|
|
x *= CBRT2;
|
|
else if (rem == 2)
|
|
x *= CBRT4;
|
|
}
|
|
else
|
|
{ /* argument less than 1 */
|
|
e = -e;
|
|
rem = e;
|
|
e /= 3;
|
|
rem -= 3 * e;
|
|
if (rem == 1)
|
|
x *= CBRT2I;
|
|
else if (rem == 2)
|
|
x *= CBRT4I;
|
|
e = -e;
|
|
}
|
|
|
|
/* multiply by power of 2 */
|
|
x = __ldexpl (x, e);
|
|
|
|
/* Newton iteration */
|
|
x -= (x - (z / (x * x))) * L(0.3333333333333333333333333333333333333333);
|
|
x -= (x - (z / (x * x))) * L(0.3333333333333333333333333333333333333333);
|
|
x -= (x - (z / (x * x))) * L(0.3333333333333333333333333333333333333333);
|
|
|
|
if (sign < 0)
|
|
x = -x;
|
|
return (x);
|
|
}
|
|
|
|
libm_alias_ldouble (__cbrt, cbrt)
|