Skip to content

Commit 8d39317

Browse files
committed
Fix FFTW warning, tests pass in 0.7
1 parent b0d6e7c commit 8d39317

21 files changed

+131
-95
lines changed

REQUIRE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ ToeplitzMatrices 0.2
33
HierarchicalMatrices 0.0.2
44
LowRankApprox 0.0.2
55
ProgressMeter 0.3.4
6+
SpecialFunctions 0.3.4
67
Compat 0.17

src/ChebyshevJacobiPlan.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
immutable ChebyshevJacobiConstants{D,T}
1+
struct ChebyshevJacobiConstants{D,T}
22
α::T
33
β::T
44
M::Int
@@ -23,7 +23,7 @@ function ChebyshevJacobiConstants{T}(c::AbstractVector{T},α::T,β::T;M::Int=7,D
2323
ChebyshevJacobiConstants{D,T}(α,β,M,N,nM₀,αN,K)
2424
end
2525

26-
immutable ChebyshevJacobiIndices
26+
struct ChebyshevJacobiIndices
2727
i₁::Vector{Int}
2828
i₂::Vector{Int}
2929
j₁::Vector{Int}
@@ -53,7 +53,7 @@ function ChebyshevJacobiIndices{D,T}(α::T,β::T,CJC::ChebyshevJacobiConstants{D
5353
ChebyshevJacobiIndices(i₁,i₂,j₁,j₂)
5454
end
5555

56-
type ChebyshevJacobiPlan{D,T,DCT,DST,SA} <: FastTransformPlan{D,T}
56+
mutable struct ChebyshevJacobiPlan{D,T,DCT,DST,SA} <: FastTransformPlan{D,T}
5757
CJC::ChebyshevJacobiConstants{D,T}
5858
CJI::ChebyshevJacobiIndices
5959
p₁::DCT

src/ChebyshevUltrasphericalPlan.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
immutable ChebyshevUltrasphericalConstants{D,T}
1+
struct ChebyshevUltrasphericalConstants{D,T}
22
λ::T
33
M::Int
44
N::Int
@@ -23,7 +23,7 @@ function ChebyshevUltrasphericalConstants{T}(c::AbstractVector{T},λ::T;M::Int=7
2323
ChebyshevUltrasphericalConstants{D,T}(λ,M,N,nM₀,αN,K)
2424
end
2525

26-
immutable ChebyshevUltrasphericalIndices
26+
struct ChebyshevUltrasphericalIndices
2727
i₁::Vector{Int}
2828
i₂::Vector{Int}
2929
j₁::Vector{Int}
@@ -53,7 +53,7 @@ function ChebyshevUltrasphericalIndices{D,T}(λ::T,CUC::ChebyshevUltrasphericalC
5353
ChebyshevUltrasphericalIndices(i₁,i₂,j₁,j₂)
5454
end
5555

56-
type ChebyshevUltrasphericalPlan{D,T,DCT,DST,SA} <: FastTransformPlan{D,T}
56+
mutable struct ChebyshevUltrasphericalPlan{D,T,DCT,DST,SA} <: FastTransformPlan{D,T}
5757
CUC::ChebyshevUltrasphericalConstants{D,T}
5858
CUI::ChebyshevUltrasphericalIndices
5959
p₁::DCT

src/FastTransforms.jl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@ __precompile__()
22
module FastTransforms
33

44
using ToeplitzMatrices, HierarchicalMatrices, LowRankApprox, ProgressMeter, Compat,
5-
FFTW, AbstractFFTs
5+
AbstractFFTs, SpecialFunctions
6+
7+
if VERSION < v"0.7-"
8+
using Base.FFTW
9+
import Base.FFTW: r2rFFTWPlan, unsafe_execute!, fftwSingle, fftwDouble, fftwNumber
10+
import Base.FFTW: libfftw, libfftwf, PlanPtr, r2rFFTWPlan
11+
else
12+
using FFTW
13+
import FFTW: r2rFFTWPlan, unsafe_execute!, fftwSingle, fftwDouble, fftwNumber
14+
import FFTW: libfftw, libfftwf, PlanPtr, r2rFFTWPlan
15+
end
616

717
import Base: *, \, size, view
818
import Base: getindex, setindex!, Factorization, length
@@ -11,8 +21,6 @@ import HierarchicalMatrices: HierarchicalMatrix, unsafe_broadcasttimes!
1121
import HierarchicalMatrices: A_mul_B!, At_mul_B!, Ac_mul_B!
1222
import LowRankApprox: ColPerm
1323
import AbstractFFTs: Plan
14-
import FFTW: r2rFFTWPlan, unsafe_execute!, fftwSingle, fftwDouble, fftwNumber
15-
import FFTW: libfftw, libfftwf, PlanPtr, r2rFFTWPlan
1624

1725

1826
export cjt, icjt, jjt, plan_cjt, plan_icjt
@@ -50,7 +58,7 @@ include("fejer.jl")
5058
include("recurrence.jl")
5159
include("PaduaTransform.jl")
5260

53-
@compat abstract type FastTransformPlan{D,T} end
61+
abstract type FastTransformPlan{D,T} end
5462

5563
include("ChebyshevJacobiPlan.jl")
5664
include("jac2cheb.jl")

src/PaduaTransform.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ doc"""
22
Pre-plan an Inverse Padua Transform.
33
"""
44
# lex indicates if its lexigraphical (i.e., x, y) or reverse (y, x)
5-
immutable IPaduaTransformPlan{lex,IDCTPLAN,T}
5+
struct IPaduaTransformPlan{lex,IDCTPLAN,T}
66
cfsmat::Matrix{T}
77
idctplan::IDCTPLAN
88
end
@@ -103,7 +103,7 @@ end
103103
doc"""
104104
Pre-plan a Padua Transform.
105105
"""
106-
immutable PaduaTransformPlan{lex,DCTPLAN,T}
106+
struct PaduaTransformPlan{lex,DCTPLAN,T}
107107
vals::Matrix{T}
108108
dctplan::DCTPLAN
109109
end

src/SphericalHarmonics/Butterfly.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
immutable Butterfly{T} <: Factorization{T}
1+
struct Butterfly{T} <: Factorization{T}
22
columns::Vector{Matrix{T}}
33
factors::Vector{Vector{IDPackedV{T}}}
44
permutations::Vector{Vector{ColumnPermutation}}
@@ -60,7 +60,7 @@ function Butterfly{T}(A::AbstractMatrix{T}, L::Int; isorthogonal::Bool = false,
6060
end
6161
permutations[1][j] = factors[1][j][:P]
6262
indices[1][j+1] = indices[1][j] + size(factors[1][j], 1)
63-
cs[1][j] = factors[1][j].sk+nl-1
63+
cs[1][j] = factors[1][j].sk .+ nl .- 1
6464
end
6565

6666
ii, jj = 2, (tL>>1)
@@ -276,7 +276,7 @@ function A_mul_B_col_J!{T}(u::VecOrMat{T}, B::Butterfly{T}, b::VecOrMat{T}, J::I
276276
end
277277

278278
for f! in (:At_mul_B!,:Ac_mul_B!)
279-
f_col_J! = parse(string(f!)[1:end-1]*"_col_J!")
279+
f_col_J! = Meta.parse(string(f!)[1:end-1]*"_col_J!")
280280
@eval begin
281281
function $f_col_J!{T}(u::VecOrMat{T}, B::Butterfly{T}, b::VecOrMat{T}, J::Int)
282282
L = length(B.factors) - 1

src/SphericalHarmonics/fastplan.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
immutable FastSphericalHarmonicPlan{T} <: SphericalHarmonicPlan{T}
1+
struct FastSphericalHarmonicPlan{T} <: SphericalHarmonicPlan{T}
22
RP::RotationPlan{T}
33
BF::Vector{Butterfly{T}}
44
p1::NormalizedLegendreToChebyshevPlan{T}

src/SphericalHarmonics/slowplan.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function A_mul_B!{T<:Real}(A::AbstractMatrix, G::Givens{T})
4141
return A
4242
end
4343

44-
immutable Pnmp2toPlm{T} <: AbstractRotation{T}
44+
struct Pnmp2toPlm{T} <: AbstractRotation{T}
4545
rotations::Vector{Givens{T}}
4646
end
4747

@@ -73,7 +73,7 @@ function Base.A_mul_B!(A::AbstractMatrix, C::Pnmp2toPlm)
7373
end
7474

7575

76-
immutable RotationPlan{T} <: AbstractRotation{T}
76+
struct RotationPlan{T} <: AbstractRotation{T}
7777
layers::Vector{Pnmp2toPlm{T}}
7878
end
7979

@@ -126,7 +126,7 @@ end
126126
Base.Ac_mul_B!(P::RotationPlan, A::AbstractMatrix) = At_mul_B!(P, A)
127127

128128

129-
immutable SlowSphericalHarmonicPlan{T} <: SphericalHarmonicPlan{T}
129+
struct SlowSphericalHarmonicPlan{T} <: SphericalHarmonicPlan{T}
130130
RP::RotationPlan{T}
131131
p1::NormalizedLegendreToChebyshevPlan{T}
132132
p2::NormalizedLegendre1ToChebyshev2Plan{T}

src/SphericalHarmonics/synthesisanalysis.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
immutable SynthesisPlan{T, P1, P2}
1+
struct SynthesisPlan{T, P1, P2}
22
planθ::P1
33
planφ::P2
44
C::ColumnPermutation
@@ -15,7 +15,7 @@ function plan_synthesis{T<:fftwNumber}(A::Matrix{T})
1515
SynthesisPlan(planθ, planφ, C, zeros(T, n))
1616
end
1717

18-
immutable AnalysisPlan{T, P1, P2}
18+
struct AnalysisPlan{T, P1, P2}
1919
planθ::P1
2020
planφ::P2
2121
C::ColumnPermutation

src/SphericalHarmonics/thinplan.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const LAYERSKELETON = 64
22

33
checklayer(j::Int) = j÷LAYERSKELETON == j/LAYERSKELETON
44

5-
immutable ThinSphericalHarmonicPlan{T} <: SphericalHarmonicPlan{T}
5+
struct ThinSphericalHarmonicPlan{T} <: SphericalHarmonicPlan{T}
66
RP::RotationPlan{T}
77
BF::Vector{Butterfly{T}}
88
p1::NormalizedLegendreToChebyshevPlan{T}

src/fftBigFloat.jl

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,49 @@
11
const BigFloats = Union{BigFloat,Complex{BigFloat}}
22

3-
real(x...)=Base.real(x...)
4-
real{T<:Real}(::Type{T})=T
5-
real{T<:Real}(::Type{Complex{T}})=T
3+
if VERSION < v"0.7-"
4+
import Base.FFTW: fft, fft!, rfft, irfft, ifft, conv, dct, idct, dct!, idct!,
5+
plan_fft!, plan_ifft!, plan_dct!, plan_idct!,
6+
plan_fft, plan_ifft, plan_rfft, plan_irfft, plan_dct, plan_idct
7+
else
8+
import FFTW: fft, fft!, rfft, irfft, ifft, conv, dct, idct, dct!, idct!,
9+
plan_fft!, plan_ifft!, plan_dct!, plan_idct!,
10+
plan_fft, plan_ifft, plan_rfft, plan_irfft, plan_dct, plan_idct
11+
end
612

713
# The following implements Bluestein's algorithm, following http://www.dsprelated.com/dspbooks/mdft/Bluestein_s_FFT_Algorithm.html
814
# To add more types, add them in the union of the function's signature.
9-
function Base.fft{T<:BigFloats}(x::Vector{T})
15+
function fft{T<:BigFloats}(x::Vector{T})
1016
n = length(x)
1117
ispow2(n) && return fft_pow2(x)
1218
ks = linspace(zero(real(T)),n-one(real(T)),n)
13-
Wks = exp.((-im).*convert(T,π).*ks.^2./n)
14-
xq,wq = x.*Wks,conj([exp(-im*convert(T,π)*n);reverse(Wks);Wks[2:end]])
19+
Wks = exp.((-im).*convert(T,π).*ks.^2 ./ n)
20+
xq, wq = x.*Wks, conj([exp(-im*convert(T,π)*n);reverse(Wks);Wks[2:end]])
1521
return Wks.*conv(xq,wq)[n+1:2n]
1622
end
1723

18-
function Base.fft!{T<:BigFloats}(x::Vector{T})
24+
function fft!{T<:BigFloats}(x::Vector{T})
1925
x[:] = fft(x)
2026
return x
2127
end
2228

2329
# add rfft for BigFloat, by calling fft
24-
# this creates ToeplitzMatrices.rfft, so avoids changing Base.rfft
25-
Base.rfft{T<:BigFloats}(v::Vector{T})=fft(v)[1:div(length(v),2)+1]
26-
function Base.irfft{T<:BigFloats}(v::Vector{T},n::Integer)
30+
# this creates ToeplitzMatrices.rfft, so avoids changing rfft
31+
rfft{T<:BigFloats}(v::Vector{T})=fft(v)[1:div(length(v),2)+1]
32+
function irfft{T<:BigFloats}(v::Vector{T},n::Integer)
2733
@assert n==2length(v)-1
2834
r = Vector{Complex{BigFloat}}(n)
2935
r[1:length(v)]=v
3036
r[length(v)+1:end]=reverse(conj(v[2:end]))
3137
real(ifft(r))
3238
end
3339

34-
Base.ifft{T<:BigFloats}(x::Vector{T}) = conj!(fft(conj(x)))/length(x)
35-
function Base.ifft!{T<:BigFloats}(x::Vector{T})
40+
ifft{T<:BigFloats}(x::Vector{T}) = conj!(fft(conj(x)))/length(x)
41+
function ifft!{T<:BigFloats}(x::Vector{T})
3642
x[:] = ifft(x)
3743
return x
3844
end
3945

40-
function Base.conv{T<:BigFloats}(u::StridedVector{T}, v::StridedVector{T})
46+
function conv{T<:BigFloats}(u::StridedVector{T}, v::StridedVector{T})
4147
nu,nv = length(u),length(v)
4248
n = nu + nv - 1
4349
np2 = nextpow2(n)
@@ -101,7 +107,7 @@ function ifft_pow2{T<:BigFloat}(x::Vector{Complex{T}})
101107
end
102108

103109

104-
function Base.dct(a::AbstractArray{Complex{BigFloat}})
110+
function dct(a::AbstractArray{Complex{BigFloat}})
105111
N = big(length(a))
106112
c = fft([a; flipdim(a,1)])
107113
d = c[1:N]
@@ -110,9 +116,9 @@ function Base.dct(a::AbstractArray{Complex{BigFloat}})
110116
scale!(inv(sqrt(2N)), d)
111117
end
112118

113-
Base.dct(a::AbstractArray{BigFloat}) = real(dct(complex(a)))
119+
dct(a::AbstractArray{BigFloat}) = real(dct(complex(a)))
114120

115-
function Base.idct(a::AbstractArray{Complex{BigFloat}})
121+
function idct(a::AbstractArray{Complex{BigFloat}})
116122
N = big(length(a))
117123
b = a * sqrt(2*N)
118124
b[1] = b[1] * sqrt(big(2))
@@ -122,18 +128,18 @@ function Base.idct(a::AbstractArray{Complex{BigFloat}})
122128
c[1:N]
123129
end
124130

125-
Base.idct(a::AbstractArray{BigFloat}) = real(idct(complex(a)))
131+
idct(a::AbstractArray{BigFloat}) = real(idct(complex(a)))
126132

127-
Base.dct!{T<:BigFloats}(a::AbstractArray{T}) = (b = dct(a); a[:] = b)
128-
Base.idct!{T<:BigFloats}(a::AbstractArray{T}) = (b = idct(a); a[:] = b)
133+
dct!{T<:BigFloats}(a::AbstractArray{T}) = (b = dct(a); a[:] = b)
134+
idct!{T<:BigFloats}(a::AbstractArray{T}) = (b = idct(a); a[:] = b)
129135

130136
# dummy plans
131-
type DummyFFTPlan{T,inplace} <: Plan{T} end
132-
type DummyiFFTPlan{T,inplace} <: Plan{T} end
133-
type DummyrFFTPlan{T,inplace} <: Plan{T} end
134-
type DummyirFFTPlan{T,inplace} <: Plan{T} end
135-
type DummyDCTPlan{T,inplace} <: Plan{T} end
136-
type DummyiDCTPlan{T,inplace} <: Plan{T} end
137+
struct DummyFFTPlan{T,inplace} <: Plan{T} end
138+
struct DummyiFFTPlan{T,inplace} <: Plan{T} end
139+
struct DummyrFFTPlan{T,inplace} <: Plan{T} end
140+
struct DummyirFFTPlan{T,inplace} <: Plan{T} end
141+
struct DummyDCTPlan{T,inplace} <: Plan{T} end
142+
struct DummyiDCTPlan{T,inplace} <: Plan{T} end
137143

138144
for (Plan,iPlan) in ((:DummyFFTPlan,:DummyiFFTPlan),
139145
(:DummyrFFTPlan,:DummyirFFTPlan),
@@ -164,19 +170,19 @@ end
164170

165171

166172

167-
Base.plan_fft!{T<:BigFloats}(x::Vector{T}) = DummyFFTPlan{Complex{BigFloat},true}()
168-
Base.plan_ifft!{T<:BigFloats}(x::Vector{T}) = DummyiFFTPlan{Complex{BigFloat},true}()
169-
#Base.plan_rfft!{T<:BigFloats}(x::Vector{T}) = DummyrFFTPlan{Complex{BigFloat},true}()
170-
#Base.plan_irfft!{T<:BigFloats}(x::Vector{T},n::Integer) = DummyirFFTPlan{Complex{BigFloat},true}()
171-
Base.plan_dct!{T<:BigFloats}(x::Vector{T}) = DummyDCTPlan{T,true}()
172-
Base.plan_idct!{T<:BigFloats}(x::Vector{T}) = DummyiDCTPlan{T,true}()
173+
plan_fft!{T<:BigFloats}(x::Vector{T}) = DummyFFTPlan{Complex{BigFloat},true}()
174+
plan_ifft!{T<:BigFloats}(x::Vector{T}) = DummyiFFTPlan{Complex{BigFloat},true}()
175+
#plan_rfft!{T<:BigFloats}(x::Vector{T}) = DummyrFFTPlan{Complex{BigFloat},true}()
176+
#plan_irfft!{T<:BigFloats}(x::Vector{T},n::Integer) = DummyirFFTPlan{Complex{BigFloat},true}()
177+
plan_dct!{T<:BigFloats}(x::Vector{T}) = DummyDCTPlan{T,true}()
178+
plan_idct!{T<:BigFloats}(x::Vector{T}) = DummyiDCTPlan{T,true}()
173179

174-
Base.plan_fft{T<:BigFloats}(x::Vector{T}) = DummyFFTPlan{Complex{BigFloat},false}()
175-
Base.plan_ifft{T<:BigFloats}(x::Vector{T}) = DummyiFFTPlan{Complex{BigFloat},false}()
176-
Base.plan_rfft{T<:BigFloats}(x::Vector{T}) = DummyrFFTPlan{Complex{BigFloat},false}()
177-
Base.plan_irfft{T<:BigFloats}(x::Vector{T},n::Integer) = DummyirFFTPlan{Complex{BigFloat},false}()
178-
Base.plan_dct{T<:BigFloats}(x::Vector{T}) = DummyDCTPlan{T,false}()
179-
Base.plan_idct{T<:BigFloats}(x::Vector{T}) = DummyiDCTPlan{T,false}()
180+
plan_fft{T<:BigFloats}(x::Vector{T}) = DummyFFTPlan{Complex{BigFloat},false}()
181+
plan_ifft{T<:BigFloats}(x::Vector{T}) = DummyiFFTPlan{Complex{BigFloat},false}()
182+
plan_rfft{T<:BigFloats}(x::Vector{T}) = DummyrFFTPlan{Complex{BigFloat},false}()
183+
plan_irfft{T<:BigFloats}(x::Vector{T},n::Integer) = DummyirFFTPlan{Complex{BigFloat},false}()
184+
plan_dct{T<:BigFloats}(x::Vector{T}) = DummyDCTPlan{T,false}()
185+
plan_idct{T<:BigFloats}(x::Vector{T}) = DummyiDCTPlan{T,false}()
180186

181187

182188
function interlace{S<:Number,V<:Number}(a::Vector{S},b::Vector{V})

0 commit comments

Comments
 (0)