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

Bug for ifft! with empty dimensions #229

Open
RainerHeintzmann opened this issue Jan 21, 2022 · 1 comment
Open

Bug for ifft! with empty dimensions #229

RainerHeintzmann opened this issue Jan 21, 2022 · 1 comment

Comments

@RainerHeintzmann
Copy link

By chance we found a change in behaviour. Probably caused by Julia 1.7.1:
ifft!(rand(ComplexF64,3,4),[])
yields an error:

julia> ifft!(rand(ComplexF64,3,4),[])
ERROR: ArgumentError: reducing over an empty collection is not allowed
Stacktrace:
  [1] _empty_reduce_error()
    @ Base .\reduce.jl:301
  [2] mapreduce_empty(f::Function, op::Base.BottomRF{typeof(Base.mul_prod)}, T::Type)
    @ Base .\reduce.jl:344
  [3] reduce_empty(op::Base.MappingRF{AbstractFFTs.var"#17#18"{Tuple{Int64, Int64}}, Base.BottomRF{typeof(Base.mul_prod)}}, #unused#::Type{Any})
    @ Base .\reduce.jl:331
  [4] reduce_empty_iter
    @ .\reduce.jl:357 [inlined]
  [5] reduce_empty_iter
    @ .\reduce.jl:356 [inlined]
  [6] foldl_impl
    @ .\reduce.jl:49 [inlined]
  [7] mapfoldl_impl
    @ .\reduce.jl:44 [inlined]
  [8] #mapfoldl#244
    @ .\reduce.jl:162 [inlined]
  [9] mapfoldl
    @ .\reduce.jl:162 [inlined]
 [10] #mapreduce#248
    @ .\reduce.jl:289 [inlined]
 [11] mapreduce
    @ .\reduce.jl:289 [inlined]
 [12] #prod#255
    @ .\reduce.jl:588 [inlined]
 [13] prod
    @ .\reduce.jl:588 [inlined]
 [14] normalization(#unused#::Type{Float64}, sz::Tuple{Int64, Int64}, region::Vector{Any})
    @ AbstractFFTs C:\Users\pi96doc\.julia\packages\AbstractFFTs\Ih3rT\src\definitions.jl:259
 [15] normalization
    @ C:\Users\pi96doc\.julia\packages\AbstractFFTs\Ih3rT\src\definitions.jl:260 [inlined]
 [16] #plan_ifft!#20
    @ C:\Users\pi96doc\.julia\packages\AbstractFFTs\Ih3rT\src\definitions.jl:264 [inlined]
 [17] plan_ifft!
    @ C:\Users\pi96doc\.julia\packages\AbstractFFTs\Ih3rT\src\definitions.jl:264 [inlined]
 [18] ifft!(x::Matrix{ComplexF64}, region::Vector{Any})
    @ AbstractFFTs C:\Users\pi96doc\.julia\packages\AbstractFFTs\Ih3rT\src\definitions.jl:51
 [19] top-level scope
    @ REPL[43]:1
@martinholters
Copy link
Collaborator

martinholters commented Jan 27, 2022

Issue originates in AbstractFFTs.jl, possible fix:

diff --git a/src/definitions.jl b/src/definitions.jl
index 80a6656..bac7127 100644
--- a/src/definitions.jl
+++ b/src/definitions.jl
@@ -256,7 +256,7 @@ 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
+normalization(::Type{T}, sz, region) where T = one(T) / Int(prod(sz[r] for r in region; init=1))::Int
 normalization(X, region) = normalization(real(eltype(X)), size(X), region)
 
 plan_ifft(x::AbstractArray, region; kws...) =

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants