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

Cannot push to a vector after applying a 3-arg ldiv! #897

Closed
simonbyrne opened this issue Dec 21, 2021 · 4 comments · Fixed by JuliaLang/julia#43510
Closed

Cannot push to a vector after applying a 3-arg ldiv! #897

simonbyrne opened this issue Dec 21, 2021 · 4 comments · Fixed by JuliaLang/julia#43510

Comments

@simonbyrne
Copy link
Contributor

using LinearAlgebra
u = rand(2)
A = rand(2,2)
b = rand(2)

push!(b,3.0) # works
u = rand(3)
A = rand(3,3)
ldiv!(u,lu(A),b)

push!(b,4.0) # Error: cannot resize array with shared data

Originally posted by @ChrisRackauckas in JuliaLang/julia#33143 (comment)

@KristofferC
Copy link
Member

3-arg ldiv!, right?

@simonbyrne
Copy link
Contributor Author

simonbyrne commented Dec 21, 2021

The problem are the views, which trigger JuliaLang/julia#33143:
https://github.com/JuliaLang/julia/blob/4b0d6c9407e337c249498185b146f80141c492ca/stdlib/LinearAlgebra/src/factorization.jl#L117-L128

The rationale was to handle factorizations (e.g. QR) of non-square matrices (#25810).

@simonbyrne simonbyrne changed the title Cannot push to a vector after applying a 2-arg ldiv! Cannot push to a vector after applying a 3-arg ldiv! Dec 21, 2021
@simonbyrne
Copy link
Contributor Author

simonbyrne commented Dec 21, 2021

Honestly, by putting a copy in the first branch, it seems a bit self-defeating to define a 3-arg ldiv! to begin with (you might as well use /). But I don't get the rationale for the view in the 2nd branch (which is what triggers the problem above)? @andreasnoack any ideas?

@simonbyrne
Copy link
Contributor Author

ah, it seems to be for matrix args: in that case, it probably makes sense to split them out into separate methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants