Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 0f42658

Browse files
committed
moving the rows around => 1 less lu-factorization
1 parent b348809 commit 0f42658

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/klement.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,15 @@ function SciMLBase.solve(prob::NonlinearProblem,
6666
# x is a vector
6767
else
6868
J = init_J(x)
69-
F = lu(J, check = false)
7069
for _ in 1:maxiters
70+
F = lu(J, check = false)
71+
72+
# Singularity test
73+
if any(abs.(F.U[diagind(F.U)]) .< singular_tol)
74+
J = init_J(xₙ)
75+
F = lu(J, check = false)
76+
end
77+
7178
tmp = F \ fₙ₋₁
7279
xₙ = xₙ₋₁ - tmp
7380
fₙ = f(xₙ)
@@ -89,13 +96,6 @@ function SciMLBase.solve(prob::NonlinearProblem,
8996

9097
k = (Δfₙ - J * Δxₙ) ./ denominator
9198
J += (k * Δxₙ' .* J) * J
92-
F = lu(J, check = false)
93-
94-
# Singularity test
95-
if any(abs.(F.U[diagind(F.U)]) .< singular_tol)
96-
J = init_J(xₙ)
97-
F = lu(J, check = false)
98-
end
9999

100100
xₙ₋₁ = xₙ
101101
fₙ₋₁ = fₙ

0 commit comments

Comments
 (0)