Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix oop suport for extension #121

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions ext/FractionalDiffEqFdeSolverExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,24 @@
# const default_values = (2^-6, 1, nothing, 1e-6, 100)
function SciMLBase.__solve(prob::FODEProblem, alg::FdeSolverPECE; dt = 0.0, abstol = 1e-3, maxiters = 1000, kwargs...)
(; f, order, tspan, u0, p) = prob

iip = isinplace(prob)

tSpan = [first(tspan), last(tspan)]
# FdeSolver only supports out-of-place computing
newf = function (t, y, par)
du = similar(y)
f(du, y, par, t)
return du
newf = if iip
function (t, y, par)
du = similar(y)
f(du, y, par, t)
return du
end
else
function (t, y, par)

Check warning on line 21 in ext/FractionalDiffEqFdeSolverExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/FractionalDiffEqFdeSolverExt.jl#L21

Added line #L21 was not covered by tests
return f.(y, par, t)
end
end
t, y = FDEsolver(newf, tSpan, u0, order, p, JF = prob.f.jac, h = dt, tol = abstol)
par = p isa SciMLBase.NullParameters ? nothing : p
t, y = FDEsolver(newf, tSpan, u0, order, par, JF = prob.f.jac, h = dt, tol = abstol)
u = eachrow(y)

return DiffEqBase.build_solution(prob, alg, t, u)
Expand Down
Loading