1998-07-28 16:26:04 +00:00
|
|
|
/* w_gammal.c -- long double version of w_gamma.c.
|
|
|
|
* Conversion to long double by Ulrich Drepper,
|
|
|
|
* Cygnus Support, drepper@cygnus.com.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ====================================================
|
|
|
|
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
|
|
* Permission to use, copy, modify, and distribute this
|
|
|
|
* software is freely granted, provided that this notice
|
|
|
|
* is preserved.
|
|
|
|
* ====================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* long double gammal(double x)
|
|
|
|
* Return the Gamma function of x.
|
|
|
|
*/
|
|
|
|
|
2013-12-05 14:01:41 +00:00
|
|
|
#include <errno.h>
|
2005-12-14 15:06:39 +00:00
|
|
|
#include <math.h>
|
2011-10-08 09:16:04 +00:00
|
|
|
#include <math_private.h>
|
1998-07-28 16:26:04 +00:00
|
|
|
|
2011-10-12 15:27:51 +00:00
|
|
|
long double
|
|
|
|
__tgammal(long double x)
|
1998-07-28 16:26:04 +00:00
|
|
|
{
|
|
|
|
int local_signgam;
|
2011-10-12 15:27:51 +00:00
|
|
|
long double y = __ieee754_gammal_r(x,&local_signgam);
|
1998-07-28 16:26:04 +00:00
|
|
|
|
2015-06-03 14:36:34 +00:00
|
|
|
if(__glibc_unlikely (!isfinite (y) || y == 0)
|
2015-09-18 20:19:48 +00:00
|
|
|
&& (isfinite (x) || (isinf (x) && x < 0.0))
|
2011-10-12 15:27:51 +00:00
|
|
|
&& _LIB_VERSION != _IEEE_) {
|
2004-11-21 19:58:34 +00:00
|
|
|
if(x==0.0)
|
2012-03-28 09:32:12 +00:00
|
|
|
return __kernel_standard_l(x,x,250); /* tgamma pole */
|
2011-10-12 15:27:51 +00:00
|
|
|
else if(__floorl(x)==x&&x<0.0L)
|
2012-03-28 09:32:12 +00:00
|
|
|
return __kernel_standard_l(x,x,241); /* tgamma domain */
|
2013-12-05 14:01:41 +00:00
|
|
|
else if (y == 0)
|
|
|
|
__set_errno (ERANGE); /* tgamma underflow */
|
1998-07-28 16:26:04 +00:00
|
|
|
else
|
2012-03-28 09:32:12 +00:00
|
|
|
return __kernel_standard_l(x,x,240); /* tgamma overflow */
|
1998-07-28 16:26:04 +00:00
|
|
|
}
|
2011-10-12 15:27:51 +00:00
|
|
|
return local_signgam < 0 ? - y : y;
|
1998-07-28 16:26:04 +00:00
|
|
|
}
|
|
|
|
weak_alias (__tgammal, tgammal)
|