[libgfortran,patch] Add fallback functions tgamma, lgamma, tgammaf and lgammaf

FX Coudert fxcoudert@gmail.com
Mon Nov 12 04:25:00 GMT 2007


Attached patch adds fallback implementations of gamma-related C99  
functions that are missing on some targets. gamma and lgamma follow  
the formulas used in the Fortran netlib implementation, with extra  
care taken of exceptionnal values (when an argument or the result is  
either an infinity or a NaN) and handling of negative arguments for  
lgamma (which the netlib version ignores altogether).

Results of these implementation have be checked against glibc results  
on x86_64-linux, and only small differences in the last significant  
digits are observed (enough for a fallback implementation; it is also  
noteworthy that glibc results are always exact, especially for  
lgamma). There is one case where a difference exist: for very large  
negative arguments, this implementation returns +Inf while glibc  
returns NaN; I don't think it's worth putting extra effort into this  
case.

Regtested on x86_64-linux by pretending (tweaking config.h) that it  
didn't have any of these function in libm. OK to commit?

FX

PS: Thomas, as you were interested in these, if you later feel like  
refining this implementation, please feel free to do so!



:ADDPATCH libgfortran:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gamma.ChangeLog
Type: application/octet-stream
Size: 406 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20071112/0059bdfd/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gamma.diff
Type: application/octet-stream
Size: 10473 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20071112/0059bdfd/attachment-0001.obj>


More information about the Fortran mailing list