OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [newlib/] [newlib/] [newlib/] [libm/] [math/] [w_lgamma.c] - Blame information for rev 39

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
 
2
/* @(#)w_lgamma.c 5.1 93/09/24 */
3
/*
4
 * ====================================================
5
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6
 *
7
 * Developed at SunPro, a Sun Microsystems, Inc. business.
8
 * Permission to use, copy, modify, and distribute this
9
 * software is freely granted, provided that this notice
10
 * is preserved.
11
 * ====================================================
12
 *
13
 */
14
 
15
/* double lgamma(double x)
16
 * Return the logarithm of the Gamma function of x.
17
 *
18
 * Method: call __ieee754_lgamma_r
19
 */
20
 
21
#include "fdlibm.h"
22
#include <errno.h>
23
 
24
#ifndef _DOUBLE_IS_32BITS
25
 
26
#ifdef __STDC__
27
        double lgamma(double x)
28
#else
29
        double lgamma(x)
30
        double x;
31
#endif
32
{
33
#ifdef _IEEE_LIBM
34
        return __ieee754_lgamma_r(x,&signgam);
35
#else
36
        double y;
37
        struct exception exc;
38
        y = __ieee754_lgamma_r(x,&signgam);
39
        if(_LIB_VERSION == _IEEE_) return y;
40
        if(!finite(y)&&finite(x)) {
41
#ifndef HUGE_VAL 
42
#define HUGE_VAL inf
43
            double inf = 0.0;
44
 
45
            SET_HIGH_WORD(inf,0x7ff00000);      /* set inf to infinite */
46
#endif
47
            exc.name = "lgamma";
48
            if (_LIB_VERSION == _SVID_)
49
               exc.retval = HUGE;
50
            else
51
               exc.retval = HUGE_VAL;
52
            if(floor(x)==x&&x<=0.0) {
53
                /* lgamma(-integer) */
54
                exc.type = SING;
55
                if (_LIB_VERSION == _POSIX_)
56
                   errno = EDOM;
57
                else if (!matherr(&exc)) {
58
                   errno = EDOM;
59
                }
60
 
61
            } else {
62
                /* lgamma(finite) overflow */
63
                exc.type = OVERFLOW;
64
                if (_LIB_VERSION == _POSIX_)
65
                   errno = ERANGE;
66
                else if (!matherr(&exc)) {
67
                   errno = ERANGE;
68
                }
69
            }
70
            if (exc.err != 0)
71
               errno = exc.err;
72
            return exc.retval;
73
        } else
74
            return y;
75
#endif
76
}
77
 
78
#endif /* defined(_DOUBLE_IS_32BITS) */
79
 
80
 
81
 
82
 
83
 
84
 
85
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.