diff options
Diffstat (limited to 'src/complex')
-rw-r--r-- | src/complex/cacosf.c | 4 | ||||
-rw-r--r-- | src/complex/cacosh.c | 2 | ||||
-rw-r--r-- | src/complex/catanf.c | 18 | ||||
-rw-r--r-- | src/complex/catanl.c | 14 | ||||
-rw-r--r-- | src/complex/cproj.c | 2 | ||||
-rw-r--r-- | src/complex/cprojf.c | 2 | ||||
-rw-r--r-- | src/complex/cprojl.c | 2 |
7 files changed, 12 insertions, 32 deletions
diff --git a/src/complex/cacosf.c b/src/complex/cacosf.c index 2e048540..ed8acf0f 100644 --- a/src/complex/cacosf.c +++ b/src/complex/cacosf.c @@ -2,8 +2,10 @@ // FIXME +static const float float_pi_2 = M_PI_2; + float complex cacosf(float complex z) { z = casinf(z); - return CMPLXF((float)M_PI_2 - crealf(z), -cimagf(z)); + return CMPLXF(float_pi_2 - crealf(z), -cimagf(z)); } diff --git a/src/complex/cacosh.c b/src/complex/cacosh.c index 76127f75..55b857ce 100644 --- a/src/complex/cacosh.c +++ b/src/complex/cacosh.c @@ -1,6 +1,6 @@ #include "complex_impl.h" -/* acosh(z) = i acos(z) */ +/* acosh(z) = ±i acos(z) */ double complex cacosh(double complex z) { diff --git a/src/complex/catanf.c b/src/complex/catanf.c index e10d9c09..1d569f2d 100644 --- a/src/complex/catanf.c +++ b/src/complex/catanf.c @@ -61,13 +61,15 @@ static const double DP1 = 3.140625; static const double DP2 = 9.67502593994140625E-4; static const double DP3 = 1.509957990978376432E-7; +static const float float_pi = M_PI; + static float _redupif(float xx) { float x, t; long i; x = xx; - t = x/(float)M_PI; + t = x/float_pi; if (t >= 0.0f) t += 0.5f; else @@ -87,29 +89,17 @@ float complex catanf(float complex z) x = crealf(z); y = cimagf(z); - if ((x == 0.0f) && (y > 1.0f)) - goto ovrf; - x2 = x * x; a = 1.0f - x2 - (y * y); - if (a == 0.0f) - goto ovrf; t = 0.5f * atan2f(2.0f * x, a); w = _redupif(t); t = y - 1.0f; a = x2 + (t * t); - if (a == 0.0f) - goto ovrf; t = y + 1.0f; a = (x2 + (t * t))/a; - w = w + (0.25f * logf (a)) * I; - return w; - -ovrf: - // FIXME - w = MAXNUMF + MAXNUMF * I; + w = CMPLXF(w, 0.25f * logf(a)); return w; } diff --git a/src/complex/catanl.c b/src/complex/catanl.c index a9fc02db..e62526c0 100644 --- a/src/complex/catanl.c +++ b/src/complex/catanl.c @@ -97,30 +97,18 @@ long double complex catanl(long double complex z) x = creall(z); y = cimagl(z); - if ((x == 0.0L) && (y > 1.0L)) - goto ovrf; - x2 = x * x; a = 1.0L - x2 - (y * y); - if (a == 0.0L) - goto ovrf; t = atan2l(2.0L * x, a) * 0.5L; w = redupil(t); t = y - 1.0L; a = x2 + (t * t); - if (a == 0.0L) - goto ovrf; t = y + 1.0L; a = (x2 + (t * t)) / a; - w = w + (0.25L * logl(a)) * I; - return w; - -ovrf: - // FIXME - w = LDBL_MAX + LDBL_MAX * I; + w = CMPLXF(w, 0.25L * logl(a)); return w; } #endif diff --git a/src/complex/cproj.c b/src/complex/cproj.c index 9ae1e17c..d2b8f5a9 100644 --- a/src/complex/cproj.c +++ b/src/complex/cproj.c @@ -3,6 +3,6 @@ double complex cproj(double complex z) { if (isinf(creal(z)) || isinf(cimag(z))) - return CMPLX(INFINITY, copysign(0.0, creal(z))); + return CMPLX(INFINITY, copysign(0.0, cimag(z))); return z; } diff --git a/src/complex/cprojf.c b/src/complex/cprojf.c index 03fab339..15a874bb 100644 --- a/src/complex/cprojf.c +++ b/src/complex/cprojf.c @@ -3,6 +3,6 @@ float complex cprojf(float complex z) { if (isinf(crealf(z)) || isinf(cimagf(z))) - return CMPLXF(INFINITY, copysignf(0.0, crealf(z))); + return CMPLXF(INFINITY, copysignf(0.0, cimagf(z))); return z; } diff --git a/src/complex/cprojl.c b/src/complex/cprojl.c index 38a494c5..531ffa1c 100644 --- a/src/complex/cprojl.c +++ b/src/complex/cprojl.c @@ -9,7 +9,7 @@ long double complex cprojl(long double complex z) long double complex cprojl(long double complex z) { if (isinf(creall(z)) || isinf(cimagl(z))) - return CMPLXL(INFINITY, copysignl(0.0, creall(z))); + return CMPLXL(INFINITY, copysignl(0.0, cimagl(z))); return z; } #endif |