Skip to content
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

Merged
merged 6 commits into from
Jan 17, 2020
Merged

Conversation

stevengj
Copy link
Member

@stevengj stevengj commented Jan 11, 2020

Fixes #34348.

Seems to be about 2x faster than pivoted QR for a large underdetermined solve, with similar accuracy (assuming full row rank):

julia> A = rand(1000,1500); b = rand(size(A,1));

julia> @btime lq($A) \ $b;
  101.955 ms (14 allocations: 19.37 MiB)

julia> @btime qr($A, Val{true}()) \ $b;
  250.584 ms (8046 allocations: 31.98 MiB)

julia> x = lq(A) \ b; norm(x - qr(A, Val{true}()) \ b) / norm(x)
3.5357944054772334e-15

@ViralBShah ViralBShah added the domain:linear algebra Linear algebra label Jan 11, 2020
Copy link
Member

@dkarrasch dkarrasch left a 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!.

stdlib/LinearAlgebra/src/lq.jl Outdated Show resolved Hide resolved
stdlib/LinearAlgebra/src/lq.jl Outdated Show resolved Hide resolved
stdlib/LinearAlgebra/src/lq.jl Show resolved Hide resolved
@stevengj
Copy link
Member Author

stevengj commented Jan 12, 2020

For non-square problems with more cols n than rows m, ldiv! only looks at the first m rows of its input (which should have n rows to store the output solution)

(As noted above, ldiv! is exercised by the tests because it is actually called by \.)

You’re right that I was mixing up over/under determined some of the time — it's fixed now.

@stevengj
Copy link
Member Author

win32 CI failure seems to be an unrelated Error in testset SharedArrays

@stevengj
Copy link
Member Author

win32 failure is now another unrelated glitch cp: cannot stat 'dist-extras/7z.*': No such file or directory.

Should be good to merge?

@andreasnoack andreasnoack merged commit 40569c2 into master Jan 17, 2020
@andreasnoack andreasnoack deleted the sgj/lq_underdetermined branch January 17, 2020 07:40
KristofferC pushed a commit that referenced this pull request Apr 11, 2020
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lq(A) \ b unnecessarily requires square A
5 participants