Compiler optimizations - #84
Merged
Merged
Conversation
vatsal-j
requested changes
Jun 25, 2026
vatsal-j
left a comment
Member
There was a problem hiding this comment.
@pgbrodrick The code itself looks good as far as I can tell (and you've already tested it). The doc building test failed because the new functions:
│ SpectralUnmixing._unmix_pixel_kernel :: Tuple{SpectralLibrary, Matrix{Float64}, Union{Nothing, Matrix{Float64}}, Any, Any, String, Int64, Vector{Int64}, String, String, Int64, String}
│ SpectralUnmixing.ensure_2d :: Tuple{AbstractVector{Float64}}
│ SpectralUnmixing.ensure_2d :: Tuple{AbstractMatrix{Float64}}
need to be added to docs/src/api.md
Member
Author
|
Merging now that the above request on documentation has been cleared. |
Closed
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.
Leverage views and strategic function definition for fully type-specific compilation.
In practice, this reduces runtime by about 35% (EMIT style runs) with identical results. This PR uses more sophisticated views and TLS, but no increased performance was found, and there is notably more complexity, so keeping this implementation. The solver Levenberg-Marquardt solver referenced in the above is perhaps worth considering, however.
Note that the above PR also identifies a small algorithm bug in the BVLS solver, which I chose not to address here. Presently, we modify all bounds simultaneously, instead of one at a time. Technically, I believe this is incorrect, but in practice I found minuscule differences from the unmixing problem. For the sake of numerical consistency, I've allowed it to persist, though this could be reconsidered.