1
- using LinearSolve, RecursiveFactorization, LinearAlgebra, SparseArrays, Test
1
+ using LinearSolve, ForwardDiff, RecursiveFactorization, LinearAlgebra, SparseArrays, Test
2
2
using JET
3
3
4
4
# Dense problem setup
@@ -22,6 +22,18 @@ prob_sparse = LinearProblem(A_sparse, b)
22
22
A_sparse_spd = sparse (A_spd)
23
23
prob_sparse_spd = LinearProblem (A_sparse_spd, b)
24
24
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
+
25
37
@testset " JET Tests for Dense Factorizations" begin
26
38
# Working tests - these pass JET optimization checks
27
39
JET. @test_opt init (prob, nothing )
109
121
JET. @test_opt solve (prob) broken= true
110
122
JET. @test_opt solve (prob_sparse) broken= true
111
123
end
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