@@ -213,6 +213,7 @@ function is_discrete_expression(indp, expr)
213
213
length (ts_idxs) > 1 || length (ts_idxs) == 1 && only (ts_idxs) != ContinuousTimeseries ()
214
214
end
215
215
216
+ # These are the two main documented user-facing interpolation API functions (out-of-place and in-place versions)
216
217
function (sol:: AbstractODESolution )(t, :: Type{deriv} = Val{0 }; idxs = nothing ,
217
218
continuity = :left ) where {deriv}
218
219
if t isa IndexedClock
@@ -225,9 +226,12 @@ function (sol::AbstractODESolution)(v, t, ::Type{deriv} = Val{0}; idxs = nothing
225
226
if t isa IndexedClock
226
227
t = canonicalize_indexed_clock (t, sol)
227
228
end
228
- sol. interp (v, t, idxs, deriv, sol . prob . p , continuity)
229
+ sol (v, t, deriv, idxs , continuity)
229
230
end
230
231
232
+ # Below are many internal dispatches for different combinations of arguments to the main API
233
+ # TODO : could use a clever rewrite, since a lot of reused code has accumulated
234
+
231
235
function (sol:: AbstractODESolution )(t:: Number , :: Type{deriv} , idxs:: Nothing ,
232
236
continuity) where {deriv}
233
237
sol. interp (t, idxs, deriv, sol. prob. p, continuity)
@@ -365,6 +369,41 @@ function (sol::AbstractODESolution)(t::AbstractVector{<:Number}, ::Type{deriv},
365
369
return DiffEqArray (u, t, p, sol; discretes)
366
370
end
367
371
372
+ function (sol:: AbstractODESolution )(v:: AbstractArray , t:: AbstractVector{<:Number} , :: Type{deriv} , idxs,
373
+ continuity) where {deriv}
374
+ symbolic_type (idxs) == NotSymbolic () && error (" Incorrect specification of `idxs`" )
375
+ error_if_observed_derivative (sol, idxs, deriv)
376
+ p = hasproperty (sol. prob, :p ) ? sol. prob. p : nothing
377
+ getter = getsym (sol, idxs)
378
+ if is_parameter_timeseries (sol) == NotTimeseries () || ! is_discrete_expression (sol, idxs)
379
+ u = zeros (eltype (sol), size (sol)[1 ])
380
+ v .= map (eachindex (t)) do ti
381
+ sol. interp (u, t[ti], nothing , deriv, p, continuity)
382
+ return getter (ProblemState (; u = u, p = p, t = t[ti]))
383
+ end
384
+ return v
385
+ end
386
+ error (" In-place interpolation with discretes is not implemented." )
387
+ end
388
+ function (sol:: AbstractODESolution )(v:: AbstractArray , t:: AbstractVector{<:Number} , :: Type{deriv} ,
389
+ idxs:: AbstractVector , continuity) where {deriv}
390
+ if symbolic_type (idxs) == NotSymbolic () && isempty (idxs)
391
+ return map (_ -> eltype (eltype (sol. u))[], t)
392
+ end
393
+ error_if_observed_derivative (sol, idxs, deriv)
394
+ p = hasproperty (sol. prob, :p ) ? sol. prob. p : nothing
395
+ getter = getsym (sol, idxs)
396
+ if is_parameter_timeseries (sol) == NotTimeseries () || ! is_discrete_expression (sol, idxs)
397
+ u = zeros (eltype (sol), size (sol)[1 ])
398
+ v .= map (eachindex (t)) do ti
399
+ sol. interp (u, t[ti], nothing , deriv, p, continuity)
400
+ return getter (ProblemState (; u = u, p = p, t = t[ti]))
401
+ end
402
+ return v
403
+ end
404
+ error (" In-place interpolation with discretes is not implemented." )
405
+ end
406
+
368
407
struct DDESolutionHistoryWrapper{T}
369
408
sol:: T
370
409
end
0 commit comments