diff --git a/common.jl b/common.jl index b9d912d..b7035db 100644 --- a/common.jl +++ b/common.jl @@ -47,7 +47,7 @@ which_index(s::system, dim::Int, coord::Int)::Int = (dim - 1) * (s.n - 1) + coor function nearest(s::system, Δk::Int)::Int # TODO: Optimize while true - if Δk > s.N ÷ 2 + if Δk > (s.N ÷ 2 - 1) Δk -= s.N elseif Δk < -s.N ÷ 2 Δk += s.N @@ -63,7 +63,7 @@ function calculate_Vs(s::system{T}, V_twobody::Function, ϕ::T, n_image::Int)::A images = collect.(Iterators.product(fill(-n_image:n_image, s.d)...)) # TODO: Learn how to use tuples instead of vectors Vs = zeros(Complex{T}, fill(s.N, s.d * (s.n - 1))...) Threads.@threads for i in CartesianIndices(Vs) - xs = reshape(collect(Tuple(i)), s.n - 1, s.d) .- (s.N ÷ 2 - 1) + xs = reshape(collect(Tuple(i)), s.n - 1, s.d) .- (s.N ÷ 2 + 1) rs = s.invU * xs for p1 in 1:s.n for p2 in 1:(p1 - 1)