00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 static char *rcs_id = "$Source: /proj/osprey/CVS/open64/osprey1.0/libm/mips/asinf.c,v $ $Revision: 1.1.1.1 $";
00060
00061 #ifdef _CALL_MATHERR
00062 #include <stdio.h>
00063 #include <math.h>
00064 #include <errno.h>
00065 #endif
00066
00067 #include "libm.h"
00068
00069 #if defined(mips) && !defined(__GNUC__)
00070 extern float fasin(float);
00071 extern float asinf(float);
00072
00073 #pragma weak fasin = __asinf
00074 #pragma weak asinf = __asinf
00075 #endif
00076
00077 #if defined(BUILD_OS_DARWIN)
00078 extern float __asinf(float);
00079 #pragma weak asinf
00080 float asinf( float x ) {
00081 return __asinf( x );
00082 }
00083 #elif defined(__GNUC__)
00084 extern float __asinf(float);
00085 float asinf(float) __attribute__ ((weak, alias ("__asinf")));
00086 #endif
00087
00088
00089
00090 static const du P[] =
00091 {
00092 {D(0x3ff00000, 0x00000000)},
00093 {D(0x3fc5555c, 0x88342cb0)},
00094 {D(0x3fb3301e, 0x4681bb77)},
00095 {D(0x3fa747e4, 0xa38c190b)},
00096 {D(0x3f98c283, 0xc04a0db6)},
00097 {D(0x3fa596d2, 0x8a9d07d2)},
00098 };
00099
00100
00101
00102 static const du P2[] =
00103 {
00104 {D(0x3ff00000, 0x00000000)},
00105 {D(0x3fc55564, 0xfd6bdcbc)},
00106 {D(0x3fb32843, 0xb5c74590)},
00107 {D(0x3fa90146, 0xd5d24e0c)},
00108 };
00109
00110 static const du one =
00111 {D(0x3ff00000, 0x00000000)};
00112
00113 static const du piby4 =
00114 {D(0x3fe921fb, 0x54442d18)};
00115
00116 static const du piby2 =
00117 {D(0x3ff921fb, 0x54442d18)};
00118
00119 static const fu Qnan = {QNANF};
00120
00121 static const fu f_half = {0x3f000000};
00122
00123 static const fu f_one = {0x3f800000};
00124
00125 static const fu f_m_one = {0xbf800000};
00126
00127 static const fu f_piby2 = {0x3fc90fdb};
00128
00129 static const fu f_m_piby2 = {0xbfc90fdb};
00130
00131 static const fu f_root3by2 = {0x3f5db3d7};
00132
00133 #ifndef _HDW_SQRT
00134
00135 #define MAGIC 0x5fe6eb3b
00136
00137 #endif
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 float
00150 __asinf( float x )
00151 {
00152 int n;
00153 float absx;
00154 double dx, xsq, poly;
00155 double y, ysq;
00156 double w;
00157 double q, Q;
00158 double ysqby2;
00159 float result;
00160 int ix, iabsx, xpt;
00161 #ifdef _CALL_MATHERR
00162 struct exception exstruct;
00163 #endif
00164
00165 FLT2INT(x, ix);
00166 iabsx = (ix & 0x7fffffff);
00167 xpt = (iabsx >> MANTWIDTH);
00168
00169 if ( xpt < 0x7e )
00170 {
00171
00172
00173 dx = x;
00174
00175 if ( xpt >= 0x73 )
00176 {
00177
00178
00179 xsq = dx*dx;
00180
00181 poly = ((((P[5].d*xsq + P[4].d)*xsq + P[3].d)*xsq +
00182 P[2].d)*xsq + P[1].d)*(xsq*dx) + dx;
00183
00184 return ( (float)poly );
00185 }
00186
00187 return ( x );
00188 }
00189
00190 if ( xpt < 0x7f )
00191 {
00192
00193
00194 absx = fabsf(x);
00195
00196 if ( absx < f_root3by2.f )
00197 {
00198
00199
00200 dx = x;
00201
00202 xsq = dx*dx;
00203 y = xsq + xsq - one.d;
00204 ysq = y*y;
00205
00206 poly = ((((P[5].d*ysq + P[4].d)*ysq + P[3].d)*ysq +
00207 P[2].d)*ysq + P[1].d);
00208
00209 poly = y + (y*ysq)*poly;
00210
00211 result = piby4.d + 0.5*poly;
00212
00213 if ( x < (float)0.0 )
00214 result = -result;
00215
00216 return ( result );
00217 }
00218
00219 ysq = f_half.f*(f_one.f - absx);
00220
00221 #ifdef _HDW_SQRT
00222
00223 y = sqrt(ysq);
00224 #else
00225
00226
00227
00228
00229
00230
00231
00232
00233 y = 0.0;
00234 DBLHI2INT(ysq, n);
00235 n >>= 1;
00236 n = MAGIC - n;
00237 INT2DBLHI(n, y);
00238 ysqby2 = 0.5*ysq;
00239
00240
00241
00242 y = y*(1.5 - ysqby2*y*y);
00243 y = y*(1.5 - ysqby2*y*y);
00244
00245
00246
00247 q = ysqby2*y;
00248 Q = q + q;
00249 y = Q*(1.5 - q*y);
00250 #endif
00251
00252
00253
00254 poly = ((P2[3].d*ysq + P2[2].d)*ysq + P2[1].d);
00255
00256 w = y + (y*ysq)*poly;
00257
00258
00259
00260 result = piby2.d - (w + w);
00261
00262 if ( x < (float)0.0 )
00263 result = -result;
00264
00265 return ( result );
00266 }
00267
00268 if ( x != x )
00269 {
00270
00271
00272 #ifdef _CALL_MATHERR
00273
00274 exstruct.type = DOMAIN;
00275 exstruct.name = "asinf";
00276 exstruct.arg1 = x;
00277 exstruct.retval = Qnan.f;
00278
00279 if ( matherr( &exstruct ) == 0 )
00280 {
00281 fprintf(stderr, "domain error in asinf\n");
00282 SETERRNO(EDOM);
00283 }
00284
00285 return ( exstruct.retval );
00286 #else
00287 NAN_SETERRNO(EDOM);
00288
00289 return ( Qnan.f );
00290 #endif
00291 }
00292
00293 if ( x == f_one.f )
00294 return ( f_piby2.f );
00295
00296 if ( x == f_m_one.f )
00297 return ( f_m_piby2.f );
00298
00299
00300
00301 #ifdef _CALL_MATHERR
00302
00303 exstruct.type = DOMAIN;
00304 exstruct.name = "asinf";
00305 exstruct.arg1 = x;
00306 exstruct.retval = Qnan.f;
00307
00308 if ( matherr( &exstruct ) == 0 )
00309 {
00310 fprintf(stderr, "domain error in asinf\n");
00311 SETERRNO(EDOM);
00312 }
00313
00314 return ( exstruct.retval );
00315 #else
00316 SETERRNO(EDOM);
00317
00318 return ( Qnan.f );
00319 #endif
00320 }
00321