-
-
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
nonsquare (underdetermined) LQ solves #34350
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.
One of us is getting over- and under-determined wrong, perhaps worth a second thought. The other issue I couldn't see resolved is ldiv!
, which promises solve in-place of B
, but must necessarily widen/stretch B
to fit the longer X
in A*X = B
. It's not easy to track the changes in the test, but I couldn't find tests for ldiv!
.
For non-square problems with more cols n than rows m, (As noted above, You’re right that I was mixing up over/under determined some of the time — it's fixed now. |
win32 CI failure seems to be an unrelated |
Co-Authored-By: Stefan Karpinski <[email protected]>
win32 failure is now another unrelated glitch Should be good to merge? |
* nonsquare (underdetermined) LQ solves * fix NEWS item * fix NEWS item * narrow method signature to eliminate ambiguity * fix docs -- under/overdetermined terms were swapped * Update stdlib/LinearAlgebra/test/lq.jl Co-Authored-By: Stefan Karpinski <[email protected]> Co-authored-by: Stefan Karpinski <[email protected]>
I wonder if we should change the default |
Currently, we only distinguish square from non-square, right? Sounds like a good idea. |
Currently, we don't have row-pivoted However, we could equivalently use pivoted QR on julia> A = rand(100, 1000); b = rand(100);
julia> @btime $A \ $b; @btime qr($A, ColumnNorm()) \ $b; @btime lq($A) \ $b; @btime qr($A', ColumnNorm())' \ $b;
6.802 ms (42 allocations: 1.89 MiB)
6.851 ms (42 allocations: 1.89 MiB)
3.847 ms (21 allocations: 926.41 KiB)
2.454 ms (29 allocations: 1008.34 KiB)
julia> A \ b ≈ qr(A, ColumnNorm()) \ b ≈ lq(A) \ b ≈ qr(A', ColumnNorm())' \ b # same answer
true Technically, the fastest option of all (by a factor of 10!) is to use julia> @btime (cholesky($A*$A') \ $b);
287.375 μs (8 allocations: 157.31 KiB)
julia> A \ b ≈ A' * (cholesky(A*A') \ b)
true (which is also why we don't use the analogous Cholesky-based algorithm in the "tall" overdetermined case). |
Fixes JuliaLang/LinearAlgebra.jl#689.
Seems to be about 2x faster than pivoted QR for a large underdetermined solve, with similar accuracy (assuming full row rank):