SDL  2.0
math_private.h File Reference
#include "SDL_endian.h"
+ Include dependency graph for math_private.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  ieee_double_shape_type
 
union  ieee_float_shape_type
 

Macros

#define attribute_hidden
 
#define libm_hidden_proto(x)
 
#define libm_hidden_def(x)
 
#define atan   SDL_uclibc_atan
 
#define __ieee754_atan2   SDL_uclibc_atan2
 
#define copysign   SDL_uclibc_copysign
 
#define cos   SDL_uclibc_cos
 
#define fabs   SDL_uclibc_fabs
 
#define floor   SDL_uclibc_floor
 
#define __ieee754_log   SDL_uclibc_log
 
#define __ieee754_pow   SDL_uclibc_pow
 
#define scalbn   SDL_uclibc_scalbn
 
#define sin   SDL_uclibc_sin
 
#define __ieee754_sqrt   SDL_uclibc_sqrt
 
#define tan   SDL_uclibc_tan
 
#define EXTRACT_WORDS(ix0, ix1, d)
 
#define GET_HIGH_WORD(i, d)
 
#define GET_LOW_WORD(i, d)
 
#define INSERT_WORDS(d, ix0, ix1)
 
#define SET_HIGH_WORD(d, v)
 
#define SET_LOW_WORD(d, v)
 
#define GET_FLOAT_WORD(i, d)
 
#define SET_FLOAT_WORD(d, i)
 

Typedefs

typedef unsigned int u_int32_t
 

Functions

double __ieee754_sqrt (double) attribute_hidden
 
double __ieee754_acos (double) attribute_hidden
 
double __ieee754_acosh (double) attribute_hidden
 
double __ieee754_log (double) attribute_hidden
 
double __ieee754_atanh (double) attribute_hidden
 
double __ieee754_asin (double) attribute_hidden
 
double __ieee754_atan2 (double, double) attribute_hidden
 
double __ieee754_exp (double) attribute_hidden
 
double __ieee754_cosh (double) attribute_hidden
 
double __ieee754_fmod (double, double) attribute_hidden
 
double __ieee754_pow (double, double) attribute_hidden
 
double __ieee754_lgamma_r (double, int *) attribute_hidden
 
double __ieee754_gamma_r (double, int *) attribute_hidden
 
double __ieee754_lgamma (double) attribute_hidden
 
double __ieee754_gamma (double) attribute_hidden
 
double __ieee754_log10 (double) attribute_hidden
 
double __ieee754_sinh (double) attribute_hidden
 
double __ieee754_hypot (double, double) attribute_hidden
 
double __ieee754_j0 (double) attribute_hidden
 
double __ieee754_j1 (double) attribute_hidden
 
double __ieee754_y0 (double) attribute_hidden
 
double __ieee754_y1 (double) attribute_hidden
 
double __ieee754_jn (int, double) attribute_hidden
 
double __ieee754_yn (int, double) attribute_hidden
 
double __ieee754_remainder (double, double) attribute_hidden
 
int __ieee754_rem_pio2 (double, double *) attribute_hidden
 
double __ieee754_scalb (double, double) attribute_hidden
 
double __kernel_standard (double, double, int) attribute_hidden
 
double __kernel_sin (double, double, int) attribute_hidden
 
double __kernel_cos (double, double) attribute_hidden
 
double __kernel_tan (double, double, int) attribute_hidden
 
int __kernel_rem_pio2 (double *, double *, int, int, int, const int *) attribute_hidden
 

Macro Definition Documentation

◆ __ieee754_atan2

#define __ieee754_atan2   SDL_uclibc_atan2

Definition at line 33 of file math_private.h.

◆ __ieee754_log

#define __ieee754_log   SDL_uclibc_log

Definition at line 38 of file math_private.h.

◆ __ieee754_pow

#define __ieee754_pow   SDL_uclibc_pow

Definition at line 39 of file math_private.h.

◆ __ieee754_sqrt

#define __ieee754_sqrt   SDL_uclibc_sqrt

Definition at line 42 of file math_private.h.

Referenced by __ieee754_pow().

◆ atan

#define atan   SDL_uclibc_atan

Definition at line 32 of file math_private.h.

◆ attribute_hidden

#define attribute_hidden

Definition at line 24 of file math_private.h.

◆ copysign

#define copysign   SDL_uclibc_copysign

Definition at line 34 of file math_private.h.

Referenced by libm_hidden_proto(), and SDL_copysign().

◆ cos

#define cos   SDL_uclibc_cos

Definition at line 35 of file math_private.h.

Referenced by libm_hidden_proto(), and SDL_cos().

◆ EXTRACT_WORDS

#define EXTRACT_WORDS (   ix0,
  ix1,
  d 
)
Value:
do { \
ieee_double_shape_type ew_u; \
ew_u.value = (d); \
(ix0) = ew_u.parts.msw; \
(ix1) = ew_u.parts.lsw; \
} while (0)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d

Definition at line 93 of file math_private.h.

Referenced by __ieee754_atan2(), __ieee754_log(), __ieee754_pow(), __ieee754_sqrt(), and libm_hidden_proto().

◆ fabs

◆ floor

#define floor   SDL_uclibc_floor

Definition at line 37 of file math_private.h.

Referenced by __kernel_rem_pio2(), libm_hidden_proto(), and SDL_floor().

◆ GET_FLOAT_WORD

#define GET_FLOAT_WORD (   i,
  d 
)
Value:
do { \
ieee_float_shape_type gf_u; \
gf_u.value = (d); \
(i) = gf_u.word; \
} while (0)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50

Definition at line 160 of file math_private.h.

◆ GET_HIGH_WORD

#define GET_HIGH_WORD (   i,
  d 
)
Value:
do { \
ieee_double_shape_type gh_u; \
gh_u.value = (d); \
(i) = gh_u.parts.msw; \
} while (0)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50

Definition at line 103 of file math_private.h.

Referenced by __ieee754_atan2(), __ieee754_log(), __ieee754_pow(), __ieee754_rem_pio2(), __kernel_cos(), __kernel_sin(), __kernel_tan(), atan(), libm_hidden_proto(), and tan().

◆ GET_LOW_WORD

#define GET_LOW_WORD (   i,
  d 
)
Value:
do { \
ieee_double_shape_type gl_u; \
gl_u.value = (d); \
(i) = gl_u.parts.lsw; \
} while (0)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50

Definition at line 112 of file math_private.h.

Referenced by __ieee754_rem_pio2(), __kernel_tan(), and atan().

◆ INSERT_WORDS

#define INSERT_WORDS (   d,
  ix0,
  ix1 
)
Value:
do { \
ieee_double_shape_type iw_u; \
iw_u.parts.msw = (ix0); \
iw_u.parts.lsw = (ix1); \
(d) = iw_u.value; \
} while (0)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d

Definition at line 121 of file math_private.h.

Referenced by __ieee754_sqrt(), __kernel_cos(), and libm_hidden_proto().

◆ libm_hidden_def

#define libm_hidden_def (   x)

Definition at line 26 of file math_private.h.

Referenced by atan(), libm_hidden_proto(), and tan().

◆ libm_hidden_proto

#define libm_hidden_proto (   x)

Definition at line 25 of file math_private.h.

◆ scalbn

#define scalbn   SDL_uclibc_scalbn

Definition at line 40 of file math_private.h.

Referenced by __ieee754_pow(), __kernel_rem_pio2(), libm_hidden_proto(), and SDL_scalbn().

◆ SET_FLOAT_WORD

#define SET_FLOAT_WORD (   d,
  i 
)
Value:
do { \
ieee_float_shape_type sf_u; \
sf_u.word = (i); \
(d) = sf_u.value; \
} while (0)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50

Definition at line 169 of file math_private.h.

◆ SET_HIGH_WORD

#define SET_HIGH_WORD (   d,
  v 
)
Value:
do { \
ieee_double_shape_type sh_u; \
sh_u.value = (d); \
sh_u.parts.msw = (v); \
(d) = sh_u.value; \
} while (0)
const GLdouble * v
Definition: SDL_opengl.h:2057
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d

Definition at line 131 of file math_private.h.

Referenced by __ieee754_atan2(), __ieee754_log(), __ieee754_pow(), __ieee754_rem_pio2(), and libm_hidden_proto().

◆ SET_LOW_WORD

#define SET_LOW_WORD (   d,
  v 
)
Value:
do { \
ieee_double_shape_type sl_u; \
sl_u.value = (d); \
sl_u.parts.lsw = (v); \
(d) = sl_u.value; \
} while (0)
const GLdouble * v
Definition: SDL_opengl.h:2057
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d

Definition at line 141 of file math_private.h.

Referenced by __ieee754_pow(), __ieee754_rem_pio2(), and __kernel_tan().

◆ sin

#define sin   SDL_uclibc_sin

Definition at line 41 of file math_private.h.

Referenced by libm_hidden_proto(), and SDL_sin().

◆ tan

#define tan   SDL_uclibc_tan

Definition at line 43 of file math_private.h.

Typedef Documentation

◆ u_int32_t

typedef unsigned int u_int32_t

Definition at line 29 of file math_private.h.

Function Documentation

◆ __ieee754_acos()

double __ieee754_acos ( double  )

◆ __ieee754_acosh()

double __ieee754_acosh ( double  )

◆ __ieee754_asin()

double __ieee754_asin ( double  )

◆ __ieee754_atan2()

double __ieee754_atan2 ( double  ,
double   
)

Definition at line 50 of file e_atan2.c.

References atan(), EXTRACT_WORDS, fabs, GET_HIGH_WORD, k, pi, pi_lo, pi_o_2, pi_o_4, SET_HIGH_WORD, tiny, and zero.

51 {
52  double z;
53  int32_t k,m,hx,hy,ix,iy;
54  u_int32_t lx,ly;
55 
56  EXTRACT_WORDS(hx,lx,x);
57  ix = hx&0x7fffffff;
58  EXTRACT_WORDS(hy,ly,y);
59  iy = hy&0x7fffffff;
60  if(((ix|((lx|-(int32_t)lx)>>31))>0x7ff00000)||
61  ((iy|((ly|-(int32_t)ly)>>31))>0x7ff00000)) /* x or y is NaN */
62  return x+y;
63  if(((hx-0x3ff00000)|lx)==0) return atan(y); /* x=1.0 */
64  m = ((hy>>31)&1)|((hx>>30)&2); /* 2*sign(x)+sign(y) */
65 
66  /* when y = 0 */
67  if((iy|ly)==0) {
68  switch(m) {
69  case 0:
70  case 1: return y; /* atan(+-0,+anything)=+-0 */
71  case 2: return pi+tiny;/* atan(+0,-anything) = pi */
72  case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */
73  }
74  }
75  /* when x = 0 */
76  if((ix|lx)==0) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny;
77 
78  /* when x is INF */
79  if(ix==0x7ff00000) {
80  if(iy==0x7ff00000) {
81  switch(m) {
82  case 0: return pi_o_4+tiny;/* atan(+INF,+INF) */
83  case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */
84  case 2: return 3.0*pi_o_4+tiny;/* atan(+INF,-INF) */
85  case 3: return -3.0*pi_o_4-tiny;/* atan(-INF,-INF) */
86  }
87  } else {
88  switch(m) {
89  case 0: return zero ; /* atan(+...,+INF) */
90  case 1: return -zero ; /* atan(-...,+INF) */
91  case 2: return pi+tiny ; /* atan(+...,-INF) */
92  case 3: return -pi-tiny ; /* atan(-...,-INF) */
93  }
94  }
95  }
96  /* when y is INF */
97  if(iy==0x7ff00000) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny;
98 
99  /* compute y/x */
100  k = (iy-ix)>>20;
101  if(k > 60) z=pi_o_2+0.5*pi_lo; /* |y/x| > 2**60 */
102  else if(hx<0&&k<-60) z=0.0; /* |y|/x < -2**60 */
103  else z=atan(fabs(y/x)); /* safe to do y/x */
104  switch (m) {
105  case 0: return z ; /* atan(+,+) */
106  case 1: {
107  u_int32_t zh;
108  GET_HIGH_WORD(zh,z);
109  SET_HIGH_WORD(z,zh ^ 0x80000000);
110  }
111  return z ; /* atan(-,+) */
112  case 2: return pi-(z-pi_lo);/* atan(+,-) */
113  default: /* case 3 */
114  return (z-pi_lo)-pi;/* atan(-,-) */
115  }
116 }
#define GET_HIGH_WORD(i, d)
Definition: math_private.h:103
static const double pi
Definition: e_atan2.c:47
static const double tiny
Definition: e_atan2.c:43
signed int int32_t
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
const GLfloat * m
static const double pi_o_4
Definition: e_atan2.c:45
#define SET_HIGH_WORD(d, v)
Definition: math_private.h:131
static const double pi_lo
Definition: e_atan2.c:48
static const double zero
Definition: e_atan2.c:44
unsigned int u_int32_t
Definition: math_private.h:29
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
#define EXTRACT_WORDS(ix0, ix1, d)
Definition: math_private.h:93
static const double pi_o_2
Definition: e_atan2.c:46
#define fabs
Definition: math_private.h:36
GLdouble GLdouble z
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHints Display Colormap XColor int return char int XTextProperty return XFontStruct _Xconst char int int int int XCharStruct return Display Window return Display Time return Display Colormap return Display Window Window int int unsigned int unsigned int int int return Display Window int return XExtensionInfo Display char XExtensionHooks int XPointer return XExtensionInfo XExtensionInfo Display return Display return Display unsigned long Display GC Display char long Display xReply int Bool return Display Bool return Display int SDL_X11_XESetEventToWireRetType return Display Window Window Window Window unsigned int return Display XShmSegmentInfo return Display Drawable GC XImage int int int int unsigned int unsigned int Boo k)
Definition: SDL_x11sym.h:211
double atan(double x)
Definition: s_atan.c:67

◆ __ieee754_atanh()

double __ieee754_atanh ( double  )

◆ __ieee754_cosh()

double __ieee754_cosh ( double  )

◆ __ieee754_exp()

double __ieee754_exp ( double  )

◆ __ieee754_fmod()

double __ieee754_fmod ( double  ,
double   
)

◆ __ieee754_gamma()

double __ieee754_gamma ( double  )

◆ __ieee754_gamma_r()

double __ieee754_gamma_r ( double  ,
int *   
)

◆ __ieee754_hypot()

double __ieee754_hypot ( double  ,
double   
)

◆ __ieee754_j0()

double __ieee754_j0 ( double  )

◆ __ieee754_j1()

double __ieee754_j1 ( double  )

◆ __ieee754_jn()

double __ieee754_jn ( int  ,
double   
)

◆ __ieee754_lgamma()

double __ieee754_lgamma ( double  )

◆ __ieee754_lgamma_r()

double __ieee754_lgamma_r ( double  ,
int *   
)

◆ __ieee754_log()

double __ieee754_log ( double  )

Definition at line 99 of file e_log.c.

References EXTRACT_WORDS, GET_HIGH_WORD, i, j, k, Lg1, Lg2, Lg3, Lg4, Lg5, Lg6, Lg7, ln2_hi, ln2_lo, SET_HIGH_WORD, two54, and zero.

102 {
103  double hfsq, f, s, z, R, w, t1, t2, dk;
104  int32_t k, hx, i, j;
105  u_int32_t lx;
106 
107  EXTRACT_WORDS(hx, lx, x);
108 
109  k = 0;
110  if (hx < 0x00100000) { /* x < 2**-1022 */
111  if (((hx & 0x7fffffff) | lx) == 0)
112  return -two54 / zero; /* log(+-0)=-inf */
113  if (hx < 0)
114  return (x - x) / zero; /* log(-#) = NaN */
115  k -= 54;
116  x *= two54; /* subnormal number, scale up x */
117  GET_HIGH_WORD(hx, x);
118  }
119  if (hx >= 0x7ff00000)
120  return x + x;
121  k += (hx >> 20) - 1023;
122  hx &= 0x000fffff;
123  i = (hx + 0x95f64) & 0x100000;
124  SET_HIGH_WORD(x, hx | (i ^ 0x3ff00000)); /* normalize x or x/2 */
125  k += (i >> 20);
126  f = x - 1.0;
127  if ((0x000fffff & (2 + hx)) < 3) { /* |f| < 2**-20 */
128  if (f == zero) {
129  if (k == 0)
130  return zero;
131  else {
132  dk = (double) k;
133  return dk * ln2_hi + dk * ln2_lo;
134  }
135  }
136  R = f * f * (0.5 - 0.33333333333333333 * f);
137  if (k == 0)
138  return f - R;
139  else {
140  dk = (double) k;
141  return dk * ln2_hi - ((R - dk * ln2_lo) - f);
142  }
143  }
144  s = f / (2.0 + f);
145  dk = (double) k;
146  z = s * s;
147  i = hx - 0x6147a;
148  w = z * z;
149  j = 0x6b851 - hx;
150  t1 = w * (Lg2 + w * (Lg4 + w * Lg6));
151  t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));
152  i |= j;
153  R = t2 + t1;
154  if (i > 0) {
155  hfsq = 0.5 * f * f;
156  if (k == 0)
157  return f - (hfsq - s * (hfsq + R));
158  else
159  return dk * ln2_hi - ((hfsq - (s * (hfsq + R) + dk * ln2_lo)) -
160  f);
161  } else {
162  if (k == 0)
163  return f - s * (f - R);
164  else
165  return dk * ln2_hi - ((s * (f - R) - dk * ln2_lo) - f);
166  }
167 }
#define GET_HIGH_WORD(i, d)
Definition: math_private.h:103
static double zero
Definition: e_log.c:91
GLdouble s
Definition: SDL_opengl.h:2056
signed int int32_t
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
static double Lg1
Definition: e_log.c:80
static double ln2_lo
Definition: e_log.c:78
GLfloat f
static double Lg6
Definition: e_log.c:85
#define SET_HIGH_WORD(d, v)
Definition: math_private.h:131
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
unsigned int u_int32_t
Definition: math_private.h:29
#define EXTRACT_WORDS(ix0, ix1, d)
Definition: math_private.h:93
static double Lg5
Definition: e_log.c:84
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
Definition: SDL_x11sym.h:50
static double Lg4
Definition: e_log.c:83
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
GLdouble GLdouble z
static double Lg3
Definition: e_log.c:82
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHints Display Colormap XColor int return char int XTextProperty return XFontStruct _Xconst char int int int int XCharStruct return Display Window return Display Time return Display Colormap return Display Window Window int int unsigned int unsigned int int int return Display Window int return XExtensionInfo Display char XExtensionHooks int XPointer return XExtensionInfo XExtensionInfo Display return Display return Display unsigned long Display GC Display char long Display xReply int Bool return Display Bool return Display int SDL_X11_XESetEventToWireRetType return Display Window Window Window Window unsigned int return Display XShmSegmentInfo return Display Drawable GC XImage int int int int unsigned int unsigned int Boo k)
Definition: SDL_x11sym.h:211
static double Lg7
Definition: e_log.c:86
static double two54
Definition: e_log.c:79
GLubyte GLubyte GLubyte GLubyte w
static double Lg2
Definition: e_log.c:81
static double ln2_hi
Definition: e_log.c:77

◆ __ieee754_log10()

double __ieee754_log10 ( double  )

◆ __ieee754_pow()

double __ieee754_pow ( double  ,
double   
)

Definition at line 106 of file e_pow.c.

References __ieee754_sqrt, cp, cp_h, cp_l, dp_h, dp_l, EXTRACT_WORDS, fabs, GET_HIGH_WORD, huge_val, i, ivln2, ivln2_h, ivln2_l, j, k, L1, L2, L3, L4, L5, L6, lg2, lg2_h, lg2_l, one, ovt, P1, P2, P3, P4, P5, scalbn, SET_HIGH_WORD, SET_LOW_WORD, tiny, two, two53, and zero.

109  {
110  double z, ax, z_h, z_l, p_h, p_l;
111  double y1, t1, t2, r, s, t, u, v, w;
112  int32_t i, j, k, yisint, n;
113  int32_t hx, hy, ix, iy;
114  u_int32_t lx, ly;
115 
116  EXTRACT_WORDS(hx, lx, x);
117  EXTRACT_WORDS(hy, ly, y);
118  ix = hx & 0x7fffffff;
119  iy = hy & 0x7fffffff;
120 
121  /* y==zero: x**0 = 1 */
122  if ((iy | ly) == 0)
123  return one;
124 
125  /* +-NaN return x+y */
126  if (ix > 0x7ff00000 || ((ix == 0x7ff00000) && (lx != 0)) ||
127  iy > 0x7ff00000 || ((iy == 0x7ff00000) && (ly != 0)))
128  return x + y;
129 
130  /* determine if y is an odd int when x < 0
131  * yisint = 0 ... y is not an integer
132  * yisint = 1 ... y is an odd int
133  * yisint = 2 ... y is an even int
134  */
135  yisint = 0;
136  if (hx < 0) {
137  if (iy >= 0x43400000)
138  yisint = 2; /* even integer y */
139  else if (iy >= 0x3ff00000) {
140  k = (iy >> 20) - 0x3ff; /* exponent */
141  if (k > 20) {
142  j = ly >> (52 - k);
143  if ((j << (52 - k)) == ly)
144  yisint = 2 - (j & 1);
145  } else if (ly == 0) {
146  j = iy >> (20 - k);
147  if ((j << (20 - k)) == iy)
148  yisint = 2 - (j & 1);
149  }
150  }
151  }
152 
153  /* special value of y */
154  if (ly == 0) {
155  if (iy == 0x7ff00000) { /* y is +-inf */
156  if (((ix - 0x3ff00000) | lx) == 0)
157  return y - y; /* inf**+-1 is NaN */
158  else if (ix >= 0x3ff00000) /* (|x|>1)**+-inf = inf,0 */
159  return (hy >= 0) ? y : zero;
160  else /* (|x|<1)**-,+inf = inf,0 */
161  return (hy < 0) ? -y : zero;
162  }
163  if (iy == 0x3ff00000) { /* y is +-1 */
164  if (hy < 0)
165  return one / x;
166  else
167  return x;
168  }
169  if (hy == 0x40000000)
170  return x * x; /* y is 2 */
171  if (hy == 0x3fe00000) { /* y is 0.5 */
172  if (hx >= 0) /* x >= +0 */
173  return __ieee754_sqrt(x);
174  }
175  }
176 
177  ax = fabs(x);
178  /* special value of x */
179  if (lx == 0) {
180  if (ix == 0x7ff00000 || ix == 0 || ix == 0x3ff00000) {
181  z = ax; /* x is +-0,+-inf,+-1 */
182  if (hy < 0)
183  z = one / z; /* z = (1/|x|) */
184  if (hx < 0) {
185  if (((ix - 0x3ff00000) | yisint) == 0) {
186  z = (z - z) / (z - z); /* (-1)**non-int is NaN */
187  } else if (yisint == 1)
188  z = -z; /* (x<0)**odd = -(|x|**odd) */
189  }
190  return z;
191  }
192  }
193 
194  /* (x<0)**(non-int) is NaN */
195  if (((((u_int32_t) hx >> 31) - 1) | yisint) == 0)
196  return (x - x) / (x - x);
197 
198  /* |y| is huge */
199  if (iy > 0x41e00000) { /* if |y| > 2**31 */
200  if (iy > 0x43f00000) { /* if |y| > 2**64, must o/uflow */
201  if (ix <= 0x3fefffff)
202  return (hy < 0) ? huge_val * huge_val : tiny * tiny;
203  if (ix >= 0x3ff00000)
204  return (hy > 0) ? huge_val * huge_val : tiny * tiny;
205  }
206  /* over/underflow if x is not close to one */
207  if (ix < 0x3fefffff)
208  return (hy < 0) ? huge_val * huge_val : tiny * tiny;
209  if (ix > 0x3ff00000)
210  return (hy > 0) ? huge_val * huge_val : tiny * tiny;
211  /* now |1-x| is tiny <= 2**-20, suffice to compute
212  log(x) by x-x^2/2+x^3/3-x^4/4 */
213  t = x - 1; /* t has 20 trailing zeros */
214  w = (t * t) * (0.5 - t * (0.3333333333333333333333 - t * 0.25));
215  u = ivln2_h * t; /* ivln2_h has 21 sig. bits */
216  v = t * ivln2_l - w * ivln2;
217  t1 = u + v;
218  SET_LOW_WORD(t1, 0);
219  t2 = v - (t1 - u);
220  } else {
221  double s2, s_h, s_l, t_h, t_l;
222  n = 0;
223  /* take care subnormal number */
224  if (ix < 0x00100000) {
225  ax *= two53;
226  n -= 53;
227  GET_HIGH_WORD(ix, ax);
228  }
229  n += ((ix) >> 20) - 0x3ff;
230  j = ix & 0x000fffff;
231  /* determine interval */
232  ix = j | 0x3ff00000; /* normalize ix */
233  if (j <= 0x3988E)
234  k = 0; /* |x|<sqrt(3/2) */
235  else if (j < 0xBB67A)
236  k = 1; /* |x|<sqrt(3) */
237  else {
238  k = 0;
239  n += 1;
240  ix -= 0x00100000;
241  }
242  SET_HIGH_WORD(ax, ix);
243 
244  /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
245  u = ax - bp[k]; /* bp[0]=1.0, bp[1]=1.5 */
246  v = one / (ax + bp[k]);
247  s = u * v;
248  s_h = s;
249  SET_LOW_WORD(s_h, 0);
250  /* t_h=ax+bp[k] High */
251  t_h = zero;
252  SET_HIGH_WORD(t_h,
253  ((ix >> 1) | 0x20000000) + 0x00080000 + (k << 18));
254  t_l = ax - (t_h - bp[k]);
255  s_l = v * ((u - s_h * t_h) - s_h * t_l);
256  /* compute log(ax) */
257  s2 = s * s;
258  r = s2 * s2 * (L1 +
259  s2 * (L2 +
260  s2 * (L3 +
261  s2 * (L4 + s2 * (L5 + s2 * L6)))));
262  r += s_l * (s_h + s);
263  s2 = s_h * s_h;
264  t_h = 3.0 + s2 + r;
265  SET_LOW_WORD(t_h, 0);
266  t_l = r - ((t_h - 3.0) - s2);
267  /* u+v = s*(1+...) */
268  u = s_h * t_h;
269  v = s_l * t_h + t_l * s;
270  /* 2/(3log2)*(s+...) */
271  p_h = u + v;
272  SET_LOW_WORD(p_h, 0);
273  p_l = v - (p_h - u);
274  z_h = cp_h * p_h; /* cp_h+cp_l = 2/(3*log2) */
275  z_l = cp_l * p_h + p_l * cp + dp_l[k];
276  /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
277  t = (double) n;
278  t1 = (((z_h + z_l) + dp_h[k]) + t);
279  SET_LOW_WORD(t1, 0);
280  t2 = z_l - (((t1 - t) - dp_h[k]) - z_h);
281  }
282 
283  s = one; /* s (sign of result -ve**odd) = -1 else = 1 */
284  if (((((u_int32_t) hx >> 31) - 1) | (yisint - 1)) == 0)
285  s = -one; /* (-ve)**(odd int) */
286 
287  /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
288  y1 = y;
289  SET_LOW_WORD(y1, 0);
290  p_l = (y - y1) * t1 + y * t2;
291  p_h = y1 * t1;
292  z = p_l + p_h;
293  EXTRACT_WORDS(j, i, z);
294  if (j >= 0x40900000) { /* z >= 1024 */
295  if (((j - 0x40900000) | i) != 0) /* if z > 1024 */
296  return s * huge_val * huge_val; /* overflow */
297  else {
298  if (p_l + ovt > z - p_h)
299  return s * huge_val * huge_val; /* overflow */
300  }
301  } else if ((j & 0x7fffffff) >= 0x4090cc00) { /* z <= -1075 */
302  if (((j - 0xc090cc00) | i) != 0) /* z < -1075 */
303  return s * tiny * tiny; /* underflow */
304  else {
305  if (p_l <= z - p_h)
306  return s * tiny * tiny; /* underflow */
307  }
308  }
309  /*
310  * compute 2**(p_h+p_l)
311  */
312  i = j & 0x7fffffff;
313  k = (i >> 20) - 0x3ff;
314  n = 0;
315  if (i > 0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */
316  n = j + (0x00100000 >> (k + 1));
317  k = ((n & 0x7fffffff) >> 20) - 0x3ff; /* new k for n */
318  t = zero;
319  SET_HIGH_WORD(t, n & ~(0x000fffff >> k));
320  n = ((n & 0x000fffff) | 0x00100000) >> (20 - k);
321  if (j < 0)
322  n = -n;
323  p_h -= t;
324  }
325  t = p_l + p_h;
326  SET_LOW_WORD(t, 0);
327  u = t * lg2_h;
328  v = (p_l - (t - p_h)) * lg2 + t * lg2_l;
329  z = u + v;
330  w = v - (z - u);
331  t = z * z;
332  t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));
333  r = (z * t1) / (t1 - two) - (w + z * w);
334  z = one - (r - z);
335  GET_HIGH_WORD(j, z);
336  j += (n << 20);
337  if ((j >> 20) <= 0)
338  z = scalbn(z, n); /* subnormal output */
339  else
340  SET_HIGH_WORD(z, j);
341  return s * z;
342  }
#define GET_HIGH_WORD(i, d)
Definition: math_private.h:103
ovt
Definition: e_pow.c:95
one
Definition: e_pow.c:78
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
GLdouble s
Definition: SDL_opengl.h:2056
ivln2_l
Definition: e_pow.c:101
GLdouble n
signed int int32_t
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
tiny
Definition: e_pow.c:79
two
Definition: e_pow.c:78
cp_l
Definition: e_pow.c:98
P3
Definition: e_pow.c:89
#define __ieee754_sqrt
Definition: math_private.h:42
lg2
Definition: e_pow.c:92
#define SET_HIGH_WORD(d, v)
Definition: math_private.h:131
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
#define scalbn
Definition: math_private.h:40
GLfixed y1
const GLdouble * v
Definition: SDL_opengl.h:2057
P2
Definition: e_pow.c:88
dp_l[]
Definition: e_pow.c:75
unsigned int u_int32_t
Definition: math_private.h:29
ivln2
Definition: e_pow.c:99
cp
Definition: e_pow.c:96
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
#define SET_LOW_WORD(d, v)
Definition: math_private.h:141
#define EXTRACT_WORDS(ix0, ix1, d)
Definition: math_private.h:93
L3
Definition: e_pow.c:83
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
Definition: SDL_x11sym.h:50
P5
Definition: e_pow.c:91
lg2_h
Definition: e_pow.c:93
P4
Definition: e_pow.c:90
#define fabs
Definition: math_private.h:36
L6
Definition: e_pow.c:86
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
ivln2_h
Definition: e_pow.c:100
GLdouble GLdouble z
L5
Definition: e_pow.c:85
lg2_l
Definition: e_pow.c:94
P1
Definition: e_pow.c:87
dp_h[]
Definition: e_pow.c:72
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display Atom return Display Window XWindowAttributes return Display Window return Display XEvent Bool(*) XPointer return Display Window Bool unsigned int int int Window Cursor Time return Display Window int return KeySym return Display _Xconst char Bool return Display _Xconst char return XKeyEvent char int KeySym XComposeStatus return Display int int int XVisualInfo return Display Window int int return _Xconst char return Display XEvent return Display Drawable GC XImage int int int int unsigned int unsigned int return Display Window Window Window int int int int unsigned int return Display Window Window int int return Display Window unsigned int unsigned int return Display Window Bool long XEvent return Display GC unsigned long return Display Window int Time return Display Window Window return Display Window unsigned long return Display Window XSizeHints Display Colormap XColor int return char int XTextProperty return XFontStruct _Xconst char int int int int XCharStruct return Display Window return Display Time return Display Colormap return Display Window Window int int unsigned int unsigned int int int return Display Window int return XExtensionInfo Display char XExtensionHooks int XPointer return XExtensionInfo XExtensionInfo Display return Display return Display unsigned long Display GC Display char long Display xReply int Bool return Display Bool return Display int SDL_X11_XESetEventToWireRetType return Display Window Window Window Window unsigned int return Display XShmSegmentInfo return Display Drawable GC XImage int int int int unsigned int unsigned int Boo k)
Definition: SDL_x11sym.h:211
GLubyte GLubyte GLubyte GLubyte w
cp_h
Definition: e_pow.c:97
huge_val
Definition: e_pow.c:79
L4
Definition: e_pow.c:84
zero
Definition: e_pow.c:78
L1
Definition: e_pow.c:81
GLdouble GLdouble t
Definition: SDL_opengl.h:2064
L2
Definition: e_pow.c:82
two53
Definition: e_pow.c:78

◆ __ieee754_rem_pio2()

int __ieee754_rem_pio2 ( double  ,
double *   
)

◆ __ieee754_remainder()

double __ieee754_remainder ( double  ,
double   
)

◆ __ieee754_scalb()

double __ieee754_scalb ( double  ,
double   
)

◆ __ieee754_sinh()

double __ieee754_sinh ( double  )

◆ __ieee754_sqrt()

double __ieee754_sqrt ( double  )

Definition at line 102 of file e_sqrt.c.

References EXTRACT_WORDS, i, INSERT_WORDS, one, and tiny.

105 {
106  double z;
107  int32_t sign = (int) 0x80000000;
108  int32_t ix0, s0, q, m, t, i;
109  u_int32_t r, t1, s1, ix1, q1;
110 
111  EXTRACT_WORDS(ix0, ix1, x);
112 
113  /* take care of Inf and NaN */
114  if ((ix0 & 0x7ff00000) == 0x7ff00000) {
115  return x * x + x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf
116  sqrt(-inf)=sNaN */
117  }
118  /* take care of zero */
119  if (ix0 <= 0) {
120  if (((ix0 & (~sign)) | ix1) == 0)
121  return x; /* sqrt(+-0) = +-0 */
122  else if (ix0 < 0)
123  return (x - x) / (x - x); /* sqrt(-ve) = sNaN */
124  }
125  /* normalize x */
126  m = (ix0 >> 20);
127  if (m == 0) { /* subnormal x */
128  while (ix0 == 0) {
129  m -= 21;
130  ix0 |= (ix1 >> 11);
131  ix1 <<= 21;
132  }
133  for (i = 0; (ix0 & 0x00100000) == 0; i++)
134  ix0 <<= 1;
135  m -= i - 1;
136  ix0 |= (ix1 >> (32 - i));
137  ix1 <<= i;
138  }
139  m -= 1023; /* unbias exponent */
140  ix0 = (ix0 & 0x000fffff) | 0x00100000;
141  if (m & 1) { /* odd m, double x to make it even */
142  ix0 += ix0 + ((ix1 & sign) >> 31);
143  ix1 += ix1;
144  }
145  m >>= 1; /* m = [m/2] */
146 
147  /* generate sqrt(x) bit by bit */
148  ix0 += ix0 + ((ix1 & sign) >> 31);
149  ix1 += ix1;
150  q = q1 = s0 = s1 = 0; /* [q,q1] = sqrt(x) */
151  r = 0x00200000; /* r = moving bit from right to left */
152 
153  while (r != 0) {
154  t = s0 + r;
155  if (t <= ix0) {
156  s0 = t + r;
157  ix0 -= t;
158  q += r;
159  }
160  ix0 += ix0 + ((ix1 & sign) >> 31);
161  ix1 += ix1;
162  r >>= 1;
163  }
164 
165  r = sign;
166  while (r != 0) {
167  t1 = s1 + r;
168  t = s0;
169  if ((t < ix0) || ((t == ix0) && (t1 <= ix1))) {
170  s1 = t1 + r;
171  if (((t1 & sign) == sign) && (s1 & sign) == 0)
172  s0 += 1;
173  ix0 -= t;
174  if (ix1 < t1)
175  ix0 -= 1;
176  ix1 -= t1;
177  q1 += r;
178  }
179  ix0 += ix0 + ((ix1 & sign) >> 31);
180  ix1 += ix1;
181  r >>= 1;
182  }
183 
184  /* use floating add to find out rounding direction */
185  if ((ix0 | ix1) != 0) {
186  z = one - tiny; /* trigger inexact flag */
187  if (z >= one) {
188  z = one + tiny;
189  if (q1 == (u_int32_t) 0xffffffff) {
190  q1 = 0;
191  q += 1;
192  } else if (z > one) {
193  if (q1 == (u_int32_t) 0xfffffffe)
194  q += 1;
195  q1 += 2;
196  } else
197  q1 += (q1 & 1);
198  }
199  }
200  ix0 = (q >> 1) + 0x3fe00000;
201  ix1 = q1 >> 1;
202  if ((q & 1) == 1)
203  ix1 |= sign;
204  ix0 += (m << 20);
205  INSERT_WORDS(z, ix0, ix1);
206  return z;
207 }
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
signed int int32_t
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
GLdouble GLdouble GLdouble GLdouble q
Definition: SDL_opengl.h:2080
const GLfloat * m
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
unsigned int u_int32_t
Definition: math_private.h:29
#define EXTRACT_WORDS(ix0, ix1, d)
Definition: math_private.h:93
#define INSERT_WORDS(d, ix0, ix1)
Definition: math_private.h:121
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s0
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
GLdouble GLdouble z
static double tiny
Definition: e_sqrt.c:94
GLdouble GLdouble t
Definition: SDL_opengl.h:2064
static double one
Definition: e_sqrt.c:94

◆ __ieee754_y0()

double __ieee754_y0 ( double  )

◆ __ieee754_y1()

double __ieee754_y1 ( double  )

◆ __ieee754_yn()

double __ieee754_yn ( int  ,
double   
)

◆ __kernel_cos()

double __kernel_cos ( double  ,
double   
)

Definition at line 74 of file k_cos.c.

References C1, C2, C3, C4, C5, C6, GET_HIGH_WORD, INSERT_WORDS, and one.

Referenced by libm_hidden_proto().

77 {
78  double a, hz, z, r, qx;
79  int32_t ix;
80  GET_HIGH_WORD(ix, x);
81  ix &= 0x7fffffff; /* ix = |x|'s high word */
82  if (ix < 0x3e400000) { /* if x < 2**27 */
83  if (((int) x) == 0)
84  return one; /* generate inexact */
85  }
86  z = x * x;
87  r = z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * C6)))));
88  if (ix < 0x3FD33333) /* if |x| < 0.3 */
89  return one - (0.5 * z - (z * r - x * y));
90  else {
91  if (ix > 0x3fe90000) { /* x > 0.78125 */
92  qx = 0.28125;
93  } else {
94  INSERT_WORDS(qx, ix - 0x00200000, 0); /* x/4 */
95  }
96  hz = 0.5 * z - qx;
97  a = one - qx;
98  return a - (hz - (z * r - x * y));
99  }
100 }
#define GET_HIGH_WORD(i, d)
Definition: math_private.h:103
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
signed int int32_t
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
static double one
Definition: k_cos.c:61
static double C2
Definition: k_cos.c:63
static double C5
Definition: k_cos.c:66
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
static double C4
Definition: k_cos.c:65
#define INSERT_WORDS(d, ix0, ix1)
Definition: math_private.h:121
static double C3
Definition: k_cos.c:64
static double C6
Definition: k_cos.c:67
GLdouble GLdouble z
static double C1
Definition: k_cos.c:62
GLboolean GLboolean GLboolean GLboolean a

◆ __kernel_rem_pio2()

int __kernel_rem_pio2 ( double *  ,
double *  ,
int  ,
int  ,
int  ,
const int *   
)

◆ __kernel_sin()

double __kernel_sin ( double  ,
double  ,
int   
)

Definition at line 67 of file k_sin.c.

References GET_HIGH_WORD, half, S1, S2, S3, S4, S5, and S6.

Referenced by libm_hidden_proto().

71 {
72  double z, r, v;
73  int32_t ix;
74  GET_HIGH_WORD(ix, x);
75  ix &= 0x7fffffff; /* high word of x */
76  if (ix < 0x3e400000) { /* |x| < 2**-27 */
77  if ((int) x == 0)
78  return x;
79  } /* generate inexact */
80  z = x * x;
81  v = z * x;
82  r = S2 + z * (S3 + z * (S4 + z * (S5 + z * S6)));
83  if (iy == 0)
84  return x + v * (S1 + z * r);
85  else
86  return x - ((z * (half * y - v * r) - y) - v * S1);
87 }
#define GET_HIGH_WORD(i, d)
Definition: math_private.h:103
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
static double S3
Definition: k_sin.c:57
signed int int32_t
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
static double S1
Definition: k_sin.c:55
const GLdouble * v
Definition: SDL_opengl.h:2057
static double S4
Definition: k_sin.c:58
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
static double S6
Definition: k_sin.c:60
GLdouble GLdouble z
static double half
Definition: k_sin.c:54
static double S5
Definition: k_sin.c:59
static double S2
Definition: k_sin.c:56

◆ __kernel_standard()

double __kernel_standard ( double  ,
double  ,
int   
)

◆ __kernel_tan()

double __kernel_tan ( double  ,
double  ,
int   
)

Definition at line 69 of file k_tan.c.

References fabs, GET_HIGH_WORD, GET_LOW_WORD, one, pio4, pio4lo, SET_LOW_WORD, and T.

Referenced by tan().

70 {
71  double z,r,v,w,s;
72  int32_t ix,hx;
73  GET_HIGH_WORD(hx,x);
74  ix = hx&0x7fffffff; /* high word of |x| */
75  if(ix<0x3e300000) /* x < 2**-28 */
76  {if((int)x==0) { /* generate inexact */
77  u_int32_t low;
78  GET_LOW_WORD(low,x);
79  if(((ix|low)|(iy+1))==0) return one/fabs(x);
80  else return (iy==1)? x: -one/x;
81  }
82  }
83  if(ix>=0x3FE59428) { /* |x|>=0.6744 */
84  if(hx<0) {x = -x; y = -y;}
85  z = pio4-x;
86  w = pio4lo-y;
87  x = z+w; y = 0.0;
88  }
89  z = x*x;
90  w = z*z;
91  /* Break x^5*(T[1]+x^2*T[2]+...) into
92  * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) +
93  * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12]))
94  */
95  r = T[1]+w*(T[3]+w*(T[5]+w*(T[7]+w*(T[9]+w*T[11]))));
96  v = z*(T[2]+w*(T[4]+w*(T[6]+w*(T[8]+w*(T[10]+w*T[12])))));
97  s = z*x;
98  r = y + z*(s*(r+v)+y);
99  r += T[0]*s;
100  w = x+r;
101  if(ix>=0x3FE59428) {
102  v = (double)iy;
103  return (double)(1-((hx>>30)&2))*(v-2.0*(x-(w*w/(w+v)-r)));
104  }
105  if(iy==1) return w;
106  else { /* if allow error up to 2 ulp,
107  simply return -1.0/(x+r) here */
108  /* compute -1.0/(x+r) accurately */
109  double a,t;
110  z = w;
111  SET_LOW_WORD(z,0);
112  v = r-(z - x); /* z+v = r+x */
113  t = a = -1.0/w; /* a = -1.0/w */
114  SET_LOW_WORD(t,0);
115  s = 1.0+t*z;
116  return t+a*(s+t*v);
117  }
118 }
#define GET_HIGH_WORD(i, d)
Definition: math_private.h:103
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2072
GLdouble s
Definition: SDL_opengl.h:2056
static const double pio4lo
Definition: k_tan.c:52
signed int int32_t
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
static const double T[]
Definition: k_tan.c:53
const GLdouble * v
Definition: SDL_opengl.h:2057
unsigned int u_int32_t
Definition: math_private.h:29
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
#define SET_LOW_WORD(d, v)
Definition: math_private.h:141
#define fabs
Definition: math_private.h:36
GLdouble GLdouble z
#define GET_LOW_WORD(i, d)
Definition: math_private.h:112
static const double pio4
Definition: k_tan.c:51
GLubyte GLubyte GLubyte GLubyte w
static const double one
Definition: k_tan.c:50
GLboolean GLboolean GLboolean GLboolean a
GLdouble GLdouble t
Definition: SDL_opengl.h:2064