[SciPy-dev] Definition of gammaln(x) for negative x

G-J van Rooyen gvrooyen at gmail.com
Mon Nov 3 10:38:44 EST 2008


The C code in the cephes maths library (for which gammaln is just a
wrapper) takes the C-ish approach of updating the sign in a global
extern int sgngam. Presumably the user of the C function would check
sgngam after a call to lgamma() if needed.

I don't much like functions returning auxiliary results in globals,
since they may have side effects (e.g. with threads) and break
modularity... but I also agree with David that a function should
return just one type of result. Alternatively, passing an optional
second mutable argument where the sign can get stored is just clunky.

Creating a second, differently-named function (e.g. gammaln2) that
returns magnitude and sign information is probably just as bad as
having varying return types.

So which of the above is the lesser evil? Or is there an elegant solution?

G-J


2008/11/3 David Cournapeau <david at ar.media.kyoto-u.ac.jp>:
> Stéfan van der Walt wrote:
>>
>> This is my favorite quote of the week!
>>
>
> Oups. This should of course read returning different *number* of return
> values depending on the argument :)
>
> David
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
>



More information about the SciPy-Dev mailing list