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: /home/bos/bk/kpro64-pending/libm/SCCS/s.vexpf.c $ $Revision: 1.5 $";
00060
00061 #include "libm.h"
00062
00063
00064
00065
00066
00067
00068
00069 #if defined(mips) && !defined(__GNUC__)
00070 extern void vfexp(float *, float *, long, long, long);
00071 extern void vexpf(float *, float *, long, long, long);
00072
00073 #pragma weak vfexp = __vexpf
00074 #pragma weak vexpf = __vexpf
00075 #endif
00076
00077 #if defined(BUILD_OS_DARWIN)
00078 extern void __vexpf( float *x, float *y, long count, long stridex,
00079 long stridey );
00080 #pragma weak vexpf
00081 void vexpf( float *x, float *y, long count, long stridex, long stridey ) {
00082 __vexpf(x, y, count, stridex, stridey);
00083 }
00084 #elif defined(__GNUC__)
00085 extern void __vexpf(float *, float *, long, long, long);
00086 void vexpf() __attribute__ ((weak, alias ("__vexpf")));
00087 #endif
00088
00089 extern const du __expftab[];
00090
00091
00092
00093 static const du P[] =
00094 {
00095 {D(0x3ff00000, 0x00000000)},
00096 {D(0x3ff00000, 0x00000000)},
00097 {D(0x3fe00008, 0x745da559)},
00098 {D(0x3fc55569, 0x9fd0029e)},
00099 };
00100
00101 static const du rln2by32 =
00102 {D(0x40471547, 0x652b82fe)};
00103
00104 static const du ln2by32hi =
00105 {D(0x3f962e42, 0xfef00000)};
00106
00107 static const du ln2by32lo =
00108 {D(0x3d8473de, 0x6af278ed)};
00109
00110 static const fu Ulimit = {0x42b17218};
00111
00112 static const fu Llimit = {0xc2cff1b5};
00113
00114 static const fu Qnan = {QNANF};
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 void
00127 __vexpf( float *x, float *y, long count, long stridex, long stridey )
00128 {
00129 #ifdef _32BIT_MACHINE
00130
00131 int l;
00132
00133 #else
00134
00135 long long l;
00136
00137 #endif
00138
00139 long i;
00140 int j, m, n;
00141 float arg, w, result;
00142 double z;
00143 double dx;
00144 double nd;
00145 double poly;
00146 double s;
00147 double twopm;
00148
00149
00150
00151 for ( i=0; i<count; i++ )
00152 {
00153 #ifdef _PREFETCH
00154 #pragma prefetch_ref=*(x+8)
00155 #pragma prefetch_ref=*(y+8)
00156 #endif
00157
00158 arg = *x;
00159 w = arg;
00160
00161 if ( arg > Ulimit.f )
00162 w = Ulimit.f;
00163
00164 if ( arg < Llimit.f )
00165 w = Llimit.f;
00166
00167 if ( arg != arg )
00168 w = 0.0f;
00169
00170 dx = w;
00171
00172
00173
00174 nd = dx*rln2by32.d;
00175 n = ROUND(nd);
00176 nd = n;
00177
00178 z = dx - nd*ln2by32hi.d - nd*ln2by32lo.d;
00179
00180 j = n & 0x1f;
00181 m = n >> 5;
00182
00183 s = __expftab[j].d;
00184
00185 poly = (P[3].d*z + P[2].d)*(z*z) + z;
00186
00187 l = m + DEXPBIAS;
00188 l <<= DMANTWIDTH;
00189
00190 #ifdef _32BIT_MACHINE
00191
00192 twopm = 0.0;
00193 INT2DBLHI(l, twopm);
00194 #else
00195 LL2DBL(l, twopm);
00196 #endif
00197 result = twopm*(s + s*poly);
00198
00199 if ( arg != arg )
00200 result = Qnan.f;
00201
00202 *y = result;
00203
00204 x += stridex;
00205 y += stridey;
00206 }
00207 }
00208