Skip to content

Commit cb68eb4

Browse files
authored
Merge pull request #1019 from SciML/sparse
fix and test sparse return
2 parents fdb4770 + b28b5c3 commit cb68eb4

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ function DiffEqBase.ODEFunction{iip}(sys::AbstractODESystem, dvs = states(sys),
221221
jac = _jac === nothing ? nothing : _jac,
222222
tgrad = _tgrad === nothing ? nothing : _tgrad,
223223
mass_matrix = _M,
224-
jac_prototype = (!isnothing(u0) && sparse) ? (!jac ? similar(jacobian_sparsity(sys),uElType) : similar(get_jac(sys)[],uElType)) : nothing,
224+
jac_prototype = (!isnothing(u0) && sparse) ? (!jac ? similar(jacobian_sparsity(sys),uElType) : SparseArrays.sparse(similar(get_jac(sys)[],uElType))) : nothing,
225225
syms = Symbol.(states(sys)),
226226
indepsym = Symbol(independent_variable(sys)),
227227
observed = observedfun,

test/odesystem.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ for p in [prob1, prob14]
225225
end
226226
prob2 = ODEProblem(sys,u0,tspan,p,jac=true)
227227
prob3 = ODEProblem(sys,u0,tspan,p,jac=true,sparse=true)
228+
@test prob3.f.sparsity isa SparseMatrixCSC
228229
@test_throws ArgumentError ODEProblem(sys,zeros(5),tspan,p)
229230
for (prob, atol) in [(prob1, 1e-12), (prob2, 1e-12), (prob3, 1e-12)]
230231
local sol

0 commit comments

Comments
 (0)