ReactOS 0.4.15-dev-8100-g1887773
asin.c File Reference
#include "libm.h"
#include "libm_util.h"
#include "libm_inlines.h"
#include "libm_errno.h"
Include dependency graph for asin.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() asin (double x)
 

Macro Definition Documentation

◆ USE_HANDLE_ERROR

#define USE_HANDLE_ERROR

Definition at line 32 of file asin.c.

◆ USE_NAN_WITH_FLAGS

#define USE_NAN_WITH_FLAGS

Definition at line 31 of file asin.c.

◆ USE_VAL_WITH_FLAGS

#define USE_VAL_WITH_FLAGS

Definition at line 30 of file asin.c.

Function Documentation

◆ asin()

double FN_PROTOTYPE() asin ( double  x)

Definition at line 44 of file asin.c.

45{
46 /* Computes arcsin(x).
47 The argument is first reduced by noting that arcsin(x)
48 is invalid for abs(x) > 1 and arcsin(-x) = -arcsin(x).
49 For denormal and small arguments arcsin(x) = x to machine
50 accuracy. Remaining argument ranges are handled as follows.
51 For abs(x) <= 0.5 use
52 arcsin(x) = x + x^3*R(x^2)
53 where R(x^2) is a rational minimax approximation to
54 (arcsin(x) - x)/x^3.
55 For abs(x) > 0.5 exploit the identity:
56 arcsin(x) = pi/2 - 2*arcsin(sqrt(1-x)/2)
57 together with the above rational approximation, and
58 reconstruct the terms carefully.
59 */
60
61 /* Some constants and split constants. */
62
63 static const double
64 piby2_tail = 6.1232339957367660e-17, /* 0x3c91a62633145c07 */
65 hpiby2_head = 7.8539816339744831e-01, /* 0x3fe921fb54442d18 */
66 piby2 = 1.5707963267948965e+00; /* 0x3ff921fb54442d18 */
67 double u, v, y, s=0.0, r;
68 int xexp, xnan, transform=0;
69
70 unsigned long long ux, aux, xneg;
71 GET_BITS_DP64(x, ux);
72 aux = ux & ~SIGNBIT_DP64;
73 xneg = (ux & SIGNBIT_DP64);
74 xnan = (aux > PINFBITPATT_DP64);
75 xexp = (int)((ux & EXPBITS_DP64) >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64;
76
77 /* Special cases */
78
79 if (xnan)
80 {
81 return _handle_error("asin", OP_ASIN, ux|0x0008000000000000, _DOMAIN,
82 0, EDOM, x, 0.0, 1);
83 }
84 else if (xexp < -28)
85 { /* y small enough that arcsin(x) = x */
86 return val_with_flags(x, AMD_F_INEXACT);
87 }
88 else if (xexp >= 0)
89 { /* abs(x) >= 1.0 */
90 if (x == 1.0)
91 return val_with_flags(piby2, AMD_F_INEXACT);
92 else if (x == -1.0)
93 return val_with_flags(-piby2, AMD_F_INEXACT);
94 else
95 return _handle_error("asin", OP_ASIN, INDEFBITPATT_DP64, _DOMAIN,
96 AMD_F_INVALID, EDOM, x, 0.0, 1);
97 }
98
99 if (xneg) y = -x;
100 else y = x;
101
102 transform = (xexp >= -1); /* abs(x) >= 0.5 */
103
104 if (transform)
105 { /* Transform y into the range [0,0.5) */
106 r = 0.5*(1.0 - y);
107 /* VC++ intrinsic call */
109 y = s;
110 }
111 else
112 r = y*y;
113
114 /* Use a rational approximation for [0.0, 0.5] */
115
116 u = r*(0.227485835556935010735943483075 +
117 (-0.445017216867635649900123110649 +
118 (0.275558175256937652532686256258 +
119 (-0.0549989809235685841612020091328 +
120 (0.00109242697235074662306043804220 +
121 0.0000482901920344786991880522822991*r)*r)*r)*r)*r)/
122 (1.36491501334161032038194214209 +
123 (-3.28431505720958658909889444194 +
124 (2.76568859157270989520376345954 +
125 (-0.943639137032492685763471240072 +
126 0.105869422087204370341222318533*r)*r)*r)*r);
127
128 if (transform)
129 { /* Reconstruct asin carefully in transformed region */
130 {
131 double c, s1, p, q;
132 unsigned long long us;
134 PUT_BITS_DP64(0xffffffff00000000 & us, s1);
135 c = (r-s1*s1)/(s+s1);
136 p = 2.0*s*u - (piby2_tail-2.0*c);
137 q = hpiby2_head - 2.0*s1;
138 v = hpiby2_head - (p-q);
139 }
140 }
141 else
142 {
143 /* Use a temporary variable to prevent VC++ rearranging
144 y + y*u
145 into
146 y * (1 + u)
147 and getting an incorrectly rounded result */
148 double tmp;
149 tmp = y * u;
150 v = y + tmp;
151 }
152
153 if (xneg) return -v;
154 else return v;
155}
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
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define EDOM
Definition: errno.h:39
__m128d _mm_setzero_pd(void)
Definition: emmintrin.h:1048
__m128d _mm_sqrt_sd(__m128d a, __m128d b)
Definition: emmintrin.h:611
__m128d _mm_load_sd(double const *dp)
Definition: emmintrin.h:991
void _mm_store_sd(double *dp, __m128d a)
Definition: emmintrin.h:1059
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
const GLdouble * v
Definition: gl.h:2040
GLdouble s
Definition: gl.h:2039
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLuint GLenum GLenum transform
Definition: glext.h:9407
const GLubyte * c
Definition: glext.h:8905
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define _DOMAIN
Definition: math.h:39
#define c
Definition: ke_i.h:80
#define AMD_F_INEXACT
Definition: libm_new.h:82
#define AMD_F_INVALID
Definition: libm_new.h:86
#define INDEFBITPATT_DP64
Definition: libm_util.h:52
#define EXPSHIFTBITS_DP64
Definition: libm_util.h:56
#define GET_BITS_DP64(x, ux)
Definition: libm_util.h:118
#define PINFBITPATT_DP64
Definition: libm_util.h:53
#define SIGNBIT_DP64
Definition: libm_util.h:44
#define EXPBITS_DP64
Definition: libm_util.h:45
#define EXPBIAS_DP64
Definition: libm_util.h:55
#define PUT_BITS_DP64(ux, x)
Definition: libm_util.h:124
static const WCHAR aux[]
struct S1 s1
static const BYTE us[]
Definition: encode.c:689