Inversion and multiplication of sparse matrices

Nope. sparse(rand(4,4)) \ rand(4,3) (i.e. a matrix of right-hand sides) works just fine.

The key point here is that while the system matrix A can be sparse, the right-hand-side vector (or matrix!) must be dense — Julia doesn’t have any method to solve with a sparse right-hand-side.

The basic reason for this is not specific to Julia: you can’t generally gain anything from sparse right-hand sides in linear algebre, since once you perform the solve the solution is no longer sparse. In fact, this is exactly the same reason why you don’t want to compute inv(A) or A^-1 for a sparse A — matrix inversion is equivalent to solving with a right-hand side equal to the identity matrix (which is very sparse!) but the resulting inverse matrix is almost always dense.

3 Likes