Skip to content

Commit

Permalink
Add fallback checkindex method
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Nov 5, 2022
1 parent 1beeace commit d72ed96
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,12 @@ 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)
# 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)
function normalization(::Type{T}, sz, region) where T
@boundscheck !isempty(region) && checkindex(Bool, eachindex(sz), region)
@boundscheck !isempty(region) && _checkindex(eachindex(sz), region)
one(T) / mapreduce(r -> Int(@inbounds sz[r])::Int, *, region; init=oneunit(eltype(sz)))::Int
end
normalization(X, region) = normalization(real(eltype(X)), size(X), region)
Expand Down

0 comments on commit d72ed96

Please sign in to comment.