Skip to content

Commit

Permalink
avoid repetition of build_solution
Browse files Browse the repository at this point in the history
  • Loading branch information
lxvm committed Mar 2, 2024
1 parent 95e27e2 commit 9a39c80
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
5 changes: 1 addition & 4 deletions ext/IntegralsArblibExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ function Integrals.__solvebp_call(
val = Arblib.integrate!(f_, res, lb, ub, atol = abstol, rtol = reltol,
check_analytic = alg.check_analytic, take_prec = alg.take_prec,
warn_on_no_convergence = alg.warn_on_no_convergence, opts = alg.opts)
SciMLBase.build_solution(
prob, alg, val, get_radius(val), retcode = ReturnCode.Success)
else
f_ = (x; kws...) -> only(prob.f(x, p; kws...))
val = Arblib.integrate(f_, lb, ub, atol = abstol, rtol = reltol,
check_analytic = alg.check_analytic, take_prec = alg.take_prec,
warn_on_no_convergence = alg.warn_on_no_convergence, opts = alg.opts)
SciMLBase.build_solution(
prob, alg, val, get_radius(val), retcode = ReturnCode.Success)
end
SciMLBase.build_solution(prob, alg, val, get_radius(val), retcode = ReturnCode.Success)
end

function get_radius(ball)
Expand Down
5 changes: 1 addition & 4 deletions src/Integrals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ function __solvebp_call(cache::IntegralCache, alg::QuadGKJL, sensealg, domain, p
end
val, err = quadgk(_f, lb, ub, segbuf = cache.cacheval, maxevals = maxiters,
rtol = reltol, atol = abstol, order = alg.order, norm = alg.norm)
SciMLBase.build_solution(prob, alg, val, err, retcode = ReturnCode.Success)
else
prototype = f(typeof(mid)[], p)
_f = if prototype isa AbstractVector
Expand All @@ -170,7 +169,6 @@ function __solvebp_call(cache::IntegralCache, alg::QuadGKJL, sensealg, domain, p
end
val, err = quadgk(_f, lb, ub, segbuf = cache.cacheval, maxevals = maxiters,
rtol = reltol, atol = abstol, order = alg.order, norm = alg.norm)
SciMLBase.build_solution(prob, alg, val, err, retcode = ReturnCode.Success)
end
else
if isinplace(f)
Expand All @@ -179,14 +177,13 @@ function __solvebp_call(cache::IntegralCache, alg::QuadGKJL, sensealg, domain, p
val, err = quadgk!(_f, result, lb, ub, segbuf = cache.cacheval,
maxevals = maxiters,
rtol = reltol, atol = abstol, order = alg.order, norm = alg.norm)
SciMLBase.build_solution(prob, alg, val, err, retcode = ReturnCode.Success)
else
_f = u -> f(u, p)
val, err = quadgk(_f, lb, ub, segbuf = cache.cacheval, maxevals = maxiters,
rtol = reltol, atol = abstol, order = alg.order, norm = alg.norm)
SciMLBase.build_solution(prob, alg, val, err, retcode = ReturnCode.Success)
end
end
SciMLBase.build_solution(prob, alg, val, err, retcode = ReturnCode.Success)
end

function init_cacheval(alg::HCubatureJL, prob::IntegralProblem)
Expand Down

0 comments on commit 9a39c80

Please sign in to comment.