Skip to content

Commit d0a709e

Browse files
handle jac_prototype when sparse
1 parent 3dc7432 commit d0a709e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ function DiffEqBase.ODEFunction{iip}(sys::AbstractODESystem, dvs = states(sys),
153153
jac = _jac === nothing ? nothing : DiffEqBase.EvalFunc(_jac),
154154
tgrad = _tgrad === nothing ? nothing : DiffEqBase.EvalFunc(_tgrad),
155155
mass_matrix = _M,
156+
jac_prototype = sparse ? similar(sys.jac,Float64) : nothing,
156157
syms = Symbol.(states(sys)))
157158
end
158159

@@ -202,6 +203,8 @@ function ODEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
202203

203204
_M = (u0 === nothing || M == I) ? M : ArrayInterface.restructure(u0 .* u0',M)
204205

206+
jp_expr = sparse ? :(similar($(sys.jac),Float64)) : :nothing
207+
205208
ex = quote
206209
f = $f
207210
tgrad = $_tgrad
@@ -212,6 +215,7 @@ function ODEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
212215
jac = jac,
213216
tgrad = tgrad,
214217
mass_matrix = M,
218+
jac_prototype = $jp_expr,
215219
syms = $(Symbol.(states(sys))))
216220
end
217221
!linenumbers ? striplines(ex) : ex
@@ -232,7 +236,7 @@ end
232236
function DiffEqBase.ODEProblem{iip}(sys::AbstractODESystem,u0map,tspan,
233237
parammap=DiffEqBase.NullParameters();
234238
version = nothing, tgrad=false,
235-
jac = false,
239+
jac = false,
236240
checkbounds = false, sparse = false,
237241
simplify = true,
238242
linenumbers = true, parallel=SerialForm(),

0 commit comments

Comments
 (0)