Use cpp median function instead of base R's - #7
Open
chinandrew wants to merge 3 commits into
Open
chinandrew wants to merge 3 commits into
chinandrew wants to merge 3 commits into
Conversation
Collaborator
|
Does this work fine with NAs/NaNs/etc? I think adding a test would help. |
Author
Yes for NA and NaN, tests with these cases have been added. Where they don't agree is NULL/c(), since Rcpp doesn't expect the NULL type so it errors. We can add a check for this case if needed. Though as I mention in the original description, I do think it's worth discussing if this change is even worth including at all. It's only a few % speedup but at the cost of some complexity, which I normally wouldn't advocate for unless there's a material difference between, say, a run taking 23 hours instead of 24. |
Collaborator
|
After discussion with @chinandrew - probably close. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relatively minor change here that I just threw in because I introduced Rcpp elsewhere already. Probably not worth including if I'm honest but opening this PR just for completeness.
Profiled code. After the other optimizations that brought runs down <30s it made a bit more sense, but by itself when runs were 70-150s (depending on compute.template.idx) it doesn't do much:
Before:

After (before I updated the naming to camelcase):
