Implement vector indexing for SDiagonal with statically sized indices#926
Open
jishnub wants to merge 3 commits intoJuliaArrays:masterfrom
Open
Implement vector indexing for SDiagonal with statically sized indices#926jishnub wants to merge 3 commits intoJuliaArrays:masterfrom
jishnub wants to merge 3 commits intoJuliaArrays:masterfrom
Conversation
Member
Author
|
Speialized Before: julia> m = SDiagonal(@SVector [11, 12, 13, 14])
4×4 Diagonal{Int64, SVector{4, Int64}} with indices SOneTo(4)×SOneTo(4):
11 ⋅ ⋅ ⋅
⋅ 12 ⋅ ⋅
⋅ ⋅ 13 ⋅
⋅ ⋅ ⋅ 14
julia> @btime [copy($m) for i = 1:100];
1.155 μs (101 allocations: 5.56 KiB)After: julia> @btime [copy($m) for i = 1:100];
809.139 ns (1 allocation: 3.25 KiB) |
Member
Author
|
Test failure on nightly seems unrelated (ambiguity in |
mateuszbaran
reviewed
Sep 7, 2021
mateuszbaran
reviewed
Sep 7, 2021
mateuszbaran
reviewed
Sep 7, 2021
mateuszbaran
reviewed
Sep 7, 2021
vector indexing for SDiagonal produces SArrays
d1eb08e to
9dd183d
Compare
|
|
||
| Base.axes(D::SDiagonal, d) = d <= 2 ? axes(D)[d] : SOneTo(1) | ||
|
|
||
| Base.reshape(a::SDiagonal, s::Tuple{SOneTo,Vararg{SOneTo}}) = reshape(a, homogenize_shape(s)) |
Collaborator
There was a problem hiding this comment.
This is the same as the generic fallback:
StaticArrays.jl/src/abstractarray.jl
Line 190 in 29a76ec
Do we really need this method?
Collaborator
There was a problem hiding this comment.
Other than this small point, the PR looks nice 👍 .
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.
On master:
After this PR: