From e7d1bedeb5dca6c932ae03e51703e2f78e1a23d3 Mon Sep 17 00:00:00 2001 From: Martynas Venckus Date: Wed, 20 Jul 2011 19:28:34 +0000 Subject: For intermediate computations use single or extended counterparts where appropriate, to avoid precision loss. --- lib/libm/src/s_cacosf.c | 4 ++-- lib/libm/src/s_cacosl.c | 4 ++-- lib/libm/src/s_casinf.c | 4 ++-- lib/libm/src/s_casinl.c | 8 ++++---- lib/libm/src/s_catanl.c | 6 +++--- lib/libm/src/s_ccoshl.c | 6 +++--- lib/libm/src/s_ccosl.c | 6 +++--- lib/libm/src/s_cexpl.c | 7 +++---- lib/libm/src/s_clogl.c | 4 ++-- lib/libm/src/s_cpowl.c | 6 +++--- lib/libm/src/s_csinhl.c | 6 +++--- lib/libm/src/s_csinl.c | 6 +++--- lib/libm/src/s_csqrtl.c | 6 +++--- lib/libm/src/s_ctanf.c | 10 +++++----- lib/libm/src/s_ctanhl.c | 6 +++--- lib/libm/src/s_ctanl.c | 10 +++++----- 16 files changed, 49 insertions(+), 50 deletions(-) (limited to 'lib') diff --git a/lib/libm/src/s_cacosf.c b/lib/libm/src/s_cacosf.c index 5a644c15bd1..885d41142ff 100644 --- a/lib/libm/src/s_cacosf.c +++ b/lib/libm/src/s_cacosf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_cacosf.c,v 1.1 2008/09/07 20:36:09 martynas Exp $ */ +/* $OpenBSD: s_cacosf.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier * @@ -55,6 +55,6 @@ cacosf(float complex z) float complex w; w = casinf( z ); - w = (M_PI_2 - creal (w)) - cimag (w) * I; + w = ((float)M_PI_2 - crealf (w)) - cimagf (w) * I; return (w); } diff --git a/lib/libm/src/s_cacosl.c b/lib/libm/src/s_cacosl.c index 54fd29a5664..9b110337a80 100644 --- a/lib/libm/src/s_cacosl.c +++ b/lib/libm/src/s_cacosl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_cacosl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ +/* $OpenBSD: s_cacosl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier @@ -58,6 +58,6 @@ cacosl(long double complex z) long double complex w; w = casinl(z); - w = (PIO2L - creal(w)) - cimag(w) * I; + w = (PIO2L - creall(w)) - cimagl(w) * I; return (w); } diff --git a/lib/libm/src/s_casinf.c b/lib/libm/src/s_casinf.c index 2a964a73763..39cbb48017e 100644 --- a/lib/libm/src/s_casinf.c +++ b/lib/libm/src/s_casinf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_casinf.c,v 1.2 2010/07/18 18:42:26 guenther Exp $ */ +/* $OpenBSD: s_casinf.c,v 1.3 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier * @@ -67,7 +67,7 @@ casinf(float complex z) if(y == 0.0f) { if(fabsf(x) > 1.0f) { - w = M_PI_2 + 0.0f * I; + w = (float)M_PI_2 + 0.0f * I; /*mtherr( "casinf", DOMAIN );*/ } else { diff --git a/lib/libm/src/s_casinl.c b/lib/libm/src/s_casinl.c index 8b50af7ef2e..abfa9ce68f1 100644 --- a/lib/libm/src/s_casinl.c +++ b/lib/libm/src/s_casinl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_casinl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ +/* $OpenBSD: s_casinl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier @@ -68,8 +68,8 @@ casinl(long double complex z) long double x, y, b; static long double complex ca, ct, zz, z2; - x = creal(z); - y = cimag(z); + x = creall(z); + y = cimagl(z); if (y == 0.0L) { if (fabsl(x) > 1.0L) { @@ -119,7 +119,7 @@ casinl(long double complex z) /* cmul(&ca, &ca, &zz) */ /* x * x - y * y */ zz = (x - y) * (x + y) + (2.0L * x * y) * I; - zz = 1.0L - creal(zz) - cimag(zz) * I; + zz = 1.0L - creall(zz) - cimagl(zz) * I; z2 = csqrtl(zz); zz = ct + z2; diff --git a/lib/libm/src/s_catanl.c b/lib/libm/src/s_catanl.c index 9d3a4985d98..eb12719bfe7 100644 --- a/lib/libm/src/s_catanl.c +++ b/lib/libm/src/s_catanl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_catanl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ +/* $OpenBSD: s_catanl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier @@ -96,8 +96,8 @@ catanl(long double complex z) long double complex w; long double a, t, x, x2, y; - x = creal(z); - y = cimag(z); + x = creall(z); + y = cimagl(z); if ((x == 0.0L) && (y > 1.0L)) goto ovrf; diff --git a/lib/libm/src/s_ccoshl.c b/lib/libm/src/s_ccoshl.c index 58acdbea43b..1928aa9b272 100644 --- a/lib/libm/src/s_ccoshl.c +++ b/lib/libm/src/s_ccoshl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_ccoshl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ +/* $OpenBSD: s_ccoshl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier @@ -52,8 +52,8 @@ ccoshl(long double complex z) long double complex w; long double x, y; - x = creal(z); - y = cimag(z); + x = creall(z); + y = cimagl(z); w = coshl(x) * cosl(y) + (sinhl(x) * sinl(y)) * I; return (w); } diff --git a/lib/libm/src/s_ccosl.c b/lib/libm/src/s_ccosl.c index 02d39a2ea65..74148e27fa1 100644 --- a/lib/libm/src/s_ccosl.c +++ b/lib/libm/src/s_ccosl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_ccosl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ +/* $OpenBSD: s_ccosl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier @@ -76,7 +76,7 @@ ccosl(long double complex z) long double complex w; long double ch, sh; - cchshl(cimag(z), &ch, &sh); - w = cosl(creal(z)) * ch + (-sinl(creal(z)) * sh) * I; + cchshl(cimagl(z), &ch, &sh); + w = cosl(creall(z)) * ch + (-sinl(creall(z)) * sh) * I; return (w); } diff --git a/lib/libm/src/s_cexpl.c b/lib/libm/src/s_cexpl.c index 6fbd347e77d..d1f63769ad7 100644 --- a/lib/libm/src/s_cexpl.c +++ b/lib/libm/src/s_cexpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_cexpl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ +/* $OpenBSD: s_cexpl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier @@ -63,8 +63,7 @@ cexpl(long double complex z) long double complex w; long double r; - r = expl(creal(z)); - w = r * cosl((long double)cimag(z)) + - (r * sinl((long double)cimag(z))) * I; + r = expl(creall(z)); + w = r * cosl(cimagl(z)) + (r * sinl(cimagl(z))) * I; return (w); } diff --git a/lib/libm/src/s_clogl.c b/lib/libm/src/s_clogl.c index 2a70dbb42d7..9b115ca4986 100644 --- a/lib/libm/src/s_clogl.c +++ b/lib/libm/src/s_clogl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_clogl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ +/* $OpenBSD: s_clogl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier @@ -67,7 +67,7 @@ clogl(long double complex z) /*rr = sqrt(z->r * z->r + z->i * z->i);*/ p = cabsl(z); p = logl(p); - rr = atan2l(cimag(z), creal(z)); + rr = atan2l(cimagl(z), creall(z)); w = p + rr * I; return (w); } diff --git a/lib/libm/src/s_cpowl.c b/lib/libm/src/s_cpowl.c index 7707827fe6e..878c0524432 100644 --- a/lib/libm/src/s_cpowl.c +++ b/lib/libm/src/s_cpowl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_cpowl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ +/* $OpenBSD: s_cpowl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier @@ -54,8 +54,8 @@ cpowl(long double complex a, long double complex z) long double complex w; long double x, y, r, theta, absa, arga; - x = creal(z); - y = cimag(z); + x = creall(z); + y = cimagl(z); absa = cabsl(a); if (absa == 0.0L) { return (0.0L + 0.0L * I); diff --git a/lib/libm/src/s_csinhl.c b/lib/libm/src/s_csinhl.c index de5e7938d0b..9f2be1538f8 100644 --- a/lib/libm/src/s_csinhl.c +++ b/lib/libm/src/s_csinhl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_csinhl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ +/* $OpenBSD: s_csinhl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier @@ -51,8 +51,8 @@ csinhl(long double complex z) long double complex w; long double x, y; - x = creal(z); - y = cimag(z); + x = creall(z); + y = cimagl(z); w = sinhl(x) * cosl(y) + (coshl(x) * sinl(y)) * I; return (w); } diff --git a/lib/libm/src/s_csinl.c b/lib/libm/src/s_csinl.c index f9e20134bee..100affa45c2 100644 --- a/lib/libm/src/s_csinl.c +++ b/lib/libm/src/s_csinl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_csinl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ +/* $OpenBSD: s_csinl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier @@ -78,7 +78,7 @@ csinl(long double complex z) long double complex w; long double ch, sh; - cchshl(cimag(z), &ch, &sh); - w = sinl(creal(z)) * ch + (cosl(creal(z)) * sh) * I; + cchshl(cimagl(z), &ch, &sh); + w = sinl(creall(z)) * ch + (cosl(creall(z)) * sh) * I; return (w); } diff --git a/lib/libm/src/s_csqrtl.c b/lib/libm/src/s_csqrtl.c index 86c4f380590..e8a35b28522 100644 --- a/lib/libm/src/s_csqrtl.c +++ b/lib/libm/src/s_csqrtl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_csqrtl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ +/* $OpenBSD: s_csqrtl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier @@ -67,8 +67,8 @@ csqrtl(long double complex z) long double complex w; long double x, y, r, t, scale; - x = creal(z); - y = cimag(z); + x = creall(z); + y = cimagl(z); if (y == 0.0L) { if (x < 0.0L) { diff --git a/lib/libm/src/s_ctanf.c b/lib/libm/src/s_ctanf.c index ca67d602e55..c4eee6a97f3 100644 --- a/lib/libm/src/s_ctanf.c +++ b/lib/libm/src/s_ctanf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_ctanf.c,v 1.1 2008/09/07 20:36:09 martynas Exp $ */ +/* $OpenBSD: s_ctanf.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier * @@ -89,8 +89,8 @@ _ctansf(float complex z) { float f, x, x2, y, y2, rn, t, d; - x = fabsf(2.0f * creal(z)); - y = fabsf(2.0f * cimag(z)); + x = fabsf(2.0f * crealf(z)); + y = fabsf(2.0f * cimagf(z)); x = _redupif(x); @@ -133,7 +133,7 @@ ctanf(float complex z) float complex w; float d; - d = cosf( 2.0f * creal(z) ) + coshf( 2.0f * cimag(z) ); + d = cosf( 2.0f * crealf(z) ) + coshf( 2.0f * cimagf(z) ); if(fabsf(d) < 0.25f) d = _ctansf(z); @@ -143,6 +143,6 @@ ctanf(float complex z) w = MAXNUMF + MAXNUMF * I; return (w); } - w = sinf (2.0f * creal(z)) / d + (sinhf (2.0f * cimag(z)) / d) * I; + w = sinf (2.0f * crealf(z)) / d + (sinhf (2.0f * cimagf(z)) / d) * I; return (w); } diff --git a/lib/libm/src/s_ctanhl.c b/lib/libm/src/s_ctanhl.c index 3826dcb8cd2..c3dd9cfc3a8 100644 --- a/lib/libm/src/s_ctanhl.c +++ b/lib/libm/src/s_ctanhl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_ctanhl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ +/* $OpenBSD: s_ctanhl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier @@ -52,8 +52,8 @@ ctanhl(long double complex z) long double complex w; long double x, y, d; - x = creal(z); - y = cimag(z); + x = creall(z); + y = cimagl(z); d = coshl(2.0L * x) + cosl(2.0L * y); w = sinhl(2.0L * x) / d + (sinl(2.0L * y) / d) * I; return (w); diff --git a/lib/libm/src/s_ctanl.c b/lib/libm/src/s_ctanl.c index 1ca033f6c55..3a984ebdbea 100644 --- a/lib/libm/src/s_ctanl.c +++ b/lib/libm/src/s_ctanl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_ctanl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ +/* $OpenBSD: s_ctanl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */ /* * Copyright (c) 2008 Stephen L. Moshier @@ -95,8 +95,8 @@ ctansl(long double complex z) long double f, x, x2, y, y2, rn, t; long double d; - x = fabsl(2.0L * creal(z)); - y = fabsl(2.0L * cimag(z)); + x = fabsl(2.0L * creall(z)); + y = fabsl(2.0L * cimagl(z)); x = redupil(x); @@ -138,8 +138,8 @@ ctanl(long double complex z) long double complex w; long double d, x, y; - x = creal(z); - y = cimag(z); + x = creall(z); + y = cimagl(z); d = cosl(2.0L * x) + coshl(2.0L * y); if (fabsl(d) < 0.25L) { -- cgit v1.2.3