Reputation: 138
I want to recreate a solve function(solve Ax = b for x) for sparse matrix. In the Julia documentation, it says that when we applied a sparse matrix to lufact(), it returns the following:
L, U, p, q, Rs = F[:(:)]
With the given formula in Julia doc: LU = Rs.*A[p,q], I did some algebra and obtained the following formula:
x = U \ ( L \ (Rs.*b[p]) )
ipermute!(x,q)
This formula matched with the default F\b solver in Julia when the matrix is dense but the result is off when the matrix is sparse. Does anyone know why?
Upvotes: 0
Views: 1336
Reputation: 19162
using LinearAlgebra
, then B = lu(A); B\b
. Julia returns a type and its dispatch on \
handles the rest.
Upvotes: 2