{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/11325","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/11325/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/11325/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/11325/events","html_url":"https://github.com/JuliaLang/julia/issues/11325","id":77571324,"number":11325,"title":"RFC - Change signature of methods A_ldiv_B!(A, B) to A_ldiv_B!(X, A, B)","user":{"login":"KristofferC","id":1282691,"avatar_url":"https://avatars.githubusercontent.com/u/1282691?v=3","gravatar_id":"","url":"https://api.github.com/users/KristofferC","html_url":"https://github.com/KristofferC","followers_url":"https://api.github.com/users/KristofferC/followers","following_url":"https://api.github.com/users/KristofferC/following{/other_user}","gists_url":"https://api.github.com/users/KristofferC/gists{/gist_id}","starred_url":"https://api.github.com/users/KristofferC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KristofferC/subscriptions","organizations_url":"https://api.github.com/users/KristofferC/orgs","repos_url":"https://api.github.com/users/KristofferC/repos","events_url":"https://api.github.com/users/KristofferC/events{/privacy}","received_events_url":"https://api.github.com/users/KristofferC/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JuliaLang/julia/labels/linear%20algebra","name":"linear algebra","color":"aa8800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-05-18T09:06:05Z","updated_at":"2015-05-19T09:05:36Z","closed_at":null,"body":"Currently, the methods for solving linear system of equations in place (`A_ldiv_B!`) takes two arguments `A` and `B`. In some cases, calling `A_ldiv_B!(A, B)` will update `B`, in some cases not, see: https://github.com/JuliaLang/julia/issues/10787.\r\n\r\nThere are many solvers that does not support updating `B` directly but instead needs a preallocated solution array passed into them to store the solution in. This is true for i.e. `UMFPACK` which means that currently there is no way to call `A_ldiv_B!` for sparse `A` and have it not allocate the solution array at each call.\r\n\r\nIt also means that there is no clean way to keep your RHS `B` intact while calling in place solvers. Instead you need to copy `B` before the call since `B` gets overwritten.\r\n\r\nI believe that a more natural signature for these methods would be `A_ldiv_B!(X, A, B)` where `X` is the preallocated array to store the solution. This has symmetry with `A_mul_B!(X, A, B)` and it leaves the RHS untouched.\r\n\r\nI might have missed a good reason why the current signatures are the way there are but from my point of view this looks cleaner. It is also the path I took in https://github.com/KristofferC/Pardiso.jl where I have the following solve methods:\r\n\r\n* solve(ps, A, B) solves AX=B and returns X\r\n* solve!(ps, X, A, B) solves AX=B and stores it in X\r\n\r\nAny comments on the sensibility and feasibility for this suggestion?"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/103407526","html_url":"https://github.com/JuliaLang/julia/issues/11325#issuecomment-103407526","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/11325","id":103407526,"user":{"login":"simonbyrne","id":1692009,"avatar_url":"https://avatars.githubusercontent.com/u/1692009?v=3","gravatar_id":"","url":"https://api.github.com/users/simonbyrne","html_url":"https://github.com/simonbyrne","followers_url":"https://api.github.com/users/simonbyrne/followers","following_url":"https://api.github.com/users/simonbyrne/following{/other_user}","gists_url":"https://api.github.com/users/simonbyrne/gists{/gist_id}","starred_url":"https://api.github.com/users/simonbyrne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonbyrne/subscriptions","organizations_url":"https://api.github.com/users/simonbyrne/orgs","repos_url":"https://api.github.com/users/simonbyrne/repos","events_url":"https://api.github.com/users/simonbyrne/events{/privacy}","received_events_url":"https://api.github.com/users/simonbyrne/received_events","type":"User","site_admin":false},"created_at":"2015-05-19T09:05:36Z","updated_at":"2015-05-19T09:05:36Z","body":"> I imagine `A_ldiv_B!(B, A, B)` might end up commonly used for types where that makes sense.\r\n\r\nI don't think this is a pattern we should encourage, as it is going to break in some cases, e.g.:\r\n\r\n```julia\r\njulia> X = randn(5,5)\r\n5x5 Array{Float64,2}:\r\n  1.33502    0.168431  -1.24184     0.152598   0.368737\r\n -0.984189  -0.112196  -0.0336856  -0.281819   0.881885\r\n  1.35078    0.7121    -1.2564      0.316167  -0.14738 \r\n  1.01016   -1.84001   -0.577902    0.286557  -1.2575  \r\n  0.560689   2.57815    1.20324    -1.54285    1.1421  \r\n\r\njulia> A_mul_B!(X,X,X)\r\n5x5 Array{Float64,2}:\r\n 0.0  0.0  0.0  0.0  0.0\r\n 0.0  0.0  0.0  0.0  0.0\r\n 0.0  0.0  0.0  0.0  0.0\r\n 0.0  0.0  0.0  0.0  0.0\r\n 0.0  0.0  0.0  0.0  0.0\r\n```\r\n\r\nAs a blatant plug, can I suggest the `Inplace{N}` type I use in [InplaceOps.jl](https://github.com/simonbyrne/InplaceOps.jl/blob/a2861bbd8d5731b15853becce55a419ad91e890d/src/InplaceOps.jl#L41)?"}}