@@ -20,21 +20,28 @@ function benchmark_scalar(f, u0)
20
20
sol = (solve (probN, NewtonRaphson ()))
21
21
end
22
22
23
- f, u0 = (u,p) -> u .* u .- 2 , @SVector [1.0 , 1.0 ]
24
- sf, su0 = (u,p) -> u * u - 2 , 1.0
25
- sol = benchmark_immutable (f, u0)
23
+ function ff (u,p)
24
+ u .* u .- 2
25
+ end
26
+ const cu0 = @SVector [1.0 , 1.0 ]
27
+ function sf (u,p)
28
+ u * u - 2
29
+ end
30
+ const csu0 = 1.0
31
+
32
+ sol = benchmark_immutable (ff, cu0)
26
33
@test sol. retcode === Symbol (NonlinearSolve. DEFAULT)
27
34
@test all (sol. u .* sol. u .- 2 .< 1e-9 )
28
- sol = benchmark_mutable (f, u0 )
35
+ sol = benchmark_mutable (ff, cu0 )
29
36
@test sol. retcode === Symbol (NonlinearSolve. DEFAULT)
30
37
@test all (sol. u .* sol. u .- 2 .< 1e-9 )
31
- sol = benchmark_scalar (sf, su0 )
38
+ sol = benchmark_scalar (sf, csu0 )
32
39
@test sol. retcode === Symbol (NonlinearSolve. DEFAULT)
33
40
@test sol. u * sol. u - 2 < 1e-9
34
41
35
- @test (@ballocated benchmark_immutable ($ f, $ u0 )) == 0
36
- @test (@ballocated benchmark_mutable ($ f, $ u0 )) < 200
37
- @test (@ballocated benchmark_scalar ($ sf, $ su0 )) == 0
42
+ @test (@ballocated benchmark_immutable (ff, cu0 )) == 0
43
+ @test (@ballocated benchmark_mutable (ff, cu0 )) < 200
44
+ @test (@ballocated benchmark_scalar (sf, csu0 )) == 0
38
45
39
46
# AD Tests
40
47
using ForwardDiff
@@ -143,7 +150,7 @@ sol = solve!(solver)
143
150
# these should call the iterator version
144
151
solver = init (probB, Bisection ())
145
152
@test solver isa NonlinearSolve. BracketingImmutableSolver
146
- # Question: Do we need BracketingImmutableSolver? We have fast scalar overload and
153
+ # Question: Do we need BracketingImmutableSolver? We have fast scalar overload and
147
154
# Bracketing solvers work only for scalars.
148
155
149
156
solver = init (probB, Bisection (); immutable = false )
0 commit comments