Skip to content

Commit 4be9585

Browse files
Merge pull request #836 from SciML/ap/specialization
feat: add unwrapped_f for NonlinearProblem
2 parents 0f8ec1f + e4cdfc3 commit 4be9585

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/scimlfunctions.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,6 +2661,35 @@ function NonlinearFunction{iip}(f::ODEFunction) where {iip}
26612661
colorvec = f.colorvec)
26622662
end
26632663

2664+
function unwrapped_f(f::NonlinearFunction, newf = unwrapped_f(f.f))
2665+
if specialization(f) === NoSpecialize
2666+
return NonlinearFunction{isinplace(f), specialization(f), Any, Any,
2667+
Any, Any, Any, Any, Any, Any, Any,
2668+
Any, Any, Any, Any, Any,
2669+
typeof(f.colorvec), Any, Any}(newf, f.mass_matrix,
2670+
f.analytic, f.tgrad, f.jac,
2671+
f.jvp, f.vjp, f.jac_prototype,
2672+
f.sparsity, f.Wfact,
2673+
f.Wfact_t, f.paramjac,
2674+
f.observed, f.colorvec, f.sys,
2675+
f.resid_prototype)
2676+
else
2677+
return NonlinearFunction{isinplace(f), specialization(f), typeof(newf),
2678+
typeof(f.mass_matrix), typeof(f.analytic), typeof(f.tgrad),
2679+
typeof(f.jac), typeof(f.jvp), typeof(f.vjp), typeof(f.jac_prototype),
2680+
typeof(f.sparsity), typeof(f.Wfact), typeof(f.Wfact_t),
2681+
typeof(f.paramjac),
2682+
typeof(f.observed), typeof(f.colorvec),
2683+
typeof(f.sys), typeof(f.resid_prototype)}(newf, f.mass_matrix,
2684+
f.analytic, f.tgrad, f.jac,
2685+
f.jvp, f.vjp, f.jac_prototype,
2686+
f.sparsity, f.Wfact,
2687+
f.Wfact_t, f.paramjac,
2688+
f.observed, f.colorvec, f.sys,
2689+
f.resid_prototype)
2690+
end
2691+
end
2692+
26642693
@add_kwonly function SplitFunction(f1, f2, mass_matrix, cache, analytic, tgrad, jac, jvp,
26652694
vjp, jac_prototype, W_prototype, sparsity, Wfact, Wfact_t, paramjac,
26662695
observed, colorvec, sys, initializeprob, update_initializeprob!,

0 commit comments

Comments
 (0)