diff --git a/.gitignore b/.gitignore index 3f02ca7..ce8b343 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,7 @@ *.jl.*.cov *.jl.mem Manifest.toml + +# vscode stuff +.vscode +.vscode/* \ No newline at end of file diff --git a/src/noise_interfaces/common.jl b/src/noise_interfaces/common.jl index e34fc92..68c982d 100644 --- a/src/noise_interfaces/common.jl +++ b/src/noise_interfaces/common.jl @@ -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 diff --git a/src/types.jl b/src/types.jl index 8849f99..8ca7bd6 100644 --- a/src/types.jl +++ b/src/types.jl @@ -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; @@ -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