Skip to content

Commit e04accf

Browse files
inplace interpolations for speed
1 parent 4afff38 commit e04accf

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/integrators/integrator_interface.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
if t < integrator.tprev
66
error("Current interpolant only works between tprev and t")
77
elseif t != integrator.t
8-
new_u = integrator(t)
9-
integrator.dtnew = integrator.t - t
10-
perform_rswm_rejection!(integrator)
11-
128
if typeof(integrator.u) <: AbstractArray
13-
recursivecopy!(integrator.u,new_u)
9+
integrator(integrator.u,t)
1410
else
15-
integrator.u = new_u
11+
integrator.u = integrator(t)
1612
end
13+
integrator.dtnew = integrator.t - t
14+
perform_rswm_rejection!(integrator) #this only changes dt and noise, so no interpolation problems
1715
integrator.t = t
1816
# reeval_internals_due_to_modification!(integrator) # Not necessary for linear interp
1917
if T

src/integrators/integrator_utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ end
7474
curt = pop!(integrator.opts.saveat)
7575
if integrator.opts.saveat!=integrator.t # If <t, interpolate
7676
Θ = (curt - integrator.tprev)/integrator.dt
77-
val = sde_interpolant(Θ,integrator)
77+
val = sde_interpolant(Θ,integrator,indices(integrator.uprev),Val{0}) # out of place, but force copy later
7878
copyat_or_push!(integrator.sol.t,integrator.saveiter,curt)
79-
copyat_or_push!(integrator.sol.u,integrator.saveiter,val)
79+
copyat_or_push!(integrator.sol.u,integrator.saveiter,val,Val{false})
8080
if typeof(integrator.alg) <: StochasticEqCompositeAlgorithm
8181
copyat_or_push!(integrator.sol.alg_choice,integrator.saveiter,integrator.cache.current)
8282
end

0 commit comments

Comments
 (0)