Use MATLAB dictionary for efficiency#100
Draft
MichaelTiemann wants to merge 1 commit into
Draft
Conversation
Replace a naive for-loop (n^2 searches for each parameter, so n^3 worst case) with a dictionary (n log n searches to construct and satisfy). Also, prepare parameter columns for processing on GPU.
Contributor
Author
|
Claude Code could apply this pattern in many instances. |
Contributor
|
looks cool, I will have to read up on what dictionary() does :) |
Contributor
Author
|
On second thought, it occurred to me there is a more elegant way to solve this (and related): to use try/catch to simply index into Parameters as needed to get the size/contents of parameters as needed. I'll rework this to demonstrate. The solution initially presented has two O(nlog(n)) terms (which add to O(nlog(n))). The more elegant solution uses the dictionary of Parameters itself, thus omitting the larger of the two O(n*log(n)) operations. |
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.
Replace a naive for-loop (n^2 searches for each parameter, so n^3 worst case) with a dictionary (n log n searches to construct and satisfy). Also, prepare parameter columns for processing on GPU.