Skip to content

Commit b2a2316

Browse files
committed
Add tests
1 parent 7450590 commit b2a2316

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/misc/linsolve_switching_tests.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@testitem "Singular Systems -- Auto Linear Solve Switching" begin
2+
using LinearSolve, NonlinearSolve
3+
4+
function f!(du, u, p)
5+
du[1] = 2u[1] - 2
6+
du[2] = (u[1] - 4u[2])^2 + 0.1
7+
end
8+
9+
u0 = [0.0, 0.0] # Singular Jacobian at u0
10+
11+
prob = NonlinearProblem(f!, u0)
12+
13+
sol = solve(prob) # This doesn't have a root so let's just test the switching
14+
@test sol.u[1.0, 0.25] atol=1e-3 rtol=1e-3
15+
16+
function nlls!(du, u, p)
17+
du[1] = 2u[1] - 2
18+
du[2] = (u[1] - 4u[2])^2 + 0.1
19+
du[3] = 0
20+
end
21+
22+
u0 = [0.0, 0.0]
23+
24+
prob = NonlinearProblem(NonlinearFunction(nlls!, resid_prototype = zeros(3)), u0)
25+
26+
solve(prob)
27+
@test sol.u[1.0, 0.25] atol=1e-3 rtol=1e-3
28+
end

0 commit comments

Comments
 (0)