summaryrefslogtreecommitdiffstats
path: root/Modules/mathmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* missing multiply symbol in the documentation (GH-24686)Alperen Serkan Aksöz2021-03-031-1/+1
|
* bpo-42323: Fix math.nextafter() on AIX (GH-24381)Victor Stinner2021-01-291-2/+2
| | | math_nextafter_impl() must return a Python object, not a C double.
* bpo-42323: Fix math.nextafter() for NaN on AIX (GH-24265)Victor Stinner2021-01-201-0/+6
|
* bpo-42161: Modules/ uses _PyLong_GetZero() and _PyLong_GetOne() (GH-22998)Victor Stinner2020-10-271-5/+6
| | | | | | Use _PyLong_GetZero() and _PyLong_GetOne() in Modules/ directory. _cursesmodule.c and zoneinfo.c are now built with Py_BUILD_CORE_MODULE macro defined.
* Update link to supporting references (GH-22488)Raymond Hettinger2020-10-021-1/+1
|
* bpo-41513: Improve order of adding fractional values. Improve variable ↵Raymond Hettinger2020-09-231-12/+12
| | | | names. (GH-22368)
* Make fractional value accumulation consistent inside and outside the loop. ↵Raymond Hettinger2020-09-191-5/+4
| | | | (GH-22315)
* bpo-41513: Add docs and tests for hypot() (GH-22238)Raymond Hettinger2020-09-141-7/+7
|
* bpo-41513: Expand comments and add references for a better understanding ↵Raymond Hettinger2020-09-061-5/+21
| | | | (GH-22123)
* Improve hypot() accuracy with three separate accumulators (GH-22032)Raymond Hettinger2020-09-021-4/+4
|
* Further improve accuracy of math.hypot() (GH-22013)Raymond Hettinger2020-08-301-3/+8
|
* bpo-41513: Save unnecessary steps in the hypot() calculation (#21994)Raymond Hettinger2020-08-291-5/+10
|
* Fix typos in comment (GH-21966)Raymond Hettinger2020-08-261-2/+2
|
* bpo-41513: More accurate hypot() (GH-21916)Raymond Hettinger2020-08-251-37/+111
|
* bpo-41513: Improve speed and accuracy of math.hypot() (GH-21803)Raymond Hettinger2020-08-161-3/+38
|
* On path with known exact float, extract the double with the fast macro. ↵Raymond Hettinger2020-06-231-5/+10
| | | | (GH-21072)
* bpo-29782: Consolidate _Py_Bit_Length() (GH-20739)Niklas Fiekas2020-06-151-0/+1
| | | | | | | | | | In GH-2866, _Py_Bit_Length() was added to pymath.h for lack of a better location. GH-20518 added a more appropriate header file for bit utilities. It also shows how to properly use intrinsics. This allows reconsidering bpo-29782. * Move the function to the new header. * Changed return type to match __builtin_clzl() and reviewed usage. * Use intrinsics where available. * Pick a fallback implementation suitable for inlining.
* bpo-40792: Make the result of PyNumber_Index() always having exact type int. ↵Serhiy Storchaka2020-05-281-28/+2
| | | | | | | | | | | | (GH-20443) Previously, the result could have been an instance of a subclass of int. Also revert bpo-26202 and make attributes start, stop and step of the range object having exact type int. Add private function _PyNumber_Index() which preserves the old behavior of PyNumber_Index() for performance to use it in the conversion functions like PyLong_AsLong().
* bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)Serhiy Storchaka2020-05-261-30/+2
| | | | Only __index__ should be used to make integer conversions lossless.
* bpo-1635741: Port math module to multiphase initialization (GH-19243)Dong-hee Na2020-03-311-25/+33
|
* bpo-39871: Fix possible SystemError in atan2, copysign and remainder (GH-18806)Zackery Spytz2020-03-141-1/+5
| | | | | | In math_2(), the first PyFloat_AsDouble() call should be checked for failure before the second call. Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* bpo-39648: Expand math.gcd() and math.lcm() to handle multiple arguments. ↵Serhiy Storchaka2020-02-231-74/+109
| | | | | | | | | | | | | | | | (GH-18604) * bpo-39648: Expand math.gcd() and math.lcm() to handle multiple arguments. * Simplify fast path. * Difine lcm() without arguments returning 1. * Apply suggestions from code review Co-Authored-By: Mark Dickinson <dickinsm@gmail.com> Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* bpo-39479:Add math.lcm() function: Least Common Multiple (#18547)ananthan-1232020-02-191-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Update math.rst * Update math.rst * updated whats new * Update test_math.py * Update mathmodule.c * Update mathmodule.c.h * Update ACKS * 📜🤖 Added by blurb_it. * Update 3.9.rst * Update 2020-02-18-12-37-16.bpo-39479.j3UcCq.rst * Update math.rst * Update 2020-02-18-12-37-16.bpo-39479.j3UcCq.rst * Update test_math.py * Update ACKS * Update mathmodule.c.h * Update mathmodule.c * Update mathmodule.c.h * Update mathmodule.c.h Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* bpo-35081: Move dtoa.h header to the internal C API (GH-18489)Victor Stinner2020-02-121-0/+1
| | | | | | | Move the dtoa.h header file to the internal C API as pycore_dtoa.h: it only contains private functions (prefixed by "_Py"). The math and cmath modules must now be compiled with the Py_BUILD_CORE macro defined.
* bpo-39396: Fix math.nextafter(-0.0, +0.0) on AIX 7.1 (GH-18094)Victor Stinner2020-01-211-2/+8
| | | | Move also math.nextafter() on math.ulp() tests from IsCloseTests to MathTests.
* bpo-31031: Unify duplicate bits_in_digit and bit_length (GH-2866)Niklas Fiekas2020-01-161-25/+3
| | | Add _Py_bit_length() to unify duplicate bits_in_digit() and bit_length().
* bpo-39310: Add math.ulp(x) (GH-17965)Victor Stinner2020-01-131-0/+32
| | | | Add math.ulp(): return the value of the least significant bit of a float.
* bpo-39288: Add math.nextafter(x, y) (GH-17937)Victor Stinner2020-01-121-0/+20
| | | Return the next floating-point value after x towards y.
* bpo-38835: Don't use PyFPE_START_PROTECT and PyFPE_END_PROTECT (GH-17231)Victor Stinner2019-11-201-19/+0
| | | | | The PyFPE_START_PROTECT() and PyFPE_END_PROTECT() macros are empty: they have been doing nothing for the last year (since commit 735ae8d139a673b30b321dc10acfd3d14f0d633b), so stop using them.
* bpo-38639: Optimize floor(), ceil() and trunc() for floats. (GH-16991)Serhiy Storchaka2019-11-161-20/+28
|
* bpo-37691: Let math.dist() accept sequences and iterables for coordinates ↵Raymond Hettinger2019-07-271-6/+36
| | | | (GH-14975)
* Fix inconsequential typo in math.remainder algorithm comments. (#14746)Mark Dickinson2019-07-131-1/+1
|
* bpo-37548: Document range of atan, acos and asin (GH-14717)Giovanni Cappellotto2019-07-131-3/+6
|
* Fix some typos (GH-14435)Min ho Kim2019-07-051-1/+1
|
* bpo-37315: Deprecate accepting floats in math.factorial(). (GH-14147)Serhiy Storchaka2019-06-171-0/+6
|
* Turn math.isqrt assertion into a comment to clarify its purpose. (GH-14131)Mark Dickinson2019-06-161-1/+1
|
* Simplify negativity checks in math.comb and math.perm. (GH-13870)Mark Dickinson2019-06-161-10/+16
|
* bpo-37178: Allow a one argument form of math.perm() (GH-13905)Raymond Hettinger2019-06-081-2/+8
|
* bpo-35431: Drop the k <= n requirement (GH-13798)Raymond Hettinger2019-06-041-15/+18
|
* bpo-37128: Add math.perm(). (GH-13731)Serhiy Storchaka2019-06-021-1/+129
|
* bpo-35431: Refactor math.comb() implementation. (GH-13725)Serhiy Storchaka2019-06-011-74/+81
| | | | | | | * Fixed some bugs. * Added support for index-likes objects. * Improved error messages. * Cleaned up and optimized the code. * Added more tests.
* bpo-35431: Implemented math.comb (GH-11414)Yash Aggarwal2019-06-011-0/+121
|
* bpo-36957: Speed up math.isqrt (#13405)Mark Dickinson2019-05-191-8/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add math.isqrt function computing the integer square root. * Code cleanup: remove redundant comments, rename some variables. * Tighten up code a bit more; use Py_XDECREF to simplify error handling. * Update Modules/mathmodule.c Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com> * Update Modules/mathmodule.c Use real argument clinic type instead of an alias Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com> * Add proof sketch * Updates from review. * Correct and expand documentation. * Fix bad reference handling on error; make some variables block-local; other tidying. * Style and consistency fixes. * Add missing error check; don't try to DECREF a NULL a * Simplify some error returns. * Another two test cases: - clarify that floats are rejected even if they happen to be squares of small integers - TypeError beats ValueError for a negative float * Add fast path for small inputs. Needs tests. * Speed up isqrt for n >= 2**64 as well; add extra tests. * Reduce number of test-cases to avoid dominating the run-time of test_math. * Don't perform unnecessary extra iterations when computing c_bit_length. * Abstract common uint64_t code out into a separate function. * Cleanup. * Add a missing Py_DECREF in an error branch. More cleanup. * Update Modules/mathmodule.c Add missing `static` declaration to helper function. Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com> * Add missing backtick.
* bpo-36957: Add _PyLong_Rshift() and _PyLong_Lshift(). (GH-13416)Serhiy Storchaka2019-05-191-23/+7
|
* bpo-36887: add math.isqrt (GH-13244)Mark Dickinson2019-05-181-0/+261
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add math.isqrt function computing the integer square root. * Code cleanup: remove redundant comments, rename some variables. * Tighten up code a bit more; use Py_XDECREF to simplify error handling. * Update Modules/mathmodule.c Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com> * Update Modules/mathmodule.c Use real argument clinic type instead of an alias Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com> * Add proof sketch * Updates from review. * Correct and expand documentation. * Fix bad reference handling on error; make some variables block-local; other tidying. * Style and consistency fixes. * Add missing error check; don't try to DECREF a NULL a * Simplify some error returns. * Another two test cases: - clarify that floats are rejected even if they happen to be squares of small integers - TypeError beats ValueError for a negative float * Documentation and markup improvements; thanks Serhiy for the suggestions! * Cleaner Misc/NEWS entry wording. * Clean up (with one fix) to the algorithm explanation and proof.
* bpo-36908: 'This module is always available' isn't helpful. (#13297)Ned Batchelder2019-05-171-2/+2
| | | | Makes the documentation of math and cmath module more helpful for the beginners.
* Rework integer overflow path in math.prod and add more tests (GH-11809)Pablo Galindo2019-03-091-5/+51
| | | | | The overflow check was relying on undefined behaviour as it was using the result of the multiplication to do the check, and once the overflow has already happened, any operation on the result is undefined behaviour. Some extra checks that exercise code paths related to this are also added.
* bpo-36106: Resolve sinpi name clash with libm (IEEE-754 violation). (GH-12027)Dima Pasechnik2019-02-261-4/+4
| | | | | | | | | The standard math library (libm) may follow IEEE-754 recommendation to include an implementation of sinPi(), i.e. sinPi(x):=sin(pi*x). And this triggers a name clash, found by FreeBSD developer Steve Kargl, who worken on putting sinpi into libm used on FreeBSD (it has to be named "sinpi", not "sinPi", cf. e.g. https://en.cppreference.com/w/c/experimental/fpext4).
* Fix division by 0 when checking for overflow in math.prod (GH-11808)Pablo Galindo2019-02-101-2/+2
|
* bpo-35606: Implement math.prod (GH-11359)Pablo Galindo2019-02-071-0/+167
|