Message92294
Finally got around to looking at this properly.
Here's a first attempt at a patch to add gamma, lgamma, erf and erfc to
the math module. It uses the pymath.c.diff code from nirinA, and adds
docs, tests, and the extra infrastructure needed for the build system.
The code has gone in a new file called Modules/math_cextra.c. The old
approach of sticking things in pymath.c really isn't right, since that
ends up putting the extra code into the core Python executable instead
of the math module.
There are currently many test failures; some of these are undoubtedly
due to the tests being too strict, but some of them show problems with
the code for these functions. It should be possible to have erf and
erfc produce results accurate to within a few ulps (<50, say) over the
entire extended real line; getting gamma and lgamma accurate for
positive inputs should also be perfectly possible. Negative arguments
seem to be more difficult to get right.
To test the code on non-Windows, build with something like:
CC='gcc -DTEST_GAMMA' ./configure && make
the '-DTEST_GAMMA' just forces the build to use nirinA's code; without
this, the math module will use the libm functions if they're available.
This is just work-in-progress; apart from the test failures, there's
still a lot of polishing to do before this can go in.
The patch is against the trunk. |
|
Date |
User |
Action |
Args |
2009-09-05 19:27:18 | mark.dickinson | set | recipients:
+ mark.dickinson, rhettinger, terry.reedy, stutzbach, nirinA |
2009-09-05 19:27:16 | mark.dickinson | set | messageid: <1252178836.95.0.940019967294.issue3366@psf.upfronthosting.co.za> |
2009-09-05 19:27:15 | mark.dickinson | link | issue3366 messages |
2009-09-05 19:27:15 | mark.dickinson | create | |
|