Skip to content

[SDE] Port SROCK2 NoiseWrapper fix from StochasticDiffEq.jl#507 #3188

@ChrisRackauckas

Description

@ChrisRackauckas

Migrated from PR: SciML/StochasticDiffEq.jl#507
Author: @axsk
Fixes: #3170

A fix for SROCK2 failing with NoiseWrapper noise for non-diagonal problems. The issue was that the code accessed W.rng which doesn't exist on NoiseWrapper.

Fix approach: Extract RNG access into a helper function with dispatch:

function init_χ!(vec_χ, W)
    rand!(rng(W), vec_χ)
    @.. vec_χ = 2*floor(vec_χ + 1//2) - 1
end

rng(W::DiffEqNoiseProcess.AbstractNoiseProcess) = W.rng
rng(W::NoiseWrapper) = W.source.rng

This also fixes SKSROCK which had the same issue. The fix was applied to both the out-of-place and in-place code paths in src/perform_step/SROCK_perform_step.jl.

Full diff preserved at: https://github.com/SciML/StochasticDiffEq.jl/pull/507.diff

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions