Skip to content

Commit

Permalink
inference tets from issue #639 and pr #735
Browse files Browse the repository at this point in the history
  • Loading branch information
jondeuce committed Feb 12, 2025
1 parent 1fe5d69 commit 881ad59
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/JacobianTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,24 @@ end
@testset "type stability" begin
g!(dy, y) = dy[1] = y[1]
@inferred ForwardDiff.jacobian(g!, [1.0], [0.0])

@testset "issue 639" begin
f(x) = SA[x[1]^2+x[2]^2, x[2]^2+x[3]^2]
x = SA[1.0, 2.0, 3.0]
y = f(x)
imdr = DiffResults.JacobianResult(y, x)
@inferred ForwardDiff.jacobian!(imdr, f, x)
end

@testset "pr 735" begin
f(x) = x .^ 2 ./ 2
function withjacobian(x)
res = DiffResults.JacobianResult(x)
res = ForwardDiff.jacobian!(res, f, x)
return DiffResults.value(res), DiffResults.jacobian(res)
end
@inferred withjacobian(SA[1.0, 2.0])
end
end

end # module

0 comments on commit 881ad59

Please sign in to comment.