SciML / StochasticDiffEq.jl

Solvers for stochastic differential equations which connect with the scientific machine learning (SciML) ecosystem
Other
248 stars 66 forks source link

Keep noise vectors dense #436

Closed ChrisRackauckas closed 2 years ago

ChrisRackauckas commented 2 years ago

Previously we would create the noise vector via noise_rate_prototype[1,:], which is the right size, but if the matrix is sparse that would be a sparse vector. This causes two issues. One is performance. The noise vector is always dense (since otherwise you would just make it smaller in the non-diagonal case), so using a sparse vector is just a bad idea. But secondly, it turns out that filling a sparse random vector that starts with 0 memory can lead to some undefined behavior, which causes the first random numbers to be truly random. Thus this performance fix is also fixes https://github.com/SciML/StochasticDiffEq.jl/issues/435, which I would thus say is the best of all worlds.

sho7014 commented 2 years ago

Thank you for the clear explanation and the fix.