Is there a way to see Scipy.Special.Gamma() function implementation in the source?

389 views Asked by At

I've tried to write functions to calculate special functions (e.g. exponential, gamma, erf, etc), but to do the sum or product operations, I used while-loop with 10k turns. This is very time-consuming.

Then, I realized that scipy.special.gamma() function is significantly faster than my while-loop and I wanted to see and study the implementation/algorithm of the gamma function, but I couldn't find the source codes on the internet.

Is there a way to see the source codes of Scipy?

1

There are 1 answers

0
Tirth Patel On BEST ANSWER

SciPy's source code is hosted on GitHub here: https://github.com/scipy/scipy

For floating-point arguments, SciPy uses CEPHES's implementation of gamma: https://github.com/scipy/scipy/blob/main/scipy/special/cephes/gamma.c

For complex arguments, SciPy uses a Cython implementation: https://github.com/scipy/scipy/blob/main/scipy/special/_loggamma.pxd