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

Robert Kern robert.kern@gmail....
Mon Nov 3 11:12:49 CST 2008

On Mon, Nov 3, 2008 at 09:38, G-J van Rooyen <gvrooyen@gmail.com> wrote:
> 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?

The latter. By far. I'm not sure why you think it would be just as bad
as having varying return types.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco

More information about the Scipy-dev mailing list