-
Notifications
You must be signed in to change notification settings - Fork 29
Sort NaNs to the end for descending order #3066
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
base: master
Are you sure you want to change the base?
Changes from all commits
989538b
6872854
5210a9d
8383540
7e8cadf
a4079d4
ce73016
68af50f
e385256
808365e
490c858
f709514
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,9 +60,10 @@ struct ExtendedRealFPLess | |
| template <typename fpT> | ||
| struct ExtendedRealFPGreater | ||
| { | ||
| /* [R, nan] — NaNs sort to the end, as in ascending order */ | ||
| bool operator()(const fpT v1, const fpT v2) const | ||
| { | ||
| return (!std::isnan(v2) && (std::isnan(v1) || (v2 < v1))); | ||
| return (!std::isnan(v1) && (std::isnan(v2) || (v2 < v1))); | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -106,10 +107,11 @@ struct ExtendedComplexFPLess | |
| template <typename cT> | ||
| struct ExtendedComplexFPGreater | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good suggestion, done —
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One perf note for the record: this form constructs two |
||
| { | ||
| /* Negating both operands reverses the finite comparison but preserves | ||
| NaN-ness, so NaN groups stay ordered to the end. */ | ||
| bool operator()(const cT &v1, const cT &v2) const | ||
| { | ||
| auto less_ = ExtendedComplexFPLess<cT>{}; | ||
| return less_(v2, v1); | ||
| return ExtendedComplexFPLess<cT>{}(-v1, -v2); | ||
| } | ||
| }; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.