1 |
solar 08/09/23 20:14:03 |
2 |
|
3 |
Added: e_log2.c ldouble_wrappers.c s_fdim.c s_fma.c |
4 |
s_fmax.c s_fmin.c s_nearbyint.c s_remquo.c |
5 |
s_scalbln.c w_exp2.c w_log2.c w_nexttoward.c |
6 |
w_tgamma.c |
7 |
Log: |
8 |
- import initial gentoo patchset for 0.9.30_rc1 |
9 |
|
10 |
Revision Changes Path |
11 |
1.1 src/patchsets/uclibc/0.9.30/math/libm/e_log2.c |
12 |
|
13 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/e_log2.c?rev=1.1&view=markup |
14 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/e_log2.c?rev=1.1&content-type=text/plain |
15 |
|
16 |
Index: e_log2.c |
17 |
=================================================================== |
18 |
/* Adapted for log2 by Ulrich Drepper <drepper@××××××.com>. */ |
19 |
/* |
20 |
* ==================================================== |
21 |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
22 |
* |
23 |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
24 |
* Permission to use, copy, modify, and distribute this |
25 |
* software is freely granted, provided that this notice |
26 |
* is preserved. |
27 |
* ==================================================== |
28 |
*/ |
29 |
|
30 |
/* __ieee754_log2(x) |
31 |
* Return the logarithm to base 2 of x |
32 |
* |
33 |
* Method : |
34 |
* 1. Argument Reduction: find k and f such that |
35 |
* x = 2^k * (1+f), |
36 |
* where sqrt(2)/2 < 1+f < sqrt(2) . |
37 |
* |
38 |
* 2. Approximation of log(1+f). |
39 |
* Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) |
40 |
* = 2s + 2/3 s**3 + 2/5 s**5 + ....., |
41 |
* = 2s + s*R |
42 |
* We use a special Reme algorithm on [0,0.1716] to generate |
43 |
* a polynomial of degree 14 to approximate R The maximum error |
44 |
* of this polynomial approximation is bounded by 2**-58.45. In |
45 |
* other words, |
46 |
* 2 4 6 8 10 12 14 |
47 |
* R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s |
48 |
* (the values of Lg1 to Lg7 are listed in the program) |
49 |
* and |
50 |
* | 2 14 | -58.45 |
51 |
* | Lg1*s +...+Lg7*s - R(z) | <= 2 |
52 |
* | | |
53 |
* Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2. |
54 |
* In order to guarantee error in log below 1ulp, we compute log |
55 |
* by |
56 |
* log(1+f) = f - s*(f - R) (if f is not too large) |
57 |
* log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy) |
58 |
* |
59 |
* 3. Finally, log(x) = k + log(1+f). |
60 |
* = k+(f-(hfsq-(s*(hfsq+R)))) |
61 |
* |
62 |
* Special cases: |
63 |
* log2(x) is NaN with signal if x < 0 (including -INF) ; |
64 |
* log2(+INF) is +INF; log(0) is -INF with signal; |
65 |
* log2(NaN) is that NaN with no signal. |
66 |
* |
67 |
* Constants: |
68 |
* The hexadecimal values are the intended ones for the following |
69 |
* constants. The decimal values may be used, provided that the |
70 |
* compiler will convert from decimal to binary accurately enough |
71 |
* to produce the hexadecimal values shown. |
72 |
*/ |
73 |
|
74 |
#include "math.h" |
75 |
#include "math_private.h" |
76 |
|
77 |
#ifdef __STDC__ |
78 |
static const double |
79 |
#else |
80 |
static double |
81 |
#endif |
82 |
ln2 = 0.69314718055994530942, |
83 |
two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */ |
84 |
Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ |
85 |
Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ |
86 |
Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ |
87 |
Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ |
88 |
Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ |
89 |
Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ |
90 |
Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ |
91 |
|
92 |
#ifdef __STDC__ |
93 |
static const double zero = 0.0; |
94 |
#else |
95 |
static double zero = 0.0; |
96 |
#endif |
97 |
|
98 |
#ifdef __STDC__ |
99 |
double __ieee754_log2(double x) |
100 |
#else |
101 |
double __ieee754_log2(x) |
102 |
double x; |
103 |
#endif |
104 |
{ |
105 |
double hfsq,f,s,z,R,w,t1,t2,dk; |
106 |
int32_t k,hx,i,j; |
107 |
u_int32_t lx; |
108 |
|
109 |
EXTRACT_WORDS(hx,lx,x); |
110 |
|
111 |
k=0; |
112 |
if (hx < 0x00100000) { /* x < 2**-1022 */ |
113 |
if (((hx&0x7fffffff)|lx)==0) |
114 |
return -two54/(x-x); /* log(+-0)=-inf */ |
115 |
if (hx<0) return (x-x)/(x-x); /* log(-#) = NaN */ |
116 |
k -= 54; x *= two54; /* subnormal number, scale up x */ |
117 |
GET_HIGH_WORD(hx,x); |
118 |
} |
119 |
if (hx >= 0x7ff00000) return x+x; |
120 |
k += (hx>>20)-1023; |
121 |
hx &= 0x000fffff; |
122 |
i = (hx+0x95f64)&0x100000; |
123 |
SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */ |
124 |
k += (i>>20); |
125 |
dk = (double) k; |
126 |
f = x-1.0; |
127 |
if((0x000fffff&(2+hx))<3) { /* |f| < 2**-20 */ |
128 |
if(f==zero) return dk; |
129 |
R = f*f*(0.5-0.33333333333333333*f); |
130 |
return dk-(R-f)/ln2; |
131 |
} |
132 |
s = f/(2.0+f); |
133 |
z = s*s; |
134 |
i = hx-0x6147a; |
135 |
w = z*z; |
136 |
j = 0x6b851-hx; |
137 |
t1= w*(Lg2+w*(Lg4+w*Lg6)); |
138 |
t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); |
139 |
i |= j; |
140 |
R = t2+t1; |
141 |
if(i>0) { |
142 |
hfsq=0.5*f*f; |
143 |
return dk-((hfsq-(s*(hfsq+R)))-f)/ln2; |
144 |
} else { |
145 |
return dk-((s*(f-R))-f)/ln2; |
146 |
} |
147 |
} |
148 |
|
149 |
|
150 |
|
151 |
1.1 src/patchsets/uclibc/0.9.30/math/libm/ldouble_wrappers.c |
152 |
|
153 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/ldouble_wrappers.c?rev=1.1&view=markup |
154 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/ldouble_wrappers.c?rev=1.1&content-type=text/plain |
155 |
|
156 |
Index: ldouble_wrappers.c |
157 |
=================================================================== |
158 |
/* vi: set sw=4 ts=4: */ |
159 |
/* |
160 |
* Wrapper functions implementing all the long double math functions |
161 |
* defined by SuSv3 by actually calling the double version of |
162 |
* each function and then casting the result back to a long double |
163 |
* to return to the user. |
164 |
* |
165 |
* Copyright (C) 2005 by Erik Andersen <andersen@××××××.org> |
166 |
* |
167 |
* This program is free software; you can redistribute it and/or modify it |
168 |
* under the terms of the GNU Library General Public License as published by |
169 |
* the Free Software Foundation; either version 2 of the License, or (at your |
170 |
* option) any later version. |
171 |
* |
172 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
173 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
174 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License |
175 |
* for more details. |
176 |
* |
177 |
* You should have received a copy of the GNU Library General Public License |
178 |
* along with this program; if not, write to the Free Software Foundation, |
179 |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
180 |
*/ |
181 |
|
182 |
#include "math.h" |
183 |
|
184 |
/* Implement the following, as defined by SuSv3 */ |
185 |
#if 0 |
186 |
long double acoshl(long double); |
187 |
long double acosl(long double); |
188 |
long double asinhl(long double); |
189 |
long double asinl(long double); |
190 |
long double atan2l(long double, long double); |
191 |
long double atanhl(long double); |
192 |
long double atanl(long double); |
193 |
long double cbrtl(long double); |
194 |
long double ceill(long double); |
195 |
long double copysignl(long double, long double); |
196 |
long double coshl(long double); |
197 |
long double cosl(long double); |
198 |
long double erfcl(long double); |
199 |
long double erfl(long double); |
200 |
long double exp2l(long double); |
201 |
long double expl(long double); |
202 |
long double expm1l(long double); |
203 |
long double fabsl(long double); |
204 |
long double fdiml(long double, long double); |
205 |
long double floorl(long double); |
206 |
long double fmal(long double, long double, long double); |
207 |
long double fmaxl(long double, long double); |
208 |
long double fminl(long double, long double); |
209 |
long double fmodl(long double, long double); |
210 |
long double frexpl(long double value, int *); |
211 |
long double hypotl(long double, long double); |
212 |
int ilogbl(long double); |
213 |
long double ldexpl(long double, int); |
214 |
long double lgammal(long double); |
215 |
long long llrintl(long double); |
216 |
long long llroundl(long double); |
217 |
long double log10l(long double); |
218 |
long double log1pl(long double); |
219 |
long double log2l(long double); |
220 |
long double logbl(long double); |
221 |
long double logl(long double); |
222 |
long lrintl(long double); |
223 |
long lroundl(long double); |
224 |
long double modfl(long double, long double *); |
225 |
long double nearbyintl(long double); |
226 |
long double nextafterl(long double, long double); |
227 |
long double nexttowardl(long double, long double); |
228 |
long double powl(long double, long double); |
229 |
long double remainderl(long double, long double); |
230 |
long double remquol(long double, long double, int *); |
231 |
long double rintl(long double); |
232 |
long double roundl(long double); |
233 |
long double scalblnl(long double, long); |
234 |
long double scalbnl(long double, int); |
235 |
long double sinhl(long double); |
236 |
long double sinl(long double); |
237 |
long double sqrtl(long double); |
238 |
long double tanhl(long double); |
239 |
long double tanl(long double); |
240 |
long double tgammal(long double); |
241 |
long double truncl(long double); |
242 |
#endif |
243 |
|
244 |
#ifdef L_acoshl |
245 |
long double acoshl (long double x) |
246 |
{ |
247 |
return (long double) acosh( (double)x ); |
248 |
} |
249 |
#endif |
250 |
|
251 |
|
252 |
#ifdef L_acosl |
253 |
long double acosl (long double x) |
254 |
{ |
255 |
return (long double) acos( (double)x ); |
256 |
} |
257 |
#endif |
258 |
|
259 |
|
260 |
#ifdef L_asinhl |
261 |
long double asinhl (long double x) |
262 |
{ |
263 |
return (long double) asinh( (double)x ); |
264 |
} |
265 |
#endif |
266 |
|
267 |
|
268 |
#ifdef L_asinl |
269 |
long double asinl (long double x) |
270 |
{ |
271 |
return (long double) asin( (double)x ); |
272 |
} |
273 |
#endif |
274 |
|
275 |
|
276 |
#ifdef L_atan2l |
277 |
long double atan2l (long double x, long double y) |
278 |
{ |
279 |
return (long double) atan2( (double)x, (double)y ); |
280 |
} |
281 |
#endif |
282 |
|
283 |
|
284 |
#ifdef L_atanhl |
285 |
long double atanhl (long double x) |
286 |
{ |
287 |
return (long double) atanh( (double)x ); |
288 |
} |
289 |
#endif |
290 |
|
291 |
|
292 |
#ifdef L_atanl |
293 |
long double atanl (long double x) |
294 |
{ |
295 |
return (long double) atan( (double)x ); |
296 |
} |
297 |
#endif |
298 |
|
299 |
|
300 |
#ifdef L_cbrtl |
301 |
long double cbrtl (long double x) |
302 |
{ |
303 |
return (long double) cbrt( (double)x ); |
304 |
} |
305 |
#endif |
306 |
|
307 |
|
308 |
#ifdef L_ceill |
309 |
long double ceill (long double x) |
310 |
{ |
311 |
return (long double) ceil( (double)x ); |
312 |
} |
313 |
#endif |
314 |
|
315 |
|
316 |
#ifdef L_copysignl |
317 |
long double copysignl (long double x, long double y) |
318 |
{ |
319 |
return (long double) copysign( (double)x, (double)y ); |
320 |
} |
321 |
#endif |
322 |
|
323 |
|
324 |
#ifdef L_coshl |
325 |
long double coshl (long double x) |
326 |
{ |
327 |
return (long double) cosh( (double)x ); |
328 |
} |
329 |
#endif |
330 |
|
331 |
|
332 |
#ifdef L_cosl |
333 |
long double cosl (long double x) |
334 |
{ |
335 |
return (long double) cos( (double)x ); |
336 |
} |
337 |
#endif |
338 |
|
339 |
|
340 |
#ifdef L_erfcl |
341 |
long double erfcl (long double x) |
342 |
{ |
343 |
return (long double) erfc( (double)x ); |
344 |
} |
345 |
#endif |
346 |
|
347 |
|
348 |
#ifdef L_erfl |
349 |
long double erfl (long double x) |
350 |
{ |
351 |
return (long double) erf( (double)x ); |
352 |
} |
353 |
#endif |
354 |
|
355 |
|
356 |
#ifdef L_exp2l |
357 |
long double exp2l (long double x) |
358 |
{ |
359 |
return (long double) exp2( (double)x ); |
360 |
} |
361 |
#endif |
362 |
|
363 |
|
364 |
#ifdef L_expl |
365 |
long double expl (long double x) |
366 |
{ |
367 |
return (long double) exp( (double)x ); |
368 |
} |
369 |
#endif |
370 |
|
371 |
|
372 |
#ifdef L_expm1l |
373 |
long double expm1l (long double x) |
374 |
{ |
375 |
return (long double) expm1( (double)x ); |
376 |
} |
377 |
#endif |
378 |
|
379 |
|
380 |
#ifdef L_fabsl |
381 |
long double fabsl (long double x) |
382 |
{ |
383 |
return (long double) fabs( (double)x ); |
384 |
} |
385 |
#endif |
386 |
|
387 |
|
388 |
#ifdef L_fdiml |
389 |
long double fdiml (long double x, long double y) |
390 |
{ |
391 |
return (long double) fdim( (double)x, (double)y ); |
392 |
} |
393 |
#endif |
394 |
|
395 |
|
396 |
#ifdef L_floorl |
397 |
long double floorl (long double x) |
398 |
{ |
399 |
return (long double) floor( (double)x ); |
400 |
} |
401 |
#endif |
402 |
|
403 |
|
404 |
#ifdef L_fmal |
405 |
long double fmal (long double x, long double y, long double z) |
406 |
{ |
407 |
return (long double) fma( (double)x, (double)y, (double)z ); |
408 |
} |
409 |
#endif |
410 |
|
411 |
|
412 |
#ifdef L_fmaxl |
413 |
long double fmaxl (long double x, long double y) |
414 |
{ |
415 |
return (long double) fmax( (double)x, (double)y ); |
416 |
} |
417 |
#endif |
418 |
|
419 |
|
420 |
#ifdef L_fminl |
421 |
long double fminl (long double x, long double y) |
422 |
{ |
423 |
return (long double) fmin( (double)x, (double)y ); |
424 |
} |
425 |
#endif |
426 |
|
427 |
|
428 |
#ifdef L_fmodl |
429 |
long double fmodl (long double x, long double y) |
430 |
{ |
431 |
return (long double) fmod( (double)x, (double)y ); |
432 |
} |
433 |
#endif |
434 |
|
435 |
|
436 |
#ifdef L_frexpl |
437 |
long double frexpl (long double x, int *exp) |
438 |
{ |
439 |
return (long double) frexp( (double)x, exp ); |
440 |
} |
441 |
#endif |
442 |
|
443 |
|
444 |
#ifdef L_hypotl |
445 |
long double hypotl (long double x, long double y) |
446 |
{ |
447 |
return (long double) hypot( (double)x, (double)y ); |
448 |
} |
449 |
#endif |
450 |
|
451 |
|
452 |
#ifdef L_ilogbl |
453 |
int ilogbl (long double x) |
454 |
{ |
455 |
return (long double) ilogb( (double)x ); |
456 |
} |
457 |
#endif |
458 |
|
459 |
|
460 |
#ifdef L_ldexpl |
461 |
long double ldexpl (long double x, int exp) |
462 |
{ |
463 |
return (long double) ldexp( (double)x, exp ); |
464 |
} |
465 |
#endif |
466 |
|
467 |
|
468 |
#ifdef L_lgammal |
469 |
long double lgammal (long double x) |
470 |
{ |
471 |
return (long double) lgamma( (double)x ); |
472 |
} |
473 |
#endif |
474 |
|
475 |
|
476 |
#ifdef L_llrintl |
477 |
long long llrintl (long double x) |
478 |
{ |
479 |
return (long double) llrint( (double)x ); |
480 |
} |
481 |
#endif |
482 |
|
483 |
|
484 |
#ifdef L_llroundl |
485 |
long long llroundl (long double x) |
486 |
{ |
487 |
return (long double) llround( (double)x ); |
488 |
} |
489 |
#endif |
490 |
|
491 |
#ifdef L_log10l |
492 |
long double log10l (long double x) |
493 |
{ |
494 |
return (long double) log10( (double)x ); |
495 |
} |
496 |
#endif |
497 |
|
498 |
|
499 |
#ifdef L_log1pl |
500 |
long double log1pl (long double x) |
501 |
{ |
502 |
return (long double) log1p( (double)x ); |
503 |
} |
504 |
#endif |
505 |
|
506 |
|
507 |
#ifdef L_log2l |
508 |
long double log2l (long double x) |
509 |
{ |
510 |
return (long double) log2( (double)x ); |
511 |
} |
512 |
#endif |
513 |
|
514 |
|
515 |
#ifdef L_logbl |
516 |
long double logbl (long double x) |
517 |
{ |
518 |
return (long double) logb( (double)x ); |
519 |
} |
520 |
#endif |
521 |
|
522 |
|
523 |
#ifdef L_logl |
524 |
long double logl (long double x) |
525 |
{ |
526 |
return (long double) log( (double)x ); |
527 |
} |
528 |
#endif |
529 |
|
530 |
|
531 |
#ifdef L_lrintl |
532 |
long lrintl (long double x) |
533 |
{ |
534 |
return (long double) lrint( (double)x ); |
535 |
} |
536 |
#endif |
537 |
|
538 |
|
539 |
#ifdef L_lroundl |
540 |
long lroundl (long double x) |
541 |
{ |
542 |
return (long double) lround( (double)x ); |
543 |
} |
544 |
#endif |
545 |
|
546 |
|
547 |
#ifdef L_modfl |
548 |
long double modfl (long double x, long double *iptr) |
549 |
{ |
550 |
double y, result; |
551 |
result = modf ( x, &y ); |
552 |
*iptr = (long double)y; |
553 |
return (long double) result; |
554 |
|
555 |
} |
556 |
#endif |
557 |
|
558 |
|
559 |
#ifdef L_nearbyintl |
560 |
long double nearbyintl (long double x) |
561 |
{ |
562 |
return (long double) nearbyint( (double)x ); |
563 |
} |
564 |
#endif |
565 |
|
566 |
|
567 |
#ifdef L_nextafterl |
568 |
long double nextafterl (long double x, long double y) |
569 |
{ |
570 |
return (long double) nextafter( (double)x, (double)y ); |
571 |
} |
572 |
#endif |
573 |
|
574 |
|
575 |
#ifdef L_nexttowardl |
576 |
long double nexttowardl (long double x, long double y) |
577 |
{ |
578 |
return (long double) nexttoward( (double)x, (double)y ); |
579 |
} |
580 |
#endif |
581 |
|
582 |
|
583 |
#ifdef L_powl |
584 |
long double powl (long double x, long double y) |
585 |
{ |
586 |
return (long double) pow( (double)x, (double)y ); |
587 |
} |
588 |
#endif |
589 |
|
590 |
|
591 |
#ifdef L_remainderl |
592 |
long double remainderl (long double x, long double y) |
593 |
{ |
594 |
return (long double) remainder( (double)x, (double)y ); |
595 |
} |
596 |
#endif |
597 |
|
598 |
|
599 |
#ifdef L_remquol |
600 |
long double remquol (long double x, long double y, int *quo) |
601 |
{ |
602 |
return (long double) remquo( (double)x, (double)y, quo ); |
603 |
} |
604 |
#endif |
605 |
|
606 |
|
607 |
#ifdef L_rintl |
608 |
long double rintl (long double x) |
609 |
{ |
610 |
return (long double) rint( (double)x ); |
611 |
} |
612 |
#endif |
613 |
|
614 |
|
615 |
#ifdef L_roundl |
616 |
long double roundl (long double x) |
617 |
{ |
618 |
return (long double) round( (double)x ); |
619 |
} |
620 |
#endif |
621 |
|
622 |
|
623 |
#ifdef L_scalblnl |
624 |
long double scalblnl (long double x, long exp) |
625 |
{ |
626 |
return (long double) scalbln( (double)x, exp ); |
627 |
} |
628 |
#endif |
629 |
|
630 |
|
631 |
#ifdef L_scalbnl |
632 |
long double scalbnl (long double x, int exp) |
633 |
{ |
634 |
return (long double) scalbn( (double)x, exp ); |
635 |
} |
636 |
#endif |
637 |
|
638 |
|
639 |
#ifdef L_sinhl |
640 |
long double sinhl (long double x) |
641 |
{ |
642 |
return (long double) sinh( (double)x ); |
643 |
} |
644 |
#endif |
645 |
|
646 |
|
647 |
#ifdef L_sinl |
648 |
long double sinl (long double x) |
649 |
{ |
650 |
return (long double) sin( (double)x ); |
651 |
} |
652 |
#endif |
653 |
|
654 |
|
655 |
#ifdef L_sqrtl |
656 |
long double sqrtl (long double x) |
657 |
{ |
658 |
return (long double) sqrt( (double)x ); |
659 |
} |
660 |
#endif |
661 |
|
662 |
|
663 |
#ifdef L_tanhl |
664 |
long double tanhl (long double x) |
665 |
{ |
666 |
return (long double) tanh( (double)x ); |
667 |
} |
668 |
#endif |
669 |
|
670 |
|
671 |
#ifdef L_tanl |
672 |
long double tanl (long double x) |
673 |
{ |
674 |
return (long double) tan( (double)x ); |
675 |
} |
676 |
#endif |
677 |
|
678 |
|
679 |
#ifdef L_tgammal |
680 |
long double tgammal (long double x) |
681 |
{ |
682 |
return (long double) tgamma( (double)x ); |
683 |
} |
684 |
#endif |
685 |
|
686 |
|
687 |
#ifdef L_truncl |
688 |
long double truncl (long double x) |
689 |
{ |
690 |
return (long double) trunc( (double)x ); |
691 |
} |
692 |
#endif |
693 |
|
694 |
|
695 |
|
696 |
|
697 |
1.1 src/patchsets/uclibc/0.9.30/math/libm/s_fdim.c |
698 |
|
699 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/s_fdim.c?rev=1.1&view=markup |
700 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/s_fdim.c?rev=1.1&content-type=text/plain |
701 |
|
702 |
Index: s_fdim.c |
703 |
=================================================================== |
704 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
705 |
* |
706 |
* Permission to use, copy, modify, and distribute this software |
707 |
* is freely granted, provided that this notice is preserved. |
708 |
*/ |
709 |
|
710 |
#include "math.h" |
711 |
#include "math_private.h" |
712 |
|
713 |
libm_hidden_proto(fdim) |
714 |
#ifdef __STDC__ |
715 |
double fdim(double x, double y) |
716 |
#else |
717 |
double fdim(x,y) |
718 |
double x; |
719 |
double y; |
720 |
#endif |
721 |
{ |
722 |
int c = __fpclassify(x); |
723 |
if (c == FP_NAN || c == FP_INFINITE) |
724 |
return HUGE_VAL; |
725 |
|
726 |
return x > y ? x - y : 0.0; |
727 |
} |
728 |
libm_hidden_def(fdim) |
729 |
|
730 |
|
731 |
|
732 |
1.1 src/patchsets/uclibc/0.9.30/math/libm/s_fma.c |
733 |
|
734 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/s_fma.c?rev=1.1&view=markup |
735 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/s_fma.c?rev=1.1&content-type=text/plain |
736 |
|
737 |
Index: s_fma.c |
738 |
=================================================================== |
739 |
#include "math.h" |
740 |
#include "math_private.h" |
741 |
|
742 |
libm_hidden_proto(fma) |
743 |
#ifdef __STDC__ |
744 |
double fma(double x, double y, double z) |
745 |
#else |
746 |
double fma(x,y) |
747 |
double x; |
748 |
double y; |
749 |
double z; |
750 |
#endif |
751 |
{ |
752 |
/* Implementation defined. */ |
753 |
return (x * y) + z; |
754 |
} |
755 |
libm_hidden_def(fma) |
756 |
|
757 |
|
758 |
|
759 |
1.1 src/patchsets/uclibc/0.9.30/math/libm/s_fmax.c |
760 |
|
761 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/s_fmax.c?rev=1.1&view=markup |
762 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/s_fmax.c?rev=1.1&content-type=text/plain |
763 |
|
764 |
Index: s_fmax.c |
765 |
=================================================================== |
766 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
767 |
* |
768 |
* Permission to use, copy, modify, and distribute this software |
769 |
* is freely granted, provided that this notice is preserved. |
770 |
*/ |
771 |
|
772 |
#include "math.h" |
773 |
#include "math_private.h" |
774 |
|
775 |
libm_hidden_proto(fmax) |
776 |
#ifdef __STDC__ |
777 |
double fmax(double x, double y) |
778 |
#else |
779 |
double fmax(x,y) |
780 |
double x; |
781 |
double y; |
782 |
#endif |
783 |
{ |
784 |
if (__fpclassify(x) == FP_NAN) |
785 |
return x; |
786 |
if (__fpclassify(y) == FP_NAN) |
787 |
return y; |
788 |
|
789 |
return x > y ? x : y; |
790 |
} |
791 |
libm_hidden_def(fmax) |
792 |
|
793 |
|
794 |
|
795 |
1.1 src/patchsets/uclibc/0.9.30/math/libm/s_fmin.c |
796 |
|
797 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/s_fmin.c?rev=1.1&view=markup |
798 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/s_fmin.c?rev=1.1&content-type=text/plain |
799 |
|
800 |
Index: s_fmin.c |
801 |
=================================================================== |
802 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
803 |
* |
804 |
* Permission to use, copy, modify, and distribute this software |
805 |
* is freely granted, provided that this notice is preserved. |
806 |
*/ |
807 |
|
808 |
#include "math.h" |
809 |
#include "math_private.h" |
810 |
|
811 |
libm_hidden_proto(fmin) |
812 |
#ifdef __STDC__ |
813 |
double fmin(double x, double y) |
814 |
#else |
815 |
double fmin(x,y) |
816 |
double x; |
817 |
double y; |
818 |
#endif |
819 |
{ |
820 |
if (__fpclassify(x) == FP_NAN) |
821 |
return x; |
822 |
if (__fpclassify(y) == FP_NAN) |
823 |
return y; |
824 |
|
825 |
return x < y ? x : y; |
826 |
} |
827 |
libm_hidden_def(fmin) |
828 |
|
829 |
|
830 |
|
831 |
1.1 src/patchsets/uclibc/0.9.30/math/libm/s_nearbyint.c |
832 |
|
833 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/s_nearbyint.c?rev=1.1&view=markup |
834 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/s_nearbyint.c?rev=1.1&content-type=text/plain |
835 |
|
836 |
Index: s_nearbyint.c |
837 |
=================================================================== |
838 |
/* |
839 |
* ==================================================== |
840 |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
841 |
* |
842 |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
843 |
* Permission to use, copy, modify, and distribute this |
844 |
* software is freely granted, provided that this notice |
845 |
* is preserved. |
846 |
* ==================================================== |
847 |
*/ |
848 |
|
849 |
#include "math.h" |
850 |
#include "math_private.h" |
851 |
|
852 |
libm_hidden_proto(nearbyint) |
853 |
#ifdef __STDC__ |
854 |
double nearbyint(double x) |
855 |
#else |
856 |
double nearbyint(x) |
857 |
double x; |
858 |
#endif |
859 |
{ |
860 |
return rint(x); |
861 |
} |
862 |
libm_hidden_def(nearbyint) |
863 |
|
864 |
|
865 |
|
866 |
1.1 src/patchsets/uclibc/0.9.30/math/libm/s_remquo.c |
867 |
|
868 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/s_remquo.c?rev=1.1&view=markup |
869 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/s_remquo.c?rev=1.1&content-type=text/plain |
870 |
|
871 |
Index: s_remquo.c |
872 |
=================================================================== |
873 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
874 |
* |
875 |
* Permission to use, copy, modify, and distribute this software |
876 |
* is freely granted, provided that this notice is preserved. |
877 |
*/ |
878 |
|
879 |
#include "math.h" |
880 |
#include "math_private.h" |
881 |
|
882 |
libm_hidden_proto(remquo) |
883 |
#ifdef __STDC__ |
884 |
double remquo(double x, double y, int *quo) /* wrapper remquo */ |
885 |
#else |
886 |
double remquo(x,y,quo) /* wrapper remquo */ |
887 |
double x,y; |
888 |
int *quo; |
889 |
#endif |
890 |
{ |
891 |
int signx, signy, signres; |
892 |
int mswx; |
893 |
int mswy; |
894 |
double x_over_y; |
895 |
|
896 |
GET_HIGH_WORD(mswx, x); |
897 |
GET_HIGH_WORD(mswy, y); |
898 |
|
899 |
signx = (mswx & 0x80000000) >> 31; |
900 |
signy = (mswy & 0x80000000) >> 31; |
901 |
|
902 |
signres = (signx ^ signy) ? -1 : 1; |
903 |
|
904 |
x_over_y = fabs(x / y); |
905 |
|
906 |
*quo = signres * (lrint(x_over_y) & 0x7f); |
907 |
|
908 |
return remainder(x,y); |
909 |
} |
910 |
libm_hidden_def(remquo) |
911 |
|
912 |
|
913 |
|
914 |
1.1 src/patchsets/uclibc/0.9.30/math/libm/s_scalbln.c |
915 |
|
916 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/s_scalbln.c?rev=1.1&view=markup |
917 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/s_scalbln.c?rev=1.1&content-type=text/plain |
918 |
|
919 |
Index: s_scalbln.c |
920 |
=================================================================== |
921 |
/* @(#)s_scalbn.c 5.1 93/09/24 */ |
922 |
/* |
923 |
* ==================================================== |
924 |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
925 |
* |
926 |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
927 |
* Permission to use, copy, modify, and distribute this |
928 |
* software is freely granted, provided that this notice |
929 |
* is preserved. |
930 |
* ==================================================== |
931 |
*/ |
932 |
|
933 |
/* |
934 |
* scalbn (double x, int n) |
935 |
* scalbn(x,n) returns x* 2**n computed by exponent |
936 |
* manipulation rather than by actually performing an |
937 |
* exponentiation or a multiplication. |
938 |
*/ |
939 |
|
940 |
#include "math.h" |
941 |
#include "math_private.h" |
942 |
|
943 |
libm_hidden_proto(scalbln) |
944 |
#ifdef __STDC__ |
945 |
static const double |
946 |
#else |
947 |
static double |
948 |
#endif |
949 |
two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ |
950 |
twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ |
951 |
huge = 1.0e+300, |
952 |
tiny = 1.0e-300; |
953 |
|
954 |
#ifdef __STDC__ |
955 |
double scalbln (double x, long int n) |
956 |
#else |
957 |
double scalbln (x,n) |
958 |
double x; long int n; |
959 |
#endif |
960 |
{ |
961 |
int32_t k,hx,lx; |
962 |
EXTRACT_WORDS(hx,lx,x); |
963 |
k = (hx&0x7ff00000)>>20; /* extract exponent */ |
964 |
if (k==0) { /* 0 or subnormal x */ |
965 |
if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */ |
966 |
x *= two54; |
967 |
GET_HIGH_WORD(hx,x); |
968 |
k = ((hx&0x7ff00000)>>20) - 54; |
969 |
} |
970 |
if (k==0x7ff) return x+x; /* NaN or Inf */ |
971 |
k = k+n; |
972 |
if (n> 50000 || k > 0x7fe) |
973 |
return huge*copysign(huge,x); /* overflow */ |
974 |
if (n< -50000) return tiny*copysign(tiny,x); /*underflow*/ |
975 |
if (k > 0) /* normal result */ |
976 |
{SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;} |
977 |
if (k <= -54) |
978 |
return tiny*copysign(tiny,x); /*underflow*/ |
979 |
k += 54; /* subnormal result */ |
980 |
SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); |
981 |
return x*twom54; |
982 |
} |
983 |
libm_hidden_def(scalbln) |
984 |
|
985 |
|
986 |
|
987 |
1.1 src/patchsets/uclibc/0.9.30/math/libm/w_exp2.c |
988 |
|
989 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/w_exp2.c?rev=1.1&view=markup |
990 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/w_exp2.c?rev=1.1&content-type=text/plain |
991 |
|
992 |
Index: w_exp2.c |
993 |
=================================================================== |
994 |
|
995 |
/* @(#)w_exp2.c 5.1 93/09/24 */ |
996 |
/* |
997 |
* ==================================================== |
998 |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
999 |
* |
1000 |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
1001 |
* Permission to use, copy, modify, and distribute this |
1002 |
* software is freely granted, provided that this notice |
1003 |
* is preserved. |
1004 |
* ==================================================== |
1005 |
*/ |
1006 |
|
1007 |
#include "math.h" |
1008 |
#include "math_private.h" |
1009 |
|
1010 |
libm_hidden_proto(exp2) |
1011 |
#ifdef __STDC__ |
1012 |
double exp2(double x) |
1013 |
#else |
1014 |
double exp2(x) |
1015 |
double x; |
1016 |
#endif |
1017 |
{ |
1018 |
return pow(2.0, x); |
1019 |
} |
1020 |
libm_hidden_def(exp2) |
1021 |
|
1022 |
|
1023 |
|
1024 |
1.1 src/patchsets/uclibc/0.9.30/math/libm/w_log2.c |
1025 |
|
1026 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/w_log2.c?rev=1.1&view=markup |
1027 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/w_log2.c?rev=1.1&content-type=text/plain |
1028 |
|
1029 |
Index: w_log2.c |
1030 |
=================================================================== |
1031 |
/* |
1032 |
* wrapper log2(X) |
1033 |
*/ |
1034 |
|
1035 |
#include "math.h" |
1036 |
#include "math_private.h" |
1037 |
|
1038 |
libm_hidden_proto(log2) |
1039 |
double log2 (double x) /* wrapper log2 */ |
1040 |
{ |
1041 |
#ifdef _IEEE_LIBM |
1042 |
return __ieee754_log2 (x); |
1043 |
#else |
1044 |
double z; |
1045 |
z = __ieee754_log2 (x); |
1046 |
if (_LIB_VERSION == _IEEE_ || __isnan (x)) return z; |
1047 |
if (x <= 0.0) |
1048 |
{ |
1049 |
if (x == 0.0) |
1050 |
return __kernel_standard (x, x, 48); /* log2 (0) */ |
1051 |
else |
1052 |
return __kernel_standard (x, x, 49); /* log2 (x < 0) */ |
1053 |
} |
1054 |
else |
1055 |
return z; |
1056 |
#endif |
1057 |
} |
1058 |
libm_hidden_def(log2) |
1059 |
|
1060 |
|
1061 |
|
1062 |
1.1 src/patchsets/uclibc/0.9.30/math/libm/w_nexttoward.c |
1063 |
|
1064 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/w_nexttoward.c?rev=1.1&view=markup |
1065 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/w_nexttoward.c?rev=1.1&content-type=text/plain |
1066 |
|
1067 |
Index: w_nexttoward.c |
1068 |
=================================================================== |
1069 |
/* vi: set sw=4 ts=4: */ |
1070 |
/* |
1071 |
* This program is free software; you can redistribute it and/or modify it |
1072 |
* under the terms of the GNU Library General Public License as published by |
1073 |
* the Free Software Foundation; either version 2 of the License, or (at your |
1074 |
* option) any later version. |
1075 |
* |
1076 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
1077 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1078 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License |
1079 |
* for more details. |
1080 |
* |
1081 |
* You should have received a copy of the GNU Library General Public License |
1082 |
* along with this program; if not, write to the Free Software Foundation, |
1083 |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1084 |
*/ |
1085 |
|
1086 |
#include "math.h" |
1087 |
#include "math_private.h" |
1088 |
|
1089 |
libm_hidden_proto(nexttoward) |
1090 |
#ifdef __STDC__ |
1091 |
double nexttoward(double x, long double y) |
1092 |
#else |
1093 |
double nexttoward(x,y) |
1094 |
double x; long double y; |
1095 |
#endif |
1096 |
{ |
1097 |
return (double) nextafter( (double)x, (double)y ); |
1098 |
} |
1099 |
libm_hidden_def(nexttoward) |
1100 |
|
1101 |
|
1102 |
|
1103 |
1.1 src/patchsets/uclibc/0.9.30/math/libm/w_tgamma.c |
1104 |
|
1105 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/w_tgamma.c?rev=1.1&view=markup |
1106 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/uclibc/0.9.30/math/libm/w_tgamma.c?rev=1.1&content-type=text/plain |
1107 |
|
1108 |
Index: w_tgamma.c |
1109 |
=================================================================== |
1110 |
/* @(#)w_gamma.c 5.1 93/09/24 */ |
1111 |
/* |
1112 |
* ==================================================== |
1113 |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
1114 |
* |
1115 |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
1116 |
* Permission to use, copy, modify, and distribute this |
1117 |
* software is freely granted, provided that this notice |
1118 |
* is preserved. |
1119 |
* ==================================================== |
1120 |
*/ |
1121 |
|
1122 |
/* double gamma(double x) |
1123 |
* Return the logarithm of the Gamma function of x or the Gamma function of x, |
1124 |
* depending on the library mode. |
1125 |
*/ |
1126 |
|
1127 |
#include "math.h" |
1128 |
#include "math_private.h" |
1129 |
|
1130 |
libm_hidden_proto(tgamma) |
1131 |
#ifdef __STDC__ |
1132 |
double tgamma(double x) |
1133 |
#else |
1134 |
double tgamma(x) |
1135 |
double x; |
1136 |
#endif |
1137 |
{ |
1138 |
double y; |
1139 |
int local_signgam; |
1140 |
y = __ieee754_gamma_r(x,&local_signgam); |
1141 |
if (local_signgam < 0) y = -y; |
1142 |
#ifdef _IEEE_LIBM |
1143 |
return y; |
1144 |
#else |
1145 |
if(_LIB_VERSION == _IEEE_) return y; |
1146 |
|
1147 |
if(!finite(y)&&finite(x)) { |
1148 |
if(floor(x)==x&&x<=0.0) |
1149 |
return __kernel_standard(x,x,41); /* tgamma pole */ |
1150 |
else |
1151 |
return __kernel_standard(x,x,40); /* tgamma overflow */ |
1152 |
} |
1153 |
return y; |
1154 |
#endif |
1155 |
} |
1156 |
libm_hidden_def(tgamma) |