|
53 | 53 |
|
54 | 54 | @testset "[IIP] u0: $(typeof(u0)) precs: $(_nameof(prec)) linsolve: $(_nameof(linsolve))" for u0 in ([
|
55 | 55 | 1.0, 1.0],), prec in precs, linsolve in (nothing, KrylovJL_GMRES())
|
| 56 | + ad isa AutoZygote && continue |
56 | 57 | if prec === :Random
|
57 | 58 | prec = (args...) -> (Diagonal(randn!(similar(u0))), nothing)
|
58 | 59 | end
|
59 |
| - sol = benchmark_nlsolve_iip(quadratic_f!, u0; linsolve, precs = prec, linesearch) |
| 60 | + sol = benchmark_nlsolve_iip(quadratic_f!, u0; linsolve, precs = prec, |
| 61 | + linesearch) |
60 | 62 | @test SciMLBase.successful_retcode(sol)
|
61 | 63 | @test all(abs.(sol.u .* sol.u .- 2) .< 1e-9)
|
62 | 64 |
|
|
67 | 69 | end
|
68 | 70 |
|
69 | 71 | if VERSION ≥ v"1.9"
|
70 |
| - @testset "[OOP] [Immutable AD] p: $(p)" for p in 1.0:0.1:100.0 |
71 |
| - @test begin |
72 |
| - res = benchmark_nlsolve_oop(quadratic_f, @SVector[1.0, 1.0], p) |
73 |
| - res_true = sqrt(p) |
74 |
| - all(res.u .≈ res_true) |
| 72 | + @testset "[OOP] [Immutable AD]" begin |
| 73 | + for p in 1.0:0.1:100.0 |
| 74 | + @test begin |
| 75 | + res = benchmark_nlsolve_oop(quadratic_f, @SVector[1.0, 1.0], p) |
| 76 | + res_true = sqrt(p) |
| 77 | + all(res.u .≈ res_true) |
| 78 | + end |
| 79 | + @test ForwardDiff.derivative(p -> benchmark_nlsolve_oop(quadratic_f, |
| 80 | + @SVector[1.0, 1.0], p).u[end], p) ≈ 1 / (2 * sqrt(p)) |
75 | 81 | end
|
76 |
| - @test ForwardDiff.derivative(p -> benchmark_nlsolve_oop(quadratic_f, |
77 |
| - @SVector[1.0, 1.0], p).u[end], p) ≈ 1 / (2 * sqrt(p)) |
78 | 82 | end
|
79 | 83 | end
|
80 | 84 |
|
81 |
| - @testset "[OOP] [Scalar AD] p: $(p)" for p in 1.0:0.1:100.0 |
82 |
| - @test begin |
83 |
| - res = benchmark_nlsolve_oop(quadratic_f, 1.0, p) |
84 |
| - res_true = sqrt(p) |
85 |
| - res.u ≈ res_true |
| 85 | + @testset "[OOP] [Scalar AD]" begin |
| 86 | + for p in 1.0:0.1:100.0 |
| 87 | + @test begin |
| 88 | + res = benchmark_nlsolve_oop(quadratic_f, 1.0, p) |
| 89 | + res_true = sqrt(p) |
| 90 | + res.u ≈ res_true |
| 91 | + end |
| 92 | + @test ForwardDiff.derivative(p -> benchmark_nlsolve_oop(quadratic_f, 1.0, p).u, |
| 93 | + p) ≈ |
| 94 | + 1 / (2 * sqrt(p)) |
86 | 95 | end
|
87 |
| - @test ForwardDiff.derivative(p -> benchmark_nlsolve_oop(quadratic_f, 1.0, p).u, p) ≈ |
88 |
| - 1 / (2 * sqrt(p)) |
89 | 96 | end
|
90 | 97 |
|
91 | 98 | if VERSION ≥ v"1.9"
|
@@ -162,33 +169,34 @@ end
|
162 | 169 | end
|
163 | 170 |
|
164 | 171 | if VERSION ≥ v"1.9"
|
165 |
| - @testset "[OOP] [Immutable AD] radius_update_scheme: $(radius_update_scheme) p: $(p)" for radius_update_scheme in radius_update_schemes, |
166 |
| - p in 1.0:0.1:100.0 |
| 172 | + @testset "[OOP] [Immutable AD] radius_update_scheme: $(radius_update_scheme)" for radius_update_scheme in radius_update_schemes |
| 173 | + for p in 1.0:0.1:100.0 |
| 174 | + @test begin |
| 175 | + res = benchmark_nlsolve_oop(quadratic_f, @SVector[1.0, 1.0], p; |
| 176 | + radius_update_scheme) |
| 177 | + res_true = sqrt(p) |
| 178 | + all(res.u .≈ res_true) |
| 179 | + end |
| 180 | + @test ForwardDiff.derivative(p -> benchmark_nlsolve_oop(quadratic_f, |
| 181 | + @SVector[1.0, 1.0], p; radius_update_scheme).u[end], p) ≈ 1 / (2 * sqrt(p)) |
| 182 | + end |
| 183 | + end |
| 184 | + end |
167 | 185 |
|
| 186 | + @testset "[OOP] [Scalar AD] radius_update_scheme: $(radius_update_scheme)" for radius_update_scheme in radius_update_schemes |
| 187 | + for p in 1.0:0.1:100.0 |
168 | 188 | @test begin
|
169 |
| - res = benchmark_nlsolve_oop(quadratic_f, @SVector[1.0, 1.0], p; |
| 189 | + res = benchmark_nlsolve_oop(quadratic_f, oftype(p, 1.0), p; |
170 | 190 | radius_update_scheme)
|
171 | 191 | res_true = sqrt(p)
|
172 |
| - all(res.u .≈ res_true) |
| 192 | + res.u ≈ res_true |
173 | 193 | end
|
174 | 194 | @test ForwardDiff.derivative(p -> benchmark_nlsolve_oop(quadratic_f,
|
175 |
| - @SVector[1.0, 1.0], p; radius_update_scheme).u[end], p) ≈ 1 / (2 * sqrt(p)) |
| 195 | + oftype(p, 1.0), |
| 196 | + p; radius_update_scheme).u, p) ≈ 1 / (2 * sqrt(p)) |
176 | 197 | end
|
177 | 198 | end
|
178 | 199 |
|
179 |
| - @testset "[OOP] [Scalar AD] radius_update_scheme: $(radius_update_scheme) p: $(p)" for radius_update_scheme in radius_update_schemes, |
180 |
| - p in 1.0:0.1:100.0 |
181 |
| - |
182 |
| - @test begin |
183 |
| - res = benchmark_nlsolve_oop(quadratic_f, oftype(p, 1.0), p; |
184 |
| - radius_update_scheme) |
185 |
| - res_true = sqrt(p) |
186 |
| - res.u ≈ res_true |
187 |
| - end |
188 |
| - @test ForwardDiff.derivative(p -> benchmark_nlsolve_oop(quadratic_f, oftype(p, 1.0), |
189 |
| - p; radius_update_scheme).u, p) ≈ 1 / (2 * sqrt(p)) |
190 |
| - end |
191 |
| - |
192 | 200 | if VERSION ≥ v"1.9"
|
193 | 201 | t = (p) -> [sqrt(p[2] / p[1])]
|
194 | 202 | p = [0.9, 50.0]
|
@@ -316,25 +324,30 @@ end
|
316 | 324 | end
|
317 | 325 |
|
318 | 326 | if VERSION ≥ v"1.9"
|
319 |
| - @testset "[OOP] [Immutable AD] p: $(p)" for p in 1.0:0.1:100.0 |
320 |
| - @test begin |
321 |
| - res = benchmark_nlsolve_oop(quadratic_f, @SVector[1.0, 1.0], p) |
322 |
| - res_true = sqrt(p) |
323 |
| - all(res.u .≈ res_true) |
| 327 | + @testset "[OOP] [Immutable AD]" begin |
| 328 | + for p in 1.0:0.1:100.0 |
| 329 | + @test begin |
| 330 | + res = benchmark_nlsolve_oop(quadratic_f, @SVector[1.0, 1.0], p) |
| 331 | + res_true = sqrt(p) |
| 332 | + all(res.u .≈ res_true) |
| 333 | + end |
| 334 | + @test ForwardDiff.derivative(p -> benchmark_nlsolve_oop(quadratic_f, |
| 335 | + @SVector[1.0, 1.0], p).u[end], p) ≈ 1 / (2 * sqrt(p)) |
324 | 336 | end
|
325 |
| - @test ForwardDiff.derivative(p -> benchmark_nlsolve_oop(quadratic_f, |
326 |
| - @SVector[1.0, 1.0], p).u[end], p) ≈ 1 / (2 * sqrt(p)) |
327 | 337 | end
|
328 | 338 | end
|
329 | 339 |
|
330 |
| - @testset "[OOP] [Scalar AD] p: $(p)" for p in 1.0:0.1:100.0 |
331 |
| - @test begin |
332 |
| - res = benchmark_nlsolve_oop(quadratic_f, 1.0, p) |
333 |
| - res_true = sqrt(p) |
334 |
| - res.u ≈ res_true |
| 340 | + @testset "[OOP] [Scalar AD]" begin |
| 341 | + for p in 1.0:0.1:100.0 |
| 342 | + @test begin |
| 343 | + res = benchmark_nlsolve_oop(quadratic_f, 1.0, p) |
| 344 | + res_true = sqrt(p) |
| 345 | + res.u ≈ res_true |
| 346 | + end |
| 347 | + @test ForwardDiff.derivative(p -> benchmark_nlsolve_oop(quadratic_f, 1.0, p).u, |
| 348 | + p) ≈ |
| 349 | + 1 / (2 * sqrt(p)) |
335 | 350 | end
|
336 |
| - @test ForwardDiff.derivative(p -> benchmark_nlsolve_oop(quadratic_f, 1.0, p).u, p) ≈ |
337 |
| - 1 / (2 * sqrt(p)) |
338 | 351 | end
|
339 | 352 |
|
340 | 353 | if VERSION ≥ v"1.9"
|
|
0 commit comments