Skip to content

Commit a29e84e

Browse files
jClugstorChrisRackauckas
authored andcommitted
add test
1 parent ec7fb50 commit a29e84e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@testitem "Simple Adjoint Test" tags=[:adjoint] begin
2+
using ForwardDiff, Zygote, DiffEqBase
3+
4+
ff(u, p) = u^2 .- p[1]
5+
6+
function solve_nlprob(p)
7+
prob = IntervalNonlinearProblem{false}(ff, [1.0, 2.0], p)
8+
sol = solve(prob, Broyden())
9+
res = sol isa AbstractArray ? sol : sol.u
10+
return sum(abs2, res)
11+
end
12+
13+
p = [3.0, 2.0]
14+
15+
∂p_zygote = only(Zygote.gradient(solve_nlprob, p))
16+
∂p_forwarddiff = ForwardDiff.gradient(solve_nlprob, p)
17+
@test ∂p_zygote ∂p_forwarddiff
18+
end

0 commit comments

Comments
 (0)