问题
I am seeking a C or C++ version of gamma and log gamma functions.
Are there any code pieces or libraries recommended?
If possible, I want to know the principle of the implementations.
Thank you!!!
回答1:
If you can't use C++11: The GNU GSL has all Gamma function you would ever need: http://www.gnu.org/software/gsl/manual/html_node/Gamma-Functions.html#index-gsl_005fsf_005flngamma-583
Or you can have a look at boost's math special functions: http://www.boost.org/doc/libs/1_53_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/sf_gamma/lgamma.html
回答2:
In c++11, you can use std::lgamma for log gamma, and tgamma for gamma.
回答3:
You can try to have a look at Numerical Recipes In C, it should contain the functions you need.
来源:https://stackoverflow.com/questions/15472803/gamma-or-log-gamma-function-in-c-or-c