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

Fix tall qr multiplication #38002

Merged
merged 2 commits into from
Oct 21, 2020
Merged

Fix tall qr multiplication #38002

merged 2 commits into from
Oct 21, 2020

Conversation

dkarrasch
Copy link
Member

@dkarrasch dkarrasch commented Oct 13, 2020

Fixes #35691. @Jutho

@dkarrasch dkarrasch added bugfix This change fixes an existing bug linear algebra Linear algebra labels Oct 13, 2020
mB = size(B, 1)
mC = size(C, 1)
if mB < mC
fill!(C, zero(T))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be slightly wasteful, but I couldn't find how to elegantly fill only the complement of C[eachindex(IndexCartesian(), B)] with zeros.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess explicit loops could work, since the dimensionality is fixed. Alternatively:

C[CartesianIndices(B)] .= B
C[CartesianIndices((mB+1:mC, 1:size(C,2))] .= zero(T)

mB = size(B, 1)
mC = size(C, 1)
if mB < mC
fill!(C, zero(T))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess explicit loops could work, since the dimensionality is fixed. Alternatively:

C[CartesianIndices(B)] .= B
C[CartesianIndices((mB+1:mC, 1:size(C,2))] .= zero(T)

@Jutho
Copy link
Contributor

Jutho commented Oct 20, 2020

Thanks for this @dkarrasch ; I had forgotten about this issue, and must somehow have missed your PR, despite being mentioned.

@dkarrasch
Copy link
Member Author

I'm marking this for backport, since the copyto! relied on the implicit use of Cartesian indices, but this behavior was changed in 3fdfb67. @KristofferC

@dkarrasch dkarrasch merged commit 24750c6 into master Oct 21, 2020
@dkarrasch dkarrasch deleted the dk/fix_tall_qr_mul! branch October 21, 2020 14:51
@dkarrasch dkarrasch mentioned this pull request Oct 22, 2020
15 tasks
KristofferC pushed a commit that referenced this pull request Nov 9, 2020
(cherry picked from commit 24750c6)
KristofferC added a commit that referenced this pull request Nov 9, 2020
(cherry picked from commit 24750c6)

Co-authored-by: Daniel Karrasch <Daniel.Karrasch@gmx.de>
@vchuravy vchuravy mentioned this pull request Jan 21, 2021
27 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

three-arg mul! with Q factor of type LinearAlgebra.QRCompactWYQ is wrong
4 participants