-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
ENH: np.hypot(x1: complex, x2: complex) -> complex #23738
Comments
What would be wanted? |
I think this not implemented on purpose. Python complex math cmath module does not implement |
And what is the use case for this operation on complexes? |
We would simply want |
So, you actually want |
If you want - but it's very specialized and won't mean much. If you want to integrate |
I'm curious about the usage in linear algebra. I'd expect to see a complex version in LAPACK, but I only see one for reals. I guess I wouldn't reject a contribution of one that adapts the simple real-valued scheme that pulls the larger argument out of the square root, but I'd want to see some tests that confirm that it does help, which I think might be original research that I'm not sure anyone's going to volunteer to do. There will also need to be tests to ensure that the rearrangement is doing the right thing with respect to branch cuts and signed zeros and all of that annoying complex stuff. |
Given the prior art, it seems to me that the only definition that we could consider adding is the one returning a real value, and that is not the one requested. (Whether it was thought through or not, but the Julia discussion seems to have a tendency towards that definition at least in hindsight.) The way to go for you is probably a custom ufunc outside of NumPy. If you use such tools, you could and don't want to dive into how that works, you could also write it using a tool like |
Ok, I can manage with my own implementation. But could at least the docs be updated to mention that hypot only works for floats? |
Happy if someone has a look if it makes sense, we have probably quite a few other similar cases... TBH, I think it is more useful to update the error message to include the complex information, chances are you see the error before you read the docs anyway. (But I am pretty sure we have an issue elsewhere for that.) |
hypot currently doesn't work for complex inputs (and this is not documented). I can't see any good reason for this to not be implemented.
The text was updated successfully, but these errors were encountered: