Skip to content

Commit 0a31c91

Browse files
feat: add resid_prototype for ImplicitDiscreteFunction
Co-authored-by: vyudu <[email protected]>
1 parent 5ec75ca commit 0a31c91

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/systems/discrete_system/implicit_discrete_system.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,12 @@ function SciMLBase.ImplicitDiscreteFunction{iip, specialize}(
379379
f(u_next, u, p, t) = f_oop(u_next, u, p, t)
380380
f(resid, u_next, u, p, t) = f_iip(resid, u_next, u, p, t)
381381

382+
if length(dvs) == length(equations(sys))
383+
resid_prototype = nothing
384+
else
385+
resid_prototype = calculate_resid_prototype(length(equations(sys)), u0, p)
386+
end
387+
382388
if specialize === SciMLBase.FunctionWrapperSpecialize && iip
383389
if u0 === nothing || p === nothing || t === nothing
384390
error("u0, p, and t must be specified for FunctionWrapperSpecialize on ImplicitDiscreteFunction.")
@@ -393,6 +399,7 @@ function SciMLBase.ImplicitDiscreteFunction{iip, specialize}(
393399
sys = sys,
394400
observed = observedfun,
395401
analytic = analytic,
402+
resid_prototype = resid_prototype,
396403
kwargs...)
397404
end
398405

0 commit comments

Comments
 (0)