py/modmath: New function math hypot.#8593
py/modmath: New function math hypot.#8593Leah1115 wants to merge 1 commit intomicropython:masterfrom
Conversation
dlech
left a comment
There was a problem hiding this comment.
It would be good to add this function to docs/library/math.rst too.
And mark the relevant line as Completed in docs/differences/python_38.rst.
| ans = (mp_float_t)0.0; | ||
| for (size_t i = 0; i < n_args; i++) { | ||
| a = mp_obj_get_float(args[i]); | ||
| a_pow2 = MICROPY_FLOAT_C_FUN(pow)(a, 2); |
There was a problem hiding this comment.
Would it be more efficient to just do ans += a * a instead of calling pow?
| (), | ||
| (1.5, 1.5, 0.5), | ||
| (1.5, 0.5, 1.5), | ||
| ), |
There was a problem hiding this comment.
Should we add tests for NaN and infinity arguments and return values?
|
This is an automated heads-up that we've just merged a Pull Request See #13763 A search suggests this PR might apply the STATIC macro to some C code. If it Although this is an automated message, feel free to @-reply to me directly if |
Implement the math.hypot function.
This implementation covers the Change in CPython 3.8, Multidimensional support of math.hypot(). python/cpython#8474
This was worked on with the assistance of @wang3450