-
Notifications
You must be signed in to change notification settings - Fork 49
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
Fixes nan value for powc of zero #116
Conversation
Is there anything I can still do to get this merged? |
src/lib.rs
Outdated
@@ -1908,6 +1897,15 @@ pub(crate) mod test { | |||
Complex::new(1.65826, -0.33502), | |||
1e-5 | |||
)); | |||
let z = Complex::new(0.0, 0.0); | |||
assert!(close(z.powc(b), z)); | |||
assert!(z.powc(Complex64::new(0., 0.)).is_nan()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this result should be one -- in fact the standard f64::powf(x, 0.0) == 1.0
for any base, even NaN! I'm going to fix both powf
and powc
here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not mathematically correct though, 0^0 is indeterminate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the prior discussions in rust-num/num-traits#78 and rust-num/num-traits#79. It's a pragmatic choice, especially to be consistent with std
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That wikipedia article also says:
Another example is the expression 0^0. Whether this expression is left undefined, or is defined to equal 1, depends on the field of application and may vary between authors. For more, see the article Zero to the power of zero.
This is consistent with the standard library powf -- even for NaN!
Let me know what you think of that additional change for 0 exponents. I'll tweak the release date when we're ready. |
I think it makes sense. So I'm fine with it. |
bors r+ |
116: Fixes nan value for powc of zero r=cuviper a=domna Fixes #114 `@cuviper` I just added a check for zero here as I suggested in #114. Co-authored-by: domna <florian.dobener@physik.hu-berlin.de> Co-authored-by: Florian Dobener <github@schroedingerscat.org> Co-authored-by: Josh Stone <cuviper@gmail.com>
RELEASES.md
Outdated
@@ -1,9 +1,19 @@ | |||
# Release 0.4.4 (2023-08-13) | |||
|
|||
- [Fixes nan value for `powc` of zero][116] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [Fixes nan value for `powc` of zero][116] | |
- [Fixes NaN value for `powc` of zero][116] |
bors r- |
Canceled. |
bors r+ |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
Fixes #114
@cuviper I just added a check for zero here as I suggested in #114.