-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eliminate uses of full from base/linalg/lq.jl #23729
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also wondering if requesting the full matrix from LQPackedQ
is a sufficiently common operation to require a separate function.
base/linalg/lq.jl
Outdated
in the (implicit) input matrix `Q`. That identity matrix is modified by the elementary | ||
reflectors held in `Q`, so this operation does not reduce to simple indexing. | ||
""" | ||
squareQ(Q::LQPackedQ) = A_mul_B!(Q, eye(eltype(Q), reverse(size(Q.factors))...)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not square. Should probably be eye(eltype(Q), size(Q.factors, 2)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I failed to read the existing code critically. And agreed, eye(eltype(Q), size(Q.factors, 2))
looks correct. What was the object the existing code returns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this PR is turning into a significant bug fix. The current version gives
julia> full(lqfact(randn(4,2))[:Q], thin = true)
2×2 Array{Float64,2}:
-0.759173 0.650889
0.650889 0.759173
julia> full(lqfact(randn(4,2))[:Q], thin = false)
2×4 Array{Float64,2}:
-0.652378 -0.757894 0.0 0.0
-0.757894 0.652378 0.0 0.0
julia> full(lqfact(randn(2,4))[:Q], thin = false)
4×2 Array{Float64,2}:
-0.22708 -0.390319
0.72372 -0.204318
-0.025446 0.888878
-0.651166 -0.125704
julia> full(lqfact(randn(2,4))[:Q], thin = false)
4×2 Array{Float64,2}:
-0.0604746 0.111308
0.822683 -0.406272
-0.158067 -0.81894
0.542725 0.389731
so only the first one is correct. Here is how they are supposed to look like
To clarify, are you suggesting |
Yes. I'm suggesting that it shouldn't exist. I think it is pretty rare that you actually want to do that. If you, for instructional purposes, want to work with the full |
Sounds good on this end :). |
Revised. Thoughts? Thanks! :) |
@andreasnoack as the author of that function, I included it for consistency with |
Thanks all! :) |
Another small step towards deprecation of
full
. Ref. JuliaLang/LinearAlgebra.jl#229, JuliaLang/LinearAlgebra.jl#231, #18850, and linked threads. Best!