diff options
author | Ulrich Drepper <drepper@redhat.com> | 1997-03-25 02:25:35 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1997-03-25 02:25:35 +0000 |
commit | 34b402e5a967b97fc73cc45fbef61bbeb8526f3d (patch) | |
tree | 73a03f61ce0cdcc0127d3cd7402597ebc8364570 /sysdeps/libm-ieee754 | |
parent | 4e1101a7dabfc438f32ef0ba0ab4f6a936ec38d6 (diff) | |
download | glibc-34b402e5a967b97fc73cc45fbef61bbeb8526f3d.tar.gz |
Update.cvs/libc-ud-970324-2
1997-03-24 19:58 Richard Henderson <rth@tamu.edu>
* stdlib/tst-strtol.c (tests): Correct 64-bit entry.
* sysdeps/alpha/bsd-_setjmp.S: Alias _setjmp to __setjmp for
change to tst-setjmp.c.
* sysdeps/alpha/dl-machine.h: Mirror Roland's recent changes.
* sysdeps/i386/dl-machine.h: Correct noexec_p comment.
* sysdeps/sparc/dl-machine.h: Likewise.
* sysdeps/libm-ieee754/s_remquo.c: Rename {hp,lp} -> {hy,ly}.
Add missing qs variable.
* sysdeps/libm-ieee754/s_remquof.c: Likewise.
Diffstat (limited to 'sysdeps/libm-ieee754')
-rw-r--r-- | sysdeps/libm-ieee754/s_cexp.c | 63 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_remquo.c | 60 | ||||
-rw-r--r-- | sysdeps/libm-ieee754/s_remquof.c | 56 |
3 files changed, 121 insertions, 58 deletions
diff --git a/sysdeps/libm-ieee754/s_cexp.c b/sysdeps/libm-ieee754/s_cexp.c new file mode 100644 index 0000000000..46f9f612eb --- /dev/null +++ b/sysdeps/libm-ieee754/s_cexp.c @@ -0,0 +1,63 @@ +/* Return value of complex exponential function for double complex value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <complex.h> +#include <math.h> + + +__complex__ double +__cexp (__complex__ double x) +{ + __complex__ double retval; + + if (isfinite (__real__ x)) + { + if (isfinite (__imag__ x)) + { + retval = __exp (__real__ x) * (__cos (__imag__ x) + + 1i * __sin (__imag__ x)); + } + else + /* If the imaginary part is +-inf or NaN and the real part is + not +-inf the result is NaN + iNan. */ + retval = __nan ("") + 1.0i * __nan (""); + } + else if (__isinf (__real__ x)) + { + if (isfinite (__imag x)) + { + if (signbit (__real__ x) == 0 && __imag__ x == 0.0) + retval = HUGE_VAL; + else + retval = ((signbit (__real__ x) ? 0.0 : HUGE_VAL) + * (__cos (__imag__ x) + 1i * __sin (__imag__ x))); + } + else if (signbit (__real__ x)) + retval = HUGE_VAL + 1.0i * __nan (""); + else + retval = 0.0; + } + else + /* If the real part is NaN the result is NaN + iNan. */ + retval = __nan ("") + 1.0i * __nan (""); + + return retval; +} +weak_alias (__cexp, cexp) diff --git a/sysdeps/libm-ieee754/s_remquo.c b/sysdeps/libm-ieee754/s_remquo.c index 5a96f75f3b..53f26c6d89 100644 --- a/sysdeps/libm-ieee754/s_remquo.c +++ b/sysdeps/libm-ieee754/s_remquo.c @@ -29,71 +29,71 @@ static const double zero = 0.0; double __remquo (double x, double y, int *quo) { - int32_t hx,hp; - u_int32_t sx,lx,lp; - int cquo; + int32_t hx,hy; + u_int32_t sx,lx,ly; + int cquo, qs; EXTRACT_WORDS (hx, lx, x); - EXTRACT_WORDS (hp, lp, p); + EXTRACT_WORDS (hy, ly, y); sx = hx & 0x80000000; - qs = (sx ^ (hp & 0x80000000)) >> 31; - hp &= 0x7fffffff; + qs = sx ^ (hy & 0x80000000); + hy &= 0x7fffffff; hx &= 0x7fffffff; /* Purge off exception values. */ - if ((hp | lp) == 0) - return (x * p) / (x * p); /* p = 0 */ + if ((hy | ly) == 0) + return (x * y) / (x * y); /* y = 0 */ if ((hx >= 0x7ff00000) /* x not finite */ - || ((hp >= 0x7ff00000) /* p is NaN */ - && (((hp - 0x7ff00000) | lp) != 0))) - return (x * p) / (x * p); + || ((hy >= 0x7ff00000) /* p is NaN */ + && (((hy - 0x7ff00000) | ly) != 0))) + return (x * y) / (x * y); - if (hp <= 0x7fbfffff) + if (hy <= 0x7fbfffff) { - x = __ieee754_fmod (x, 8 * p); /* now x < 8p */ + x = __ieee754_fmod (x, 8 * y); /* now x < 8y */ - if (fabs (x) >= 4 * fabs (p)) + if (fabs (x) >= 4 * fabs (y)) cquo += 4; } - if (((hx - hp) | (lx - lp)) == 0) + if (((hx - hy) | (lx - ly)) == 0) { *quo = qs ? -1 : 1; return zero * x; } x = fabs (x); - p = fabs (p); + y = fabs (y); cquo = 0; - if (x >= 2 * p) + if (x >= 2 * y) { - x -= 4 * p; + x -= 4 * y; cquo += 2; } - if (x >= p) + if (x >= y) { - x -= 2 * p; + x -= 2 * y; ++cquo; } - if (hp < 0x00200000) + if (hy < 0x00200000) { - if (x + x > p) + if (x + x > y) { - x -= p; - if (x + x >= p) - x -= p; + x -= y; + if (x + x >= y) + x -= y; } } else { - double p_half = 0.5 * p; - if(x > p_half) + double y_half = 0.5 * y; + if(x > y_half) { - x -= p; - if (x >= p_half) - x -= p; + x -= y; + if (x >= y_half) + x -= y; } } diff --git a/sysdeps/libm-ieee754/s_remquof.c b/sysdeps/libm-ieee754/s_remquof.c index cce5495ce8..0968fe650b 100644 --- a/sysdeps/libm-ieee754/s_remquof.c +++ b/sysdeps/libm-ieee754/s_remquof.c @@ -29,70 +29,70 @@ static const float zero = 0.0; float __remquof (float x, float y, int *quo) { - int32_t hx,hp; + int32_t hx,hy; u_int32_t sx; - int cquo; + int cquo, qs; GET_FLOAT_WORD (hx, x); - GET_FLOAT_WORD (hp, p); + GET_FLOAT_WORD (hy, y); sx = hx & 0x80000000; - qs = (sx ^ (hp & 0x80000000)) >> 31; - hp &= 0x7fffffff; + qs = sx ^ (hy & 0x80000000); + hy &= 0x7fffffff; hx &= 0x7fffffff; /* Purge off exception values. */ - if (hp == 0) - return (x * p) / (x * p); /* p = 0 */ + if (hy == 0) + return (x * y) / (x * y); /* y = 0 */ if ((hx >= 0x7f800000) /* x not finite */ - || (hp > 0x7f800000)) /* p is NaN */ - return (x * p) / (x * p); + || (hy > 0x7f800000)) /* y is NaN */ + return (x * y) / (x * y); - if (hp <= 0x7dffffff) + if (hy <= 0x7dffffff) { - x = __ieee754_fmodf (x, 8 * p); /* now x < 8p */ + x = __ieee754_fmodf (x, 8 * y); /* now x < 8y */ - if (fabs (x) >= 4 * fabs (p)) + if (fabs (x) >= 4 * fabs (y)) cquo += 4; } - if ((hx - hp) == 0) + if ((hx - hy) == 0) { *quo = qs ? -1 : 1; return zero * x; } x = fabsf (x); - p = fabsf (p); + y = fabsf (y); cquo = 0; - if (x >= 2 * p) + if (x >= 2 * y) { - x -= 4 * p; + x -= 4 * y; cquo += 2; } - if (x >= p) + if (x >= y) { - x -= 2 * p; + x -= 2 * y; ++cquo; } - if (hp < 0x01000000) + if (hy < 0x01000000) { - if (x + x > p) + if (x + x > y) { - x -= p; - if (x + x >= p) - x -= p; + x -= y; + if (x + x >= y) + x -= y; } } else { - float p_half = 0.5 * p; - if(x > p_half) + float y_half = 0.5 * y; + if(x > y_half) { - x -= p; - if (x >= p_half) - x -= p; + x -= y; + if (x >= y_half) + x -= y; } } |