Well, yes, at the cost of:
- Destroying both arguments A and B
- Using the internal method
_apply_inverse_ipiv_cols! (which currently doesn’t exist; you added it in a PR to LinearAlgebra).
Using internal methods this way is usually not a good idea. Think of it this way: in the PR you just created, you changed the name of several internal methods (
_ipiv_rows! etc). If anyone out there has code just like yours that use these internal methods, it will suddenly break once your PR is merged. Similarly, your code is likely to break the next time someone refactors this logic in
lu.jl. So I would strongly recommend not using this approach.
If you don’t want the temporary, why not define your own in-place adjoint method?
for i = 1:size(X,1), j = i:size(X,2)
@inbounds X[i,j], X[j,i] = X[j,i]', X[i,j]'
function rdiv_low_alloc!(A, B)
It even seems a bit more efficient:
julia> A,B = 1:2 .|>_-> rand(100, 100);
julia> A / B == rdiv_low_alloc!(A, B) # verify that it's correct
julia> # rdiv with temporary:
julia> @btime rdiv_low_alloc!(A, B, Y) evals = 1 setup = A,B,Y = copy($A),copy($B),similar($A);
258.882 μs (2 allocations: 928 bytes)
julia> # rdiv with internal method:
julia> @btime rdiv_lu!(A, B) evals = 1 setup = A,B = copy($A),copy($B);
257.909 μs (2 allocations: 928 bytes)
julia> # rdiv with in-place adjoint:
julia> @btime rdiv_low_alloc!(A, B) evals = 1 setup = A,B = copy($A),copy($B);
235.869 μs (2 allocations: 928 bytes)