Optimize maximization functions by using a single which.max - #5
Open
chinandrew wants to merge 2 commits into
Open
chinandrew wants to merge 2 commits into
chinandrew wants to merge 2 commits into
Conversation
Author
|
Appveyor failure looks unrelated, perhaps due to something similar to this? |
Collaborator
|
I think |
chinandrew
force-pushed
the
optimize_max
branch
from
September 11, 2023 21:25
8b8cd6c to
7720bfc
Compare
Author
This is great, didn't know about it. Updated the code accordingly. Thanks for the tip. |
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.
Previously, maxAndTune did 3 operations in its while loop that required scanning an entire similarity matrix:
These can all be combined into a single which.max
* - technically it returns the index as if the matrix was strung out into a vector, which you can then easily convert back to a row/column index. See the idxToRowCol function for more.
finetune_maxima also did the last 2 and is fixed as well.
For function naming, I saw camelCase (e.g.
scaleTemplate), words separated by periods (e.g.get.x.smoothed), and words separated by underscores (e.g.finetune_maxima). Seemed like camelCase was most common so I went with that, though let me know if something else is preferred.Profiled code (Full run is ~75s with compute.template.idx=FALSE on
master branch):Before:


After: