From 2dbb52d0018e41f4c15f5491bdd4158ad68c8215 Mon Sep 17 00:00:00 2001
From: Wimmerer <wrkimmerer@outlook.com>
Date: Mon, 13 Dec 2021 20:57:39 -0500
Subject: [PATCH] Fix accidental refactor with different patterns.

---
 src/KLU.jl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/KLU.jl b/src/KLU.jl
index 7071025..83eca13 100644
--- a/src/KLU.jl
+++ b/src/KLU.jl
@@ -560,6 +560,7 @@ end
 
 function klu!(K::KLUFactorization{U}, S::SparseMatrixCSC{U}) where {U}
     size(K) == size(S) || throw(ArgumentError("Sizes of K and S must match."))
+    K.colptr == S.colptr && K.rowval == S.rowval || throw(ArgumentError("The pattern of the original matrix must match the pattern of the refactor."))
     return klu!(K, S.nzval)
 end
 #B is the modified argument here. To match with the math it should be (klu, B). But convention is