@@ -85,19 +85,15 @@ for f in [f_oop, f_ip]
85
85
end
86
86
end
87
87
88
+ # test for https://github.com/SciML/OrdinaryDiffEq.jl/issues/2653#issuecomment-2778430025
89
+
88
90
function sparse_f! (du, u, p, t)
89
91
du[1 ] = u[1 ] + u[2 ]
90
92
du[2 ] = u[3 ]^ 2
91
93
return du[3 ] = u[1 ]^ 2
92
94
end
93
95
94
- backend_allow = AutoSparse (
95
- AutoForwardDiff ();
96
- sparsity_detector = TracerSparsityDetector (),
97
- coloring_algorithm = GreedyColoringAlgorithm (; allow_denser = true )
98
- )
99
-
100
- backend_no_allow = AutoSparse (
96
+ backend = AutoSparse (
101
97
AutoForwardDiff ();
102
98
sparsity_detector = TracerSparsityDetector (),
103
99
coloring_algorithm = GreedyColoringAlgorithm ()
@@ -107,33 +103,19 @@ u = ones(3)
107
103
du = zero (u)
108
104
p = t = nothing
109
105
110
- prep_allow = DI. prepare_jacobian (
111
- sparse_f!, du, backend_allow, u, DI. Constant (p), DI. Constant (t))
112
- prep_no_allow = DI. prepare_jacobian (
113
- sparse_f!, du, backend_no_allow, u, DI. Constant (p), DI. Constant (t))
106
+ prep = DI. prepare_jacobian (
107
+ sparse_f!, du, backend, u, DI. Constant (p), DI. Constant (t))
114
108
# this is what the user may typically provide to the ODE problem
115
109
116
- function inplace_jac_allow ! (J, u, p, t)
110
+ function inplace_jac ! (J, u, p, t)
117
111
return DI. jacobian! (
118
- sparse_f!, zeros (3 ), J, prep_allow, backend_allow , u, DI. Constant (p), DI. Constant (t))
112
+ sparse_f!, zeros (3 ), J, prep, backend , u, DI. Constant (p), DI. Constant (t))
119
113
end
120
114
121
- function inplace_jac_no_allow! (J, u, p, t)
122
- return DI. jacobian! (
123
- sparse_f!, zeros (3 ), J, prep_no_allow, backend_no_allow, u, DI. Constant (p), DI. Constant (t))
124
- end
125
-
126
- jac_prototype = similar (sparsity_pattern (prep_allow), eltype (u))
127
-
128
- ode_f_allow = ODEFunction (
129
- sparse_f!, jac = inplace_jac_allow!, jac_prototype = jac_prototype)
130
- prob_allow = ODEProblem (ode_f_allow, [1 , 1 , 1 ], (0.0 , 1.0 ))
131
-
132
- ode_f_no_allow = ODEFunction (
133
- sparse_f!, jac = inplace_jac_no_allow!, jac_prototype = jac_prototype)
134
- prob_no_allow = ODEProblem (ode_f_no_allow, [1 , 1 , 1 ], (0.0 , 1.0 ))
115
+ jac_prototype = similar (sparsity_pattern (prep), eltype (u))
135
116
136
- sol = solve (prob_allow, Rodas5 ())
117
+ ode_f = ODEFunction (sparse_f!, jac = inplace_jac!, jac_prototype = jac_prototype)
118
+ prob = ODEProblem (ode_f, [1 , 1 , 1 ], (0.0 , 1.0 ))
137
119
138
- @test_throws DimensionMismatch sol= solve (prob_no_allow , Rodas5 ())
120
+ @test_no_warn sol = solve (prob , Rodas5 ())
139
121
0 commit comments