* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
/* EXP(X)
* RETURN THE EXPONENTIAL OF X
* DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS)
/* Table-driven natural logarithm.
*
* This code was derived, with minor modifications, from:
* porting to other precisions.
#include <float.h>
#include "math.h"
#ifndef _MATHIMPL_H_
#define _MATHIMPL_H_
#include <math.h>
#include "../src/math_private.h"
#include <stdint.h>
#define STRUCT_DECLS
* ====================================================
/*
* See e_lgamma_r.c for complete comments.
* Optimized by Bruce D. Evans.
/* ld128 version of __ieee754_rem_pio2l(x,y)
* return the remainder of x rem pi/2 in y[0]+y[1]
#include "invtrig.h"
* ld128 version of k_cos.c. See ../src/k_cos.c for most comments.
* ld128 version of k_expl.h. See ../ld80/s_expl.c for most comments.
* ld128 version of k_sin.c. See ../src/k_sin.c for most comments.
* ld128 version of k_tan.c. See ../src/k_tan.c for most comments.
#include <complex.h>
* See s_erf.c for complete comments.
* ld128 version of s_expl.c. See ../ld80/s_expl.c for most comments.
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/**
* Implementation of the natural logarithm of x for 128-bit format.
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "math_private.h"
/* ld80 version of __ieee754_rem_pio2l(x,y)
* ld80 version of k_cos.c. See ../src/k_cos.c for most comments.
* See s_expl.c for more comments about __k_expl().
* ld80 version of k_sin.c. See ../src/k_sin.c for most comments.
* ld80 version of k_tan.c. See ../src/k_tan.c for most comments.
* src/s_cexp.c converted to long double complex by Steven G. Kargl
#ifdef __i386__
* Compute the exponential of x for Intel 80-bit format. This is based on:
* Implementation of the natural logarithm of x for Intel 80-bit format.
* a few comments on the right of declarations remain.
/* acos(x)
* Method :
* acos(x) = pi/2 - asin(x)
/* acosh(x)
* Based on
* See e_acosh.c for complete comments.
* See comments in e_acos.c.
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
/* asin(x)
* Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ...
* See comments in e_asin.c.
/* atan2(y,x)
* 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
* See comments in e_atan2.c.
/* atanh(x)
* 1.Reduced x to positive by atanh(-x) = -atanh(x)
* See e_atanh.c for complete comments.
/* cosh(x)
* mathematically cosh(x) if defined to be (exp(x)+exp(-x))/2
* See e_cosh.c for complete comments.
/* exp(x)
* Returns the exponential of x.
* fmod(x,y)
* Return x mod y in exact arithmetic
* fmodf(x,y)
/* gamma(x)
* Return the logarithm of the Gamma function of x.
/* gamma_r(x, signgamp)
* Reentrant version of the logarithm of the Gamma function
* with user provide pointer for the sign of Gamma(x).
/* gammaf(x)
/* gammaf_r(x, signgamp)
/* hypot(x,y)
/* long double version of hypot(). See e_hypot.c for most comments. */
/* j0(x), y0(x)
* Bessel function of the first and second kinds of order zero.
* Method -- j0(x):
* See e_j0.c for complete comments.
/* j1(x), y1(x)
* Method -- j1(x):
* See e_j1.c for complete comments.
* jn(n, x), yn(n, x)
* floating point Bessel's function of the 1st and 2nd kind
* See e_jn.c for complete comments.
/* lgamma(x)
/* lgamma_r(x, signgamp)
/* lgammaf(x)
/* log(x)
* Return the logrithm of x
* Return the base 10 logarithm of x. See e_log.c and k_log.h for most
* comments.
* Float version of e_log10.c. See the latter for most comments.
* Return the base 2 logarithm of x. See e_log.c and k_log.h for most
* Float version of e_log2.c. See the latter for most comments.
/* pow(x,y) return x**y
* n
/* __ieee754_rem_pio2(x,y)
/* __ieee754_rem_pio2f(x,y)
* return the remainder of x rem pi/2 in *y
/* remainder(x,p)
* Return :
* returns x REM p = x - [x/p]*p as if in infinite
long double
* scalb(x, fn) is provide for
* passing various standard test suite. One
/* sinh(x)
* mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
* See e_sinh.c for complete comments.
#include <fenv.h>
* __kernel_cos( x, y )
* kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164
#ifndef INLINE_KERNEL_COSDF
#endif
* k_log1p(f):
* Return log(1+f) - f for 1+f in ~[sqrt(2)/2, sqrt(2)].
* Float version of k_log.h. See the latter for most comments.
* __kernel_rem_pio2(x,y,e0,nx,prec)
* double x[],y[]; int e0,nx,prec;
/* __kernel_sin( x, y, iy)
* kernel sin function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
* Input x is assumed to be bounded by ~pi/4 in magnitude.
* k_sin.c and k_cos.c merged by Steven G. Kargl.
static const double
S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */
S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */
* k_sinf.c and k_cosf.c merged by Steven G. Kargl.
/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */
S1 = -0x15555554cbac77.0p-55, /* -0.166666666416265235595 */
* k_sinl.c and k_cosl.c merged by Steven G. Kargl
#if LDBL_MANT_DIG == 64 /* ld80 version of k_sincosl.c. */
#if defined(__amd64__) || defined(__i386__)
#ifndef INLINE_KERNEL_SINDF
/* INDENT OFF */
/* __kernel_tan( x, y, k )
* kernel tan function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
#ifndef INLINE_KERNEL_TANDF
#ifndef _MATH_H_
#define _MATH_H_
#include <sys/_types.h>
#include <machine/_limits.h>
/* asinh(x)
* See s_asinh.c for complete comments.
/* atan(x)
* Method
* 1. Reduce x to positive by atan(x) = -atan(-x).
* See comments in s_atan.c.
* and David A. Schultz.
#include <ieeefp.h>
* must satisfy both cosh(conj(z)) == conj(cosh(z)) and cosh(-z) == cosh(z).
* Float version of ccosh(). See s_ccosh.c for details.
* ceil(x)
* Return x rounded toward -inf to integral value
* ceill(x)
* copysign(double x, double y)
* copysign(x,y) returns a value with the magnitude of x and
* copysignf(float x, float y)
* copysignf(x,y) returns a value with the magnitude of x and
/* cos(x)
* Return cosine function of x.
* Limited testing on pseudorandom numbers drawn within [-2e8:4e8] shows
* an accuracy of <= 0.7412 ULP.
* must satisfy both sinh(conj(z)) == conj(sinh(z)) and sinh(-z) == -sinh(z).
* Float version of csinh(). See s_csinh.c for details.
* precision. I also handle large x differently.
* Hyperbolic tangent of a complex argument z. See s_ctanh.c for details.
/* double erf(double x)
* double erfc(double x)
* x
/* expm1(x)
* Returns exp(x)-1, the exponential of x minus 1.
* fabs(x) returns the absolute value of x.
* fabsf(x) returns the absolute value of x.
#define DECL(type, fn) \
* finite(x) returns 1 is x is finite, else 0;
* no branching!
* finitef(x) returns 1 is x is finite, else 0;
* floor(x)
* floorf(x)
* floorl(x)
#include "fpmath.h"
* for non-zero x
* x = frexp(arg,&exp);
/* ilogb(double x)
* return the binary exponent of non-zero x
* ilogb(0) = FP_ILOGB0
#include <limits.h>
#define type double
#define roundit rint
#define dtype long long
#define type float
#define roundit rintf
#define type long double
#define roundit rintl
#define roundit round
#define roundit roundf
#define roundit roundl
/* double log1p(double x)
* double logb(x)
* IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
#define dtype long
#include <sys/limits.h>
/* IEEE functions
* nextafter(x,y)
* return the next machine floating-point number of x in the
* We assume that a long double has a 15-bit exponent. On systems
* where long double is the same as double, nexttoward() is an alias
* rint(x)
* Return x rounded to integral value according to the prevailing
#define NMAX 65536
* significand(x) computes just
* scalb(x, (double) -ilogb(x)),
/* sin(x)
* Return sine function of x.
* algorithms are contained in the original files.
* Merged s_sinf.c and s_cosf.c by Steven G. Kargl.
* s_sinl.c and s_cosl.c merged by Steven G. Kargl.
/* tan(x)
* Return tangent function of x.
/* Tanh(x)
* Return the Hyperbolic Tangent of x
* See s_tanh.c for complete comments.
* Limited testing on pseudorandom numbers drawn within [0:4e8] shows
* an accuracy of <= 1.5 ULP where 247024 values of x out of 40 million
* trunc(x)
* Return x rounded toward 0 to integral value
* truncf(x)
* truncl(x)
* Placed into the Public Domain, 1994.
* Modified by Steven G. Kargl for the long double type.
* Missing tests: fmod, fmodf.
#include <stdio.h>