Skip to content

Commit 230d083

Browse files
If sparse, make the mass matrix sparse
1 parent 274c80c commit 230d083

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,14 @@ function DiffEqBase.ODEFunction{iip}(sys::AbstractODESystem, dvs = states(sys),
355355
end
356356

357357
M = calculate_massmatrix(sys)
358-
359-
_M = (u0 === nothing || M == I) ? M : ArrayInterface.restructure(u0 .* u0',M)
358+
359+
_M = if sparse && !(u0 === nothing || M == I)
360+
sparse(M)
361+
elseif u0 === nothing || M == I
362+
M
363+
else
364+
ArrayInterface.restructure(u0 .* u0',M)
365+
end
360366

361367
obs = observed(sys)
362368
observedfun = if steady_state

0 commit comments

Comments
 (0)