Modifying all the frequency components of an FFT to 0 EXCEPT the 0th, +-3rd, +-6th, etc

if N and M don’t change often, you can store the indices in an array (if they do and N is big, it might be a lot of allocations)

ind = [i for i in 2:(N÷2+1) if (i-1)%M != 0]
@views ψ[ind] .*= exp.(-abs.(ψ[ind]))

with @views to avoid allocating new arrays