Skip to content

Commit

Permalink
Lift out multiply-by-2
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurav-arya committed Aug 23, 2023
1 parent a115e97 commit d194cbe
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -699,11 +699,12 @@ function adjoint_mul(p::Plan{T}, x::AbstractArray, ::RFFTAdjointStyle) where {T<
n = size(pinv, halfdim)
# Optimization: when pinv is a ScaledPlan, fuse the scaling into our map to ensure we do not loop over x twice.
scale = pinv isa ScaledPlan ? pinv.scale / 2N : 1 / 2N
twoscale = 2 * scale
unscaled_pinv = pinv isa ScaledPlan ? pinv.p : pinv
y = map(x, CartesianIndices(x)) do xj, j
i = j[halfdim]
yj = if i == 1 || (i == n && 2 * (i - 1) == d)
xj * scale * 2
xj * twoscale
else
xj * scale
end
Expand All @@ -721,14 +722,15 @@ function adjoint_mul(p::Plan{T}, x::AbstractArray, ::IRFFTAdjointStyle) where {T
d = size(pinv, halfdim)
# Optimization: when pinv is a ScaledPlan, fuse the scaling into our map to ensure we do not loop over x twice.
scale = pinv isa ScaledPlan ? pinv.scale / N : 1 / N
twoscale = 2 * scale
unscaled_pinv = pinv isa ScaledPlan ? pinv.p : pinv
y = unscaled_pinv * x
z = map(y, CartesianIndices(y)) do yj, j
i = j[halfdim]
zj = if i == 1 || (i == n && 2 * (i - 1) == d)
yj * scale
else
yj * scale * 2
yj * twoscale
end
return zj
end
Expand Down

0 comments on commit d194cbe

Please sign in to comment.