Skip to content

Commit a5c4b0c

Browse files
committed
add some basic tests
1 parent c1e6550 commit a5c4b0c

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

test/JacobianTest.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,19 @@ end
259259
x0_mvector = MVector{2}(x0)
260260
@test ForwardDiff.jacobian(ev1, x0_mvector) isa MMatrix{2, 2}
261261
@test ForwardDiff.jacobian(ev1, x0_mvector) Calculus.finite_difference_jacobian(ev1, x0)
262+
263+
# real eigenvalues
264+
f(x) = eigvals(reshape(x, 2, 2))
265+
x1 = [1.0, 2.0, 3.0, 4.0]
266+
@test ForwardDiff.jacobian(f, x1) Calculus.finite_difference_jacobian(f, x1)
267+
268+
# complex eigenvalues
269+
g(x) = begin
270+
vals = eigvals(reshape(x, 2, 2))
271+
vcat(real(vals), imag(vals))
272+
end
273+
x2 = [0.0, -1.0, 1.0, 0.0]
274+
@test ForwardDiff.jacobian(g, x2) Calculus.finite_difference_jacobian(g, x2)
262275
end
263276

264277
@testset "type stability" begin

0 commit comments

Comments
 (0)