Rev 4872 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | |
2 | /* |
||
3 | * ==================================================== |
||
4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
||
5 | * |
||
6 | * Developed at SunPro, a Sun Microsystems, Inc. business. |
||
7 | * Permission to use, copy, modify, and distribute this |
||
8 | * software is freely granted, provided that this notice |
||
9 | * is preserved. |
||
10 | * ==================================================== |
||
11 | */ |
||
12 | |||
13 | |||
14 | * wrapper double lgamma_r(double x, int *signgamp) |
||
15 | */ |
||
16 | |||
17 | |||
18 | #include |
||
19 | |||
20 | |||
21 | |||
22 | |||
23 | double lgamma_r(double x, int *signgamp) /* wrapper lgamma_r */ |
||
24 | #else |
||
25 | double lgamma_r(x,signgamp) /* wrapper lgamma_r */ |
||
26 | double x; int *signgamp; |
||
27 | #endif |
||
28 | { |
||
29 | #ifdef _IEEE_LIBM |
||
30 | return __ieee754_lgamma_r(x,signgamp); |
||
31 | #else |
||
32 | double y; |
||
33 | struct exception exc; |
||
34 | y = __ieee754_lgamma_r(x,signgamp); |
||
35 | if(_LIB_VERSION == _IEEE_) return y; |
||
36 | if(!finite(y)&&finite(x)) { |
||
37 | #ifndef HUGE_VAL |
||
38 | #define HUGE_VAL inf |
||
39 | double inf = 0.0; |
||
40 | |||
41 | |||
42 | #endif |
||
43 | exc.name = "lgamma"; |
||
44 | exc.err = 0; |
||
45 | exc.arg1 = exc.arg2 = (double)x; |
||
46 | if (_LIB_VERSION == _SVID_) |
||
47 | exc.retval = HUGE; |
||
48 | else |
||
49 | exc.retval = HUGE_VAL; |
||
50 | if(floor(x)==x&&x<=0.0) { |
||
51 | /* lgamma(-integer) */ |
||
52 | exc.type = SING; |
||
53 | if (_LIB_VERSION == _POSIX_) |
||
54 | errno = EDOM; |
||
55 | else if (!matherr(&exc)) { |
||
56 | errno = EDOM; |
||
57 | } |
||
58 | |||
59 | |||
60 | /* lgamma(finite) overflow */ |
||
61 | exc.type = OVERFLOW; |
||
62 | if (_LIB_VERSION == _POSIX_) |
||
63 | errno = ERANGE; |
||
64 | else if (!matherr(&exc)) { |
||
65 | errno = ERANGE; |
||
66 | } |
||
67 | } |
||
68 | if (exc.err != 0) |
||
69 | errno = exc.err; |
||
70 | return exc.retval; |
||
71 | } else |
||
72 | return y; |
||
73 | #endif |
||
74 | } |
||
75 | |||
76 | |||
77 |