1996-03-05 21:41:30 +00:00
|
|
|
/*
|
2001-03-12 00:04:52 +00:00
|
|
|
* IBM Accurate Mathematical Library
|
2002-07-06 06:36:39 +00:00
|
|
|
* written by International Business Machines Corp.
|
2016-01-04 16:05:18 +00:00
|
|
|
* Copyright (C) 2001-2016 Free Software Foundation, Inc.
|
1996-03-05 21:41:30 +00:00
|
|
|
*
|
2001-03-12 00:04:52 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
2002-08-26 22:40:48 +00:00
|
|
|
* the Free Software Foundation; either version 2.1 of the License, or
|
2001-03-12 00:04:52 +00:00
|
|
|
* (at your option) any later version.
|
1996-03-05 21:41:30 +00:00
|
|
|
*
|
2001-03-12 00:04:52 +00:00
|
|
|
* This program 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
|
2002-08-20 21:51:55 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
1996-03-05 21:41:30 +00:00
|
|
|
*
|
2001-03-12 00:04:52 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2012-02-09 23:18:22 +00:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
1996-03-05 21:41:30 +00:00
|
|
|
*/
|
2001-03-12 00:04:52 +00:00
|
|
|
/***************************************************************************/
|
|
|
|
/* MODULE_NAME: upow.c */
|
|
|
|
/* */
|
|
|
|
/* FUNCTIONS: upow */
|
|
|
|
/* power1 */
|
2011-10-12 11:27:51 -04:00
|
|
|
/* my_log2 */
|
2001-03-12 00:04:52 +00:00
|
|
|
/* log1 */
|
|
|
|
/* checkint */
|
|
|
|
/* FILES NEEDED: dla.h endian.h mpa.h mydefs.h */
|
|
|
|
/* halfulp.c mpexp.c mplog.c slowexp.c slowpow.c mpa.c */
|
2011-10-12 11:27:51 -04:00
|
|
|
/* uexp.c upow.c */
|
2001-03-12 00:04:52 +00:00
|
|
|
/* root.tbl uexp.tbl upow.tbl */
|
|
|
|
/* An ultimate power routine. Given two IEEE double machine numbers y,x */
|
|
|
|
/* it computes the correctly rounded (to nearest) value of x^y. */
|
|
|
|
/* Assumption: Machine arithmetic operations are performed in */
|
|
|
|
/* round to nearest mode of IEEE 754 standard. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
2014-06-23 20:12:33 +00:00
|
|
|
#include <math.h>
|
2001-03-12 00:04:52 +00:00
|
|
|
#include "endian.h"
|
|
|
|
#include "upow.h"
|
2011-10-23 12:50:28 -04:00
|
|
|
#include <dla.h>
|
2001-03-12 00:04:52 +00:00
|
|
|
#include "mydefs.h"
|
|
|
|
#include "MathLib.h"
|
|
|
|
#include "upow.tbl"
|
2012-03-09 11:29:16 -08:00
|
|
|
#include <math_private.h>
|
2012-03-05 12:22:46 +00:00
|
|
|
#include <fenv.h>
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2011-10-25 00:56:33 -04:00
|
|
|
#ifndef SECTION
|
|
|
|
# define SECTION
|
|
|
|
#endif
|
|
|
|
|
2012-04-09 09:43:18 +00:00
|
|
|
static const double huge = 1.0e300, tiny = 1.0e-300;
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2013-10-08 16:23:16 +05:30
|
|
|
double __exp1 (double x, double xx, double error);
|
|
|
|
static double log1 (double x, double *delta, double *error);
|
|
|
|
static double my_log2 (double x, double *delta, double *error);
|
|
|
|
double __slowpow (double x, double y, double z);
|
|
|
|
static double power1 (double x, double y);
|
|
|
|
static int checkint (double x);
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2013-10-08 16:23:16 +05:30
|
|
|
/* An ultimate power routine. Given two IEEE double machine numbers y, x it
|
|
|
|
computes the correctly rounded (to nearest) value of X^y. */
|
2011-10-25 00:56:33 -04:00
|
|
|
double
|
|
|
|
SECTION
|
2013-10-08 16:23:16 +05:30
|
|
|
__ieee754_pow (double x, double y)
|
|
|
|
{
|
|
|
|
double z, a, aa, error, t, a1, a2, y1, y2;
|
|
|
|
mynumber u, v;
|
2001-03-12 00:04:52 +00:00
|
|
|
int k;
|
2013-10-08 16:23:16 +05:30
|
|
|
int4 qx, qy;
|
|
|
|
v.x = y;
|
|
|
|
u.x = x;
|
|
|
|
if (v.i[LOW_HALF] == 0)
|
|
|
|
{ /* of y */
|
|
|
|
qx = u.i[HIGH_HALF] & 0x7fffffff;
|
|
|
|
/* Is x a NaN? */
|
|
|
|
if (((qx == 0x7ff00000) && (u.i[LOW_HALF] != 0)) || (qx > 0x7ff00000))
|
|
|
|
return x;
|
|
|
|
if (y == 1.0)
|
|
|
|
return x;
|
|
|
|
if (y == 2.0)
|
|
|
|
return x * x;
|
|
|
|
if (y == -1.0)
|
|
|
|
return 1.0 / x;
|
|
|
|
if (y == 0)
|
|
|
|
return 1.0;
|
|
|
|
}
|
2001-03-12 00:04:52 +00:00
|
|
|
/* else */
|
2013-10-08 16:23:16 +05:30
|
|
|
if (((u.i[HIGH_HALF] > 0 && u.i[HIGH_HALF] < 0x7ff00000) || /* x>0 and not x->0 */
|
|
|
|
(u.i[HIGH_HALF] == 0 && u.i[LOW_HALF] != 0)) &&
|
|
|
|
/* 2^-1023< x<= 2^-1023 * 0x1.0000ffffffff */
|
|
|
|
(v.i[HIGH_HALF] & 0x7fffffff) < 0x4ff00000)
|
|
|
|
{ /* if y<-1 or y>1 */
|
|
|
|
double retval;
|
2012-03-05 12:22:46 +00:00
|
|
|
|
2014-06-23 20:12:33 +00:00
|
|
|
{
|
|
|
|
SET_RESTORE_ROUND (FE_TONEAREST);
|
2012-03-05 12:22:46 +00:00
|
|
|
|
2014-06-23 20:12:33 +00:00
|
|
|
/* Avoid internal underflow for tiny y. The exact value of y does
|
|
|
|
not matter if |y| <= 2**-64. */
|
2015-05-15 10:53:55 +00:00
|
|
|
if (fabs (y) < 0x1p-64)
|
2014-06-23 20:12:33 +00:00
|
|
|
y = y < 0 ? -0x1p-64 : 0x1p-64;
|
|
|
|
z = log1 (x, &aa, &error); /* x^y =e^(y log (X)) */
|
|
|
|
t = y * CN;
|
|
|
|
y1 = t - (t - y);
|
|
|
|
y2 = y - y1;
|
|
|
|
t = z * CN;
|
|
|
|
a1 = t - (t - z);
|
|
|
|
a2 = (z - a1) + aa;
|
|
|
|
a = y1 * a1;
|
|
|
|
aa = y2 * a1 + y * a2;
|
|
|
|
a1 = a + aa;
|
|
|
|
a2 = (a - a1) + aa;
|
2015-05-15 10:53:55 +00:00
|
|
|
error = error * fabs (y);
|
2014-06-23 20:12:33 +00:00
|
|
|
t = __exp1 (a1, a2, 1.9e16 * error); /* return -10 or 0 if wasn't computed exactly */
|
|
|
|
retval = (t > 0) ? t : power1 (x, y);
|
|
|
|
}
|
2012-03-05 12:22:46 +00:00
|
|
|
|
2015-06-03 15:36:34 +01:00
|
|
|
if (isinf (retval))
|
2014-06-23 20:12:33 +00:00
|
|
|
retval = huge * huge;
|
|
|
|
else if (retval == 0)
|
|
|
|
retval = tiny * tiny;
|
2015-09-25 22:29:10 +00:00
|
|
|
else
|
|
|
|
math_check_force_underflow_nonneg (retval);
|
2013-10-08 16:23:16 +05:30
|
|
|
return retval;
|
|
|
|
}
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2013-10-08 16:23:16 +05:30
|
|
|
if (x == 0)
|
|
|
|
{
|
|
|
|
if (((v.i[HIGH_HALF] & 0x7fffffff) == 0x7ff00000 && v.i[LOW_HALF] != 0)
|
|
|
|
|| (v.i[HIGH_HALF] & 0x7fffffff) > 0x7ff00000) /* NaN */
|
|
|
|
return y;
|
2015-05-15 10:53:55 +00:00
|
|
|
if (fabs (y) > 1.0e20)
|
2013-10-08 16:23:16 +05:30
|
|
|
return (y > 0) ? 0 : 1.0 / 0.0;
|
|
|
|
k = checkint (y);
|
|
|
|
if (k == -1)
|
|
|
|
return y < 0 ? 1.0 / x : x;
|
|
|
|
else
|
|
|
|
return y < 0 ? 1.0 / 0.0 : 0.0; /* return 0 */
|
|
|
|
}
|
2007-03-05 19:38:56 +00:00
|
|
|
|
2013-10-08 16:23:16 +05:30
|
|
|
qx = u.i[HIGH_HALF] & 0x7fffffff; /* no sign */
|
|
|
|
qy = v.i[HIGH_HALF] & 0x7fffffff; /* no sign */
|
2007-03-05 19:38:56 +00:00
|
|
|
|
2013-10-08 16:23:16 +05:30
|
|
|
if (qx >= 0x7ff00000 && (qx > 0x7ff00000 || u.i[LOW_HALF] != 0)) /* NaN */
|
2013-04-03 22:00:21 +02:00
|
|
|
return x;
|
2013-10-08 16:23:16 +05:30
|
|
|
if (qy >= 0x7ff00000 && (qy > 0x7ff00000 || v.i[LOW_HALF] != 0)) /* NaN */
|
2013-04-03 22:00:21 +02:00
|
|
|
return x == 1.0 ? 1.0 : y;
|
2007-03-05 19:38:56 +00:00
|
|
|
|
2001-03-12 00:04:52 +00:00
|
|
|
/* if x<0 */
|
2013-10-08 16:23:16 +05:30
|
|
|
if (u.i[HIGH_HALF] < 0)
|
|
|
|
{
|
|
|
|
k = checkint (y);
|
|
|
|
if (k == 0)
|
|
|
|
{
|
|
|
|
if (qy == 0x7ff00000)
|
|
|
|
{
|
|
|
|
if (x == -1.0)
|
|
|
|
return 1.0;
|
|
|
|
else if (x > -1.0)
|
|
|
|
return v.i[HIGH_HALF] < 0 ? INF.x : 0.0;
|
|
|
|
else
|
|
|
|
return v.i[HIGH_HALF] < 0 ? 0.0 : INF.x;
|
|
|
|
}
|
|
|
|
else if (qx == 0x7ff00000)
|
|
|
|
return y < 0 ? 0.0 : INF.x;
|
|
|
|
return (x - x) / (x - x); /* y not integer and x<0 */
|
|
|
|
}
|
2007-03-05 19:38:56 +00:00
|
|
|
else if (qx == 0x7ff00000)
|
2013-10-08 16:23:16 +05:30
|
|
|
{
|
|
|
|
if (k < 0)
|
|
|
|
return y < 0 ? nZERO.x : nINF.x;
|
|
|
|
else
|
|
|
|
return y < 0 ? 0.0 : INF.x;
|
|
|
|
}
|
|
|
|
/* if y even or odd */
|
2014-06-23 20:12:33 +00:00
|
|
|
if (k == 1)
|
|
|
|
return __ieee754_pow (-x, y);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
double retval;
|
|
|
|
{
|
|
|
|
SET_RESTORE_ROUND (FE_TONEAREST);
|
|
|
|
retval = -__ieee754_pow (-x, y);
|
|
|
|
}
|
2015-06-03 15:36:34 +01:00
|
|
|
if (isinf (retval))
|
2014-06-23 20:12:33 +00:00
|
|
|
retval = -huge * huge;
|
|
|
|
else if (retval == 0)
|
|
|
|
retval = -tiny * tiny;
|
|
|
|
return retval;
|
|
|
|
}
|
2001-03-13 02:01:34 +00:00
|
|
|
}
|
2001-03-12 00:04:52 +00:00
|
|
|
/* x>0 */
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2013-10-08 16:23:16 +05:30
|
|
|
if (qx == 0x7ff00000) /* x= 2^-0x3ff */
|
2013-04-03 21:10:02 +02:00
|
|
|
return y > 0 ? x : 0;
|
2001-02-19 23:16:05 +00:00
|
|
|
|
2013-10-08 16:23:16 +05:30
|
|
|
if (qy > 0x45f00000 && qy < 0x7ff00000)
|
|
|
|
{
|
|
|
|
if (x == 1.0)
|
|
|
|
return 1.0;
|
|
|
|
if (y > 0)
|
|
|
|
return (x > 1.0) ? huge * huge : tiny * tiny;
|
|
|
|
if (y < 0)
|
|
|
|
return (x < 1.0) ? huge * huge : tiny * tiny;
|
|
|
|
}
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2013-10-08 16:23:16 +05:30
|
|
|
if (x == 1.0)
|
|
|
|
return 1.0;
|
|
|
|
if (y > 0)
|
|
|
|
return (x > 1.0) ? INF.x : 0;
|
|
|
|
if (y < 0)
|
|
|
|
return (x < 1.0) ? INF.x : 0;
|
|
|
|
return 0; /* unreachable, to make the compiler happy */
|
2001-03-12 00:04:52 +00:00
|
|
|
}
|
2013-10-08 16:23:16 +05:30
|
|
|
|
2011-10-24 20:19:17 -04:00
|
|
|
#ifndef __ieee754_pow
|
2011-10-12 11:27:51 -04:00
|
|
|
strong_alias (__ieee754_pow, __pow_finite)
|
2011-10-24 20:19:17 -04:00
|
|
|
#endif
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2013-10-08 16:23:16 +05:30
|
|
|
/* Compute x^y using more accurate but more slow log routine. */
|
2011-10-25 00:56:33 -04:00
|
|
|
static double
|
|
|
|
SECTION
|
2013-10-08 16:23:16 +05:30
|
|
|
power1 (double x, double y)
|
|
|
|
{
|
|
|
|
double z, a, aa, error, t, a1, a2, y1, y2;
|
|
|
|
z = my_log2 (x, &aa, &error);
|
|
|
|
t = y * CN;
|
|
|
|
y1 = t - (t - y);
|
2001-03-12 00:04:52 +00:00
|
|
|
y2 = y - y1;
|
2013-10-08 16:23:16 +05:30
|
|
|
t = z * CN;
|
|
|
|
a1 = t - (t - z);
|
2001-03-12 00:04:52 +00:00
|
|
|
a2 = z - a1;
|
2013-10-08 16:23:16 +05:30
|
|
|
a = y * z;
|
|
|
|
aa = ((y1 * a1 - a) + y1 * a2 + y2 * a1) + y2 * a2 + aa * y;
|
|
|
|
a1 = a + aa;
|
|
|
|
a2 = (a - a1) + aa;
|
2015-05-15 10:53:55 +00:00
|
|
|
error = error * fabs (y);
|
2013-10-08 16:23:16 +05:30
|
|
|
t = __exp1 (a1, a2, 1.9e16 * error);
|
|
|
|
return (t >= 0) ? t : __slowpow (x, y, z);
|
2001-03-12 00:04:52 +00:00
|
|
|
}
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2013-10-08 16:23:16 +05:30
|
|
|
/* Compute log(x) (x is left argument). The result is the returned double + the
|
|
|
|
parameter DELTA. The result is bounded by ERROR. */
|
2011-10-25 00:56:33 -04:00
|
|
|
static double
|
|
|
|
SECTION
|
2013-10-08 16:23:16 +05:30
|
|
|
log1 (double x, double *delta, double *error)
|
|
|
|
{
|
2016-01-04 13:28:52 -02:00
|
|
|
unsigned int i, j;
|
|
|
|
int m;
|
2013-10-08 16:23:16 +05:30
|
|
|
double uu, vv, eps, nx, e, e1, e2, t, t1, t2, res, add = 0;
|
|
|
|
mynumber u, v;
|
2002-08-24 01:36:09 +00:00
|
|
|
#ifdef BIG_ENDI
|
2013-10-08 16:23:16 +05:30
|
|
|
mynumber /**/ two52 = {{0x43300000, 0x00000000}}; /* 2**52 */
|
2002-08-24 01:36:09 +00:00
|
|
|
#else
|
2013-10-08 16:23:16 +05:30
|
|
|
# ifdef LITTLE_ENDI
|
|
|
|
mynumber /**/ two52 = {{0x00000000, 0x43300000}}; /* 2**52 */
|
|
|
|
# endif
|
2002-08-24 01:36:09 +00:00
|
|
|
#endif
|
update from main archive 961030
Thu Oct 31 00:01:39 1996 Ulrich Drepper <drepper@cygnus.com>
* signal/Makefile (routines): Add sigwait.
* signal/signal.h: Add prototype for sigwait.
* sysdeps/posix/sigwait.c: New file. Implementation of sigwait
function from POSIX.1c.
* sysdeps/stub/sigwait.c: New file. Stub version of sigwait.
Wed Oct 30 02:01:17 1996 Richard Henderson <rth@tamu.edu>
* sunrpc/xdr_float.c (xdr_float): Handle sizeof(float)!=sizeof(long),
but don't bother going farther than sizeof(float)==sizeof(int).
(xdr_double): Handle little-endian machines! Handle sizeof(double)
!= 2*sizeof(long), though again don't bother with more than int.
Thu Oct 29 16:09:42 1996 Craig Metz <cmetz@inner.net>
* sysdeps/posix/getaddrinfo.c: Use buffer limits for inet_ntop
function.
Tue Oct 29 12:37:22 1996 Ulrich Drepper <drepper@cygnus.com>
* Makerules: Create symbolic links for linking in $(libdir).
(make-link): Use absolute path for destination if this is not in
the same directory.
* elf/rtld.c (dl_main): When verifying don't check the name of
the dynamic linker.
* shlib-versions: Change entries for Hurd specific libs from
*-*-gnu* to *-*-gnu?* so that i586-pc-linux-gnu does not match
these entries.
* assert/assert.h: Reformat copyright.
Change reference to ANSI into reference to ISO C.
* ctype/ctype.h: Likewise.
* errno.h: Likewise.
* limits.h: Likewise.
* math/math.h: Likewise.
* setjmp/setjmp.h: Likewise.
* stdio/stdio.h: Likewise.
* libio/stdio.h: Likewise.
* stdlib/stdlib.h: Likewise.
* string/string.h: Likewise.
* time/time.h: Likewise.
* string/argz.h: Use __const is definitions.
* elf/dlfcn.h: Use __const and __P. Reformat copyright.
* misc/err.h: Likewise.
* wctype/wctype.h (wctrans_t): Use __const instead of const.
* Makeconfig ($(common-objpfx)soversions.mk): Generate list of
sonames for versioned libraries.
* Makefile: Remove code to generate libc-version.h.
Generate gnu/lib-names.h with info from soversions.mk.
* features.h: Define __GLIBC__ and __GLIBC_MINOR__.
* dirent/tst-seekdir.c: Initialize save3.
* grp/testgrp.c: Initialize my_group.
* grp/fgetgrent_r.c: Change interface to follow POSIX.1c.
* grp/grp.h: Likewise.
* nss/getXXbyYY.c: Likewise.
* nss/getXXbyYY_r.c: Likewise.
* nss/getXXent.c: Likewise.
* nss/getXXent_r.c: Likewise.
* pwd/fgetpwent_r.c: Likewise.
* pwd/pwd.h: Likewise.
* shadow/fgetspent_r.c: Likewise.
* shadow/sgetspent.c: Likewise.
* shadow/sgetspent_r.c: Likewise.
* grp/fgetgrent.c: Adapt for change in interface of fgetgrent_r.
* pwd/fgetpwent.c: Likewise, for fgetpwent_r.c.
* shadow/fgetspent.c: Likewise, for fgetpwent_r.c.
* resolv/netdb.h: Adapt prototypes for reentrant functions to
follow POSIX.1c.
* sunrpc/rpc/netdb.h: Likewise,
* shadow/shadow.h: Likewise.
* inet/getnetgrent_r.c: Follow change in pwd/grp function interface.
* sysdeps/unix/getlogin_r.c: Return ERANGE when buffer is too small.
* inet/herrno.c: Don't define __h_errno. Only h_errno otherwise the
ELF aliasing creates strange situations.
* sysdeps/unix/sysv/linux/errnos.H: Define __set_errno as inline
function.
* sysdeps/unix/sysv/linux/i386/sysdep.S: Don't define __errno.
* sysdeps/unix/sysv/linux/m68k/sysdep.S: Likewise.
* libio/libio.h: Don't declare _IO_flockfile and _IO_funlockfile
weak.
* locale/programs/charmap.c: Add casts to prevent warnings.
* locale/programs/linereader.h: Likewise.
* locale/programs/ld-collate.c: Likewise.
* locale/programs/stringtrans.c: Likewise.
Change types for various variables to prevent warnings.
* locale/programs/ld-ctype.c: Likewise.
* locale/programs/linereader.h (lr_ungetc): Likewise.
* locale/programs/charset.h (struct charset): Use `unsigned int'
as type for width_default.
* posix/regex.c: Change type of `this_reg' variables.
* stdio-common/Makefile: Use -Wno-format for tstdiomisc.c.
* stdio-common/bug5.c: De-ANSI-fy. Use correct types for
variables.
* stdio-common/printf_fp.c: Initialize to_shift.
* stdio-common/test_rdwr.c: Add cast.
* stdio-common/vfprintf.c: Add casts and use correct types to
prevent warnings.
* stdio-common/vfscanf.c: Initialize str and strptr.
* sysdeps/libm-ieee754/e_jnf.c: Use correct types to prevent warnings.
* sysdeps/libm-ieee754/e_pow.c: Likewise.
* sysdeps/libm-ieee754/e_powf.c: Likewise.
* sysdeps/libm-ieee754/e_rem_pio2f.c: Likewise.
* time/test-tz.c: Likewise.
* manual/creature.texi: Document _REENTRANT and _THREAD_SAFE.
* manual/libc.texinfo: Prevent makeinfo failure by avoiding
libc.cp index. This must be fixed.
* manual/nss.texi: Adapt for correct POSIX.1c interface of
reentrant functions.
* manual/users.texi: Document netgroup functions.
* po/es.po: Updated.
* po/fr.po: Updated.
* posix/fnmatch.c: Change to match libit version.
* posix/unistd.h: Change prototype for ttyname_r to match POSIX.1c.
* sysdep/posix/ttyname_r.c: Likewise.
* stdlib/atexit.h (__new_exitfn): Add internal locking.
* stdlib/exit.c: De-ANSI-fy. Handle new ef_us value for flavor.
* stdlib/exit.h: De-ANSI-fy. Define new ef_us value for flavor.
* stdlib/random.c (__srandom): Add internal locking.
(__initstate): Likewise.
(__setstate): Likewise.
(__random): Likewise.
Mon Oct 28 22:28:37 1996 NIIBE Yutaka <gniibe@mri.co.jp>
* sysdeps/generic/crypt-entry.c (crypt_r): Use __set_errno.
(crypt): Likewise.
* resolv/gethnamaddr.c (gethostbyname2): Likewise.
* sysdeps/generic/uname.c: Likewise.
* sysdeps/posix/rename.c: Likewise.
* sysdeps/stub/setrlimit.c: Likewise.
* nss/nss_db/db-netgrp.c (_nss_db_setnetgrent): Fix typo.
Sun Oct 27 11:12:50 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* locale/programs/ld-collate.c (collate_order_elem): Fix format
string.
(collate_element_to): Cast field width argument to `int' for
format string.
(collate_symbol): Likewise.
(collate_order_elem): Likewise.
(collate_weight_bsymbol): Likewise.
(collate_simple_weight): Likewise.
* locale/programs/ld-time.c (STRARR_ELEM): Fix format string.
* locale/programs/ld-ctype.c (ctype_class_newP): Add missing
argument for format string.
(ctype_map_newP): Likewise.
(set_class_defaults): Fix format string.
* locale/programs/localedef.c (construct_output_path): Putting an
explicit \0 into the format string does not work, use %c.
Sat Oct 26 20:38:36 1996 Richard Henderson <rth@tamu.edu>
* Makerules: Install all shared libraries in $(slibdir).
* login/Makefile: Build libutil.so in others pass after
libc.so is created.
* misc/mntent.h: Include <paths.h> for _PATH_MNTTAB & _PATH_MOUNTED.
* string/stratcliff.c: Allocate 3 pages instead of one, then use
mprotect so that we know that the adjacent pages are inaccessible.
* resource/sys/resource.h: Move all structures and enums to ...
* sysdeps/generic/resourcebits.h: ... here ...
* sysdeps/unix/bsd/sun/sunos4/resourcebits.h: ... and here.
* sysdeps/unix/sysv/linux/alpha/resourcebits.h: Remove.
* sysdeps/unix/sysv/linux/i386/resourcebits.h: Remove.
* sysdeps/unix/sysv/linux/m68k/resourcebits.h: Remove.
* sysdeps/unix/sysv/linux/mips/resourcebits.h: Remove.
* sysdeps/unix/sysv/linux/resourcebits.h: New file. Use kernel
header for RLIMIT_* definitions. The members of struct rlimit
are longs.
Thu Oct 24 17:43:34 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* MakeTAGS (sysdep-dirs): Fix typo.
Wed Oct 23 03:45:22 1996 Ulrich Drepper <drepper@cygnus.com>
* Makefile (headers): Don't mention libc-version.h.
(install-others): ...but here.
* time/strptime.c: Recognize %s, %u, %g, and %G format.
nothing is found. This guarantees all subsequent calls behave
* sysdeps/unix/sysv/linux/syscalls.list: Change function name for
* io/getwd.c (getwd) [! PATH_MAX]: Don't assume that the user's
buffer is any longer than the amount necessary to hold the
filename; the Hurd getcwd uses the *entire* contents of the
buffer, however long it is specified to be.
* posix/getconf.c: De-ANSI-fy. Recognize POSIX.2 constant names.
since these do not depend on the platform.
1996-10-31 02:57:12 +00:00
|
|
|
|
2001-03-12 00:04:52 +00:00
|
|
|
u.x = x;
|
|
|
|
m = u.i[HIGH_HALF];
|
|
|
|
*error = 0;
|
|
|
|
*delta = 0;
|
2013-10-08 16:23:16 +05:30
|
|
|
if (m < 0x00100000) /* 1<x<2^-1007 */
|
|
|
|
{
|
|
|
|
x = x * t52.x;
|
|
|
|
add = -52.0;
|
|
|
|
u.x = x;
|
|
|
|
m = u.i[HIGH_HALF];
|
|
|
|
}
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2013-10-08 16:23:16 +05:30
|
|
|
if ((m & 0x000fffff) < 0x0006a09e)
|
|
|
|
{
|
|
|
|
u.i[HIGH_HALF] = (m & 0x000fffff) | 0x3ff00000;
|
|
|
|
two52.i[LOW_HALF] = (m >> 20);
|
|
|
|
}
|
2001-03-12 00:04:52 +00:00
|
|
|
else
|
2013-10-08 16:23:16 +05:30
|
|
|
{
|
|
|
|
u.i[HIGH_HALF] = (m & 0x000fffff) | 0x3fe00000;
|
|
|
|
two52.i[LOW_HALF] = (m >> 20) + 1;
|
|
|
|
}
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2001-03-12 00:04:52 +00:00
|
|
|
v.x = u.x + bigu.x;
|
|
|
|
uu = v.x - bigu.x;
|
2013-10-08 16:23:16 +05:30
|
|
|
i = (v.i[LOW_HALF] & 0x000003ff) << 2;
|
|
|
|
if (two52.i[LOW_HALF] == 1023) /* nx = 0 */
|
|
|
|
{
|
|
|
|
if (i > 1192 && i < 1208) /* |x-1| < 1.5*2**-10 */
|
|
|
|
{
|
2001-03-12 00:04:52 +00:00
|
|
|
t = x - 1.0;
|
2013-10-08 16:23:16 +05:30
|
|
|
t1 = (t + 5.0e6) - 5.0e6;
|
|
|
|
t2 = t - t1;
|
|
|
|
e1 = t - 0.5 * t1 * t1;
|
|
|
|
e2 = (t * t * t * (r3 + t * (r4 + t * (r5 + t * (r6 + t
|
|
|
|
* (r7 + t * r8)))))
|
|
|
|
- 0.5 * t2 * (t + t1));
|
|
|
|
res = e1 + e2;
|
2015-05-15 10:53:55 +00:00
|
|
|
*error = 1.0e-21 * fabs (t);
|
2013-10-08 16:23:16 +05:30
|
|
|
*delta = (e1 - res) + e2;
|
2001-03-12 00:04:52 +00:00
|
|
|
return res;
|
2013-10-08 16:23:16 +05:30
|
|
|
} /* |x-1| < 1.5*2**-10 */
|
2001-03-12 00:04:52 +00:00
|
|
|
else
|
2013-10-08 16:23:16 +05:30
|
|
|
{
|
|
|
|
v.x = u.x * (ui.x[i] + ui.x[i + 1]) + bigv.x;
|
|
|
|
vv = v.x - bigv.x;
|
|
|
|
j = v.i[LOW_HALF] & 0x0007ffff;
|
|
|
|
j = j + j + j;
|
|
|
|
eps = u.x - uu * vv;
|
|
|
|
e1 = eps * ui.x[i];
|
|
|
|
e2 = eps * (ui.x[i + 1] + vj.x[j] * (ui.x[i] + ui.x[i + 1]));
|
|
|
|
e = e1 + e2;
|
|
|
|
e2 = ((e1 - e) + e2);
|
|
|
|
t = ui.x[i + 2] + vj.x[j + 1];
|
|
|
|
t1 = t + e;
|
|
|
|
t2 = ((((t - t1) + e) + (ui.x[i + 3] + vj.x[j + 2])) + e2 + e * e
|
|
|
|
* (p2 + e * (p3 + e * p4)));
|
|
|
|
res = t1 + t2;
|
2001-03-12 00:04:52 +00:00
|
|
|
*error = 1.0e-24;
|
2013-10-08 16:23:16 +05:30
|
|
|
*delta = (t1 - res) + t2;
|
2001-03-12 00:04:52 +00:00
|
|
|
return res;
|
2013-10-08 16:23:16 +05:30
|
|
|
}
|
|
|
|
} /* nx = 0 */
|
|
|
|
else /* nx != 0 */
|
|
|
|
{
|
2001-03-12 00:04:52 +00:00
|
|
|
eps = u.x - uu;
|
2013-10-08 16:23:16 +05:30
|
|
|
nx = (two52.x - two52e.x) + add;
|
|
|
|
e1 = eps * ui.x[i];
|
|
|
|
e2 = eps * ui.x[i + 1];
|
|
|
|
e = e1 + e2;
|
|
|
|
e2 = (e1 - e) + e2;
|
|
|
|
t = nx * ln2a.x + ui.x[i + 2];
|
|
|
|
t1 = t + e;
|
|
|
|
t2 = ((((t - t1) + e) + nx * ln2b.x + ui.x[i + 3] + e2) + e * e
|
|
|
|
* (q2 + e * (q3 + e * (q4 + e * (q5 + e * q6)))));
|
|
|
|
res = t1 + t2;
|
2001-03-12 00:04:52 +00:00
|
|
|
*error = 1.0e-21;
|
2013-10-08 16:23:16 +05:30
|
|
|
*delta = (t1 - res) + t2;
|
2001-03-12 00:04:52 +00:00
|
|
|
return res;
|
2013-10-08 16:23:16 +05:30
|
|
|
} /* nx != 0 */
|
2001-03-12 00:04:52 +00:00
|
|
|
}
|
|
|
|
|
2013-10-08 16:23:16 +05:30
|
|
|
/* Slower but more accurate routine of log. The returned result is double +
|
|
|
|
DELTA. The result is bounded by ERROR. */
|
2011-10-25 00:56:33 -04:00
|
|
|
static double
|
|
|
|
SECTION
|
2013-10-08 16:23:16 +05:30
|
|
|
my_log2 (double x, double *delta, double *error)
|
|
|
|
{
|
2016-01-04 13:28:52 -02:00
|
|
|
unsigned int i, j;
|
|
|
|
int m;
|
2013-10-08 16:23:16 +05:30
|
|
|
double uu, vv, eps, nx, e, e1, e2, t, t1, t2, res, add = 0;
|
|
|
|
double ou1, ou2, lu1, lu2, ov, lv1, lv2, a, a1, a2;
|
|
|
|
double y, yy, z, zz, j1, j2, j7, j8;
|
2011-10-24 14:21:18 -04:00
|
|
|
#ifndef DLA_FMS
|
2013-10-08 16:23:16 +05:30
|
|
|
double j3, j4, j5, j6;
|
2011-10-22 19:02:20 -04:00
|
|
|
#endif
|
2013-10-08 16:23:16 +05:30
|
|
|
mynumber u, v;
|
2002-08-24 01:36:09 +00:00
|
|
|
#ifdef BIG_ENDI
|
2013-10-08 16:23:16 +05:30
|
|
|
mynumber /**/ two52 = {{0x43300000, 0x00000000}}; /* 2**52 */
|
2002-08-24 01:36:09 +00:00
|
|
|
#else
|
2013-10-08 16:23:16 +05:30
|
|
|
# ifdef LITTLE_ENDI
|
|
|
|
mynumber /**/ two52 = {{0x00000000, 0x43300000}}; /* 2**52 */
|
|
|
|
# endif
|
2002-08-24 01:36:09 +00:00
|
|
|
#endif
|
2001-03-12 00:04:52 +00:00
|
|
|
|
|
|
|
u.x = x;
|
|
|
|
m = u.i[HIGH_HALF];
|
|
|
|
*error = 0;
|
|
|
|
*delta = 0;
|
2013-10-08 16:23:16 +05:30
|
|
|
add = 0;
|
|
|
|
if (m < 0x00100000)
|
|
|
|
{ /* x < 2^-1022 */
|
|
|
|
x = x * t52.x;
|
|
|
|
add = -52.0;
|
|
|
|
u.x = x;
|
|
|
|
m = u.i[HIGH_HALF];
|
|
|
|
}
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2013-10-08 16:23:16 +05:30
|
|
|
if ((m & 0x000fffff) < 0x0006a09e)
|
|
|
|
{
|
|
|
|
u.i[HIGH_HALF] = (m & 0x000fffff) | 0x3ff00000;
|
|
|
|
two52.i[LOW_HALF] = (m >> 20);
|
|
|
|
}
|
2001-03-12 00:04:52 +00:00
|
|
|
else
|
2013-10-08 16:23:16 +05:30
|
|
|
{
|
|
|
|
u.i[HIGH_HALF] = (m & 0x000fffff) | 0x3fe00000;
|
|
|
|
two52.i[LOW_HALF] = (m >> 20) + 1;
|
|
|
|
}
|
2001-03-12 00:04:52 +00:00
|
|
|
|
|
|
|
v.x = u.x + bigu.x;
|
|
|
|
uu = v.x - bigu.x;
|
2013-10-08 16:23:16 +05:30
|
|
|
i = (v.i[LOW_HALF] & 0x000003ff) << 2;
|
2001-03-12 00:04:52 +00:00
|
|
|
/*------------------------------------- |x-1| < 2**-11------------------------------- */
|
2013-10-08 16:23:16 +05:30
|
|
|
if ((two52.i[LOW_HALF] == 1023) && (i == 1200))
|
|
|
|
{
|
2001-03-12 00:04:52 +00:00
|
|
|
t = x - 1.0;
|
2013-10-08 16:23:16 +05:30
|
|
|
EMULV (t, s3, y, yy, j1, j2, j3, j4, j5);
|
|
|
|
ADD2 (-0.5, 0, y, yy, z, zz, j1, j2);
|
|
|
|
MUL2 (t, 0, z, zz, y, yy, j1, j2, j3, j4, j5, j6, j7, j8);
|
|
|
|
MUL2 (t, 0, y, yy, z, zz, j1, j2, j3, j4, j5, j6, j7, j8);
|
2001-03-12 00:04:52 +00:00
|
|
|
|
2013-10-08 16:23:16 +05:30
|
|
|
e1 = t + z;
|
|
|
|
e2 = ((((t - e1) + z) + zz) + t * t * t
|
|
|
|
* (ss3 + t * (s4 + t * (s5 + t * (s6 + t * (s7 + t * s8))))));
|
|
|
|
res = e1 + e2;
|
2015-05-15 10:53:55 +00:00
|
|
|
*error = 1.0e-25 * fabs (t);
|
2013-10-08 16:23:16 +05:30
|
|
|
*delta = (e1 - res) + e2;
|
2001-03-12 00:04:52 +00:00
|
|
|
return res;
|
2013-10-08 16:23:16 +05:30
|
|
|
}
|
2001-03-12 00:04:52 +00:00
|
|
|
/*----------------------------- |x-1| > 2**-11 -------------------------- */
|
|
|
|
else
|
2013-10-08 16:23:16 +05:30
|
|
|
{ /*Computing log(x) according to log table */
|
|
|
|
nx = (two52.x - two52e.x) + add;
|
2001-03-12 00:04:52 +00:00
|
|
|
ou1 = ui.x[i];
|
2013-10-08 16:23:16 +05:30
|
|
|
ou2 = ui.x[i + 1];
|
|
|
|
lu1 = ui.x[i + 2];
|
|
|
|
lu2 = ui.x[i + 3];
|
|
|
|
v.x = u.x * (ou1 + ou2) + bigv.x;
|
|
|
|
vv = v.x - bigv.x;
|
|
|
|
j = v.i[LOW_HALF] & 0x0007ffff;
|
|
|
|
j = j + j + j;
|
|
|
|
eps = u.x - uu * vv;
|
|
|
|
ov = vj.x[j];
|
|
|
|
lv1 = vj.x[j + 1];
|
|
|
|
lv2 = vj.x[j + 2];
|
|
|
|
a = (ou1 + ou2) * (1.0 + ov);
|
|
|
|
a1 = (a + 1.0e10) - 1.0e10;
|
|
|
|
a2 = a * (1.0 - a1 * uu * vv);
|
|
|
|
e1 = eps * a1;
|
|
|
|
e2 = eps * a2;
|
|
|
|
e = e1 + e2;
|
|
|
|
e2 = (e1 - e) + e2;
|
|
|
|
t = nx * ln2a.x + lu1 + lv1;
|
|
|
|
t1 = t + e;
|
|
|
|
t2 = ((((t - t1) + e) + (lu2 + lv2 + nx * ln2b.x + e2)) + e * e
|
|
|
|
* (p2 + e * (p3 + e * p4)));
|
|
|
|
res = t1 + t2;
|
2001-03-12 00:04:52 +00:00
|
|
|
*error = 1.0e-27;
|
2013-10-08 16:23:16 +05:30
|
|
|
*delta = (t1 - res) + t2;
|
2001-03-12 00:04:52 +00:00
|
|
|
return res;
|
2013-10-08 16:23:16 +05:30
|
|
|
}
|
2001-03-12 00:04:52 +00:00
|
|
|
}
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2013-10-08 16:23:16 +05:30
|
|
|
/* This function receives a double x and checks if it is an integer. If not,
|
|
|
|
it returns 0, else it returns 1 if even or -1 if odd. */
|
2011-10-25 00:56:33 -04:00
|
|
|
static int
|
|
|
|
SECTION
|
2013-10-08 16:23:16 +05:30
|
|
|
checkint (double x)
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
int4 i[2];
|
|
|
|
double x;
|
|
|
|
} u;
|
|
|
|
int k, m, n;
|
2001-03-12 00:04:52 +00:00
|
|
|
u.x = x;
|
2013-10-08 16:23:16 +05:30
|
|
|
m = u.i[HIGH_HALF] & 0x7fffffff; /* no sign */
|
|
|
|
if (m >= 0x7ff00000)
|
|
|
|
return 0; /* x is +/-inf or NaN */
|
|
|
|
if (m >= 0x43400000)
|
|
|
|
return 1; /* |x| >= 2**53 */
|
|
|
|
if (m < 0x40000000)
|
|
|
|
return 0; /* |x| < 2, can not be 0 or 1 */
|
2001-03-12 00:04:52 +00:00
|
|
|
n = u.i[LOW_HALF];
|
2013-10-08 16:23:16 +05:30
|
|
|
k = (m >> 20) - 1023; /* 1 <= k <= 52 */
|
|
|
|
if (k == 52)
|
|
|
|
return (n & 1) ? -1 : 1; /* odd or even */
|
|
|
|
if (k > 20)
|
|
|
|
{
|
2016-10-14 12:53:27 -07:00
|
|
|
if (n << (k - 20) != 0)
|
2013-10-08 16:23:16 +05:30
|
|
|
return 0; /* if not integer */
|
2016-10-14 12:53:27 -07:00
|
|
|
return (n << (k - 21) != 0) ? -1 : 1;
|
2013-10-08 16:23:16 +05:30
|
|
|
}
|
|
|
|
if (n)
|
|
|
|
return 0; /*if not integer */
|
|
|
|
if (k == 20)
|
|
|
|
return (m & 1) ? -1 : 1;
|
2016-10-14 12:53:27 -07:00
|
|
|
if (m << (k + 12) != 0)
|
2013-10-08 16:23:16 +05:30
|
|
|
return 0;
|
2016-10-14 12:53:27 -07:00
|
|
|
return (m << (k + 11) != 0) ? -1 : 1;
|
1996-03-05 21:41:30 +00:00
|
|
|
}
|