builtin gamma function

Ed Smith-Rowland 3dw4rd@verizon.net
Tue Nov 15 21:45:00 GMT 2011


On 11/15/2011 08:51 AM, James Hirschorn wrote:
> I guess "fold" means do the computation at compile time?
>
> No, it is being called with a variable. That is interesting that libc has a
> gamma function. I will have to track down the implementation ...
>
> -----Original Message-----
> From: Ian Lance Taylor [mailto:iant@google.com]
> Sent: Tuesday, November 15, 2011 1:58 AM
> To: James Hirschorn
> Cc: gcc@gcc.gnu.org; james.hirschorn@gmail.com
> Subject: Re: builtin gamma function
>
> James Hirschorn<James.Hirschorn@hotmail.com>  writes:
>
>> I have noticed that the builtin gamma function is very accurate and
>> extremely fast. Can someone tell me where to find the source code for the
>> implementation?
> Are you calling it on a constant?  Because gcc will fold gamma applied
> to a constant which meets certain characteristics.
>
> If you aren't calling it on a constant, then you are getting the
> function from your libc.  gcc does not itself include an implementation
> of the gamma function.
>
> Ian
>
>
The Lancsos algorithm should be pretty fast.  OTOH there are a few logs 
and some divisions.
I'm betting they have a polynomial fit from 0 to 1 and then do 
\Gamma(x+1) = x\Gamma(x) or something.

Also, Maybe we could use constexpr in C++11 mode in some cases.



More information about the Gcc mailing list