1- using LinearSolve, RecursiveFactorization, LinearAlgebra, SparseArrays, Test
1+ using LinearSolve, ForwardDiff, RecursiveFactorization, LinearAlgebra, SparseArrays, Test
22using JET
33
44# Dense problem setup
@@ -22,6 +22,18 @@ prob_sparse = LinearProblem(A_sparse, b)
2222A_sparse_spd = sparse (A_spd)
2323prob_sparse_spd = LinearProblem (A_sparse_spd, b)
2424
25+ # Dual problem set up
26+ function h (p)
27+ (A = [p[1 ] p[2 ]+ 1 p[2 ]^ 3 ;
28+ 3 * p[1 ] p[1 ]+ 5 p[2 ] * p[1 ]- 4 ;
29+ p[2 ]^ 2 9 * p[1 ] p[2 ]],
30+ b = [p[1 ] + 1 , p[2 ] * 2 , p[1 ]^ 2 ])
31+ end
32+
33+ A, b = h ([ForwardDiff. Dual (5.0 , 1.0 , 0.0 ), ForwardDiff. Dual (5.0 , 0.0 , 1.0 )])
34+
35+ dual_prob = LinearProblem (A, b)
36+
2537@testset " JET Tests for Dense Factorizations" begin
2638 # Working tests - these pass JET optimization checks
2739 JET. @test_opt init (prob, nothing )
109121 JET. @test_opt solve (prob) broken= true
110122 JET. @test_opt solve (prob_sparse) broken= true
111123end
124+
125+ @testset " JET Tests for creating Dual solutions" begin
126+ # Make sure there's no runtime dispatch when making solutions of Dual problems
127+ dual_cache = init (prob)
128+ ext = Base. get_extension (LinearSolve, :LinearSolveForwardDiffExt )
129+ JET. @test_opt ext. linearsolve_dual_solution (
130+ [1.0 , 1.0 , 1.0 ], [[1.0 , 1.0 , 1.0 ], [1.0 , 1.0 , 1.0 ]], cache)
131+ end
0 commit comments