diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2013-07-03 04:48:19 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2013-07-03 04:48:19 +0000 |
commit | c9e58393a92e1d719ef8c53e55b489cd596ae915 (patch) | |
tree | b5e63aeb3dc48e665be3bc1789e588c18102adc4 /lib | |
parent | 4ec383e4e0ff014be7f68c1d058de506cbcd01fa (diff) |
with DBL vs LDBL fixed, tedu some source in noieee which is actually the
same as code in generic src.
introduce PURE_SRCS for completely MI math code.
okau martynas@
Diffstat (limited to 'lib')
30 files changed, 25 insertions, 1777 deletions
diff --git a/lib/libm/Makefile b/lib/libm/Makefile index 46220d0743e..63f9905c29e 100644 --- a/lib/libm/Makefile +++ b/lib/libm/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.101 2012/09/15 13:15:22 miod Exp $ +# $OpenBSD: Makefile,v 1.102 2013/07/03 04:48:16 espie Exp $ # $NetBSD: Makefile,v 1.28 1995/11/20 22:06:19 jtc Exp $ # # @(#)Makefile 5.1beta 93/09/24 @@ -103,18 +103,18 @@ COMMON_SRCS = b_exp__D.c b_log__D.c b_tgamma.c \ k_cos.c k_cosf.c k_rem_pio2.c k_rem_pio2f.c k_sin.c k_sinf.c \ k_tan.c k_tanf.c \ s_lround.c s_lroundf.c s_llround.c s_llroundf.c \ - s_asinh.c s_asinhf.c s_atan.c s_atanf.c s_cabs.c s_cabsf.c s_cacos.c \ - s_cacosf.c s_cacosh.c s_cacoshf.c s_carg.c s_cargf.c s_casin.c \ - s_casinf.c s_casinh.c s_casinhf.c s_catan.c s_catanf.c s_catanh.c \ - s_catanhf.c s_cbrt.c s_cbrtf.c s_conj.c s_conjf.c s_ccos.c s_ccosf.c \ - s_ccosh.c s_ccoshf.c s_ceil.c \ - s_ceilf.c s_cexp.c s_cexpf.c s_cimag.c s_cimagf.c s_clog.c s_clogf.c \ - s_copysign.c s_copysignf.c s_cos.c s_cosf.c s_cpow.c s_cpowf.c \ - s_cproj.c s_cprojf.c s_creal.c s_crealf.c s_csin.c s_csinf.c s_csinh.c \ - s_csinhf.c s_csqrt.c s_csqrtf.c s_ctan.c s_ctanf.c s_ctanh.c \ + s_asinh.c s_asinhf.c s_atan.c s_atanf.c s_cabsf.c \ + s_cacosf.c s_cacoshf.c s_cargf.c \ + s_casinf.c s_casinhf.c s_catanf.c \ + s_catanhf.c s_cbrt.c s_cbrtf.c s_ccosf.c \ + s_ccoshf.c s_ceil.c \ + s_ceilf.c s_cexpf.c s_clogf.c \ + s_copysign.c s_copysignf.c s_cos.c s_cosf.c s_cpowf.c \ + s_cproj.c s_cprojf.c s_csinf.c \ + s_csinhf.c s_csqrtf.c s_ctanf.c \ s_ctanhf.c s_erf.c s_erff.c s_exp2.c s_exp2f.c s_expm1.c s_expm1f.c \ - s_fabsf.c s_fdim.c s_fma.c s_fmaf.c s_fmax.c s_fmaxf.c s_fmin.c \ - s_fminf.c s_floor.c s_floorf.c s_frexpf.c s_ilogb.c s_ilogbf.c \ + s_fabsf.c s_fma.c s_fmaf.c \ + s_floor.c s_floorf.c s_frexpf.c s_ilogb.c s_ilogbf.c \ s_log1p.c \ s_log1pf.c s_logb.c s_logbf.c s_llrint.c s_llrintf.c s_lrint.c \ s_lrintf.c s_modff.c s_nan.c s_nearbyint.c s_nextafter.c \ @@ -144,22 +144,26 @@ LONG_SRCS = e_acoshl.c e_acosl.c e_asinl.c e_atan2l.c e_atanhl.c \ # math routines for non-IEEE architectures. NOIEEE_SRCS = n_acosh.c n_argred.c n_asincos.c n_asinh.c n_atan.c \ - n_atan2.c n_atanh.c n_cabs.c n_cacos.c n_cacosh.c n_carg.c \ - n_casin.c n_casinh.c n_catan.c n_catanh.c n_cbrt.c n_ccos.c \ - n_ccosh.c n_cexp.c n_cimag.c n_cimagf.c n_clog.c n_conj.c \ - n_conjf.c n_cosh.c n_cpow.c n_cproj.c n_cprojf.c n_creal.c \ - n_crealf.c n_csin.c n_csinh.c n_csqrt.c n_ctan.c n_ctanh.c \ - n_erf.c n_exp.c n_exp__E.c n_expm1.c n_fdim.c n_floor.c \ - n_fmax.c n_fmaxf.c n_fmin.c n_fminf.c n_fmod.c n_hypot.c \ + n_atan2.c n_atanh.c n_cbrt.c \ + n_cosh.c n_cproj.c n_cprojf.c \ + n_erf.c n_exp.c n_exp__E.c n_expm1.c n_floor.c \ + n_fmod.c n_hypot.c \ n_infnan.c n_j0.c n_j1.c n_jn.c n_lgamma.c n_log.c n_log10.c \ n_log1p.c n_log__L.c n_nan.c n_pow.c n_round.c n_scalbln.c \ n_sincos.c n_sinh.c n_sqrt.c n_support.c n_tan.c n_tanh.c \ n_tgamma.c +# math routines that are completely MI +PURE_SRCS = s_cabs.c s_cacos.c s_cacosh.c s_carg.c s_casin.c \ + s_casinh.c s_catan.c s_catanh.c s_ccos.c s_ccosh.c s_cexp.c \ + s_cimag.c s_cimagf.c s_clog.c s_conj.c s_conjf.c s_cpow.c \ + s_creal.c s_crealf.c s_csin.c s_csinh.c s_csqrt.c s_ctan.c \ + s_ctanh.c s_fdim.c s_fmax.c s_fmaxf.c s_fmin.c s_fminf.c + .if (${MACHINE_ARCH} == "vax") -SRCS= ${NOIEEE_SRCS} ${NOIEEE_ARCH} +SRCS= ${NOIEEE_SRCS} ${NOIEEE_ARCH} ${PURE_SRCS} .else -SRCS= ${COMMON_SRCS} +SRCS= ${COMMON_SRCS} ${PURE_SRCS} .if (${MACHINE_ARCH} == "amd64") || (${MACHINE_ARCH} == "i386") || \ (${MACHINE_ARCH} == "m68k") .PATH: ${.CURDIR}/src/ld80 diff --git a/lib/libm/noieee_src/n_cabs.c b/lib/libm/noieee_src/n_cabs.c deleted file mode 100644 index c07c1891945..00000000000 --- a/lib/libm/noieee_src/n_cabs.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $OpenBSD: n_cabs.c,v 1.12 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <complex.h> -#include <math.h> - -double -cabs(double complex z) -{ - return hypot(__real__ z, __imag__ z); -} diff --git a/lib/libm/noieee_src/n_cacos.c b/lib/libm/noieee_src/n_cacos.c deleted file mode 100644 index 929aa0fa8b3..00000000000 --- a/lib/libm/noieee_src/n_cacos.c +++ /dev/null @@ -1,60 +0,0 @@ -/* $OpenBSD: n_cacos.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* cacos() - * - * Complex circular arc cosine - * - * - * - * SYNOPSIS: - * - * double complex cacos(); - * double complex z, w; - * - * w = cacos (z); - * - * - * - * DESCRIPTION: - * - * - * w = arccos z = PI/2 - arcsin z. - * - * - * - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * DEC -10,+10 5200 1.6e-15 2.8e-16 - * IEEE -10,+10 30000 1.8e-14 2.2e-15 - */ - -#include <complex.h> -#include <math.h> - -double complex -cacos(double complex z) -{ - double complex w; - - w = casin (z); - w = (M_PI_2 - creal (w)) - cimag (w) * I; - return (w); -} diff --git a/lib/libm/noieee_src/n_cacosh.c b/lib/libm/noieee_src/n_cacosh.c deleted file mode 100644 index 246aadab4ed..00000000000 --- a/lib/libm/noieee_src/n_cacosh.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $OpenBSD: n_cacosh.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* cacosh - * - * Complex inverse hyperbolic cosine - * - * - * - * SYNOPSIS: - * - * double complex cacosh(); - * double complex z, w; - * - * w = cacosh (z); - * - * - * - * DESCRIPTION: - * - * acosh z = i acos z . - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * IEEE -10,+10 30000 1.6e-14 2.1e-15 - * - */ - -#include <complex.h> -#include <math.h> - -double complex -cacosh(double complex z) -{ - double complex w; - - w = I * cacos (z); - return (w); -} diff --git a/lib/libm/noieee_src/n_carg.c b/lib/libm/noieee_src/n_carg.c deleted file mode 100644 index 2d8033b0f07..00000000000 --- a/lib/libm/noieee_src/n_carg.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $OpenBSD: n_carg.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <complex.h> -#include <math.h> - -double -carg(double complex z) -{ - return atan2 (__imag__ z, __real__ z); -} diff --git a/lib/libm/noieee_src/n_casin.c b/lib/libm/noieee_src/n_casin.c deleted file mode 100644 index cebc2ffe9bf..00000000000 --- a/lib/libm/noieee_src/n_casin.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $OpenBSD: n_casin.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* casin() - * - * Complex circular arc sine - * - * - * - * SYNOPSIS: - * - * double complex casin(); - * double complex z, w; - * - * w = casin (z); - * - * - * - * DESCRIPTION: - * - * Inverse complex sine: - * - * 2 - * w = -i clog( iz + csqrt( 1 - z ) ). - * - * casin(z) = -i casinh(iz) - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * DEC -10,+10 10100 2.1e-15 3.4e-16 - * IEEE -10,+10 30000 2.2e-14 2.7e-15 - * Larger relative error can be observed for z near zero. - * Also tested by csin(casin(z)) = z. - */ - -#include <complex.h> -#include <math.h> - -double complex -casin(double complex z) -{ - double complex w; - static double complex ca, ct, zz, z2; - double x, y; - - x = creal (z); - y = cimag (z); - - if (y == 0.0) { - if (fabs(x) > 1.0) { - w = M_PI_2 + 0.0 * I; - /*mtherr ("casin", DOMAIN);*/ - } - else { - w = asin (x) + 0.0 * I; - } - return (w); - } - - /* Power series expansion */ - /* - b = cabs(z); - if( b < 0.125 ) { - z2.r = (x - y) * (x + y); - z2.i = 2.0 * x * y; - - cn = 1.0; - n = 1.0; - ca.r = x; - ca.i = y; - sum.r = x; - sum.i = y; - do { - ct.r = z2.r * ca.r - z2.i * ca.i; - ct.i = z2.r * ca.i + z2.i * ca.r; - ca.r = ct.r; - ca.i = ct.i; - - cn *= n; - n += 1.0; - cn /= n; - n += 1.0; - b = cn/n; - - ct.r *= b; - ct.i *= b; - sum.r += ct.r; - sum.i += ct.i; - b = fabs(ct.r) + fabs(ct.i); - } - while( b > MACHEP ); - w->r = sum.r; - w->i = sum.i; - return; - } - */ - - ca = x + y * I; - ct = ca * I; - /* sqrt( 1 - z*z) */ - /* cmul( &ca, &ca, &zz ) */ - /*x * x - y * y */ - zz = (x - y) * (x + y) + (2.0 * x * y) * I; - - zz = 1.0 - creal(zz) - cimag(zz) * I; - z2 = csqrt (zz); - - zz = ct + z2; - zz = clog (zz); - /* multiply by 1/i = -i */ - w = zz * (-1.0 * I); - return (w); -} diff --git a/lib/libm/noieee_src/n_casinh.c b/lib/libm/noieee_src/n_casinh.c deleted file mode 100644 index ee3df8af99a..00000000000 --- a/lib/libm/noieee_src/n_casinh.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $OpenBSD: n_casinh.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* casinh - * - * Complex inverse hyperbolic sine - * - * - * - * SYNOPSIS: - * - * double complex casinh(); - * double complex z, w; - * - * w = casinh (z); - * - * - * - * DESCRIPTION: - * - * casinh z = -i casin iz . - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * IEEE -10,+10 30000 1.8e-14 2.6e-15 - * - */ - -#include <complex.h> -#include <math.h> - -double complex -casinh(double complex z) -{ - double complex w; - - w = -1.0 * I * casin (z * I); - return (w); -} diff --git a/lib/libm/noieee_src/n_catan.c b/lib/libm/noieee_src/n_catan.c deleted file mode 100644 index 431fe0a209d..00000000000 --- a/lib/libm/noieee_src/n_catan.c +++ /dev/null @@ -1,126 +0,0 @@ -/* $OpenBSD: n_catan.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* catan() - * - * Complex circular arc tangent - * - * - * - * SYNOPSIS: - * - * double complex catan(); - * double complex z, w; - * - * w = catan (z); - * - * - * - * DESCRIPTION: - * - * If - * z = x + iy, - * - * then - * 1 ( 2x ) - * Re w = - arctan(-----------) + k PI - * 2 ( 2 2) - * (1 - x - y ) - * - * ( 2 2) - * 1 (x + (y+1) ) - * Im w = - log(------------) - * 4 ( 2 2) - * (x + (y-1) ) - * - * Where k is an arbitrary integer. - * - * catan(z) = -i catanh(iz). - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * DEC -10,+10 5900 1.3e-16 7.8e-18 - * IEEE -10,+10 30000 2.3e-15 8.5e-17 - * The check catan( ctan(z) ) = z, with |x| and |y| < PI/2, - * had peak relative error 1.5e-16, rms relative error - * 2.9e-17. See also clog(). - */ - -#include <complex.h> -#include <math.h> - -#define MAXNUM 1.0e308 - -static const double DP1 = 3.14159265160560607910E0; -static const double DP2 = 1.98418714791870343106E-9; -static const double DP3 = 1.14423774522196636802E-17; - -static double -_redupi(double x) -{ - double t; - long i; - - t = x/M_PI; - if(t >= 0.0) - t += 0.5; - else - t -= 0.5; - - i = t; /* the multiple */ - t = i; - t = ((x - t * DP1) - t * DP2) - t * DP3; - return (t); -} - -double complex -catan(double complex z) -{ - double complex w; - double a, t, x, x2, y; - - x = creal (z); - y = cimag (z); - - if ((x == 0.0) && (y > 1.0)) - goto ovrf; - - x2 = x * x; - a = 1.0 - x2 - (y * y); - if (a == 0.0) - goto ovrf; - - t = 0.5 * atan2 (2.0 * x, a); - w = _redupi (t); - - t = y - 1.0; - a = x2 + (t * t); - if (a == 0.0) - goto ovrf; - - t = y + 1.0; - a = (x2 + (t * t))/a; - w = w + (0.25 * log (a)) * I; - return (w); - -ovrf: - /*mtherr ("catan", OVERFLOW);*/ - w = MAXNUM + MAXNUM * I; - return (w); -} diff --git a/lib/libm/noieee_src/n_catanh.c b/lib/libm/noieee_src/n_catanh.c deleted file mode 100644 index c1c1f8cff03..00000000000 --- a/lib/libm/noieee_src/n_catanh.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $OpenBSD: n_catanh.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* catanh - * - * Complex inverse hyperbolic tangent - * - * - * - * SYNOPSIS: - * - * double complex catanh(); - * double complex z, w; - * - * w = catanh (z); - * - * - * - * DESCRIPTION: - * - * Inverse tanh, equal to -i catan (iz); - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * IEEE -10,+10 30000 2.3e-16 6.2e-17 - * - */ - -#include <complex.h> -#include <math.h> - -double complex -catanh(double complex z) -{ - double complex w; - - w = -1.0 * I * catan (z * I); - return (w); -} diff --git a/lib/libm/noieee_src/n_ccos.c b/lib/libm/noieee_src/n_ccos.c deleted file mode 100644 index 21ff994418b..00000000000 --- a/lib/libm/noieee_src/n_ccos.c +++ /dev/null @@ -1,84 +0,0 @@ -/* $OpenBSD: n_ccos.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* ccos() - * - * Complex circular cosine - * - * - * - * SYNOPSIS: - * - * double complex ccos(); - * double complex z, w; - * - * w = ccos (z); - * - * - * - * DESCRIPTION: - * - * If - * z = x + iy, - * - * then - * - * w = cos x cosh y - i sin x sinh y. - * - * - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * DEC -10,+10 8400 4.5e-17 1.3e-17 - * IEEE -10,+10 30000 3.8e-16 1.0e-16 - */ - -#include <complex.h> -#include <math.h> - -/* calculate cosh and sinh */ - -static void -_cchsh(double x, double *c, double *s) -{ - double e, ei; - - if (fabs(x) <= 0.5) { - *c = cosh(x); - *s = sinh(x); - } - else { - e = exp(x); - ei = 0.5/e; - e = 0.5 * e; - *s = e - ei; - *c = e + ei; - } -} - -double complex -ccos(double complex z) -{ - double complex w; - double ch, sh; - - _cchsh( cimag(z), &ch, &sh ); - w = cos(creal (z)) * ch - (sin (creal (z)) * sh) * I; - return (w); -} diff --git a/lib/libm/noieee_src/n_ccosh.c b/lib/libm/noieee_src/n_ccosh.c deleted file mode 100644 index 7151977977e..00000000000 --- a/lib/libm/noieee_src/n_ccosh.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $OpenBSD: n_ccosh.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* ccosh - * - * Complex hyperbolic cosine - * - * - * - * SYNOPSIS: - * - * double complex ccosh(); - * double complex z, w; - * - * w = ccosh (z); - * - * - * - * DESCRIPTION: - * - * ccosh(z) = cosh x cos y + i sinh x sin y . - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * IEEE -10,+10 30000 2.9e-16 8.1e-17 - * - */ - -#include <complex.h> -#include <math.h> - -double complex -ccosh(double complex z) -{ - double complex w; - double x, y; - - x = creal(z); - y = cimag(z); - w = cosh (x) * cos (y) + (sinh (x) * sin (y)) * I; - return (w); -} diff --git a/lib/libm/noieee_src/n_cexp.c b/lib/libm/noieee_src/n_cexp.c deleted file mode 100644 index 8dbaf613e5e..00000000000 --- a/lib/libm/noieee_src/n_cexp.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: n_cexp.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* cexp() - * - * Complex exponential function - * - * - * - * SYNOPSIS: - * - * double complex cexp (); - * double complex z, w; - * - * w = cexp (z); - * - * - * - * DESCRIPTION: - * - * Returns the exponential of the complex argument z - * into the complex result w. - * - * If - * z = x + iy, - * r = exp(x), - * - * then - * - * w = r cos y + i r sin y. - * - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * DEC -10,+10 8700 3.7e-17 1.1e-17 - * IEEE -10,+10 30000 3.0e-16 8.7e-17 - * - */ - -#include <complex.h> -#include <math.h> - -double complex -cexp(double complex z) -{ - double complex w; - double r, x, y; - - x = creal (z); - y = cimag (z); - r = exp (x); - w = r * cos (y) + r * sin (y) * I; - return (w); -} diff --git a/lib/libm/noieee_src/n_cimag.c b/lib/libm/noieee_src/n_cimag.c deleted file mode 100644 index 5bd9d882bbf..00000000000 --- a/lib/libm/noieee_src/n_cimag.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $OpenBSD: n_cimag.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <complex.h> -#include <math.h> - -double -cimag(double complex z) -{ - return __imag__ z; -} diff --git a/lib/libm/noieee_src/n_cimagf.c b/lib/libm/noieee_src/n_cimagf.c deleted file mode 100644 index 245de7e827f..00000000000 --- a/lib/libm/noieee_src/n_cimagf.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $OpenBSD: n_cimagf.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <complex.h> -#include <math.h> - -float -cimagf(float complex z) -{ - return __imag__ z; -} diff --git a/lib/libm/noieee_src/n_clog.c b/lib/libm/noieee_src/n_clog.c deleted file mode 100644 index a3cd4b59ead..00000000000 --- a/lib/libm/noieee_src/n_clog.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $OpenBSD: n_clog.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* clog.c - * - * Complex natural logarithm - * - * - * - * SYNOPSIS: - * - * double complex clog(); - * double complex z, w; - * - * w = clog (z); - * - * - * - * DESCRIPTION: - * - * Returns complex logarithm to the base e (2.718...) of - * the complex argument x. - * - * If z = x + iy, r = sqrt( x**2 + y**2 ), - * then - * w = log(r) + i arctan(y/x). - * - * The arctangent ranges from -PI to +PI. - * - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * DEC -10,+10 7000 8.5e-17 1.9e-17 - * IEEE -10,+10 30000 5.0e-15 1.1e-16 - * - * Larger relative error can be observed for z near 1 +i0. - * In IEEE arithmetic the peak absolute error is 5.2e-16, rms - * absolute error 1.0e-16. - */ - -#include <complex.h> -#include <math.h> - -double complex -clog(double complex z) -{ - double complex w; - double p, rr; - - /*rr = sqrt( z->r * z->r + z->i * z->i );*/ - rr = cabs(z); - p = log(rr); - rr = atan2 (cimag (z), creal (z)); - w = p + rr * I; - return (w); -} diff --git a/lib/libm/noieee_src/n_conj.c b/lib/libm/noieee_src/n_conj.c deleted file mode 100644 index b776d2de957..00000000000 --- a/lib/libm/noieee_src/n_conj.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $OpenBSD: n_conj.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <complex.h> -#include <math.h> - -double complex -conj(double complex z) -{ - return ~z; -} diff --git a/lib/libm/noieee_src/n_conjf.c b/lib/libm/noieee_src/n_conjf.c deleted file mode 100644 index f0589a986c1..00000000000 --- a/lib/libm/noieee_src/n_conjf.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $OpenBSD: n_conjf.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <complex.h> -#include <math.h> - -float complex -conjf(float complex z) -{ - return ~z; -} diff --git a/lib/libm/noieee_src/n_cpow.c b/lib/libm/noieee_src/n_cpow.c deleted file mode 100644 index 85cb93c228a..00000000000 --- a/lib/libm/noieee_src/n_cpow.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $OpenBSD: n_cpow.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* cpow - * - * Complex power function - * - * - * - * SYNOPSIS: - * - * double complex cpow(); - * double complex a, z, w; - * - * w = cpow (a, z); - * - * - * - * DESCRIPTION: - * - * Raises complex A to the complex Zth power. - * Definition is per AMS55 # 4.2.8, - * analytically equivalent to cpow(a,z) = cexp(z clog(a)). - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * IEEE -10,+10 30000 9.4e-15 1.5e-15 - * - */ - -#include <complex.h> -#include <math.h> - -double complex -cpow(double complex a, double complex z) -{ - double complex w; - double x, y, r, theta, absa, arga; - - x = creal (z); - y = cimag (z); - absa = cabs (a); - if (absa == 0.0) { - return (0.0 + 0.0 * I); - } - arga = carg (a); - r = pow (absa, x); - theta = x * arga; - if (y != 0.0) { - r = r * exp (-y * arga); - theta = theta + y * log (absa); - } - w = r * cos (theta) + (r * sin (theta)) * I; - return (w); -} diff --git a/lib/libm/noieee_src/n_creal.c b/lib/libm/noieee_src/n_creal.c deleted file mode 100644 index 3bceac5719e..00000000000 --- a/lib/libm/noieee_src/n_creal.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $OpenBSD: n_creal.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <complex.h> -#include <math.h> - -double -creal(double complex z) -{ - return __real__ z; -} diff --git a/lib/libm/noieee_src/n_crealf.c b/lib/libm/noieee_src/n_crealf.c deleted file mode 100644 index a31c5393696..00000000000 --- a/lib/libm/noieee_src/n_crealf.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $OpenBSD: n_crealf.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <complex.h> -#include <math.h> - -float -crealf(float complex z) -{ - return __real__ z; -} diff --git a/lib/libm/noieee_src/n_csin.c b/lib/libm/noieee_src/n_csin.c deleted file mode 100644 index 017f6d6068b..00000000000 --- a/lib/libm/noieee_src/n_csin.c +++ /dev/null @@ -1,86 +0,0 @@ -/* $OpenBSD: n_csin.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* csin() - * - * Complex circular sine - * - * - * - * SYNOPSIS: - * - * double complex csin(); - * double complex z, w; - * - * w = csin (z); - * - * - * - * DESCRIPTION: - * - * If - * z = x + iy, - * - * then - * - * w = sin x cosh y + i cos x sinh y. - * - * csin(z) = -i csinh(iz). - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * DEC -10,+10 8400 5.3e-17 1.3e-17 - * IEEE -10,+10 30000 3.8e-16 1.0e-16 - * Also tested by csin(casin(z)) = z. - * - */ - -#include <complex.h> -#include <math.h> - -/* calculate cosh and sinh */ - -static void -cchsh(double x, double *c, double *s) -{ - double e, ei; - - if (fabs(x) <= 0.5) { - *c = cosh(x); - *s = sinh(x); - } - else { - e = exp(x); - ei = 0.5/e; - e = 0.5 * e; - *s = e - ei; - *c = e + ei; - } -} - -double complex -csin(double complex z) -{ - double complex w; - double ch, sh; - - cchsh( cimag (z), &ch, &sh ); - w = sin (creal(z)) * ch + (cos (creal(z)) * sh) * I; - return (w); -} diff --git a/lib/libm/noieee_src/n_csinh.c b/lib/libm/noieee_src/n_csinh.c deleted file mode 100644 index 122985612bb..00000000000 --- a/lib/libm/noieee_src/n_csinh.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $OpenBSD: n_csinh.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* csinh - * - * Complex hyperbolic sine - * - * - * - * SYNOPSIS: - * - * double complex csinh(); - * double complex z, w; - * - * w = csinh (z); - * - * DESCRIPTION: - * - * csinh z = (cexp(z) - cexp(-z))/2 - * = sinh x * cos y + i cosh x * sin y . - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * IEEE -10,+10 30000 3.1e-16 8.2e-17 - * - */ - -#include <complex.h> -#include <math.h> - -double complex -csinh(double complex z) -{ - double complex w; - double x, y; - - x = creal(z); - y = cimag(z); - w = sinh (x) * cos (y) + (cosh (x) * sin (y)) * I; - return (w); -} diff --git a/lib/libm/noieee_src/n_csqrt.c b/lib/libm/noieee_src/n_csqrt.c deleted file mode 100644 index 13f0903fcb2..00000000000 --- a/lib/libm/noieee_src/n_csqrt.c +++ /dev/null @@ -1,131 +0,0 @@ -/* $OpenBSD: n_csqrt.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* csqrt() - * - * Complex square root - * - * - * - * SYNOPSIS: - * - * double complex csqrt(); - * double complex z, w; - * - * w = csqrt (z); - * - * - * - * DESCRIPTION: - * - * - * If z = x + iy, r = |z|, then - * - * 1/2 - * Re w = [ (r + x)/2 ] , - * - * 1/2 - * Im w = [ (r - x)/2 ] . - * - * Cancellation error in r-x or r+x is avoided by using the - * identity 2 Re w Im w = y. - * - * Note that -w is also a square root of z. The root chosen - * is always in the right half plane and Im w has the same sign as y. - * - * - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * DEC -10,+10 25000 3.2e-17 9.6e-18 - * IEEE -10,+10 1,000,000 2.9e-16 6.1e-17 - * - */ - -#include <complex.h> -#include <math.h> - -double complex -csqrt(double complex z) -{ - double complex w; - double x, y, r, t, scale; - - x = creal (z); - y = cimag (z); - - if (y == 0.0) { - if (x == 0.0) { - w = 0.0 + y * I; - } - else { - r = fabs (x); - r = sqrt (r); - if (x < 0.0) { - w = 0.0 + r * I; - } - else { - w = r + y * I; - } - } - return (w); - } - if (x == 0.0) { - r = fabs (y); - r = sqrt (0.5*r); - if (y > 0) - w = r + r * I; - else - w = r - r * I; - return (w); - } - /* Rescale to avoid internal overflow or underflow. */ - if ((fabs(x) > 4.0) || (fabs(y) > 4.0)) { - x *= 0.25; - y *= 0.25; - scale = 2.0; - } - else { - x *= 1.8014398509481984e16; /* 2^54 */ - y *= 1.8014398509481984e16; - scale = 7.450580596923828125e-9; /* 2^-27 */ -#if 0 - x *= 4.0; - y *= 4.0; - scale = 0.5; -#endif - } - w = x + y * I; - r = cabs(w); - if (x > 0) { - t = sqrt(0.5 * r + 0.5 * x); - r = scale * fabs((0.5 * y) / t); - t *= scale; - } - else { - r = sqrt( 0.5 * r - 0.5 * x ); - t = scale * fabs( (0.5 * y) / r ); - r *= scale; - } - if (y < 0) - w = t - r * I; - else - w = t + r * I; - return (w); -} diff --git a/lib/libm/noieee_src/n_ctan.c b/lib/libm/noieee_src/n_ctan.c deleted file mode 100644 index 6ae9cca8d30..00000000000 --- a/lib/libm/noieee_src/n_ctan.c +++ /dev/null @@ -1,152 +0,0 @@ -/* $OpenBSD: n_ctan.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* ctan() - * - * Complex circular tangent - * - * - * - * SYNOPSIS: - * - * double complex ctan(); - * double complex z, w; - * - * w = ctan (z); - * - * - * - * DESCRIPTION: - * - * If - * z = x + iy, - * - * then - * - * sin 2x + i sinh 2y - * w = --------------------. - * cos 2x + cosh 2y - * - * On the real axis the denominator is zero at odd multiples - * of PI/2. The denominator is evaluated by its Taylor - * series near these points. - * - * ctan(z) = -i ctanh(iz). - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * DEC -10,+10 5200 7.1e-17 1.6e-17 - * IEEE -10,+10 30000 7.2e-16 1.2e-16 - * Also tested by ctan * ccot = 1 and catan(ctan(z)) = z. - */ - -#include <complex.h> -#include <math.h> - -#define MACHEP 1.1e-16 -#define MAXNUM 1.0e308 - -static const double DP1 = 3.14159265160560607910E0; -static const double DP2 = 1.98418714791870343106E-9; -static const double DP3 = 1.14423774522196636802E-17; - -static double -_redupi(double x) -{ - double t; - long i; - - t = x/M_PI; - if (t >= 0.0) - t += 0.5; - else - t -= 0.5; - - i = t; /* the multiple */ - t = i; - t = ((x - t * DP1) - t * DP2) - t * DP3; - return (t); -} - -/* Taylor series expansion for cosh(2y) - cos(2x) */ - -static double -_ctans(double complex z) -{ - double f, x, x2, y, y2, rn, t; - double d; - - x = fabs (2.0 * creal (z)); - y = fabs (2.0 * cimag(z)); - - x = _redupi(x); - - x = x * x; - y = y * y; - x2 = 1.0; - y2 = 1.0; - f = 1.0; - rn = 0.0; - d = 0.0; - do { - rn += 1.0; - f *= rn; - rn += 1.0; - f *= rn; - x2 *= x; - y2 *= y; - t = y2 + x2; - t /= f; - d += t; - - rn += 1.0; - f *= rn; - rn += 1.0; - f *= rn; - x2 *= x; - y2 *= y; - t = y2 - x2; - t /= f; - d += t; - } - while (fabs(t/d) > MACHEP) - ; - return (d); -} - -double complex -ctan(double complex z) -{ - double complex w; - double d; - - d = cos (2.0 * creal (z)) + cosh (2.0 * cimag (z)); - - if (fabs(d) < 0.25) - d = _ctans (z); - - if (d == 0.0) { - /*mtherr ("ctan", OVERFLOW);*/ - w = MAXNUM + MAXNUM * I; - return (w); - } - - w = sin (2.0 * creal(z)) / d + (sinh (2.0 * cimag(z)) / d) * I; - return (w); -} diff --git a/lib/libm/noieee_src/n_ctanh.c b/lib/libm/noieee_src/n_ctanh.c deleted file mode 100644 index 4d3536f9986..00000000000 --- a/lib/libm/noieee_src/n_ctanh.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $OpenBSD: n_ctanh.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */ -/* - * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* ctanh - * - * Complex hyperbolic tangent - * - * - * - * SYNOPSIS: - * - * double complex ctanh(); - * double complex z, w; - * - * w = ctanh (z); - * - * - * - * DESCRIPTION: - * - * tanh z = (sinh 2x + i sin 2y) / (cosh 2x + cos 2y) . - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * IEEE -10,+10 30000 1.7e-14 2.4e-16 - * - */ - -#include <complex.h> -#include <math.h> - -double complex -ctanh(double complex z) -{ - double complex w; - double x, y, d; - - x = creal(z); - y = cimag(z); - d = cosh (2.0 * x) + cos (2.0 * y); - w = sinh (2.0 * x) / d + (sin (2.0 * y) / d) * I; - return (w); -} diff --git a/lib/libm/noieee_src/n_fdim.c b/lib/libm/noieee_src/n_fdim.c deleted file mode 100644 index 6b982987d8d..00000000000 --- a/lib/libm/noieee_src/n_fdim.c +++ /dev/null @@ -1,44 +0,0 @@ -/* $OpenBSD: n_fdim.c,v 1.6 2013/01/13 03:44:59 martynas Exp $ */ -/*- - * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <math.h> - -#define DECL(type, fn) \ -type \ -fn(type x, type y) \ -{ \ - \ - if (isnan(x)) \ - return (x); \ - if (isnan(y)) \ - return (y); \ - return (x > y ? x - y : 0.0); \ -} - -DECL(double, fdim) -DECL(float, fdimf) -DECL(long double, fdiml) diff --git a/lib/libm/noieee_src/n_fmax.c b/lib/libm/noieee_src/n_fmax.c deleted file mode 100644 index f29f407b74a..00000000000 --- a/lib/libm/noieee_src/n_fmax.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: n_fmax.c,v 1.7 2013/03/28 18:09:38 martynas Exp $ */ -/*- - * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <math.h> - -double -fmax(double x, double y) -{ - /* Check for NaNs to avoid raising spurious exceptions. */ - if (isnan(x)) - return (y); - if (isnan(y)) - return (x); - - /* Handle comparisons of signed zeroes. */ - if (signbit(x) != signbit(y)) - if (signbit(x)) - return (y); - else - return (x); - - return (x > y ? x : y); -} - -__strong_alias(fmaxl, fmax); diff --git a/lib/libm/noieee_src/n_fmaxf.c b/lib/libm/noieee_src/n_fmaxf.c deleted file mode 100644 index 87903a89164..00000000000 --- a/lib/libm/noieee_src/n_fmaxf.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: n_fmaxf.c,v 1.1 2008/09/11 19:19:34 martynas Exp $ */ -/*- - * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <math.h> - -float -fmaxf(float x, float y) -{ - /* Check for NaNs to avoid raising spurious exceptions. */ - if (isnan(x)) - return (y); - if (isnan(y)) - return (x); - - /* Handle comparisons of signed zeroes. */ - if (signbit(x) != signbit(y)) - if (signbit(x)) - return (y); - else - return (x); - - return (x > y ? x : y); -} diff --git a/lib/libm/noieee_src/n_fmin.c b/lib/libm/noieee_src/n_fmin.c deleted file mode 100644 index e7c8c9c715d..00000000000 --- a/lib/libm/noieee_src/n_fmin.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: n_fmin.c,v 1.7 2013/03/28 18:09:38 martynas Exp $ */ -/*- - * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <math.h> - -double -fmin(double x, double y) -{ - /* Check for NaNs to avoid raising spurious exceptions. */ - if (isnan(x)) - return (y); - if (isnan(y)) - return (x); - - /* Handle comparisons of signed zeroes. */ - if (signbit(x) != signbit(y)) - if (signbit(y)) - return (y); - else - return (x); - - return (x < y ? x : y); -} - -__strong_alias(fminl, fmin); diff --git a/lib/libm/noieee_src/n_fminf.c b/lib/libm/noieee_src/n_fminf.c deleted file mode 100644 index 7ee08ed7e44..00000000000 --- a/lib/libm/noieee_src/n_fminf.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: n_fminf.c,v 1.1 2008/09/11 19:19:34 martynas Exp $ */ -/*- - * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <math.h> - -float -fminf(float x, float y) -{ - /* Check for NaNs to avoid raising spurious exceptions. */ - if (isnan(x)) - return (y); - if (isnan(y)) - return (x); - - /* Handle comparisons of signed zeroes. */ - if (signbit(x) != signbit(y)) - if (signbit(y)) - return (y); - else - return (x); - - return (x < y ? x : y); -} |