JuliaSIMD / VectorizedRNG.jl

Vectorized uniform and normal random samplers.
MIT License
33 stars 7 forks source link

Support sampling into non-contiguous arrays #15

Open chriselrod opened 3 years ago

chriselrod commented 3 years ago

This is currently silently broken, which is dangerous:

julia> randn!(local_rng(), view(X, :,2,:))
3×3 view(::Array{Float64, 3}, :, 2, :) with eltype Float64:
 -0.601185  0.0  0.0
  0.529745  0.0  0.0
 -1.30729   0.0  0.0

julia> X
3×3×3 Array{Float64, 3}:
[:, :, 1] =
 0.0  -0.601185  -0.662154
 0.0   0.529745   1.66186
 0.0  -1.30729    0.848472

[:, :, 2] =
  0.891294  0.0  0.0
  0.928313  0.0  0.0
 -1.01618   0.0  0.0

[:, :, 3] =
 0.0  0.0  0.0
 0.0  0.0  0.0
 0.0  0.0  0.0