[SciPy-dev] Definition of gammaln(x) for negative x
G-J van Rooyen
Mon Nov 3 09:38:44 CST 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?
2008/11/3 David Cournapeau <firstname.lastname@example.org>:
> 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 :)
> Scipy-dev mailing list
More information about the Scipy-dev