Skip to content

Commit 0d8bafe

Browse files
committed
Added ifft plan
1 parent 53cc6d5 commit 0d8bafe

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Dispersions"
22
uuid = "9451dd48-6b2a-4bde-a443-9ec270a37806"
33
authors = ["Julian Stobbe <Atomtomate@gmx.de>", "Jan Frederik Weissler <f.weissler@outlook.de>", "<Marvin Leusch <marvin.leusch@studium.uni-hamburg.de>"]
4-
version = "1.1.1"
4+
version = "1.2.0"
55

66
[deps]
77
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

TODO

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +0,0 @@
1-
- missing tests:
2-
- fft
3-
- ifft
4-
- conv
5-
- conv_fft1
6-
- conv_fft

src/KGrid.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ struct KGrid{T <: KGridType, D}
4040
cache1::Array{ComplexF64,D}
4141
cache2::Array{ComplexF64,D}
4242
fftw_plan::FFTW.cFFTWPlan
43-
function KGrid(GT::Type{T}, D::Int, Ns::Int, t::Float64, tp::Float64, tpp::Float64; full::Bool=false, fftw_plan=nothing) where T<:KGridType
43+
ifftw_plan::AbstractFFTs.ScaledPlan
44+
function KGrid(GT::Type{T}, D::Int, Ns::Int, t::Float64, tp::Float64, tpp::Float64; full::Bool=false, fftw_plan=nothing, ifftw_plan=nothing) where T<:KGridType
4445
sampling = gen_sampling(GT, D, Ns)
4546
kGrid_f = map(v -> basis_transform(GT, v), sampling)
4647
kInd, kInd_conv, kInd_crossc, kMult, expand_perms, kGrid = full ? reduce_KGrid_ident(GT, D, Ns, kGrid_f) : reduce_KGrid(GT, D, Ns, kGrid_f)
@@ -51,9 +52,13 @@ struct KGrid{T <: KGridType, D}
5152
#println("WARNING!!! k-grid sampling must contain zero-vector in order for convolutions to work!")
5253
k0 = first(CartesianIndices([1 2; 3 4]))
5354
end
54-
fftw_plan = fftw_plan === nothing ? plan_fft!(FFTW.FakeArray{ComplexF64}(gs...), flags=FFTW.ESTIMATE, timelimit=Inf) : fftw_plan
55+
cache1 = Array{ComplexF64,D}(undef, gs...)
56+
cache2 = Array{ComplexF64,D}(undef, gs...)
57+
FFTW.set_num_threads(1);
58+
fftw_plan = fftw_plan === nothing ? plan_fft!(cache1, flags=FFTW.PATIENT, timelimit=Inf, num_threads=1) : fftw_plan
59+
ifftw_plan = ifftw_plan === nothing ? plan_ifft!(cache1, flags=FFTW.PATIENT, timelimit=Inf, num_threads=1) : ifftw_plan
5560
new{GT,D}(Ns^D, Ns, t, tp, tpp, k0, kGrid, ϵkGrid, kInd, kInd_conv, kInd_crossc, kMult, expand_perms,
56-
Array{ComplexF64,D}(undef, gs...), Array{ComplexF64,D}(undef, gs...), fftw_plan)
61+
cache1, cache2, fftw_plan, ifftw_plan)
5762
end
5863
end
5964

src/common.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,13 @@ function expandKArr!(
113113
kG::KGrid{gT,D},
114114
res::AbstractArray{T,D},
115115
arr::Array{T,1},
116-
) where {gT <: KGridType,T,D}
116+
)::Nothing where {gT <: KGridType,T,D}
117117
for (ri, perms) in enumerate(kG.expand_perms)
118118
@simd for p in perms
119119
@inbounds res[p] = arr[ri]
120120
end
121121
end
122+
return nothing
122123
end
123124

124125
"""
@@ -355,7 +356,7 @@ function conv_fft_noPlan!(
355356
for i in eachindex(cache)
356357
@inbounds cache[i] = arr1[i] * arr2[i]
357358
end
358-
ifft!(cache)
359+
kG.ifftw_plan * cache
359360
conv_post!(kG, res, cache, crosscorrelation=crosscorrelation)
360361
end
361362

0 commit comments

Comments
 (0)