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

Allow pushing to vector after 3-arg ldiv! #43510

Merged
merged 3 commits into from
Mar 29, 2022
Merged

Allow pushing to vector after 3-arg ldiv! #43510

merged 3 commits into from
Mar 29, 2022

Conversation

simonbyrne
Copy link
Contributor

@simonbyrne simonbyrne commented Dec 21, 2021

Fixes #43507. Fixes #29852.

@simonbyrne simonbyrne added the linear algebra Linear algebra label Dec 21, 2021
@oscardssmith
Copy link
Member

This doesn't seem like a good fix. It fixes the specific problem, but doesn't do anything to address the more general problem which is that you can't resize a Vector if it ever has been viewed, even if none of those views exist.

@simonbyrne
Copy link
Contributor Author

Sure, but that's a much more general issue. This solves a specific concrete issue that causes problems elsewhere (SciML/LinearSolve.jl#81)

@oscardssmith
Copy link
Member

In that case, can you add a TODO to this to say it's safe to remove once the general issue is solved?

@simonbyrne
Copy link
Contributor Author

Is there a big problem to having separate methods? It does make it simpler, and avoids intermediate views

@dkarrasch
Copy link
Member

In the failing test (which fails for Julia v1.6+), the untouched matrix-method in the m <= n branch copies to the wrong place: Y is 3x3, B is 2x3 and copyto! (in the new line 136) copies along linear indices. It should perhaps read as:

function ldiv!(Y::AbstractMatrix, A::Factorization, B::AbstractMatrix)
    require_one_based_indexing(Y, B)
    m, n = size(A, 1), size(A, 2)
    if m > n
        Bc = copy(B)
        ldiv!(A, Bc)
        return copyto!(Y, view(Bc, 1:n, :))
    else
        copyto!(view(Y, 1:m, :), view(B, 1:m, :))
        return ldiv!(A, Y)
    end
end

At least with this change the failing test fails no more. Not sure if we need more size checks here, actually.

@dkarrasch dkarrasch added backport 1.7 bugfix This change fixes an existing bug backport 1.6 Change should be backported to release-1.6 and removed backport 1.6 Change should be backported to release-1.6 labels Dec 23, 2021
@dkarrasch
Copy link
Member

Backporting to v1.6 requires special care due to the ColumnNorm() argument...

@simonbyrne
Copy link
Contributor Author

Thanks @dkarrasch!

Backporting to v1.6 requires special care due to the ColumnNorm() argument...

I think changing it to Val(true) should work.

@simonbyrne simonbyrne closed this Jan 2, 2022
@simonbyrne simonbyrne reopened this Jan 2, 2022
@KristofferC KristofferC mentioned this pull request Jan 5, 2022
23 tasks
@dkarrasch
Copy link
Member

Shall we just merge or rebase before merging?

@KristofferC KristofferC mentioned this pull request Feb 15, 2022
40 tasks
@dkarrasch dkarrasch added the backport 1.8 Change should be backported to release-1.8 label Feb 17, 2022
@dkarrasch dkarrasch added the backport 1.6 Change should be backported to release-1.6 label Mar 29, 2022
@dkarrasch dkarrasch merged commit e2ea152 into master Mar 29, 2022
@dkarrasch dkarrasch deleted the sb/ldiv-3arg branch March 29, 2022 07:35
aviatesk pushed a commit to aviatesk/julia that referenced this pull request Mar 29, 2022
Co-authored-by: Daniel Karrasch <daniel.karrasch@posteo.de>
@KristofferC KristofferC mentioned this pull request May 16, 2022
45 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.6 Change should be backported to release-1.6 backport 1.8 Change should be backported to release-1.8 bugfix This change fixes an existing bug linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot push to a vector after applying a 3-arg ldiv! resize! failure after using ldiv! on v1.0
3 participants