ReactOS 0.4.15-dev-8349-g6f277e9
atan.c File Reference
#include "libm.h"
#include "libm_util.h"
#include "libm_inlines.h"
#include "libm_errno.h"
Include dependency graph for atan.c:

Go to the source code of this file.

Macros

#define USE_VAL_WITH_FLAGS
 
#define USE_NAN_WITH_FLAGS
 
#define USE_HANDLE_ERROR
 

Functions

double FN_PROTOTYPE() atan (double x)
 

Macro Definition Documentation

◆ USE_HANDLE_ERROR

#define USE_HANDLE_ERROR

Definition at line 32 of file atan.c.

◆ USE_NAN_WITH_FLAGS

#define USE_NAN_WITH_FLAGS

Definition at line 31 of file atan.c.

◆ USE_VAL_WITH_FLAGS

#define USE_VAL_WITH_FLAGS

Definition at line 30 of file atan.c.

Function Documentation

◆ atan()

double FN_PROTOTYPE() atan ( double  x)

Definition at line 44 of file atan.c.

45{
46
47 /* Some constants and split constants. */
48
49 static double piby2 = 1.5707963267948966e+00; /* 0x3ff921fb54442d18 */
50 double chi, clo, v, s, q, z;
51
52 /* Find properties of argument x. */
53
54 unsigned long long ux, aux, xneg;
55 GET_BITS_DP64(x, ux);
56 aux = ux & ~SIGNBIT_DP64;
57 xneg = (ux != aux);
58
59 if (xneg) v = -x;
60 else v = x;
61
62 /* Argument reduction to range [-7/16,7/16] */
63
64 if (aux > 0x4003800000000000) /* v > 39./16. */
65 {
66
68 {
69 /* x is NaN */
70 return _handle_error("atan", OP_ATAN, ux|0x0008000000000000, _DOMAIN, 0,
71 EDOM, x, 0.0, 1);
72 }
73 else if (v > 0x4370000000000000)
74 { /* abs(x) > 2^56 => arctan(1/x) is
75 insignificant compared to piby2 */
76 if (xneg)
77 return val_with_flags(-piby2, AMD_F_INEXACT);
78 else
79 return val_with_flags(piby2, AMD_F_INEXACT);
80 }
81
82 x = -1.0/v;
83 /* (chi + clo) = arctan(infinity) */
84 chi = 1.57079632679489655800e+00; /* 0x3ff921fb54442d18 */
85 clo = 6.12323399573676480327e-17; /* 0x3c91a62633145c06 */
86 }
87 else if (aux > 0x3ff3000000000000) /* 39./16. > v > 19./16. */
88 {
89 x = (v-1.5)/(1.0+1.5*v);
90 /* (chi + clo) = arctan(1.5) */
91 chi = 9.82793723247329054082e-01; /* 0x3fef730bd281f69b */
92 clo = 1.39033110312309953701e-17; /* 0x3c7007887af0cbbc */
93 }
94 else if (aux > 0x3fe6000000000000) /* 19./16. > v > 11./16. */
95 {
96 x = (v-1.0)/(1.0+v);
97 /* (chi + clo) = arctan(1.) */
98 chi = 7.85398163397448278999e-01; /* 0x3fe921fb54442d18 */
99 clo = 3.06161699786838240164e-17; /* 0x3c81a62633145c06 */
100 }
101 else if (aux > 0x3fdc000000000000) /* 11./16. > v > 7./16. */
102 {
103 x = (2.0*v-1.0)/(2.0+v);
104 /* (chi + clo) = arctan(0.5) */
105 chi = 4.63647609000806093515e-01; /* 0x3fddac670561bb4f */
106 clo = 2.26987774529616809294e-17; /* 0x3c7a2b7f222f65e0 */
107 }
108 else /* v < 7./16. */
109 {
110 x = v;
111 chi = 0.0;
112 clo = 0.0;
113 }
114
115 /* Core approximation: Remez(4,4) on [-7/16,7/16] */
116
117 s = x*x;
118 q = x*s*
119 (0.268297920532545909e0 +
120 (0.447677206805497472e0 +
121 (0.220638780716667420e0 +
122 (0.304455919504853031e-1 +
123 0.142316903342317766e-3*s)*s)*s)*s)/
124 (0.804893761597637733e0 +
125 (0.182596787737507063e1 +
126 (0.141254259931958921e1 +
127 (0.424602594203847109e0 +
128 0.389525873944742195e-1*s)*s)*s)*s);
129
130 z = chi - ((q - clo) - x);
131
132 if (xneg) z = -z;
133 return z;
134}
double __cdecl _handle_error(char *fname, int opcode, unsigned long long value, int type, int flags, int error, double arg1, double arg2, int nargs)
Handles an error condition.
Definition: _handle_error.c:34
#define EDOM
Definition: errno.h:39
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
const GLdouble * v
Definition: gl.h:2040
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLdouble GLdouble z
Definition: glext.h:5874
#define _DOMAIN
Definition: math.h:39
#define AMD_F_INEXACT
Definition: libm_new.h:82
#define GET_BITS_DP64(x, ux)
Definition: libm_util.h:118
#define PINFBITPATT_DP64
Definition: libm_util.h:53
static const WCHAR aux[]