C++ code for gamma and log gamma

ANSI C99 and POSIX compliant compilers include functions tgamma and lgamma for computing the gamma function and its natural logarithm respectively. Visual Studio, however, does not support these standards.

Why are there separate functions for gamma and its logarithm? See this post for an explanation.

Here is stand-alone C++ code for the functions Gamma and LogGamma. Both require a positive argument.


Note that the functions Gamma and LogGamma are mutually dependent, but do not depend on anything else.

Related links:

C++ random number generation
Stand-alone numerical code

Click to find out more about consulting for numerical computing