inv, size, and \ for QR objects#1300
Open
gustafsson wants to merge 2 commits intoJuliaArrays:masterfrom
Open
Conversation
a654b37 to
354bbd5
Compare
354bbd5 to
20a66de
Compare
311cacc to
b2b6202
Compare
mateuszbaran
reviewed
Apr 1, 2025
Collaborator
mateuszbaran
left a comment
There was a problem hiding this comment.
Thank you for the contribution. I have a few comments.
| end | ||
| end | ||
| push!(ex.args, :( | ||
| return SMatrix(R_inv) |
Collaborator
There was a problem hiding this comment.
Please use similar_type similarly to _A_ldiv_B above.
|
|
||
| @generated function _inv_upper_triangular(R::StaticMatrix{n, n, T}) where {n, T} | ||
| ex = quote | ||
| R_inv = MMatrix{n,n,T}(undef) |
Collaborator
There was a problem hiding this comment.
You should either use similar (to properly handle non-isbits T) or the same trick as _A_ldiv_B. Also, make sure the method works to T being an integer.
Comment on lines
-77
to
+84
| Base.@propagate_inbounds function invperm(p::StaticVector) | ||
| # in difference to base, this does not check if p is a permutation (every value unique) | ||
| ip = similar(p) | ||
| ip[p] = 1:length(p) | ||
| similar_type(p)(ip) | ||
| @inline function invperm(p::StaticVector{N,T}) where {N,T<:Integer} | ||
| ip = zeros(MVector{N,T}) | ||
| @inbounds for i in SOneTo(N) | ||
| j = p[i] | ||
| 1 <= j <= N && iszero(ip[j]) || throw(ArgumentError("argument is not a permutation")) | ||
| ip[j] = i | ||
| end | ||
| SVector(ip) |
Collaborator
There was a problem hiding this comment.
Quite likely someone relied on this being faster thanks to not performing the checks so I'm not sure about this change.
| return similar_type(R, Int, Size((M,)))(ntuple(x -> x, Val{M}())) | ||
| end | ||
|
|
||
| is_identity_perm(p::StaticVector{M}) where {M} = all(i->i==p[i], 1:M) |
Collaborator
There was a problem hiding this comment.
Suggested change
| is_identity_perm(p::StaticVector{M}) where {M} = all(i->i==p[i], 1:M) | |
| is_identity_perm(p::StaticVector{M}) where {M} = all(i->i==p[i], SOneTo(M)) |
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.
Fixes #1192