Merged revisions 62380,62382-62383 via svnmerge from · wrongnull/cpython@53876d9 · GitHub
Skip to content

Commit 53876d9

Browse files
committed
Merged revisions 62380,62382-62383 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r62380 | christian.heimes | 2008-04-19 01:13:07 +0200 (Sat, 19 Apr 2008) | 3 lines 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 :) ........ r62382 | christian.heimes | 2008-04-19 01:40:40 +0200 (Sat, 19 Apr 2008) | 2 lines Added new files to Windows project files More Windows related fixes are coming soon ........ r62383 | christian.heimes | 2008-04-19 01:49:11 +0200 (Sat, 19 Apr 2008) | 1 line Stupid me. Py_RETURN_NAN should actually return something ... ........
1 parent dc3e06c commit 53876d9

27 files changed

Lines changed: 5096 additions & 1162 deletions

Doc/library/cmath.rst

Lines changed: 107 additions & 13 deletions

Doc/library/math.rst

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,26 @@ Power and logarithmic functions:
128128
return the natural logarithm of *x* (that is, the logarithm to base *e*).
129129

130130

131+
.. function:: log1p(x)
132+
133+
Return the natural logarithm of *1+x* (base *e*). The
134+
result is calculated in a way which is accurate for *x* near zero.
135+
136+
.. versionadded:: 2.6
137+
138+
131139
.. function:: log10(x)
132140

133141
Return the base-10 logarithm of *x*.
134142

135143

136144
.. function:: pow(x, y)
137145

138-
Return ``x**y``.
146+
Return ``x**y``. ``1.0**y`` returns *1.0*, even for ``1.0**nan``. ``0**y``
147+
returns *0.* for all positive *y*, *0* and *NAN*.
148+
149+
.. versionchanged:: 2.6
150+
The outcome of ``1**nan`` and ``0**nan`` was undefined.
139151

140152

141153
.. function:: sqrt(x)
@@ -186,6 +198,13 @@ Trigonometric functions:
186198
Return the sine of *x* radians.
187199

188200

201+
.. function:: asinh(x)
202+
203+
Return the inverse hyperbolic sine of *x*, in radians.
204+
205+
.. versionadded:: 2.6
206+
207+
189208
.. function:: tan(x)
190209

191210
Return the tangent of *x* radians.
@@ -210,6 +229,13 @@ Hyperbolic functions:
210229
Return the hyperbolic cosine of *x*.
211230

212231

232+
.. function:: acosh(x)
233+
234+
Return the inverse hyperbolic cosine of *x*, in radians.
235+
236+
.. versionadded:: 2.6
237+
238+
213239
.. function:: sinh(x)
214240

215241
Return the hyperbolic sine of *x*.
@@ -219,6 +245,14 @@ Hyperbolic functions:
219245

220246
Return the hyperbolic tangent of *x*.
221247

248+
249+
.. function:: atanh(x)
250+
251+
Return the inverse hyperbolic tangent of *x*, in radians.
252+
253+
.. versionadded:: 2.6
254+
255+
222256
The module also defines two mathematical constants:
223257

224258

@@ -231,6 +265,7 @@ The module also defines two mathematical constants:
231265

232266
The mathematical constant *e*.
233267

268+
234269
.. note::
235270

236271
The :mod:`math` module consists mostly of thin wrappers around the platform C
@@ -244,9 +279,17 @@ The module also defines two mathematical constants:
244279
:exc:`OverflowError` isn't defined, and in cases where ``math.log(0)`` raises
245280
:exc:`OverflowError`, ``math.log(0L)`` may raise :exc:`ValueError` instead.
246281

282+
All functions return a quite *NaN* if at least one of the args is *NaN*.
283+
Signaling *NaN*s raise an exception. The exception type still depends on the
284+
platform and libm implementation. It's usually :exc:`ValueError` for *EDOM*
285+
and :exc:`OverflowError` for errno *ERANGE*.
286+
287+
..versionchanged:: 2.6
288+
In earlier versions of Python the outcome of an operation with NaN as
289+
input depended on platform and libm implementation.
290+
247291

248292
.. seealso::
249293

250294
Module :mod:`cmath`
251295
Complex number versions of many of these functions.
252-

Include/Python.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC)
5858
#error "PYMALLOC_DEBUG requires WITH_PYMALLOC"
5959
#endif
60+
#include "pymath.h"
6061
#include "pymem.h"
6162

6263
#include "object.h"

Include/complexobject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ typedef struct {
1919
#define c_prod _Py_c_prod
2020
#define c_quot _Py_c_quot
2121
#define c_pow _Py_c_pow
22+
#define c_abs _Py_c_abs
2223

2324
PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex);
2425
PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex);
2526
PyAPI_FUNC(Py_complex) c_neg(Py_complex);
2627
PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex);
2728
PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex);
2829
PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex);
30+
PyAPI_FUNC(double) c_abs(Py_complex);
2931

3032

3133
/* Complex object interface */

Include/floatobject.h

Lines changed: 11 additions & 0 deletions

0 commit comments

Comments
 (0)