2005-02-11 Gregory W. Chicares <chicares at cox dot net>
Danny Smith <dannysmith@users at sourceforge dot net> * include/math.h (expm1, expm1f, expmll): Add prototypes. * mingwex/Makefile.in (MATH_DISTFILES): Add expm1.c, expm1f.c, expm1l.c. (MATH_OBJS): Add expm1.o, expm1f.o, expm1l.o. * mingwex/math/expm1.c: New file. * mingwex/math/expm1f.c: New file. * mingwex/math/expm1l.c: New file.
This commit is contained in:
parent
ccf32128b3
commit
ba16f5aa83
|
@ -454,7 +454,11 @@ extern double __cdecl exp2(double);
|
|||
extern float __cdecl exp2f(float);
|
||||
extern long double __cdecl exp2l(long double);
|
||||
|
||||
/* 7.12.6.3 The expm1 functions: TODO */
|
||||
/* 7.12.6.3 The expm1 functions */
|
||||
/* TODO: These could be inlined */
|
||||
extern double __cdecl expm1(double);
|
||||
extern float __cdecl expm1f(float);
|
||||
extern long double __cdecl expm1l(long double);
|
||||
|
||||
/* 7.12.6.4 Double in C89 */
|
||||
__CRT_INLINE float __cdecl frexpf (float x, int* expn)
|
||||
|
|
|
@ -41,7 +41,8 @@ MATH_DISTFILES = \
|
|||
atanf.c atanl.c cbrt.c cbrtf.c cbrtl.c ceilf.S ceill.S \
|
||||
cephes_emath.h cephes_emath.c cephes_mconf.h \
|
||||
copysign.S copysignf.S copysignl.S cosf.S coshf.c coshl.c cosl.S \
|
||||
exp2.S exp2f.S exp2l.S expf.c expl.c fabs.c fabsf.c fabsl.c \
|
||||
exp2.S exp2f.S exp2l.S expf.c expl.c expm1.c expm1l.c expm1f.c \
|
||||
fabs.c fabsf.c fabsl.c \
|
||||
fdim.c fdimf.c fdiml.c floorf.S floorl.S fma.S fmaf.S fmal.c \
|
||||
fmax.c fmaxf.c fmaxl.c fmin.c fminf.c fminl.c fmodf.c \
|
||||
fmodl.c fp_consts.c fp_consts.h fp_constsf.c fp_constsl.c \
|
||||
|
@ -131,7 +132,8 @@ MATH_OBJS = \
|
|||
atanf.o atanl.o cbrt.o cbrtf.o cbrtl.o ceilf.o ceill.o \
|
||||
cephes_emath.o \
|
||||
copysign.o copysignf.o copysignl.o cosf.o coshf.o coshl.o cosl.o \
|
||||
exp2.o exp2f.o exp2l.o expf.o expl.o fabs.o fabsf.o fabsl.o \
|
||||
exp2.o exp2f.o exp2l.o expf.o expl.o expm1.o expm1l.o expm1f.o \
|
||||
fabs.o fabsf.o fabsl.o \
|
||||
fdim.o fdimf.o fdiml.o floorf.o floorl.o fma.o fmaf.o fmal.o \
|
||||
fmax.o fmaxf.o fmaxl.o fmin.o fminf.o fminl.o fmodf.o \
|
||||
fmodl.o fp_consts.o fp_constsf.o fp_constsl.o \
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Written 2005 by Gregory W. Chicares <chicares@cox.net>.
|
||||
* Adapted to double by Danny Smith <dannysmith@users.sourceforge.net>.
|
||||
* Public domain.
|
||||
*
|
||||
* F2XM1's input is constrained to (-1, +1), so the domain of
|
||||
* 'x * LOG2EL' is (-LOGE2L, +LOGE2L). Outside that domain,
|
||||
* delegating to exp() handles C99 7.12.6.3/2 range errors.
|
||||
*
|
||||
* Constants from moshier.net, file cephes/ldouble/constl.c,
|
||||
* are used instead of M_LN2 and M_LOG2E, which would not be
|
||||
* visible with 'gcc std=c99'. The use of these extended precision
|
||||
* constants also allows gcc to replace them with x87 opcodes.
|
||||
*/
|
||||
|
||||
#include <math.h> /* expl() */
|
||||
#include "cephes_mconf.h"
|
||||
double expm1 (double x)
|
||||
{
|
||||
if (fabs(x) < LOGE2L)
|
||||
{
|
||||
x *= LOG2EL;
|
||||
__asm__("f2xm1" : "=t" (x) : "0" (x));
|
||||
return x;
|
||||
}
|
||||
else
|
||||
return exp(x) - 1.0;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Written 2005 by Gregory W. Chicares <chicares@cox.net>.
|
||||
* Adapted to float by Danny Smith <dannysmith@users.sourceforge.net>.
|
||||
* Public domain.
|
||||
*
|
||||
* F2XM1's input is constrained to (-1, +1), so the domain of
|
||||
* 'x * LOG2EL' is (-LOGE2L, +LOGE2L). Outside that domain,
|
||||
* delegating to exp() handles C99 7.12.6.3/2 range errors.
|
||||
*
|
||||
* Constants from moshier.net, file cephes/ldouble/constl.c,
|
||||
* are used instead of M_LN2 and M_LOG2E, which would not be
|
||||
* visible with 'gcc std=c99'. The use of these extended precision
|
||||
* constants also allows gcc to replace them with x87 opcodes.
|
||||
*/
|
||||
|
||||
#include <math.h> /* expl() */
|
||||
#include "cephes_mconf.h"
|
||||
|
||||
float expm1f (float x)
|
||||
{
|
||||
if (fabsf(x) < LOGE2L)
|
||||
{
|
||||
x *= LOG2EL;
|
||||
__asm__("f2xm1" : "=t" (x) : "0" (x));
|
||||
return x;
|
||||
}
|
||||
else
|
||||
return expf(x) - 1.0F;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Written 2005 by Gregory W. Chicares <chicares@cox.net> with
|
||||
* help from Danny Smith. dannysmith@users.sourceforge.net>.
|
||||
* Public domain.
|
||||
*
|
||||
* F2XM1's input is constrained to (-1, +1), so the domain of
|
||||
* 'x * LOG2EL' is (-LOGE2L, +LOGE2L). Outside that domain,
|
||||
* delegating to expl() handles C99 7.12.6.3/2 range errors.
|
||||
*
|
||||
* Constants from moshier.net, file cephes/ldouble/constl.c,
|
||||
* are used instead of M_LN2 and M_LOG2E, which would not be
|
||||
* visible with 'gcc std=c99'. The use of these extended precision
|
||||
* constants also allows gcc to replace them with x87 opcodes.
|
||||
*/
|
||||
|
||||
#include <math.h> /* expl() */
|
||||
#include "cephes_mconf.h"
|
||||
|
||||
long double expm1l (long double x)
|
||||
{
|
||||
if (fabsl(x) < LOGE2L)
|
||||
{
|
||||
x *= LOG2EL;
|
||||
__asm__("f2xm1" : "=t" (x) : "0" (x));
|
||||
return x;
|
||||
}
|
||||
else
|
||||
return expl(x) - 1.0L;
|
||||
}
|
Loading…
Reference in New Issue