Skip to content

Commit

Permalink
ker3
Browse files Browse the repository at this point in the history
  • Loading branch information
ZongyuLi-umich committed Oct 14, 2021
1 parent 420a02f commit 368d4a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/fft_convolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ end


"""
fft_conv!(output, image3, ker, plans)
In-place version of convolving a 3D `image3` with `ker`
fft_conv!(output, image3, ker3, plans)
In-place version of convolving a 3D `image3` with a 3D kernel `ker3`
"""
function fft_conv!(
output::AbstractArray{<:RealU,3},
image3::AbstractArray{<:RealU,3},
ker::AbstractMatrix{<:RealU},
ker3::AbstractArray{<:RealU,3},
plans::Vector{<:PlanPSF},
)

Expand All @@ -159,7 +159,7 @@ function fft_conv!(
fun = y -> fft_conv!(
(@view output[:, y, :]),
(@view image3[:, y, :]),
ker,
(@view ker3[:, :, y]),
plans[Threads.threadid()],
)

Expand All @@ -171,13 +171,13 @@ end


"""
fft_conv_adj!(output, image3, ker, plans)
In-place version of adjoint of convolving a 3D `image3` with `ker`
fft_conv_adj!(output, image3, ker3, plans)
In-place version of adjoint of convolving a 3D `image3` with a 3D kernel `ker3`
"""
function fft_conv_adj!(
output::AbstractArray{<:RealU,3},
image3::AbstractArray{<:RealU,3},
ker::AbstractMatrix{<:RealU},
ker3::AbstractArray{<:RealU,3},
plans::Vector{<:PlanPSF},
)

Expand All @@ -186,7 +186,7 @@ function fft_conv_adj!(
fun = y -> fft_conv_adj!(
(@view output[:, y, :]),
(@view image3[:, y, :]),
ker,
(@view ker3[:, :, y]),
plans[Threads.threadid()],
)

Expand Down
6 changes: 3 additions & 3 deletions test/adjoint-fftconv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ end
T = Float32
plan = plan_psf(nx, nz, nx_psf; T)
image3 = rand(T, nx, nx, nz)
ker = ones(T, nx_psf, nx_psf) / (nx_psf)^2
ker3 = ones(T, nx_psf, nx_psf, nx) / (nx_psf)^2
result = similar(image3)
fft_conv!(result, image3, ker, plan)
fft_conv!(result, image3, ker3, plan)
@test maximum(result) 1
fft_conv_adj!(result, image3, ker, plan)
fft_conv_adj!(result, image3, ker3, plan)
@test maximum(result) 1.5 # boundary is the sum of replicate padding
end

Expand Down

0 comments on commit 368d4a2

Please sign in to comment.