Skip to content

Commit

Permalink
add type assertions to work around inference problem (fix #9772)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj authored and yuyichao committed Jul 20, 2015
1 parent f69842e commit 05c0d00
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions base/fft/ctfft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ function CTPlan{Tr<:FloatingPoint}(::Type{Complex{Tr}}, forward::Bool, n::Int)
end

plan_fft{Tr<:FloatingPoint}(x::AbstractVector{Complex{Tr}}) =
CTPlan(Complex{Tr}, true, length(x))
CTPlan(Complex{Tr}, true, length(x))::CTPlan{Complex{Tr},true}
plan_bfft{Tr<:FloatingPoint}(x::AbstractVector{Complex{Tr}}) =
CTPlan(Complex{Tr}, false, length(x))
CTPlan(Complex{Tr}, false, length(x))::CTPlan{Complex{Tr},false}

function applystep{T}(p::CTPlan{T},
x::AbstractArray{T}, x0, xs,
Expand Down
4 changes: 2 additions & 2 deletions base/fft/fftn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ function MultiDimPlan{T<:Complex}(::Type{T}, forward::Bool, region, sz)
end

plan_fft{Tr<:FloatingPoint}(x::AbstractArray{Complex{Tr}}, region) =
MultiDimPlan(Complex{Tr}, true, region, size(x))
MultiDimPlan(Complex{Tr}, true, region, size(x))::MultiDimPlan{Complex{Tr}, true}
plan_bfft{Tr<:FloatingPoint}(x::AbstractArray{Complex{Tr}}, region) =
MultiDimPlan(Complex{Tr}, false, region, size(x))
MultiDimPlan(Complex{Tr}, false, region, size(x))::MultiDimPlan{Complex{Tr}, false}

# recursive execution of a MultiDim plan, starting at dimension d, for
# strided arrays (so that we can use linear indexing):
Expand Down
15 changes: 15 additions & 0 deletions test/fft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,18 @@ for T in (Complex128, Complex{BigFloat})
end
end
end

# issue #9772
for x in (randn(10),randn(10,12))
z = complex(x)
y = rfft(x)
@inferred rfft(x)
@inferred brfft(x,18)
@inferred brfft(y,10)
for f in (fft,plan_fft,bfft,plan_bfft,fft_)
@inferred f(x)
@inferred f(z)
end
# note: inference doesn't work for plan_fft_ since the
# algorithm steps are included in the CTPlan type
end

0 comments on commit 05c0d00

Please sign in to comment.