Skip to content

Commit

Permalink
Merge pull request #114 from rmsrosa/reset_noisefunction
Browse files Browse the repository at this point in the history
Reset noisefunction
  • Loading branch information
ChrisRackauckas authored Aug 19, 2022
2 parents 6536a7d + 510eeb3 commit 86e61dc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
*.jl.*.cov
*.jl.mem
Manifest.toml

# vscode stuff
.vscode
.vscode/*
26 changes: 26 additions & 0 deletions src/noise_interfaces/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,32 @@ function DiffEqBase.reinit!(W::AbstractNoiseProcess, dt;
return nothing
end

function DiffEqBase.reinit!(W::NoiseFunction, dt;
t0 = W.t0,
erase_sol = true,
setup_next = false)
W.curt = t0
W.dt = dt

if isinplace(W)
W.curW .= first(W(t0))
W.dW .= W.curW
if W.Z !== nothing
W.curZ .= last(W(t0))
W.dZ .= W.curZ
end
else
W.curW = first(W(t0))
W.dW = W.curW
if W.Z !== nothing
W.curZ = last(W(t0))
W.dZ = W.curZ
end
end

return nothing
end

function Base.reverse(W::AbstractNoiseProcess)
if typeof(W) <: NoiseGrid
if W.Z === nothing
Expand Down
3 changes: 2 additions & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ mutable struct NoiseFunction{T, N, wType, zType, Tt, T2, T3, inplace} <:
dt::Tt
dW::T2
dZ::T3
t0::Tt
reset::Bool

function NoiseFunction{iip}(t0, W, Z = nothing;
Expand All @@ -560,7 +561,7 @@ mutable struct NoiseFunction{T, N, wType, zType, Tt, T2, T3, inplace} <:
end
new{typeof(noise_prototype), ndims(noise_prototype), typeof(W), typeof(Z),
typeof(curt), typeof(curW), typeof(curZ), iip}(W, Z, curt, curW, curZ,
dt, dW, dZ, reset)
dt, dW, dZ, t0, reset)
end
end

Expand Down

0 comments on commit 86e61dc

Please sign in to comment.