Skip to content

Commit 2fe481e

Browse files
committed
quick fix for #106
1 parent 5f3dc6c commit 2fe481e

File tree

4 files changed

+46
-21
lines changed

4 files changed

+46
-21
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "NFFT"
22
uuid = "efe261a4-0d2b-5849-be55-fc731d526b0d"
33
authors = ["Tobias Knopp <tobias@knoppweb.de>"]
4-
version = "0.13.1"
4+
version = "0.13.2"
55

66
[deps]
77
AbstractNFFTs = "7f219486-4aa7-41d6-80a7-e08ef20ceed7"
@@ -21,7 +21,7 @@ SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c"
2121
[compat]
2222
AbstractNFFTs = "0.8"
2323
BasicInterpolators = "0.6.5"
24-
DataFrames = "1.3.1"
24+
DataFrames = "1.3.1, 1.4.1"
2525
FFTW = "1.5"
2626
FLoops = "0.2"
2727
Reexport = "1.0"

src/precomputation.jl

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -180,26 +180,32 @@ function precomputeOneNodeBlocking(winLin, winTensor::Nothing, winPoly::Nothing,
180180
return (y, tmpWin)
181181
end
182182

183-
@generated function shiftedWindowEntries(winLin::Vector, idx, scale, d, L::Val{Z}) where {Z}
183+
@generated function shiftedWindowEntries(winLin::Vector, idx::T, scale, d, L::Val{Z}) where {T,Z}
184184
quote
185-
idxL = floor(Int,idx)
186-
idxInt = Int(idxL)
187-
α = ( idx-idxL )
188-
189-
tmpWin = @ntuple $(Z) l -> begin
190-
# Uncommented code: This is the version where we pull in l into the abs.
191-
# We pulled this out of the iteration.
192-
# idx = abs((kscale - (l-1) - off)*LUTSize)/(m)
193-
194-
# The second +1 is because Julia has 1-based indexing
195-
# The first +1 is part of the index calculation and needs(!)
196-
# to be part of the abs. The abs is shifting to the positive interval
197-
# and this +1 matches the `floor` above, which rounds down. In turn
198-
# for positive and negative indices a different neighbour is calculated
199-
idxInt1 = abs( idxInt - (l-1)*scale ) +1
200-
idxInt2 = abs( idxInt - (l-1)*scale +1) +1
201-
202-
(winLin[idxInt1] + α * (winLin[idxInt2] - winLin[idxInt1]))
185+
idxInt = floor(Int,idx)
186+
α = ( idx-idxInt )
187+
188+
if α != zero(T)
189+
tmpWin = @ntuple $(Z) l -> begin
190+
# Uncommented code: This is the version where we pull in l into the abs.
191+
# We pulled this out of the iteration.
192+
# idx = abs((kscale - (l-1) - off)*LUTSize)/(m)
193+
194+
# The second +1 is because Julia has 1-based indexing
195+
# The first +1 is part of the index calculation and needs(!)
196+
# to be part of the abs. The abs is shifting to the positive interval
197+
# and this +1 matches the `floor` above, which rounds down. In turn
198+
# for positive and negative indices a different neighbour is calculated
199+
idxInt1 = abs( idxInt - (l-1)*scale ) +1
200+
idxInt2 = abs( idxInt - (l-1)*scale +1) +1
201+
202+
(winLin[idxInt1] + α * (winLin[idxInt2] - winLin[idxInt1]))
203+
end
204+
else
205+
tmpWin = @ntuple $(Z) l -> begin
206+
idxInt1 = abs( idxInt - (l-1)*scale ) + 1
207+
winLin[idxInt1]
208+
end
203209
end
204210
return tmpWin
205211
end

test/issues.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@testset "Issues Encountered during Development" begin
2+
3+
# https://github.com/JuliaMath/NFFT.jl/issues/106
4+
# The issue was an out of bounce in the linear interpolation code.
5+
T = Float32
6+
Nz = 120
7+
img_shape_os = (2Nz,)
8+
λ = Array{Complex{T}}(undef, img_shape_os)
9+
10+
trj = Matrix{T}(undef, 1, 2)
11+
nfftplan = plan_nfft(trj, img_shape_os; precompute = LINEAR, blocking = false, fftflags = FFTW.ESTIMATE)
12+
13+
trj[1,:] .= 0.008333333 # throws error
14+
nfftplan = plan_nfft(trj, img_shape_os; precompute = LINEAR, blocking = false, fftflags = FFTW.ESTIMATE)
15+
mul!(λ, adjoint(nfftplan), ones(Complex{T}, size(trj,2)))
16+
17+
18+
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ using NFFTTools
77

88
Random.seed!(123)
99

10+
include("issues.jl")
1011
include("accuracy.jl")
1112
include("constructors.jl")
1213
include("performance.jl")

0 commit comments

Comments
 (0)