Skip to content

Commit

Permalink
Merge pull request #155 from ArnoStrouwen/stability
Browse files Browse the repository at this point in the history
stability
  • Loading branch information
ChrisRackauckas authored Mar 13, 2023
2 parents 4b3aecf + 5679067 commit aa6cc25
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
10 changes: 3 additions & 7 deletions lib/IntegralsCuba/src/IntegralsCuba.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,15 @@ function Integrals.__solvebp_call(prob::IntegralProblem, alg::AbstractCubaAlgori
reltol = 1e-8, abstol = 1e-8,
maxiters = alg isa CubaSUAVE ? 1000000 : typemax(Int))
@assert maxiters>=1000 "maxiters for $alg should be larger than 1000"
prob = transformation_if_inf(prob) #intercept for infinite transformation
p = p
if lb isa Number && prob.batch == 0
_x = Float64[lb]
elseif lb isa Number
_x = zeros(length(lb), prob.batch)
_x = zeros(eltype(lb), length(lb), prob.batch)
elseif prob.batch == 0
_x = zeros(length(lb))
_x = zeros(eltype(lb), length(lb))
else
_x = zeros(length(lb), prob.batch)
_x = zeros(eltype(lb), length(lb), prob.batch)
end
ub = ub
lb = lb

if prob.batch == 0
if isinplace(prob)
Expand Down
3 changes: 1 addition & 2 deletions lib/IntegralsCubature/src/IntegralsCubature.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ function Integrals.__solvebp_call(prob::IntegralProblem,
sensealg, lb, ub, p;
reltol = 1e-8, abstol = 1e-8,
maxiters = typemax(Int))
prob = transformation_if_inf(prob) #intercept for infinite transformation
nout = prob.nout
if nout == 1
if prob.batch == 0
if isinplace(prob)
dx = zeros(prob.nout)
dx = zeros(eltype(lb), prob.nout)
f = (x) -> (prob.f(dx, x, p); dx[1])
else
f = (x) -> prob.f(x, p)[1]
Expand Down
6 changes: 3 additions & 3 deletions src/Integrals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function __solvebp_call(prob::IntegralProblem, alg::HCubatureJL, sensealg, lb, u
p = p

if isinplace(prob)
dx = zeros(prob.nout)
dx = zeros(eltype(lb), prob.nout)
f = x -> (prob.f(dx, x, prob.p); dx)
else
f = x -> prob.f(x, prob.p)
Expand All @@ -142,14 +142,14 @@ function __solvebp_call(prob::IntegralProblem, alg::VEGAS, sensealg, lb, ub, p;
@assert prob.nout == 1
if prob.batch == 0
if isinplace(prob)
dx = zeros(prob.nout)
dx = zeros(eltype(lb), prob.nout)
f = x -> (prob.f(dx, x, p); dx[1])
else
f = x -> prob.f(x, prob.p)
end
else
if isinplace(prob)
dx = zeros(prob.batch)
dx = zeros(eltype(lb), prob.batch)
f = x -> (prob.f(dx, x', p); dx)
else
f = x -> prob.f(x', p)
Expand Down

0 comments on commit aa6cc25

Please sign in to comment.