0

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?

Junwei su
  • 138
  • 1
  • 10

1 Answers1

2

using LinearAlgebra, then B = lu(A); B\b. Julia returns a type and its dispatch on \ handles the rest.

user14717
  • 4,757
  • 2
  • 44
  • 68
Chris Rackauckas
  • 18,645
  • 3
  • 50
  • 81