shrivasshankar opened a new issue, #50196:
URL: https://github.com/apache/arrow/issues/50196

   Describe the enhancement requested
   =====================================
   
   Arrow's compute layer has binary floating-point math kernels such as `atan2` 
and `logb`, but no `hypot`. NumPy provides 
[`numpy.hypot`](https://numpy.org/doc/stable/reference/generated/numpy.hypot.html)
 and the C++ standard library provides `std::hypot`; both compute the 
hypotenuse `sqrt(x^2 + y^2)` while avoiding the overflow/underflow that a naive 
`sqrt(x*x + y*y)` suffers when the intermediate squares fall out of range — 
even when the true result is perfectly representable.
   
   Today, computing a Euclidean norm/distance over Arrow data requires 
composing `sqrt(add(multiply(x, x), multiply(y, y)))`, which is both verbose 
and numerically unsafe (the intermediate `multiply` can overflow to infinity). 
A dedicated `hypot` kernel would be correct and convenient. It is useful for 
Euclidean distance/norm computations such as geospatial point-to-point 
distances, ML feature L2 norms, and magnitude of complex/IQ data (`hypot(real, 
imag)`).
   
   Proposed semantics (mirroring the existing `atan2` registration):
   
   - Binary, element-wise.
   - Floating-point kernels for `float32` and `float64`; integer and decimal 
inputs promoted to `float64` via the standard arithmetic floating-point 
dispatch.
   - Delegates per element to `std::hypot`, inheriting its IEEE 754 / C99 
behavior, e.g. `hypot(±Inf, NaN) == +Inf`.
   - No `_checked` variant, since the operation is overflow-safe by 
construction (like `atan2`).
   - Exposed in Python as `pyarrow.compute.hypot`.
   
   I have a change implementing this ready to open as a PR.
   
   Component(s)
   ============
   
   C++, Python


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to