Missing erf()

Carsten Haese carsten at uniqsys.com
Mon Jan 1 21:53:44 CET 2007


On Sun, 2006-12-31 at 13:23 -0600, skip at pobox.com wrote:
>     rrenaud> Is there a reason why erf() is not included in the math
>     rrenaud> package?  According to the following URL it looks like it has
>     rrenaud> been standard C since 1999.
> 
> Python is implemented in the C89 dialect.  Maybe Python 3.0 will be
> implemented using C99.

In the meantime, you could:

1) Patch mathmodule.c to add the missing function(s), or
2) Make a small extension module that exposes the missing function(s),
or
3) Use ctypes to access libm directly. Something along the lines of
this:

>>> from ctypes import *
>>> libm = CDLL("libm.so")
>>> libm.erf.restype = c_double
>>> libm.erf(c_double(0))
0.0
>>> libm.erf(c_double(1))
0.84270079294971489
>>> libm.erf(c_double(2))
0.99532226501895271

Hope this helps,

Carsten.





More information about the Python-list mailing list