-
-
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
Fix Matrix(QRSparseQ) constructor #26392
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 propose to leave SuiteSparse unchanged and change the constructor of Matrix as noted in my comment.
To add some comments to the change here. The Q in QR of julia> A = randn(4,2);
julia> F = qrfact(A);
julia> F.Q*Matrix(I,2,2)
4×2 Array{Float64,2}:
-0.481088 -0.70301
0.404963 -0.240095
0.397627 -0.668398
0.668171 0.037106
julia> F.Q*Matrix(I,3,2)
ERROR: DimensionMismatch("first dimension of matrix must have size either 4 or 2")
Stacktrace:
[1] *(::LinearAlgebra.QRCompactWYQ{Float64,Array{Float64,2}}, ::Array{Bool,2}) at /Users/andreasnoack/julia-dev/usr/share/julia/site/v0.7/LinearAlgebra/src/qr.jl:607
[2] top-level scope
julia> F.Q*Matrix(I,4,2)
4×2 Array{Float64,2}:
-0.481088 -0.70301
0.404963 -0.240095
0.397627 -0.668398
0.668171 0.037106 You can argue if that is a good idea but if one of the interpretations should go, it would definately be the Regarding the implementation then we'd need a way to get the size of
As a result the number of columns in A = sparse([0.0 1 0 0; 0 0 0 0]) the number of reflectors needed is zero. When A is rank deficient that means that we can decompose |
I just added some analysis to my post in discourse: about QR-decomposition |
I don't want to argue like that - when left multiplying with Unfortunately I found another issue:
All I want here is clarity: that should be documented close to
I agree completely. In my post I suggest to make a decision about those case and also to store the row count of
I am not sure, if it is wise to rely on an implementation detail of the upstream library here. I would prefer to store the row count of
It would be easy, to add the rank-estimation also in the LAPACK and generic cases with pivoting: Just remove the last rows of |
39e66f5
to
05f7f25
Compare
In the dense case, the rank estimation is currently delayed until e.g. |
Weird. I cannot reproduce the test errors locally. |
Fixes #26367
d31d3ed
to
6eac678
Compare
Is this really completely non-breaking? |
Yes. It shouldn't change any correct behavior. |
The policy for backports to long-term support branches is to be extremely conservative. Can you elaborate on the details of what that means? |
It's a bugfix. Before this PR, we wrongly assumed that the number of reflectors was the same as the number of columns in a matrix. That isn't the case for sparse matrices so a field is added to the struct to indicate number of columns. |
Fixes JuliaLang/LinearAlgebra.jl#505