Skip to content

Commit

Permalink
better fix for #106
Browse files Browse the repository at this point in the history
  • Loading branch information
tknopp committed Oct 25, 2022
1 parent 2fe481e commit bbda1e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
41 changes: 17 additions & 24 deletions src/precomputation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,32 +180,25 @@ function precomputeOneNodeBlocking(winLin, winTensor::Nothing, winPoly::Nothing,
return (y, tmpWin)
end

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

if α != zero(T)
tmpWin = @ntuple $(Z) l -> begin
# Uncommented code: This is the version where we pull in l into the abs.
# We pulled this out of the iteration.
# idx = abs((kscale - (l-1) - off)*LUTSize)/(m)

# The second +1 is because Julia has 1-based indexing
# The first +1 is part of the index calculation and needs(!)
# to be part of the abs. The abs is shifting to the positive interval
# and this +1 matches the `floor` above, which rounds down. In turn
# for positive and negative indices a different neighbour is calculated
idxInt1 = abs( idxInt - (l-1)*scale ) +1
idxInt2 = abs( idxInt - (l-1)*scale +1) +1

(winLin[idxInt1] + α * (winLin[idxInt2] - winLin[idxInt1]))
end
else
tmpWin = @ntuple $(Z) l -> begin
idxInt1 = abs( idxInt - (l-1)*scale ) + 1
winLin[idxInt1]
end
tmpWin = @ntuple $(Z) l -> begin
# Uncommented code: This is the version where we pull in l into the abs.
# We pulled this out of the iteration.
# idx = abs((kscale - (l-1) - off)*LUTSize)/(m)

# The second +1 is because Julia has 1-based indexing
# The first +1 is part of the index calculation and needs(!)
# to be part of the abs. The abs is shifting to the positive interval
# and this +1 matches the `floor` above, which rounds down. In turn
# for positive and negative indices a different neighbour is calculated
idxInt1 = abs( idxInt - (l-1)*scale ) +1
idxInt2 = abs( idxInt - (l-1)*scale +1) +1

(winLin[idxInt1] + α * (winLin[idxInt2] - winLin[idxInt1]))
end
return tmpWin
end
Expand Down Expand Up @@ -300,10 +293,10 @@ Remarks:
an error while the later variant would silently error.
"""
function precomputeLinInterp(win, m, σ, K, T)
windowLinInterp = Vector{T}(undef, K+1)
windowLinInterp = Vector{T}(undef, K+2)

step = (m) / (K)
@cthreads for l = 1:(K+1)
@cthreads for l = 1:(K+2)
y = ( (l-1) * step )
windowLinInterp[l] = win(y, 1, m, σ)
end
Expand Down
2 changes: 1 addition & 1 deletion test/issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
img_shape_os = (2Nz,)
λ = Array{Complex{T}}(undef, img_shape_os)

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

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

2 comments on commit bbda1e3

@tknopp
Copy link
Member Author

@tknopp tknopp commented on bbda1e3 Oct 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/71037

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.13.2 -m "<description of version>" bbda1e30c51874ce81ea06fe65dd90d8bf568b62
git push origin v0.13.2

Please sign in to comment.