-
Notifications
You must be signed in to change notification settings - Fork 16
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
Extend the NORM2 intrinsic function to COMPLEX argument #340
Comments
Did you mean |
Um, yeah... That was dumb of me. |
I can't see which difficulties, actually. The complex array would be internally treated as a real array of twice the size: So in practice the over/underflow protections could be applied the same way. |
I agree. The technique that I use in f18 is to make one pass over the data, keeping both the maximum magnitude element value and a running sum of (x(i)/currmax) squared, adjusting that as necessary when larger maxima are found. (Maybe I should make two passes, one to find the true maximum and another to compute the sum of squares of scaled values, but that's how it works today.). Seems easy to adapt this to COMPLEX arguments. |
It would be useful to extend the
norm2
intrinsic function to complex arrays, so thatnorm2(z)
returnssqrt(sum(conjg(z)* z))
. Note thatdot_product
already appropriately handles the case of complex arrays so that in the case of a rank-1 array this is equivalent tosqrt(dot_product(z,z))
.This is such an obvious extension of
norm2
that is is puzzling why it wasn't included in the first place. There must be implementation difficulties (e.g., the standard recommendation "that the processor compute the result without undue overflow or underflow") for it to have been omitted.Edit:
sqrt(sum(conjg(z),z))
-->sqrt(sum(conjg(z)*z))
The text was updated successfully, but these errors were encountered: