-
Notifications
You must be signed in to change notification settings - Fork 52
Add support for computing the hypotenuse via hypot
#544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This seems like a reasonable addition, given it's already commonly implemented (the linked data shows it is named differently in MXNet though). Are the signatures consistent among libraries?
That does not seem directly relevant here. For |
It does in order for the specification to be able to define special case behavior. |
Concerning special case behavior, according to IEEE 754, Wrt complex number support, while we could explicitly spell out complex number special case behavior for |
In terms of API, all supporting libraries implement as a standard element-wise binary function: |
hypot
hypot
As discussed last Thursday, the special cases for We're already nearing the end of 2022, and are close to finalizing the 2022 standard. |
This RFC requests to include a new API in the array API specification for the purpose of computing the hypotenuse.
Based on array comparison data, the API is available across all major array libraries in the PyData ecosystem (note: TensorFlow implements
hypot
in its experimentalnumpy
namespace).While
hypot
can be implemented in userland using existing array API functions (e.g.,sqrt(x1*x1 + x2*x2)
), this function is typically implemented in a specialized manner to help prevent over/underflow.Furthermore, need for this API arose when adding complex number support to the array API specification, particularly with regard to adding complex number support to
abs
, where the absolute value (magnitude) of a complex number is computed ashypot(real(z), imag(z))
.As this API already exists in the ecosystem and satisfies needs (e.g., numerical stability and complex number support), this API seems a good candidate for inclusion in the standard.
The text was updated successfully, but these errors were encountered: