Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass init to prod in normalization #81

Merged
merged 10 commits into from
Feb 6, 2024
9 changes: 8 additions & 1 deletion src/definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,14 @@ summary(p::ScaledPlan) = string(p.scale, " * ", summary(p.p))
*(p::Plan, I::UniformScaling) = ScaledPlan(p, I.λ)

# Normalization for ifft, given unscaled bfft, is 1/prod(dimensions)
normalization(::Type{T}, sz, region) where T = one(T) / Int(prod(sz[r] for r in region))::Int
jishnub marked this conversation as resolved.
Show resolved Hide resolved
# ensure that region is a subset of eachindex(sz).
_checkindex(sz, region::AbstractVector) = checkindex(Bool, sz, region)
# this method handles the case where region is not an array, e.g. it is a Tuple
_checkindex(sz, region) = all(r -> checkindex(Bool, eachindex(sz), r), region)
jishnub marked this conversation as resolved.
Show resolved Hide resolved
function normalization(::Type{T}, sz, region) where T
@boundscheck !isempty(region) && _checkindex(eachindex(sz), region)
jishnub marked this conversation as resolved.
Show resolved Hide resolved
one(T) / mapreduce(r -> Int(@inbounds sz[r])::Int, *, region; init=oneunit(eltype(sz)))::Int
jishnub marked this conversation as resolved.
Show resolved Hide resolved
end
normalization(X, region) = normalization(real(eltype(X)), size(X), region)

plan_ifft(x::AbstractArray, region; kws...) =
Expand Down