FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

py/modmath: New function math hypot. by Leah1115 · Pull Request #8593 · micropython/micropython · GitHub

Repository navigation

py/modmath: New function math hypot. - #8593

Open
Leah1115 wants to merge 1 commit into
micropython:masterfrom
ECE595:math/hypot-new-func
Open

Leah1115 wants to merge 1 commit into
micropython:masterfrom
ECE595:math/hypot-new-func

Conversation

Copy link
Copy Markdown

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

dlech left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Comment thread py/modmath.c
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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Would it be more efficient to just do ans += a * a instead of calling pow?

dpgeorge added the py-core Relates to py/ directory in source label Apr 29, 2022
(),
(1.5, 1.5, 0.5),
(1.5, 0.5, 1.5),
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Should we add tests for NaN and infinity arguments and return values?

Copy link
Copy Markdown
Contributor

This is an automated heads-up that we've just merged a Pull Request
that removes the STATIC macro from MicroPython's C API.

See #13763

A search suggests this PR might apply the STATIC macro to some C code. If it
does, then next time you rebase the PR (or merge from master) then you should
please replace all the STATIC keywords with static.

Although this is an automated message, feel free to @-reply to me directly if
you have any questions about this.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

py-core Relates to py/ directory in source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL