Custom Iterator with one big computation at the begin + in place operation at every iterations

Thanks!
I used your piece of code + that which looks simpler (and maybe more up to date according to docs?).

using Random
struct MyIterator{T <: Real}
    X::Matrix{T}
    count::Int
end

MyIterator(n::Integer, d::Integer, M::Integer) = MyIterator(reshape(range(0, step = π, length = d*n), d, n).%1, M)

Base.length(s::MyIterator) = s.count
Base.iterate(s::MyIterator{T}, state=1) where {T} = state > s.count ? nothing : (shuffle!(@view(s.X[:,:])), state+1) # view for in place modification of s.X
Base.eltype(::Type{MyIterator{T}}) where {T} = Matrix{T}

# it works
for i in MyIterator(5,2,3) println(i) end
collect(MyIterator(5,2,3))