Benjamin Peterson
9de7298102
remove redundant sentence
2008-12-20 22:49:24 +00:00
Benjamin Peterson
fed67fd41e
beef up docstring
2008-12-20 02:57:19 +00:00
Mark Dickinson
4c96fa5525
Issues #3167 , #3682 : tests for math.log and math.log10 were failing on
...
Solaris and OpenBSD. Fix this by handling special values and domain
errors directly in mathmodule.c, passing only positive nonspecial floats
to the system log/log10.
2008-12-11 19:28:08 +00:00
Mark Dickinson
ff3fdce0d2
Replace math.sum with math.fsum in a couple of comments
...
that were missed by r65308
2008-07-30 16:25:16 +00:00
Mark Dickinson
fef6b13c32
Rename math.sum to math.fsum
2008-07-30 16:20:10 +00:00
Mark Dickinson
abe0aee3cf
Fix special-value handling for math.sum.
...
Also minor cleanups to the code: fix tabbing, remove
trailing whitespace, and reformat to fit into 80
columns.
2008-07-30 12:01:41 +00:00
Mark Dickinson
2fcd8c9703
Fix another typo in math_sum comment
2008-06-20 15:26:19 +00:00
Andrew M. Kuchling
5f198bee4e
Fix comment typos
2008-06-20 02:11:42 +00:00
Raymond Hettinger
2281da42b0
Fix double decref.
2008-06-18 00:56:57 +00:00
Mark Dickinson
fb1c4b98e9
Issue 3118: make test_math pass on Ubuntu/ia64. exp(-745.0) was raising
...
OverflowError incorrectly on this platform, presumably as a result of
the libm setting errno = ERANGE for this call.
2008-06-17 21:16:55 +00:00
Raymond Hettinger
d623414141
Unhappy buildbots. Revert 64052. Long doubles have unexpected effects on some builds.
2008-06-09 11:24:47 +00:00
Raymond Hettinger
7b1ed66372
Address double-rounding scenarios by setting all variables to long doubles.
2008-06-09 09:29:17 +00:00
Raymond Hettinger
ecbdd2e9b0
Issue #2138 : Add math.factorial().
2008-06-09 06:54:45 +00:00
Raymond Hettinger
ef712d6fd3
* Mark intermedidate computes values (hi, lo, yr) as volatile.
...
* Expand comments.
* Swap variable names in the sum_exact code so that x and y
are consistently chosen as the larger and smaller magnitude
values respectively.
2008-05-30 18:20:50 +00:00
Raymond Hettinger
2a9179ac73
Fix two typos.
2008-05-29 08:38:23 +00:00
Raymond Hettinger
778d5cc4fb
Tweak the comments and formatting.
2008-05-23 04:32:43 +00:00
Mark Dickinson
99dfe92759
Issue #2819 : Add math.sum, a function that sums a sequence of floats
...
efficiently but with no intermediate loss of precision. Based on
Raymond Hettinger's ASPN recipe. Thanks Jean Brouwers for the patch.
2008-05-23 01:35:30 +00:00
Mark Dickinson
f8476c1573
Issue #2487 . math.ldexp(x, n) raised OverflowError when n was large and
...
negative; fix to return an (appropriately signed) zero instead.
2008-05-09 17:54:23 +00:00
Mark Dickinson
0da94c8a34
Silence 'r may be used uninitialized' compiler warning.
2008-04-21 01:55:50 +00:00
Mark Dickinson
92483cd8da
math.atan2 is misbehaving on Windows; this patch
...
should fix the problem in the same way that
the cmath.phase problems were fixed.
2008-04-20 21:39:04 +00:00
Mark Dickinson
cec3f138d8
Yet more explicit special case handling to make
...
math.pow behave on alpha Tru64. All IEEE 754
special values are now handled directly; only
the finite**finite case is handled by libm.
2008-04-20 04:13:13 +00:00
Mark Dickinson
b2f7090239
FreeBSD doesn't follow C99 for modf(inf); so add explicit
...
special-value handling to math.modf code.
2008-04-20 01:39:24 +00:00
Mark Dickinson
a1293eb65f
Additional special-case handling for math.pow.
...
Windows/VS2008 doesn't like (-1)**(+-inf).
2008-04-19 19:41:52 +00:00
Mark Dickinson
e941d97d12
Additional tests for math.pow, and extra special-case
...
handling code in math.pow, in the hope of making all
tests pass on the alpha Tru64 buildbot.
2008-04-19 18:51:48 +00:00
Christian Heimes
6f34109384
I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
...
The patch also adds acosh, asinh, atanh, log1p and copysign to all platforms. Finally it fixes differences between platforms like different results or exceptions for edge cases. Have fun :)
2008-04-18 23:13:07 +00:00
Raymond Hettinger
fe424f754f
Neaten-up a bit.
2008-02-02 05:24:44 +00:00
Jeffrey Yasskin
ca2b69f765
Move __builtins__.trunc() to math.trunc() per
...
http://mail.python.org/pipermail/python-dev/2008-January/076626.html and issue
1965.
2008-02-01 06:22:46 +00:00
Christian Heimes
543cabc842
setup.py doesn't pick up changes to a header file
2008-01-25 14:54:23 +00:00
Neal Norwitz
5f95a79b2b
Add prototypes to get the mathmodule.c to compile on OSF1 5.1 (Tru64)
...
and eliminate a compiler warning in floatobject.c. There might be
a better way to go about this, but it should be good enough for now.
2008-01-25 08:04:16 +00:00
Jeffrey Yasskin
9871d8fe22
Continue rolling back pep-3141 changes that changed behavior from 2.5. This
...
round included:
* Revert round to its 2.6 behavior (half away from 0).
* Because round, floor, and ceil always return float again, it's no
longer necessary to have them delegate to __xxx___, so I've ripped
that out of their implementations and the Real ABC. This also helps
in implementing types that work in both 2.6 and 3.0: you return int
from the __xxx__ methods, and let it get enabled by the version
upgrade.
* Make pow(-1, .5) raise a ValueError again.
2008-01-05 08:47:13 +00:00
Christian Heimes
66ecda4990
Fixed math.copysign() on Windows
2008-01-04 01:48:50 +00:00
Christian Heimes
eebb79cc69
Added copysign(x, y) function to the math module
2008-01-03 22:32:26 +00:00
Christian Heimes
e2ca4245c9
Added math.isinf() and math.isnan()
2008-01-03 20:23:15 +00:00
Jeffrey Yasskin
2f3c16be73
Backport PEP 3141 from the py3k branch to the trunk. This includes r50877 (just
...
the complex_pow part), r56649, r56652, r56715, r57296, r57302, r57359, r57361,
r57372, r57738, r57739, r58017, r58039, r58040, and r59390, and new
documentation. The only significant difference is that round(x) returns a float
to preserve backward-compatibility. See http://bugs.python.org/issue1689 .
2008-01-03 02:21:52 +00:00
Neal Norwitz
45e230a8e1
Speed up function calls into the math module by using METH_O.
...
There should be no functional changes. However, the error msgs are
slightly different. Also verified that the module dict is not NULL on init.
2006-11-19 21:26:53 +00:00
Georg Brandl
a355c14fa1
Whoops.
2006-05-29 22:00:30 +00:00
Georg Brandl
bf92f46572
Convert more modules to METH_VARARGS.
2006-05-29 21:58:42 +00:00
Neal Norwitz
1ac754fa10
Check return result from Py_InitModule*(). This API can fail.
...
Probably should be backported.
2006-01-19 06:09:39 +00:00
Michael W. Hudson
9ef852c6c2
Make that a C, not a C++, comment.
2005-04-06 13:05:18 +00:00
Michael W. Hudson
2ea3072805
Add a comment explaining the import of longintrepr.h.
2005-04-06 11:27:40 +00:00
Hye-Shik Chang
77d9a3effa
Patch #871657 : Set EDOM for `nan' return values on FreeBSD and OpenBSD.
...
This fixes a problem that math.sqrt(-1) doesn't raise math.error.
2004-03-22 08:43:55 +00:00
Jack Jansen
fb2765666f
Getting rid of support for the ancient Apple MPW compiler.
2003-11-19 15:24:47 +00:00
Raymond Hettinger
8ae4689657
Simplify and speedup uses of Py_BuildValue():
...
* Py_BuildValue("(OOO)",a,b,c) --> PyTuple_Pack(3,a,b,c)
* Py_BuildValue("()",a) --> PyTuple_New(0)
* Py_BuildValue("O", a) --> Py_INCREF(a)
2003-10-12 19:09:37 +00:00
Raymond Hettinger
ea3fdf44a2
SF patch #659536 : Use PyArg_UnpackTuple where possible.
...
Obtain cleaner coding and a system wide
performance boost by using the fast, pre-parsed
PyArg_Unpack function instead of PyArg_ParseTuple
function which is driven by a format string.
2002-12-29 16:33:45 +00:00
Raymond Hettinger
866964c3a3
Apply SF patch 652930: Add optional base argument to math.log(x[, base]).
2002-12-14 19:51:34 +00:00
Mark Hammond
fe51c6d66e
Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototype
...
for Py_Main().
Thanks to Kalle Svensson and Skip Montanaro for the patches.
2002-08-02 02:27:13 +00:00
Martin v. Löwis
14f8b4cfcb
Patch #568124 : Add doc string macros.
2002-06-13 20:33:02 +00:00
Raymond Hettinger
d6f2267a83
Added degrees() and radians() to mathmodule. Closes patch 552452 and
...
feature request 426539.
2002-05-13 03:56:10 +00:00
Martin v. Löwis
387c547fd3
Revert parts of patch #453627 , documenting the resulting test failures
...
instead.
2001-09-06 08:16:17 +00:00
Tim Peters
a40c793d06
Rework the way we try to check for libm overflow, given that C99 no longer
...
requires that errno ever get set, and it looks like glibc is already
playing that game. New rules:
+ Never use HUGE_VAL. Use the new Py_HUGE_VAL instead.
+ Never believe errno. If overflow is the only thing you're interested in,
use the new Py_OVERFLOWED(x) macro. If you're interested in any libm
errors, use the new Py_SET_ERANGE_IF_OVERFLOW(x) macro, which attempts
to set errno the way C89 said it worked.
Unfortunately, none of these are reliable, but they work on Windows and I
*expect* under glibc too.
2001-09-05 22:36:56 +00:00