Skip to content

Commit

Permalink
Prevent dynamic dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Dec 25, 2023
1 parent 344f505 commit 701e441
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/solutions/ode_solutions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,6 @@ function BVPSolution{T, N}(u, u_analytic, errors, t, k, prob, alg, interp, dense
original_nlsolve)
end

function BVPSolution(sol::ODESolution{T, N}; resid = nothing, retcode = sol.retcode,
original::Union{Nothing, AbstractNonlinearSolution} = nothing) where {T, N}
if original !== nothing && resid === nothing && hasfield(typeof(original), :resid)
resid = original.resid
end
return BVPSolution{T, N}(sol.u, sol.u_analytic, sol.errors, sol.t, sol.k, sol.prob,
sol.alg, sol.interp, sol.dense, sol.tslocation, sol.stats, sol.alg_choice,
retcode, resid, sol, original)
end

Base.@propagate_inbounds function Base.getproperty(x::AbstractODESolution, s::Symbol)
if s === :destats
Base.depwarn("`sol.destats` is deprecated. Use `sol.stats` instead.", "sol.destats")
Expand Down Expand Up @@ -278,6 +268,22 @@ function (sol::AbstractODESolution)(t::AbstractVector{<:Number}, ::Type{deriv},
return DiffEqArray([[interp_sol[idx][i] for idx in idxs] for i in 1:length(t)], t, p, sol)
end

function build_solution(prob::BVProblem, ivpsol::AbstractODESolution{T, N},
nlsol::Union{Nothing, AbstractNonlinearSolution}; retcode = nothing) where {T, N}
if retcode === nothing
if nlsol === nothing
retcode = ivpsol.retcode
else
retcode = ifelse(successful_retcode(nlsol.retcode), ivpsol.retcode,
nlsol.retcode)
end
end
return BVPSolution{T, N}(ivpsol.u, ivpsol.u_analytic, ivpsol.errors, ivpsol.t,
ivpsol.k, prob, ivpsol.alg, ivpsol.interp, ivpsol.dense, ivpsol.tslocation,
ivpsol.stats, ivpsol.alg_choice, retcode, nlsol === nothing ? nothing : nlsol.resid,
ivpsol, nlsol)
end

function build_solution(prob::Union{AbstractODEProblem, AbstractDDEProblem},
alg, t, u; timeseries_errors = length(u) > 2,
dense = false, dense_errors = dense,
Expand Down

0 comments on commit 701e441

Please sign in to comment.