Skip to content

Commit bbda1e3

Browse files
committed
better fix for #106
1 parent 2fe481e commit bbda1e3

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

src/precomputation.jl

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

183-
@generated function shiftedWindowEntries(winLin::Vector, idx::T, scale, d, L::Val{Z}) where {T,Z}
183+
@generated function shiftedWindowEntries(winLin::Vector, idx, scale, d, L::Val{Z}) where {Z}
184184
quote
185185
idxInt = floor(Int,idx)
186186
α = ( idx-idxInt )
187187

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
188+
tmpWin = @ntuple $(Z) l -> begin
189+
# Uncommented code: This is the version where we pull in l into the abs.
190+
# We pulled this out of the iteration.
191+
# idx = abs((kscale - (l-1) - off)*LUTSize)/(m)
192+
193+
# The second +1 is because Julia has 1-based indexing
194+
# The first +1 is part of the index calculation and needs(!)
195+
# to be part of the abs. The abs is shifting to the positive interval
196+
# and this +1 matches the `floor` above, which rounds down. In turn
197+
# for positive and negative indices a different neighbour is calculated
198+
idxInt1 = abs( idxInt - (l-1)*scale ) +1
199+
idxInt2 = abs( idxInt - (l-1)*scale +1) +1
200+
201+
(winLin[idxInt1] + α * (winLin[idxInt2] - winLin[idxInt1]))
209202
end
210203
return tmpWin
211204
end
@@ -300,10 +293,10 @@ Remarks:
300293
an error while the later variant would silently error.
301294
"""
302295
function precomputeLinInterp(win, m, σ, K, T)
303-
windowLinInterp = Vector{T}(undef, K+1)
296+
windowLinInterp = Vector{T}(undef, K+2)
304297

305298
step = (m) / (K)
306-
@cthreads for l = 1:(K+1)
299+
@cthreads for l = 1:(K+2)
307300
y = ( (l-1) * step )
308301
windowLinInterp[l] = win(y, 1, m, σ)
309302
end

test/issues.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
img_shape_os = (2Nz,)
88
λ = Array{Complex{T}}(undef, img_shape_os)
99

10-
trj = Matrix{T}(undef, 1, 2)
10+
trj = zeros(T, 1, 2)
1111
nfftplan = plan_nfft(trj, img_shape_os; precompute = LINEAR, blocking = false, fftflags = FFTW.ESTIMATE)
1212

1313
trj[1,:] .= 0.008333333 # throws error

0 commit comments

Comments
 (0)