aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/libm-ieee754
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/libm-ieee754')
-rw-r--r--sysdeps/libm-ieee754/s_ccos.c16
-rw-r--r--sysdeps/libm-ieee754/s_ccosf.c16
-rw-r--r--sysdeps/libm-ieee754/s_ccosh.c14
-rw-r--r--sysdeps/libm-ieee754/s_ccoshf.c16
-rw-r--r--sysdeps/libm-ieee754/s_ccoshl.c14
-rw-r--r--sysdeps/libm-ieee754/s_ccosl.c16
-rw-r--r--sysdeps/libm-ieee754/s_cexpf.c15
-rw-r--r--sysdeps/libm-ieee754/s_cexpl.c15
-rw-r--r--sysdeps/libm-ieee754/s_cproj.c2
-rw-r--r--sysdeps/libm-ieee754/s_cprojf.c2
-rw-r--r--sysdeps/libm-ieee754/s_cprojl.c2
-rw-r--r--sysdeps/libm-ieee754/s_csin.c104
-rw-r--r--sysdeps/libm-ieee754/s_csinf.c104
-rw-r--r--sysdeps/libm-ieee754/s_csinh.c18
-rw-r--r--sysdeps/libm-ieee754/s_csinhf.c18
-rw-r--r--sysdeps/libm-ieee754/s_csinhl.c17
-rw-r--r--sysdeps/libm-ieee754/s_csinl.c104
-rw-r--r--sysdeps/libm-ieee754/s_ctanh.c6
-rw-r--r--sysdeps/libm-ieee754/s_ctanhf.c6
-rw-r--r--sysdeps/libm-ieee754/s_ctanhl.c6
20 files changed, 441 insertions, 70 deletions
diff --git a/sysdeps/libm-ieee754/s_ccos.c b/sysdeps/libm-ieee754/s_ccos.c
index 8a4b55d..f8dfcc8 100644
--- a/sysdeps/libm-ieee754/s_ccos.c
+++ b/sysdeps/libm-ieee754/s_ccos.c
@@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
@@ -33,16 +34,31 @@ __ccos (__complex__ double x)
{
__real__ res = __nan ("");
__imag__ res = 0.0;
+
+#ifdef FE_INVALID
+ if (__isinf (__real__ x))
+ feraiseexcept (FE_INVALID);
+#endif
}
else if (__isinf (__imag__ x))
{
__real__ res = HUGE_VAL;
__imag__ res = __nan ("");
+
+#ifdef FE_INVALID
+ if (__isinf (__real__ x))
+ feraiseexcept (FE_INVALID);
+#endif
}
else
{
__real__ res = __nan ("");
__imag__ res = __nan ("");
+
+#ifdef FE_INVALID
+ if (isfinite (__imag__ x))
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else
diff --git a/sysdeps/libm-ieee754/s_ccosf.c b/sysdeps/libm-ieee754/s_ccosf.c
index 9d1a972..b090ae5 100644
--- a/sysdeps/libm-ieee754/s_ccosf.c
+++ b/sysdeps/libm-ieee754/s_ccosf.c
@@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
@@ -33,16 +34,31 @@ __ccosf (__complex__ float x)
{
__real__ res = __nanf ("");
__imag__ res = 0.0;
+
+#ifdef FE_INVALID
+ if (__isinff (__real__ x))
+ feraiseexcept (FE_INVALID);
+#endif
}
else if (__isinff (__imag__ x))
{
__real__ res = HUGE_VALF;
__imag__ res = __nanf ("");
+
+#ifdef FE_INVALID
+ if (__isinff (__real__ x))
+ feraiseexcept (FE_INVALID);
+#endif
}
else
{
__real__ res = __nanf ("");
__imag__ res = __nanf ("");
+
+#ifdef FE_INVALID
+ if (isfinite (__imag__ x))
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else
diff --git a/sysdeps/libm-ieee754/s_ccosh.c b/sysdeps/libm-ieee754/s_ccosh.c
index fa958f4..1e92f03 100644
--- a/sysdeps/libm-ieee754/s_ccosh.c
+++ b/sysdeps/libm-ieee754/s_ccosh.c
@@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
#include "math_private.h"
@@ -39,18 +40,24 @@ __ccosh (__complex__ double x)
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
+ double sinh_val = __ieee754_sinh (__real__ x);
double cosh_val = __ieee754_cosh (__real__ x);
double sinix, cosix;
__sincos (__imag__ x, &sinix, &cosix);
__real__ retval = cosh_val * cosix;
- __imag__ retval = cosh_val * sinix;
+ __imag__ retval = sinh_val * sinix;
}
else
{
__imag__ retval = __real__ x == 0.0 ? 0.0 : __nan ("");
__real__ retval = __nan ("") + __nan ("");
+
+#ifdef FE_INVALID
+ if (icls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else if (rcls == FP_INFINITE)
@@ -77,6 +84,11 @@ __ccosh (__complex__ double x)
/* The addition raises the invalid exception. */
__real__ retval = HUGE_VAL;
__imag__ retval = __nan ("") + __nan ("");
+
+#ifdef FE_INVALID
+ if (icls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else
diff --git a/sysdeps/libm-ieee754/s_ccoshf.c b/sysdeps/libm-ieee754/s_ccoshf.c
index aeeacba..573a633 100644
--- a/sysdeps/libm-ieee754/s_ccoshf.c
+++ b/sysdeps/libm-ieee754/s_ccoshf.c
@@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
#include "math_private.h"
@@ -39,18 +40,24 @@ __ccoshf (__complex__ float x)
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
+ float sinh_val = __ieee754_sinhf (__real__ x);
float cosh_val = __ieee754_coshf (__real__ x);
float sinix, cosix;
__sincosf (__imag__ x, &sinix, &cosix);
__real__ retval = cosh_val * cosix;
- __imag__ retval = cosh_val * sinix;
+ __imag__ retval = sinh_val * sinix;
}
else
{
__imag__ retval = __real__ x == 0.0 ? 0.0 : __nanf ("");
- __real__ retval = __nanf ("") + __nanf ("");
+ __real__ retval = __nanf ("");
+
+#ifdef FE_INVALID
+ if (icls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else if (rcls == FP_INFINITE)
@@ -77,6 +84,11 @@ __ccoshf (__complex__ float x)
/* The addition raises the invalid exception. */
__real__ retval = HUGE_VALF;
__imag__ retval = __nanf ("") + __nanf ("");
+
+#ifdef FE_INVALID
+ if (icls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else
diff --git a/sysdeps/libm-ieee754/s_ccoshl.c b/sysdeps/libm-ieee754/s_ccoshl.c
index 9937ba1..feb1351 100644
--- a/sysdeps/libm-ieee754/s_ccoshl.c
+++ b/sysdeps/libm-ieee754/s_ccoshl.c
@@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
#include "math_private.h"
@@ -39,18 +40,24 @@ __ccoshl (__complex__ long double x)
if (icls >= FP_ZERO)
{
/* Imaginary part is finite. */
+ long double sinh_val = __ieee754_sinhl (__real__ x);
long double cosh_val = __ieee754_coshl (__real__ x);
long double sinix, cosix;
__sincosl (__imag__ x, &sinix, &cosix);
__real__ retval = cosh_val * cosix;
- __imag__ retval = cosh_val * sinix;
+ __imag__ retval = sinh_val * sinix;
}
else
{
__imag__ retval = __real__ x == 0.0 ? 0.0 : __nanl ("");
__real__ retval = __nanl ("") + __nanl ("");
+
+#ifdef FE_INVALID
+ if (icls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else if (rcls == FP_INFINITE)
@@ -77,6 +84,11 @@ __ccoshl (__complex__ long double x)
/* The addition raises the invalid exception. */
__real__ retval = HUGE_VALL;
__imag__ retval = __nanl ("") + __nanl ("");
+
+#ifdef FE_INVALID
+ if (icls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else
diff --git a/sysdeps/libm-ieee754/s_ccosl.c b/sysdeps/libm-ieee754/s_ccosl.c
index a41d48b..fdcc7a6 100644
--- a/sysdeps/libm-ieee754/s_ccosl.c
+++ b/sysdeps/libm-ieee754/s_ccosl.c
@@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
@@ -33,16 +34,31 @@ __ccosl (__complex__ long double x)
{
__real__ res = __nanl ("");
__imag__ res = 0.0;
+
+#ifdef FE_INVALID
+ if (__isinfl (__real__ x))
+ feraiseexcept (FE_INVALID);
+#endif
}
else if (__isinfl (__imag__ x))
{
__real__ res = HUGE_VALL;
__imag__ res = __nanl ("");
+
+#ifdef FE_INVALID
+ if (__isinfl (__real__ x))
+ feraiseexcept (FE_INVALID);
+#endif
}
else
{
__real__ res = __nanl ("");
__imag__ res = __nanl ("");
+
+#ifdef FE_INVALID
+ if (isfinite (__imag__ x))
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else
diff --git a/sysdeps/libm-ieee754/s_cexpf.c b/sysdeps/libm-ieee754/s_cexpf.c
index 99f33dc..603e78d 100644
--- a/sysdeps/libm-ieee754/s_cexpf.c
+++ b/sysdeps/libm-ieee754/s_cexpf.c
@@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
#include "math_private.h"
@@ -59,6 +60,10 @@ __cexpf (__complex__ float x)
is not +-inf the result is NaN + iNaN. */
__real__ retval = __nanf ("");
__imag__ retval = __nanf ("");
+
+#ifdef FE_INVALID
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else if (rcls == FP_INFINITE)
@@ -89,6 +94,11 @@ __cexpf (__complex__ float x)
{
__real__ retval = HUGE_VALF;
__imag__ retval = __nanf ("");
+
+#ifdef FE_INVALID
+ if (icls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
}
else
{
@@ -101,6 +111,11 @@ __cexpf (__complex__ float x)
/* If the real part is NaN the result is NaN + iNaN. */
__real__ retval = __nanf ("");
__imag__ retval = __nanf ("");
+
+#ifdef FE_INVALID
+ if (rcls != FP_NAN || icls != FP_NAN)
+ feraiseexcept (FE_INVALID);
+#endif
}
return retval;
diff --git a/sysdeps/libm-ieee754/s_cexpl.c b/sysdeps/libm-ieee754/s_cexpl.c
index 1b97dba..67fa7a0 100644
--- a/sysdeps/libm-ieee754/s_cexpl.c
+++ b/sysdeps/libm-ieee754/s_cexpl.c
@@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
#include "math_private.h"
@@ -59,6 +60,10 @@ __cexpl (__complex__ long double x)
is not +-inf the result is NaN + iNaN. */
__real__ retval = __nanl ("");
__imag__ retval = __nanl ("");
+
+#ifdef FE_INVALID
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else if (rcls == FP_INFINITE)
@@ -89,6 +94,11 @@ __cexpl (__complex__ long double x)
{
__real__ retval = HUGE_VALL;
__imag__ retval = __nanl ("");
+
+#ifdef FE_INVALID
+ if (icls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
}
else
{
@@ -101,6 +111,11 @@ __cexpl (__complex__ long double x)
/* If the real part is NaN the result is NaN + iNaN. */
__real__ retval = __nanl ("");
__imag__ retval = __nanl ("");
+
+#ifdef FE_INVALID
+ if (rcls != FP_NAN || icls != FP_NAN)
+ feraiseexcept (FE_INVALID);
+#endif
}
return retval;
diff --git a/sysdeps/libm-ieee754/s_cproj.c b/sysdeps/libm-ieee754/s_cproj.c
index 8ad27c0..fb50bb5 100644
--- a/sysdeps/libm-ieee754/s_cproj.c
+++ b/sysdeps/libm-ieee754/s_cproj.c
@@ -27,7 +27,7 @@ __cproj (__complex__ double x)
{
__complex__ double res;
- if (!finite (__real__ x) || !finite (__imag__ x))
+ if (!isfinite (__real__ x) || !isfinite (__imag__ x))
{
__real__ res = INFINITY;
__imag__ res = __copysign (0.0, __imag__ x);
diff --git a/sysdeps/libm-ieee754/s_cprojf.c b/sysdeps/libm-ieee754/s_cprojf.c
index 8ee61c7..b905908 100644
--- a/sysdeps/libm-ieee754/s_cprojf.c
+++ b/sysdeps/libm-ieee754/s_cprojf.c
@@ -27,7 +27,7 @@ __cprojf (__complex__ float x)
{
__complex__ float res;
- if (!finite (__real__ x) || !finite (__imag__ x))
+ if (!isfinite (__real__ x) || !isfinite (__imag__ x))
{
__real__ res = INFINITY;
__imag__ res = __copysignf (0.0, __imag__ x);
diff --git a/sysdeps/libm-ieee754/s_cprojl.c b/sysdeps/libm-ieee754/s_cprojl.c
index 34298e1..13da4b4 100644
--- a/sysdeps/libm-ieee754/s_cprojl.c
+++ b/sysdeps/libm-ieee754/s_cprojl.c
@@ -27,7 +27,7 @@ __cprojl (__complex__ long double x)
{
__complex__ long double res;
- if (!finite (__real__ x) || !finite (__imag__ x))
+ if (!isfinite (__real__ x) || !isfinite (__imag__ x))
{
__real__ res = INFINITY;
__imag__ res = __copysignl (0.0, __imag__ x);
diff --git a/sysdeps/libm-ieee754/s_csin.c b/sysdeps/libm-ieee754/s_csin.c
index 4639bca..6627387 100644
--- a/sysdeps/libm-ieee754/s_csin.c
+++ b/sysdeps/libm-ieee754/s_csin.c
@@ -19,46 +19,110 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
+#include "math_private.h"
+
__complex__ double
__csin (__complex__ double x)
{
- __complex__ double res;
+ __complex__ double retval;
+ int negate = signbit (__real__ x);
+ int rcls = fpclassify (__real__ x);
+ int icls = fpclassify (__imag__ x);
+
+ __real__ x = fabs (__real__ x);
- if (!isfinite (__real__ x) || isnan (__imag__ x))
+ if (icls >= FP_ZERO)
{
- if (__real__ x == 0.0 || __imag__ x == 0.0)
- {
- __real__ res = __nan ("");
- __imag__ res = 0.0;
- }
- else if (__isinf (__imag__ x))
+ /* Imaginary part is finite. */
+ if (rcls >= FP_ZERO)
{
- __real__ res = __nan ("");
- __imag__ res = __imag__ x;
+ /* Real part is finite. */
+ double sinh_val = __ieee754_sinh (__imag__ x);
+ double cosh_val = __ieee754_cosh (__imag__ x);
+ double sinix, cosix;
+
+ __sincos (__real__ x, &sinix, &cosix);
+
+ __real__ retval = cosh_val * sinix;
+ __imag__ retval = sinh_val * cosix;
+
+ if (negate)
+ __real__ retval = -__real__ retval;
}
else
{
- __real__ res = __nan ("");
- __imag__ res = __nan ("");
+ if (icls == FP_ZERO)
+ {
+ /* Imaginary part is 0.0. */
+ __real__ retval = __nan ("");
+ __imag__ retval = __imag__ x;
+
+#ifdef FE_INVALID
+ if (rcls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
+ }
+ else
+ {
+ __real__ retval = __nan ("");
+ __imag__ retval = __nan ("");
+
+#ifdef FE_INVALID
+ feraiseexcept (FE_INVALID);
+#endif
+ }
}
}
- else
+ else if (icls == FP_INFINITE)
{
- __complex__ double y;
+ /* Imaginary part is infinite. */
+ if (rcls == FP_ZERO)
+ {
+ /* Real part is 0.0. */
+ __real__ retval = __copysign (0.0, negate ? -1.0 : 1.0);
+ __imag__ retval = __imag__ x;
+ }
+ else if (rcls > FP_ZERO)
+ {
+ /* Real part is finite. */
+ double sinix, cosix;
+
+ __sincos (__real__ x, &sinix, &cosix);
- __real__ y = -__imag__ x;
- __imag__ y = __real__ x;
+ __real__ retval = __copysign (HUGE_VAL, sinix);
+ __imag__ retval = __copysign (HUGE_VAL, cosix);
- y = __csinh (y);
+ if (negate)
+ __real__ retval = -__real__ retval;
+ if (signbit (__imag__ x))
+ __imag__ retval = -__imag__ retval;
+ }
+ else
+ {
+ /* The addition raises the invalid exception. */
+ __real__ retval = __nan ("");
+ __imag__ retval = HUGE_VAL;
- __real__ res = __imag__ y;
- __imag__ res = -__real__ y;
+#ifdef FE_INVALID
+ if (rcls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
+ }
+ }
+ else
+ {
+ if (rcls == FP_ZERO)
+ __real__ retval = __copysign (0.0, negate ? -1.0 : 1.0);
+ else
+ __real__ retval = __nan ("");
+ __imag__ retval = __nan ("");
}
- return res;
+ return retval;
}
weak_alias (__csin, csin)
#ifdef NO_LONG_DOUBLE
diff --git a/sysdeps/libm-ieee754/s_csinf.c b/sysdeps/libm-ieee754/s_csinf.c
index f7f10e6..31d2f1f 100644
--- a/sysdeps/libm-ieee754/s_csinf.c
+++ b/sysdeps/libm-ieee754/s_csinf.c
@@ -19,45 +19,109 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
+#include "math_private.h"
+
__complex__ float
__csinf (__complex__ float x)
{
- __complex__ float res;
+ __complex__ float retval;
+ int negate = signbit (__real__ x);
+ int rcls = fpclassify (__real__ x);
+ int icls = fpclassify (__imag__ x);
+
+ __real__ x = fabsf (__real__ x);
- if (!isfinite (__real__ x) || isnan (__imag__ x))
+ if (icls >= FP_ZERO)
{
- if (__real__ x == 0.0 || __imag__ x == 0.0)
- {
- __real__ res = __nanf ("");
- __imag__ res = 0.0;
- }
- else if (__isinff (__imag__ x))
+ /* Imaginary part is finite. */
+ if (rcls >= FP_ZERO)
{
- __real__ res = __nanf ("");
- __imag__ res = __imag__ x;
+ /* Real part is finite. */
+ float sinh_val = __ieee754_sinhf (__imag__ x);
+ float cosh_val = __ieee754_coshf (__imag__ x);
+ float sinix, cosix;
+
+ __sincosf (__real__ x, &sinix, &cosix);
+
+ __real__ retval = cosh_val * sinix;
+ __imag__ retval = sinh_val * cosix;
+
+ if (negate)
+ __real__ retval = -__real__ retval;
}
else
{
- __real__ res = __nanf ("");
- __imag__ res = __nanf ("");
+ if (icls == FP_ZERO)
+ {
+ /* Imaginary part is 0.0. */
+ __real__ retval = __nanf ("");
+ __imag__ retval = __imag__ x;
+
+#ifdef FE_INVALID
+ if (rcls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
+ }
+ else
+ {
+ __real__ retval = __nanf ("");
+ __imag__ retval = __nanf ("");
+
+#ifdef FE_INVALID
+ feraiseexcept (FE_INVALID);
+#endif
+ }
}
}
- else
+ else if (icls == FP_INFINITE)
{
- __complex__ float y;
+ /* Imaginary part is infinite. */
+ if (rcls == FP_ZERO)
+ {
+ /* Real part is 0.0. */
+ __real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0);
+ __imag__ retval = __imag__ x;
+ }
+ else if (rcls > FP_ZERO)
+ {
+ /* Real part is finite. */
+ float sinix, cosix;
+
+ __sincosf (__real__ x, &sinix, &cosix);
- __real__ y = -__imag__ x;
- __imag__ y = __real__ x;
+ __real__ retval = __copysignf (HUGE_VALF, sinix);
+ __imag__ retval = __copysignf (HUGE_VALF, cosix);
- y = __csinhf (y);
+ if (negate)
+ __real__ retval = -__real__ retval;
+ if (signbit (__imag__ x))
+ __imag__ retval = -__imag__ retval;
+ }
+ else
+ {
+ /* The addition raises the invalid exception. */
+ __real__ retval = __nanf ("");
+ __imag__ retval = HUGE_VALF;
- __real__ res = __imag__ y;
- __imag__ res = -__real__ y;
+#ifdef FE_INVALID
+ if (rcls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
+ }
+ }
+ else
+ {
+ if (rcls == FP_ZERO)
+ __real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0);
+ else
+ __real__ retval = __nanf ("");
+ __imag__ retval = __nanf ("");
}
- return res;
+ return retval;
}
weak_alias (__csinf, csinf)
diff --git a/sysdeps/libm-ieee754/s_csinh.c b/sysdeps/libm-ieee754/s_csinh.c
index 98f06a5..29a271f 100644
--- a/sysdeps/libm-ieee754/s_csinh.c
+++ b/sysdeps/libm-ieee754/s_csinh.c
@@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
#include "math_private.h"
@@ -41,12 +42,13 @@ __csinh (__complex__ double x)
{
/* Imaginary part is finite. */
double sinh_val = __ieee754_sinh (__real__ x);
+ double cosh_val = __ieee754_cosh (__real__ x);
double sinix, cosix;
__sincos (__imag__ x, &sinix, &cosix);
__real__ retval = sinh_val * cosix;
- __imag__ retval = sinh_val * sinix;
+ __imag__ retval = cosh_val * sinix;
if (negate)
__real__ retval = -__real__ retval;
@@ -58,11 +60,20 @@ __csinh (__complex__ double x)
/* Real part is 0.0. */
__real__ retval = __copysign (0.0, negate ? -1.0 : 1.0);
__imag__ retval = __nan ("") + __nan ("");
+
+#ifdef FE_INVALID
+ if (icls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
}
else
{
__real__ retval = __nan ("");
__imag__ retval = __nan ("");
+
+#ifdef FE_INVALID
+ feraiseexcept (FE_INVALID);
+#endif
}
}
}
@@ -93,6 +104,11 @@ __csinh (__complex__ double x)
/* The addition raises the invalid exception. */
__real__ retval = HUGE_VAL;
__imag__ retval = __nan ("") + __nan ("");
+
+#ifdef FE_INVALID
+ if (icls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else
diff --git a/sysdeps/libm-ieee754/s_csinhf.c b/sysdeps/libm-ieee754/s_csinhf.c
index c644d3a..9c479bb 100644
--- a/sysdeps/libm-ieee754/s_csinhf.c
+++ b/sysdeps/libm-ieee754/s_csinhf.c
@@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
#include "math_private.h"
@@ -41,12 +42,13 @@ __csinhf (__complex__ float x)
{
/* Imaginary part is finite. */
float sinh_val = __ieee754_sinhf (__real__ x);
+ float cosh_val = __ieee754_coshf (__real__ x);
float sinix, cosix;
__sincosf (__imag__ x, &sinix, &cosix);
__real__ retval = sinh_val * cosix;
- __imag__ retval = sinh_val * sinix;
+ __imag__ retval = cosh_val * sinix;
if (negate)
__real__ retval = -__real__ retval;
@@ -58,11 +60,20 @@ __csinhf (__complex__ float x)
/* Real part is 0.0. */
__real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0);
__imag__ retval = __nanf ("") + __nanf ("");
+
+#ifdef FE_INVALID
+ if (icls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
}
else
{
__real__ retval = __nanf ("");
__imag__ retval = __nanf ("");
+
+#ifdef FE_INVALID
+ feraiseexcept (FE_INVALID);
+#endif
}
}
}
@@ -93,6 +104,11 @@ __csinhf (__complex__ float x)
/* The addition raises the invalid exception. */
__real__ retval = HUGE_VALF;
__imag__ retval = __nanf ("") + __nanf ("");
+
+#ifdef FE_INVALID
+ if (icls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else
diff --git a/sysdeps/libm-ieee754/s_csinhl.c b/sysdeps/libm-ieee754/s_csinhl.c
index 4bb9e63..694b39d 100644
--- a/sysdeps/libm-ieee754/s_csinhl.c
+++ b/sysdeps/libm-ieee754/s_csinhl.c
@@ -41,12 +41,13 @@ __csinhl (__complex__ long double x)
{
/* Imaginary part is finite. */
long double sinh_val = __ieee754_sinhl (__real__ x);
+ long double cosh_val = __ieee754_coshl (__real__ x);
long double sinix, cosix;
__sincosl (__imag__ x, &sinix, &cosix);
__real__ retval = sinh_val * cosix;
- __imag__ retval = sinh_val * sinix;
+ __imag__ retval = cosh_val * sinix;
if (negate)
__real__ retval = -__real__ retval;
@@ -58,11 +59,20 @@ __csinhl (__complex__ long double x)
/* Real part is 0.0. */
__real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0);
__imag__ retval = __nanl ("") + __nanl ("");
+
+#ifdef FE_INVALID
+ if (icls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
}
else
{
__real__ retval = __nanl ("");
__imag__ retval = __nanl ("");
+
+#ifdef FE_INVALID
+ feraiseexcept (FE_INVALID);
+#endif
}
}
}
@@ -93,6 +103,11 @@ __csinhl (__complex__ long double x)
/* The addition raises the invalid exception. */
__real__ retval = HUGE_VALL;
__imag__ retval = __nanl ("") + __nanl ("");
+
+#ifdef FE_INVALID
+ if (icls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else
diff --git a/sysdeps/libm-ieee754/s_csinl.c b/sysdeps/libm-ieee754/s_csinl.c
index 513c144..bae8648 100644
--- a/sysdeps/libm-ieee754/s_csinl.c
+++ b/sysdeps/libm-ieee754/s_csinl.c
@@ -19,45 +19,109 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
+#include "math_private.h"
+
__complex__ long double
__csinl (__complex__ long double x)
{
- __complex__ long double res;
+ __complex__ long double retval;
+ int negate = signbit (__real__ x);
+ int rcls = fpclassify (__real__ x);
+ int icls = fpclassify (__imag__ x);
+
+ __real__ x = fabsl (__real__ x);
- if (!isfinite (__real__ x) || isnan (__imag__ x))
+ if (icls >= FP_ZERO)
{
- if (__real__ x == 0.0 || __imag__ x == 0.0)
- {
- __real__ res = __nanl ("");
- __imag__ res = 0.0;
- }
- else if (__isinfl (__imag__ x))
+ /* Imaginary part is finite. */
+ if (rcls >= FP_ZERO)
{
- __real__ res = __nanl ("");
- __imag__ res = __imag__ x;
+ /* Real part is finite. */
+ long double sinh_val = __ieee754_sinhl (__imag__ x);
+ long double cosh_val = __ieee754_coshl (__imag__ x);
+ long double sinix, cosix;
+
+ __sincosl (__real__ x, &sinix, &cosix);
+
+ __real__ retval = cosh_val * sinix;
+ __imag__ retval = sinh_val * cosix;
+
+ if (negate)
+ __real__ retval = -__real__ retval;
}
else
{
- __real__ res = __nanl ("");
- __imag__ res = __nanl ("");
+ if (icls == FP_ZERO)
+ {
+ /* Imaginary part is 0.0. */
+ __real__ retval = __nanl ("");
+ __imag__ retval = __imag__ x;
+
+#ifdef FE_INVALID
+ if (rcls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
+ }
+ else
+ {
+ __real__ retval = __nanl ("");
+ __imag__ retval = __nanl ("");
+
+#ifdef FE_INVALID
+ feraiseexcept (FE_INVALID);
+#endif
+ }
}
}
- else
+ else if (icls == FP_INFINITE)
{
- __complex__ long double y;
+ /* Imaginary part is infinite. */
+ if (rcls == FP_ZERO)
+ {
+ /* Real part is 0.0. */
+ __real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0);
+ __imag__ retval = __imag__ x;
+ }
+ else if (rcls > FP_ZERO)
+ {
+ /* Real part is finite. */
+ long double sinix, cosix;
+
+ __sincosl (__real__ x, &sinix, &cosix);
- __real__ y = -__imag__ x;
- __imag__ y = __real__ x;
+ __real__ retval = __copysignl (HUGE_VALL, sinix);
+ __imag__ retval = __copysignl (HUGE_VALL, cosix);
- y = __csinhl (y);
+ if (negate)
+ __real__ retval = -__real__ retval;
+ if (signbit (__imag__ x))
+ __imag__ retval = -__imag__ retval;
+ }
+ else
+ {
+ /* The addition raises the invalid exception. */
+ __real__ retval = __nanl ("");
+ __imag__ retval = HUGE_VALL;
- __real__ res = __imag__ y;
- __imag__ res = -__real__ y;
+#ifdef FE_INVALID
+ if (rcls == FP_INFINITE)
+ feraiseexcept (FE_INVALID);
+#endif
+ }
+ }
+ else
+ {
+ if (rcls == FP_ZERO)
+ __real__ retval = __copysignl (0.0, negate ? -1.0 : 1.0);
+ else
+ __real__ retval = __nanl ("");
+ __imag__ retval = __nanl ("");
}
- return res;
+ return retval;
}
weak_alias (__csinl, csinl)
diff --git a/sysdeps/libm-ieee754/s_ctanh.c b/sysdeps/libm-ieee754/s_ctanh.c
index eb6ff84..d8825f3 100644
--- a/sysdeps/libm-ieee754/s_ctanh.c
+++ b/sysdeps/libm-ieee754/s_ctanh.c
@@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
#include "math_private.h"
@@ -44,6 +45,11 @@ __ctanh (__complex__ double x)
{
__real__ res = __nan ("");
__imag__ res = __nan ("");
+
+#ifdef FE_INVALID
+ if (__isinf (__imag__ x))
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else
diff --git a/sysdeps/libm-ieee754/s_ctanhf.c b/sysdeps/libm-ieee754/s_ctanhf.c
index aec02fe..fd66648 100644
--- a/sysdeps/libm-ieee754/s_ctanhf.c
+++ b/sysdeps/libm-ieee754/s_ctanhf.c
@@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
#include "math_private.h"
@@ -44,6 +45,11 @@ __ctanhf (__complex__ float x)
{
__real__ res = __nanf ("");
__imag__ res = __nanf ("");
+
+#ifdef FE_INVALID
+ if (__isinff (__imag__ x))
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else
diff --git a/sysdeps/libm-ieee754/s_ctanhl.c b/sysdeps/libm-ieee754/s_ctanhl.c
index 8ed131e..5ec06a6 100644
--- a/sysdeps/libm-ieee754/s_ctanhl.c
+++ b/sysdeps/libm-ieee754/s_ctanhl.c
@@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */
#include <complex.h>
+#include <fenv.h>
#include <math.h>
#include "math_private.h"
@@ -44,6 +45,11 @@ __ctanhl (__complex__ long double x)
{
__real__ res = __nanl ("");
__imag__ res = __nanl ("");
+
+#ifdef FE_INVALID
+ if (__isinfl (__imag__ x))
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else