@@ -85,12 +85,14 @@ function test_enzyme_eig_trunc(
8585 D = eig_vals (A)
8686 trunc = trunctol (atol = midgap_tol (D); by = abs)
8787 truncalg = TruncatedAlgorithm (alg, trunc)
88- DV, _, ΔDV, ΔDVtrunc = ad_eig_trunc_setup (A, truncalg)
89- test_reverse (eig_trunc_no_error, RT, (A, TA), (truncalg, Const); atol, rtol, output_tangent = ΔDVtrunc, fdm)
90- test_reverse (call_and_zero!, RT, (eig_trunc_no_error!, Const), (copy (A), TA), (truncalg, Const); atol, rtol, output_tangent = ΔDVtrunc, fdm)
88+ DV, DVtrunc, ΔDV, ΔDVtrunc = ad_eig_trunc_setup (A, truncalg)
89+ # trunctol keeps LAPACK's eigenvalue ordering, so sort the outputs (and the tangent)
90+ ΔDVtrunc = permute_eigpairs (ΔDVtrunc, eigvals_sortperm (diagview (DVtrunc[1 ])))
91+ test_reverse (eig_trunc_wrapper, RT, (eig_trunc_no_error, Const), (A, TA), (truncalg, Const); atol, rtol, output_tangent = ΔDVtrunc, fdm)
92+ test_reverse (eig_trunc!_wrapper, RT, (eig_trunc_no_error!, Const), (copy (A), TA), (truncalg, Const); atol, rtol, output_tangent = ΔDVtrunc, fdm)
9193 # use max range here to try to dodge issues when the gap between eigenvalues is close to the FD perturbation
92- test_forward (eig_trunc_no_error , RT, (A, TA), (truncalg, Const); atol, rtol, fdm = EnzymeTestUtils. FiniteDifferences. central_fdm (5 , 1 , max_range = 1.0e-3 ))
93- test_forward (call_and_zero! , RT, (eig_trunc_no_error!, Const), (copy (A), TA), (truncalg, Const); atol, rtol, fdm = EnzymeTestUtils. FiniteDifferences. central_fdm (5 , 1 , max_range = 1.0e-3 ))
94+ test_forward (eig_trunc_wrapper , RT, (eig_trunc_no_error, Const) , (A, TA), (truncalg, Const); atol, rtol, fdm = EnzymeTestUtils. FiniteDifferences. central_fdm (5 , 1 , max_range = 1.0e-3 ))
95+ test_forward (eig_trunc!_wrapper , RT, (eig_trunc_no_error!, Const), (copy (A), TA), (truncalg, Const); atol, rtol, fdm = EnzymeTestUtils. FiniteDifferences. central_fdm (5 , 1 , max_range = 1.0e-3 ))
9496 end
9597 end
9698end
0 commit comments