Raymond Hettinger
808180c206
Fast path for int inputs to math.dist() and math.hypot() (GH-11692)
2019-01-28 13:59:56 -08:00
Serhiy Storchaka
d0d3e99120
bpo-35719: Optimize multi-argument math functions. (GH-11527)
...
Use the fast call convention for math functions atan2(),
copysign(), hypot() and remainder() and inline unpacking
arguments. This sped up them by 1.3--2.5 times.
2019-01-12 08:26:34 +02:00
Ammar Askar
cb08a71c5c
bpo-34838: Use subclass_of for math.dist. (GH-9659)
...
Argument clinic now generates fast inline code for
positional parsing, so the manually implemented type
check in math.dist can be removed.
2019-01-12 08:23:41 +02:00
Zackery Spytz
4c49da0cb7
bpo-35436: Add missing PyErr_NoMemory() calls and other minor bug fixes. (GH-11015)
...
Set MemoryError when appropriate, add missing failure checks,
and fix some potential leaks.
2018-12-07 12:11:30 +02:00
Raymond Hettinger
216aaaa056
Fixing wording in comment. (GH-10425)
...
Since the n==1 case just returns *max*, it cannot be larger
than the magnitude of the vector entry.
2018-11-09 01:06:02 -08:00
Raymond Hettinger
df8101517a
Speed-up math.dist() by 30% (GH-9628)
2018-09-29 14:30:38 -07:00
Pablo Galindo
e9ba3705de
bpo-33083 - Make math.factorial reject arguments that are not int-like (GH-6149)
...
math.factorial() was accepting non-integral Decimal instances. This is inconsistent with the actual behaviour for floats, which are not accepted.
2018-09-03 22:20:06 +01:00
Raymond Hettinger
f326714426
Minor improvement to code clarity (GH-9036)
...
Make it clear that the n==0 case is included. Otherwise, you have to know that max==0.0 whenever n==0.
2018-09-02 13:34:21 -07:00
Raymond Hettinger
745c0f3980
Simplify vector_norm() by eliminating special cases in the main loop (GH-9006)
...
The *max* value is no longer treated as a special case in the main loop. Besides making the main loop simpler and branchless, this also lets us relax the input restriction of *vec* to contain only non-negative values.
2018-08-31 11:22:13 -07:00
Raymond Hettinger
21786f5186
Improve commutativity of math.hypot() and math.dist() (GH-8984)
2018-08-28 22:47:24 -07:00
Raymond Hettinger
74734f73ca
Fast path for exact floats in math.hypot() and math.dist() (GH-8949)
2018-08-26 19:38:31 -05:00
Raymond Hettinger
a47f394af8
Minor code clean-up. Don't alter the input vector. Use variables instead. GH-8748
2018-08-12 14:18:56 -07:00
Raymond Hettinger
00414597b4
Add more tests and assertions for math.hypot() and math.dist() (GH-8747)
2018-08-12 12:15:23 -07:00
Raymond Hettinger
c630e10440
Factor-out common code. Also, optimize common cases by preallocating space on the stack. GH-8738
...
Improves speed by 9 to 10ns per call.
2018-08-11 18:39:05 -07:00
Raymond Hettinger
1399074535
Replace straight addition with Kahan summation and move max to the end (GH-8727)
2018-08-11 11:26:36 -07:00
Raymond Hettinger
9c18b1ae52
bpo-33089: Add math.dist() for computing the Euclidean distance between two points (GH-8561)
2018-07-31 00:45:49 -07:00
Raymond Hettinger
c6dabe37e3
bpo-33089: Multidimensional math.hypot() (GH-8474)
2018-07-28 07:48:04 -07:00
Barry Warsaw
b2e5794870
bpo-31338 ( #3374 )
...
* Add Py_UNREACHABLE() as an alias to abort().
* Use Py_UNREACHABLE() instead of assert(0)
* Convert more unreachable code to use Py_UNREACHABLE()
* Document Py_UNREACHABLE() and a few other macros.
2017-09-14 18:13:16 -07:00
Mark Dickinson
a0ce375e10
bpo-29962: add math.remainder ( #950 )
...
* Implement math.remainder.
* Fix markup for arguments; use double spaces after period.
* Mark up function reference in what's new entry.
* Add comment explaining the calculation in the final branch.
* Fix out-of-order entry in whatsnew.
* Add comment explaining why it's good enough to compare m with c, in spite of possible rounding error.
2017-04-05 18:34:27 +01:00
Louie Lu
7a26464c64
bpo-29946: Fix "sqrtpi defined but not used" ( #908 )
2017-03-30 20:05:10 +03:00
Serhiy Storchaka
4125e5c60e
bpo-26121: Revert to using the own implementations of lgamma and gamma on all platforms. ( #637 )
2017-03-12 14:08:06 +02:00
Serhiy Storchaka
97553fdf9d
bpo-26121: Use C library implementation for math functions: ( #515 )
...
* bpo-26121: Use C library implementation for math functions:
tgamma(), lgamma(), erf() and erfc().
* Don't use tgamma() and lgamma() from libc on OS X.
2017-03-11 21:37:16 +00:00
Mark Dickinson
5e65cd39df
Issue #29282 : Backed out changeset b33012ef1417
2017-01-21 13:10:52 +00:00
Mark Dickinson
d1b230e48b
Issue #29282 : add fused multiply-add function, math.fma.
2017-01-21 12:35:30 +00:00
Serhiy Storchaka
c9ea933586
Issue #20186 : Converted the math module to Argument Clinic.
...
Patch by Tal Einat.
2017-01-19 18:13:09 +02:00