From b12676a5853278cf006fbc0908d35cb9d5ba7adc Mon Sep 17 00:00:00 2001 From: jakub Date: Sun, 16 Jan 2011 16:42:37 +0000 Subject: PR fortran/46416 * quadmath.h (cacosq, cacoshq, casinq, casinhq, catanq, catanhq): New prototypes. (M_Eq, M_LOG2Eq, M_LOG10Eq, M_LN2q, M_LN10q, M_PIq, M_PI_2q, M_PI_4q, M_1_PIq, M_2_PIq, M_2_SQRTPIq, M_SQRT2q, M_SQRT1_2q): Define. * quadmath_weak.h (cacosq, cacoshq, casinq, casinhq, catanq, catanhq): Add. * quadmath-imp.h (fpclassifyq, QUADFP_NAN, QUADFP_INFINITE, QUADFP_ZERO, QUADFP_SUBNORMAL, QUADFP_NORMAL): Define. * quadmath.map (QUADMATH_1.0): Add cacosq, cacoshq, casinq, casinhq, catanq and catanhq. * Makefile.am (libquadmath_la_SOURCES): Add math/cacosq.c, math/cacoshq.c, math/casinq.c, math/casinhq.c, math/catanq.c and math/catanhq.c. * Makefile.in: Regenerated. * libquadmath.texi (cacosq, cacoshq, casinq, casinhq, catanq, catanhq): Add. * math/cacoshq.c: New file. * math/cacosq.c: New file. * math/catanq.c: New file. * math/catanhq.c: New file. * math/casinq.c: New file. * math/casinhq.c: New file. * math/hypotq.c (hypotq): Use Q suffix instead of L. * math/atan2q.c (tiny, pi_o_4, pi_o_2, pi, pi_lo, atan2q): Likewise. * math/cosq.c (cosq): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@168853 138bc75d-0d04-0410-961f-82ee72b054a4 --- libquadmath/math/atan2q.c | 20 +++++------ libquadmath/math/cacoshq.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++ libquadmath/math/cacosq.c | 35 ++++++++++++++++++ libquadmath/math/casinhq.c | 78 ++++++++++++++++++++++++++++++++++++++++ libquadmath/math/casinq.c | 60 +++++++++++++++++++++++++++++++ libquadmath/math/catanhq.c | 76 +++++++++++++++++++++++++++++++++++++++ libquadmath/math/catanq.c | 81 +++++++++++++++++++++++++++++++++++++++++ libquadmath/math/cosq.c | 2 +- libquadmath/math/hypotq.c | 2 +- 9 files changed, 431 insertions(+), 12 deletions(-) create mode 100644 libquadmath/math/cacoshq.c create mode 100644 libquadmath/math/cacosq.c create mode 100644 libquadmath/math/casinhq.c create mode 100644 libquadmath/math/casinq.c create mode 100644 libquadmath/math/catanhq.c create mode 100644 libquadmath/math/catanq.c (limited to 'libquadmath/math') diff --git a/libquadmath/math/atan2q.c b/libquadmath/math/atan2q.c index 9d24dccb54e..fbe64d62b95 100644 --- a/libquadmath/math/atan2q.c +++ b/libquadmath/math/atan2q.c @@ -43,12 +43,12 @@ #include "quadmath-imp.h" static const __float128 -tiny = 1.0e-4900L, +tiny = 1.0e-4900Q, zero = 0.0, -pi_o_4 = 7.85398163397448309615660845819875699e-01L, /* 3ffe921fb54442d18469898cc51701b8 */ -pi_o_2 = 1.57079632679489661923132169163975140e+00L, /* 3fff921fb54442d18469898cc51701b8 */ -pi = 3.14159265358979323846264338327950280e+00L, /* 4000921fb54442d18469898cc51701b8 */ -pi_lo = 8.67181013012378102479704402604335225e-35L; /* 3f8dcd129024e088a67cc74020bbea64 */ +pi_o_4 = 7.85398163397448309615660845819875699e-01Q, /* 3ffe921fb54442d18469898cc51701b8 */ +pi_o_2 = 1.57079632679489661923132169163975140e+00Q, /* 3fff921fb54442d18469898cc51701b8 */ +pi = 3.14159265358979323846264338327950280e+00Q, /* 4000921fb54442d18469898cc51701b8 */ +pi_lo = 8.67181013012378102479704402604335225e-35Q; /* 3f8dcd129024e088a67cc74020bbea64 */ __float128 atan2q (__float128 y, __float128 x) @@ -64,7 +64,7 @@ atan2q (__float128 y, __float128 x) if(((ix|((lx|-lx)>>63))>0x7fff000000000000LL)|| ((iy|((ly|-ly)>>63))>0x7fff000000000000LL)) /* x or y is NaN */ return x+y; - if(((hx-0x3fff000000000000LL)|lx)==0) return atanq(y); /* x=1.0L */ + if(((hx-0x3fff000000000000LL)|lx)==0) return atanq(y); /* x=1.0Q */ m = ((hy>>63)&1)|((hx>>62)&2); /* 2*sign(x)+sign(y) */ /* when y = 0 */ @@ -85,8 +85,8 @@ atan2q (__float128 y, __float128 x) switch(m) { case 0: return pi_o_4+tiny;/* atan(+INF,+INF) */ case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */ - case 2: return 3.0L*pi_o_4+tiny;/*atan(+INF,-INF)*/ - case 3: return -3.0L*pi_o_4-tiny;/*atan(-INF,-INF)*/ + case 2: return 3.0Q*pi_o_4+tiny;/*atan(+INF,-INF)*/ + case 3: return -3.0Q*pi_o_4-tiny;/*atan(-INF,-INF)*/ } } else { switch(m) { @@ -102,8 +102,8 @@ atan2q (__float128 y, __float128 x) /* compute y/x */ k = (iy-ix)>>48; - if(k > 120) z=pi_o_2+0.5L*pi_lo; /* |y/x| > 2**120 */ - else if(hx<0&&k<-120) z=0.0L; /* |y|/x < -2**120 */ + if(k > 120) z=pi_o_2+0.5Q*pi_lo; /* |y/x| > 2**120 */ + else if(hx<0&&k<-120) z=0.0Q; /* |y|/x < -2**120 */ else z=atanq(fabsq(y/x)); /* safe to do y/x */ switch (m) { case 0: return z ; /* atan(+,+) */ diff --git a/libquadmath/math/cacoshq.c b/libquadmath/math/cacoshq.c new file mode 100644 index 00000000000..8acc570de76 --- /dev/null +++ b/libquadmath/math/cacoshq.c @@ -0,0 +1,89 @@ +/* Return arc hyperbole cosine for __float128 value. + Copyright (C) 1997, 1998, 2006 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include "quadmath-imp.h" + + +__complex128 +cacoshq (__complex128 x) +{ + __complex128 res; + int rcls = fpclassifyq (__real__ x); + int icls = fpclassifyq (__imag__ x); + + if (rcls <= QUADFP_INFINITE || icls <= QUADFP_INFINITE) + { + if (icls == QUADFP_INFINITE) + { + __real__ res = HUGE_VALQ; + + if (rcls == QUADFP_NAN) + __imag__ res = nanq (""); + else + __imag__ res = copysignq ((rcls == QUADFP_INFINITE + ? (__real__ x < 0.0 + ? M_PIq - M_PI_4q : M_PI_4q) + : M_PI_2q), __imag__ x); + } + else if (rcls == QUADFP_INFINITE) + { + __real__ res = HUGE_VALQ; + + if (icls >= QUADFP_ZERO) + __imag__ res = copysignq (signbitq (__real__ x) ? M_PIq : 0.0, + __imag__ x); + else + __imag__ res = nanq (""); + } + else + { + __real__ res = nanq (""); + __imag__ res = nanq (""); + } + } + else if (rcls == QUADFP_ZERO && icls == QUADFP_ZERO) + { + __real__ res = 0.0; + __imag__ res = copysignq (M_PI_2q, __imag__ x); + } + else + { + __complex128 y; + + __real__ y = (__real__ x - __imag__ x) * (__real__ x + __imag__ x) - 1.0; + __imag__ y = 2.0 * __real__ x * __imag__ x; + + y = csqrtq (y); + + if (__real__ x < 0.0) + y = -y; + + __real__ y += __real__ x; + __imag__ y += __imag__ x; + + res = clogq (y); + + /* We have to use the positive branch. */ + if (__real__ res < 0.0) + res = -res; + } + + return res; +} diff --git a/libquadmath/math/cacosq.c b/libquadmath/math/cacosq.c new file mode 100644 index 00000000000..3c257b029bf --- /dev/null +++ b/libquadmath/math/cacosq.c @@ -0,0 +1,35 @@ +/* Return cosine of complex __float128 value. + Copyright (C) 1997, 1998 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include "quadmath-imp.h" + +__complex128 +cacosq (__complex128 x) +{ + __complex128 y; + __complex128 res; + + y = casinq (x); + + __real__ res = M_PI_2q - __real__ y; + __imag__ res = -__imag__ y; + + return res; +} diff --git a/libquadmath/math/casinhq.c b/libquadmath/math/casinhq.c new file mode 100644 index 00000000000..ffa45fa81d9 --- /dev/null +++ b/libquadmath/math/casinhq.c @@ -0,0 +1,78 @@ +/* Return arc hyperbole sine for __float128 value. + Copyright (C) 1997, 1998 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include "quadmath-imp.h" + + +__complex128 +casinhq (__complex128 x) +{ + __complex128 res; + int rcls = fpclassifyq (__real__ x); + int icls = fpclassifyq (__imag__ x); + + if (rcls <= QUADFP_INFINITE || icls <= QUADFP_INFINITE) + { + if (icls == QUADFP_INFINITE) + { + __real__ res = copysignq (HUGE_VALQ, __real__ x); + + if (rcls == QUADFP_NAN) + __imag__ res = nanq (""); + else + __imag__ res = copysignq (rcls >= QUADFP_ZERO ? M_PI_2q : M_PI_4q, + __imag__ x); + } + else if (rcls <= QUADFP_INFINITE) + { + __real__ res = __real__ x; + if ((rcls == QUADFP_INFINITE && icls >= QUADFP_ZERO) + || (rcls == QUADFP_NAN && icls == QUADFP_ZERO)) + __imag__ res = copysignq (0.0, __imag__ x); + else + __imag__ res = nanq (""); + } + else + { + __real__ res = nanq (""); + __imag__ res = nanq (""); + } + } + else if (rcls == QUADFP_ZERO && icls == QUADFP_ZERO) + { + res = x; + } + else + { + __complex128 y; + + __real__ y = (__real__ x - __imag__ x) * (__real__ x + __imag__ x) + 1.0; + __imag__ y = 2.0 * __real__ x * __imag__ x; + + y = csqrtq (y); + + __real__ y += __real__ x; + __imag__ y += __imag__ x; + + res = clogq (y); + } + + return res; +} diff --git a/libquadmath/math/casinq.c b/libquadmath/math/casinq.c new file mode 100644 index 00000000000..122ef5d85ae --- /dev/null +++ b/libquadmath/math/casinq.c @@ -0,0 +1,60 @@ +/* Return arc sine of complex __float128 value. + Copyright (C) 1997 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include "quadmath-imp.h" + + +__complex128 +casinq (__complex128 x) +{ + __complex128 res; + + if (isnanq (__real__ x) || isnanq (__imag__ x)) + { + if (__real__ x == 0.0) + { + res = x; + } + else if (isinfq (__real__ x) || isinfq (__imag__ x)) + { + __real__ res = nanq (""); + __imag__ res = copysignq (HUGE_VALQ, __imag__ x); + } + else + { + __real__ res = nanq (""); + __imag__ res = nanq (""); + } + } + else + { + __complex128 y; + + __real__ y = -__imag__ x; + __imag__ y = __real__ x; + + y = casinhq (y); + + __real__ res = __imag__ y; + __imag__ res = -__real__ y; + } + + return res; +} diff --git a/libquadmath/math/catanhq.c b/libquadmath/math/catanhq.c new file mode 100644 index 00000000000..6a86e2d0202 --- /dev/null +++ b/libquadmath/math/catanhq.c @@ -0,0 +1,76 @@ +/* Return arc hyperbole tangent for __float128 value. + Copyright (C) 1997, 1998 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include "quadmath-imp.h" + + +__complex128 +catanhq (__complex128 x) +{ + __complex128 res; + int rcls = fpclassifyq (__real__ x); + int icls = fpclassifyq (__imag__ x); + + if (rcls <= QUADFP_INFINITE || icls <= QUADFP_INFINITE) + { + if (icls == QUADFP_INFINITE) + { + __real__ res = copysignq (0.0, __real__ x); + __imag__ res = copysignq (M_PI_2q, __imag__ x); + } + else if (rcls == QUADFP_INFINITE || rcls == QUADFP_ZERO) + { + __real__ res = copysignq (0.0, __real__ x); + if (icls >= QUADFP_ZERO) + __imag__ res = copysignq (M_PI_2q, __imag__ x); + else + __imag__ res = nanq (""); + } + else + { + __real__ res = nanq (""); + __imag__ res = nanq (""); + } + } + else if (rcls == QUADFP_ZERO && icls == QUADFP_ZERO) + { + res = x; + } + else + { + __float128 i2, num, den; + + i2 = __imag__ x * __imag__ x; + + num = 1.0 + __real__ x; + num = i2 + num * num; + + den = 1.0 - __real__ x; + den = i2 + den * den; + + __real__ res = 0.25 * (logq (num) - logq (den)); + + den = 1 - __real__ x * __real__ x - i2; + + __imag__ res = 0.5 * atan2q (2.0 * __imag__ x, den); + } + + return res; +} diff --git a/libquadmath/math/catanq.c b/libquadmath/math/catanq.c new file mode 100644 index 00000000000..a9c92579734 --- /dev/null +++ b/libquadmath/math/catanq.c @@ -0,0 +1,81 @@ +/* Return arc tangent of complex __float128 value. + Copyright (C) 1997, 1998 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include "quadmath-imp.h" + + +__complex128 +catanq (__complex128 x) +{ + __complex128 res; + int rcls = fpclassifyq (__real__ x); + int icls = fpclassifyq (__imag__ x); + + if (rcls <= QUADFP_INFINITE || icls <= QUADFP_INFINITE) + { + if (rcls == QUADFP_INFINITE) + { + __real__ res = copysignq (M_PI_2q, __real__ x); + __imag__ res = copysignq (0.0, __imag__ x); + } + else if (icls == QUADFP_INFINITE) + { + if (rcls >= QUADFP_ZERO) + __real__ res = copysignq (M_PI_2q, __real__ x); + else + __real__ res = nanq (""); + __imag__ res = copysignq (0.0, __imag__ x); + } + else if (icls == QUADFP_ZERO || icls == QUADFP_INFINITE) + { + __real__ res = nanq (""); + __imag__ res = copysignq (0.0, __imag__ x); + } + else + { + __real__ res = nanq (""); + __imag__ res = nanq (""); + } + } + else if (rcls == QUADFP_ZERO && icls == QUADFP_ZERO) + { + res = x; + } + else + { + __float128 r2, num, den; + + r2 = __real__ x * __real__ x; + + den = 1 - r2 - __imag__ x * __imag__ x; + + __real__ res = 0.5 * atan2q (2.0 * __real__ x, den); + + num = __imag__ x + 1.0; + num = r2 + num * num; + + den = __imag__ x - 1.0; + den = r2 + den * den; + + __imag__ res = 0.25 * logq (num / den); + } + + return res; +} diff --git a/libquadmath/math/cosq.c b/libquadmath/math/cosq.c index 16955511e04..dc321a27d17 100644 --- a/libquadmath/math/cosq.c +++ b/libquadmath/math/cosq.c @@ -49,7 +49,7 @@ __float128 cosq (__float128 x) { - __float128 y[2],z=0.0L; + __float128 y[2],z=0.0Q; int64_t n, ix; /* High word of x. */ diff --git a/libquadmath/math/hypotq.c b/libquadmath/math/hypotq.c index e4c2d1bc214..2df317f3681 100644 --- a/libquadmath/math/hypotq.c +++ b/libquadmath/math/hypotq.c @@ -116,7 +116,7 @@ hypotq (__float128 x, __float128 y) } if(k!=0) { uint64_t high; - t1 = 1.0L; + t1 = 1.0Q; GET_FLT128_MSW64(high,t1); SET_FLT128_MSW64(t1,high+(k<<48)); return t1*w; -- cgit v1.2.3