[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2010-01-09 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
status: pending - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2010-01-03 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Will close this unless there's an outcry of support for exp2 and log2.
nirinA,  if you're still interested in adding the euler constant, please open 
another issue.

--
status: open - pending

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2010-01-02 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

The last two functions to consider adding are exp2 and log2.  Does anyone 
care about these?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2010-01-02 Thread Daniel Stutzbach

Daniel Stutzbach dan...@stutzbachenterprises.com added the comment:

Any time I've ever needed log2(x), log(x)/log(2) was sufficient.

In Python, exp2(x) can be spelled 2.0**x.  What would exp2(x) gain us?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2010-01-02 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

 In Python, exp2(x) can be spelled 2.0**x.  What would exp2(x) gain us?

Not much, I suspect.  :)

I'd expect (but am mostly guessing) exp2(x) to have better accuracy than 
pow(2.0, x) for some math libraries;  I'd further guess that it's somewhat 
more likely to give exact results for (small) integral x.

Similarly for log2:  log2(n) should be a touch more accurate than 
log(n)/log(2), and the time you're most likely to notice the difference is 
when n is an exact power of 2.

But we've already got the 'bit_length' method for integers, which fills 
some of the potential uses for log2.  So unless there's a feeling that 
these functions are needed, I'd rather leave them out.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-12-19 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Added erf and erfc in r76879 (trunk), r76880 (py3k).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-12-19 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Oops.  That's r76878 (trunk) and r76879 (py3k).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-12-16 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Here's a patch to add expm1.  Rather than putting the code in pymath.c, 
which is the wrong place (see issue #7518), I've added a new file 
Modules/_math.c for this;  log1p, atanh, etc. should also eventually be 
moved from pymath.c into this file.

I'm fairly confident that the maths and numerics are okay, but less 
confident about my changes to the build structure;  if anyone has a chance 
to test this patch, especially on Windows, I'd welcome feedback.  I've 
tested it on OS X, and will test on Linux.

--
Added file: http://bugs.python.org/file15574/expm1.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-12-16 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

I committed the patch for expm1 in r76861 (trunk) and r76863 (py3k), with 
one small change:  instead of using 2 * exp(x/2) * sinh(x/2), expm1 is now 
computed using a method due to Kahan that involves only exp and log.  This 
seems a little safer, and guards against problems on platforms with a 
naive implementation of sinh.  (I *hope* no such platforms exist, but 
suspect that's wishful thinking. :-)

Thanks to Eric Smith for testing the build system changes on Windows.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-12-13 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

nirinA: thanks for the erf patch.  It's fine as far as it goes;  the main 
technical issue is that the series development only converges at a 
sensible rate for smallish x;  for larger x something more is needed.

Here's a prototype patch for the erf and erfc functions that uses a power 
series (not quite the same as the series nirinA used;  by pulling out a 
factor of exp(-x*2) you can make all coefficients in the remaining series 
positive, which is good for the numerics) for small x, and a continued 
fraction expansion for larger x.   The erf and erfc functions are 
currently written in Python.  I'll do some more testing (and possibly 
tweaking) of this patch and then translate the Python to C.

--
Added file: http://bugs.python.org/file15539/erf.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-12-13 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Here's the C version.

--
Added file: http://bugs.python.org/file15540/erf_c.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-12-11 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

nirinA:  thanks for prodding this issue.  Yes, it is still alive (just). 
:)

About adding the Euler constant:  I agree this should be added.  Do you 
have time to expand your patch to include docs and a test or two?

For expm1, I was planning to use the libm function when it exists (which 
I expect it will on most platforms), and just use a quick hack based on 
the identity

  expm1(x) = sinh(x/2)*exp(x/2)

for platforms where it's missing.

I'll look at the erf and erfc implementations.

Daniel:  re incomplete beta and gamma functions, I'd prefer to limit 
this particular issue to the C99 math functions.  It's difficult to know 
where to draw the line, but it seems to me that these are really the 
domain of numpy/scipy.  And they involve multiple input arguments, which 
makes them *darned hard* to write and test!  Anyway, if you'd like to 
see those added to Python's math module, maybe this could be brought up 
on python-dev to see how much support there is.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-12-11 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

 expm1(x) = sinh(x/2)*exp(x/2)

Should be 2*sinh(x/2)*exp(x/2).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-12-11 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

lgamma patch committed to trunk (with looser tests) in r76755.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-12-07 Thread nirinA raseliarison

nirinA raseliarison nir...@mail.blueline.mg added the comment:

having the gamma function, one certainly needs the other Euler constant:
C = 0.5772

the C constant is taken from GSL

--
Added file: http://bugs.python.org/file15488/pymath.h.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-12-07 Thread nirinA raseliarison

nirinA raseliarison nir...@mail.blueline.mg added the comment:

for expm1, we use the Taylor development near zero, but
we have to precise what means small value for x. here this means
abs(x)  math.log(2.0).
one can also use abs(x)  C

--
Added file: http://bugs.python.org/file15489/mathmodule.c.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-12-07 Thread nirinA raseliarison

nirinA raseliarison nir...@mail.blueline.mg added the comment:

finally, for the error function, with the same kind of idea as with expm1,
here is a pure python definition

these patches are against r27a1:76674

if all these make sense, i'll check for NAN, infinity, test suite...

--
Added file: http://bugs.python.org/file15490/erf.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-12-07 Thread nirinA raseliarison

nirinA raseliarison nir...@mail.blueline.mg added the comment:

may be some error when i send this the first time,
i cannot see the file, so i resend mathmodule.c.diff
sorry if you get it twice

--
Added file: http://bugs.python.org/file15491/mathmodule.c.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-10-18 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

Verified that r75454 makes the gamma test errors go away on a PPC Mac.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-10-17 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

For the record, these OS X installer build scripts (running on 10.5) 
results in these gcc options:

gcc-4.0 -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -
fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -
I/tmp/_py/libraries/usr/local/include -I. -IInclude -I/usr/local/include 
-I/private/tmp/_t/Include -I/private/tmp/_py/_bld/python -c 
/private/tmp/_t/Modules/mathmodule.c -o build/temp.macosx-10.3-fat-
3.2/private/tmp/_t/Modules/mathmodule.o

and:

$ gcc-4.0 --version
powerpc-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-10-17 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Hmm.  It looks as though the gamma computation itself is fine;  it's the 
accuracy check that's going wrong.

I'm suspecting an endianness issue and/or a struct module bug.

Ned, do you still get these failures with a direct single-architecture 
build on PPC?  Or just for the universal build?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-10-17 Thread Tim Peters

Tim Peters tim.pet...@gmail.com added the comment:

Adding

-mno-fused-madd

would be worth trying.  It usually fixes PPC bugs ;-)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-10-17 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

It was a stupid Mark bug.  I'd missed out a '' from the struct.unpack 
call that was translating floats into integers, for the purposes of 
computing ulps difference.  Fixed in r75454 (trunk), r75455 (py3k).

Thanks for reporting this, Ned.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-10-17 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

BTW, the gamma computation shouldn't be at all fragile, unless I've messed 
up somewhere:  the Lanczos sum is evaluated as a rational function in 
which both numerator and denominator have only positive coefficients, so 
there's little danger of nasty cancellations boosting the relative error.
I'd be surprised if use of fma instructions made more than 1 or 2 ulps 
difference to the result, but I'll take a look.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-10-17 Thread Tim Peters

Tim Peters tim.pet...@gmail.com added the comment:

Mark, you needn't bother:  you found the smoking gun already!  From your
description, I agree it would be very surprising if FMA made a
significant difference in the absence of catastrophic cancellation.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-10-16 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

FYI, approximately 20 of the gamma test cases fail on PPC Macs.  Attached 
are snippets from regrtest runs with trunk and with py3k, both on a G4 ppc 
(32-bit) running OS X 10.5.  Identical failures for trunk (did not try 
py3k) were observed on a G3 ppc with OS X 10.4.

--
nosy: +ned.deily
Added file: http://bugs.python.org/file15152/gamma-failures.txt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-10-16 Thread Tim Peters

Tim Peters tim.pet...@gmail.com added the comment:

FYI, mysterious numeric differences on PPC are often due to the C
compiler generated code to use the fused multiply-add HW instruction.
 In which case, find a way to turn that off :-)

--
nosy: +tim_one

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-09-21 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

New patch for gamma , with some tweaks:

 - return exact values for integral arguments: gamma(1) through gamma(23)
 - apply a cheap correction to improve accuracy of exp and pow
   computations
 - use a different form of the reflection formula:

 gamma(x) = -pi/sinpi(x)/x/gamma(x)

   (the usual reflection formula has accuracy problems for
x close to a power of 2;  e.g., x in (-64,-63) or x
in (-128, -127))

 - avoid duplication formula for large negative arguments
 - add a few extra tests

On my machine, testing with approx. 10**7 random samples, this version 
achieves an accuracy of = 10 ulps across the domain (comparing with 
correctly-rounded results generated by MPFR).  Limiting the test to 
arguments in the range (-256.0, 1/256.0] + [1/256.0, 256.0) (with each 
float in that range equally likely), the error in ulps from 10**6 samples 
has mean -0.104 and standard deviation 1.230.

I plan to check this in in a week or two.  Feedback welcome!  It would be 
especially useful to know whether this patch compiles correctly on 
Windows.

--
keywords: +needs review
stage:  - commit review
Added file: http://bugs.python.org/file14940/gamma4.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-09-21 Thread Daniel Stutzbach

Daniel Stutzbach dan...@stutzbachenterprises.com added the comment:

I'll test your patch on Windows.  Are you working against the trunk or
the py3k branch?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-09-21 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Thanks!  The patch is against the trunk.  (It doesn't quite apply cleanly 
to py3k, but the changes needed to make it do so should be minimal.)

Hmm. Rereading my previous comment, I seem to have a blindness for 
negative signs:

gamma(x) = -pi/sinpi(x)/x/gamma(x)

should have been

gamma(-x) = -pi/sinpi(x)/x/gamma(x)

and

(-256.0, 1/256.0] + [1/256.0, 256.0)

should have been

(-256.0, -1/256.0] + [1/256.0, 256.0)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-09-21 Thread Daniel Stutzbach

Daniel Stutzbach dan...@stutzbachenterprises.com added the comment:

I'm only setup to test the official Windows build setup under PCbuild. 
I'm not testing the legacy build setups under PC/VC6, PC/VS7.1, or PC/VS8.0.

The patch against the trunk failed for PC/VC6/pythoncore.dsp.  I don't
need that to build, though.

Your patch built fine, with one warning about a loss of precision on the
following line in sinpi():

n = round(2.0*y);

I recommend explicitly casting the result of round() to int, to get rid
of the warning and because explicit is better than implicit. :)

I ran the following tests, all of which passed:

PCbuild/python.exe Lib/test/regrtest.py -v test_math

I appreciate your work on this patch.  Let me know if there's anything
else I can do.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-09-21 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Many thanks, Daniel.

 The patch against the trunk failed for PC/VC6/pythoncore.dsp.  I don't
 need that to build, though.

I've no idea why that would happen.  A line-ending issue, perhaps?  If 
it doesn't stop me committing the change, then perhaps it's not a 
problem.

 Your patch built fine, with one warning about a loss of precision on
 the following line in sinpi():

n = round(2.0*y);

I recommend explicitly casting the result of round() to int, to get
rid of the warning and because explicit is better than implicit. :)

Done.  Thanks!

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-09-21 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

gamma5.patch.  very minor changes from the last patch:

 - add (int) cast suggested by Daniel Stutzbach
 - Misc/NEWS entry
 - ..versionadded in docs
 - minor corrections to some comments

--
Added file: http://bugs.python.org/file14943/gamma5.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-09-18 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Here's a more careful patch for just the gamma function.  It's a fairly 
direct implementation of Lanczos' formula, with the choice of parameters 
(N=13, g=6.024680040776729583740234375) taken from the Boost library.  In 
testing of random values and known difficult values, it's consistently 
giving errors of  5ulps across its domain.  This is considerably better 
than the error from the exp(lgamma(x)) method, since the exp call alone 
can easily introduce errors of hundreds of ulps for larger values of x.

I'd appreciate any feedback, especially if anyone has the chance to test 
on Windows:  I'd like to know whether I got the build modifications right.

This patch *doesn't* use the system gamma function, even when available.  
At least on OS X 10.5.8, the supplied gamma function has pretty terrible 
accuracy, and some severe numerical problems near negative integers.  I 
don't imagine Linux is much better.

Once this is working, I'll concentrate on lgamma.  Then erf and erfc.

--
Added file: http://bugs.python.org/file14927/gamma3.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-09-05 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

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.

--
versions: +Python 3.2 -Python 3.1
Added file: http://bugs.python.org/file14844/gamma.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2009-05-17 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


Removed file: http://bugs.python.org/file10983/unnamed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3366] Add gamma function, error functions and other C99 math.h functions to math module

2008-12-05 Thread Mark Dickinson

Mark Dickinson [EMAIL PROTECTED] added the comment:

There have been requests to add other C99 libm functions to Python:
expm1 is requested in issue 3501, and log2 came up in the issue 3724 
discussion.  I'm absorbing those issues into this one.

With these two, and the gamma and error functions, we're pretty close to 
implementing all the functions in C99s math.h.  Seems to me that we might 
as well aim for completeness and implement the whole lot.

--
title: Add gamma and error functions to math module - Add gamma function, 
error functions and other C99 math.h functions to math module

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3366
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com