In-place backslash operator for sparse matrices

I have been doing A\b where A is a sparse matrix. However, is there an in place version of \? I have stumbled upon A_ldiv_B! but it seems to me (1) this function has been deprecated and (2) it didn’t work on sparse matrices anyway.

I don’t think A_ldiv_B! has been deprecated — you can still find this function in the latest master. (Maybe a specific method of it was deprecated?)

A_ldiv_B! is supported for sparse matrices, but you have to give a factorization object, not the matrix itself. That is, if A is a sparse matrix, then F = factorize(A) to create the (sparse) LU (etc.) factorization, and then do A_ldiv_B!(F, b) to solve Ax=b in-place in b with the precomputed factorization.

Note that this is explained in the A_ldiv_B! documentation: https://docs.julialang.org/en/latest/stdlib/linalg/#Base.LinAlg.A_ldiv_B!

Update in 2019: The corresponding function in Julia 1.0 or later is ldiv! in the LinearAlgebra standard library.

5 Likes