@@ -5,9 +5,9 @@ if VERSION < v"0.7-"
5
5
plan_fft!, plan_ifft!, plan_dct!, plan_idct!,
6
6
plan_fft, plan_ifft, plan_rfft, plan_irfft, plan_dct, plan_idct
7
7
else
8
- import FFTW: fft, fft !, rfft, irfft, ifft, ifft!, 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
8
+ import FFTW: dct, dct !, idct, idct!,
9
+ plan_fft!, plan_ifft!, plan_dct!, plan_idct!,
10
+ plan_fft, plan_ifft, plan_rfft, plan_irfft, plan_dct, plan_idct
11
11
import DSP: conv
12
12
end
13
13
32
32
# add rfft for AbstractFloat, by calling fft
33
33
# this creates ToeplitzMatrices.rfft, so avoids changing rfft
34
34
35
- generic_rfft (v:: Vector{T} ) where T<: AbstractFloats = fft (v)[1 : div (length (v),2 )+ 1 ]
35
+ generic_rfft (v:: Vector{T} ) where T<: AbstractFloats = generic_fft (v)[1 : div (length (v),2 )+ 1 ]
36
+
36
37
function generic_irfft (v:: Vector{T} ,n:: Integer ) where T<: AbstractFloats
37
38
@assert n== 2 length (v)- 1
38
39
r = Vector {Complex{real(T)}} (undef, n)
@@ -138,6 +139,8 @@ generic_idct(a::AbstractArray{T}) where {T <: AbstractFloat} = real(generic_idct
138
139
generic_dct! (a:: AbstractArray{T} ) where {T<: AbstractFloats } = (b = generic_dct (a); a[:] = b)
139
140
generic_idct! (a:: AbstractArray{T} ) where {T<: AbstractFloats } = (b = generic_idct (a); a[:] = b)
140
141
142
+ # These lines mimick the corresponding ones in FFTW/src/dct.jl, but with
143
+ # AbstractFloat rather than fftwNumber.
141
144
for f in (:dct , :dct! , :idct , :idct! )
142
145
pf = Symbol (" plan_" , f)
143
146
@eval begin
@@ -149,25 +152,33 @@ end
149
152
# dummy plans
150
153
struct DummyFFTPlan{T,inplace} <: Plan{T} end
151
154
struct DummyiFFTPlan{T,inplace} <: Plan{T} end
152
- struct DummyrFFTPlan{T,inplace} <: Plan{T} end
153
- struct DummyirFFTPlan{T,inplace} <: Plan{T} end
154
155
struct DummyDCTPlan{T,inplace} <: Plan{T} end
155
156
struct DummyiDCTPlan{T,inplace} <: Plan{T} end
157
+ struct DummyrFFTPlan{T,inplace} <: Plan{T}
158
+ n :: Integer
159
+ end
160
+ struct DummyirFFTPlan{T,inplace} <: Plan{T}
161
+ n :: Integer
162
+ end
156
163
157
164
for (Plan,iPlan) in ((:DummyFFTPlan ,:DummyiFFTPlan ),
158
- (:DummyrFFTPlan ,:DummyirFFTPlan ),
165
+ # (:DummyrFFTPlan,:DummyirFFTPlan),
159
166
(:DummyDCTPlan ,:DummyiDCTPlan ))
160
167
@eval begin
161
168
Base. inv (:: $Plan{T,inplace} ) where {T,inplace} = $ iPlan {T,inplace} ()
162
169
Base. inv (:: $iPlan{T,inplace} ) where {T,inplace} = $ Plan {T,inplace} ()
163
170
end
164
171
end
165
172
173
+ # Specific for rfft and irfft:
174
+ Base. inv (:: DummyirFFTPlan{T,inplace} ) where {T,inplace} = DummyrFFTPlan {T,Inplace} (p. n)
175
+ Base. inv (:: DummyrFFTPlan{T,inplace} ) where {T,inplace} = DummyirFFTPlan {T,Inplace} (p. n)
176
+
166
177
167
178
for (Plan,ff,ff!) in ((:DummyFFTPlan ,:generic_fft ,:generic_fft! ),
168
179
(:DummyiFFTPlan ,:generic_ifft ,:generic_ifft! ),
169
180
(:DummyrFFTPlan ,:generic_rfft ,:generic_rfft! ),
170
- (:DummyirFFTPlan ,:generic_irfft ,:generic_irfft! ),
181
+ # (:DummyirFFTPlan,:generic_irfft,:generic_irfft!),
171
182
(:DummyDCTPlan ,:generic_dct ,:generic_dct! ),
172
183
(:DummyiDCTPlan ,:generic_idct ,:generic_idct! ))
173
184
@eval begin
@@ -180,24 +191,34 @@ for (Plan,ff,ff!) in ((:DummyFFTPlan,:generic_fft,:generic_fft!),
180
191
end
181
192
end
182
193
194
+ # Specific for irfft:
195
+ * (p:: DummyirFFTPlan{T,true} , x:: StridedArray{T,N} ) where {T<: AbstractFloats ,N} = generic_irfft! (x, p. n)
196
+ * (p:: DummyirFFTPlan{T,false} , x:: StridedArray{T,N} ) where {T<: AbstractFloats ,N} = generic_irfft (x, p. n)
197
+ function LAmul! (C:: StridedVector , p:: DummyirFFTPlan , x:: StridedVector )
198
+ C[:] = generic_irfft (x, p. n)
199
+ C
200
+ end
201
+
183
202
# We override these for AbstractFloat, so that conversion from reals to
184
203
# complex numbers works for any AbstractFloat (instead of only BlasFloat's)
185
204
AbstractFFTs. complexfloat (x:: StridedArray{Complex{<:AbstractFloat}} ) = x
186
205
AbstractFFTs. realfloat (x:: StridedArray{<:Real} ) = x
206
+ # We override this one in order to avoid throwing an error that the type is
207
+ # unsupported (as defined in AbstractFFTs)
187
208
AbstractFFTs. _fftfloat (:: Type{T} ) where {T <: AbstractFloat } = T
188
209
189
210
plan_fft! (x:: StridedArray{T} , region) where {T <: AbstractFloats } = DummyFFTPlan {Complex{real(T)},true} ()
190
211
plan_ifft! (x:: StridedArray{T} , region) where {T <: AbstractFloats } = DummyiFFTPlan {Complex{real(T)},true} ()
191
212
192
- # plan_rfft!{T<:AbstractFloats} (x::Vector {T}) = DummyrFFTPlan{Complex{real(T)},true}()
193
- # plan_irfft!{T<:AbstractFloats} (x::Vector {T},n::Integer) = DummyirFFTPlan{Complex{real(T)},true}()
213
+ # plan_rfft!(x::StridedArray {T}) where {T <: AbstractFloat} = DummyrFFTPlan{Complex{real(T)},true}()
214
+ # plan_irfft!(x::StridedArray {T},n::Integer) where {T <: AbstractFloat} = DummyirFFTPlan{Complex{real(T)},true}()
194
215
plan_dct! (x:: StridedArray{T} , region) where {T <: AbstractFloats } = DummyDCTPlan {T,true} ()
195
216
plan_idct! (x:: StridedArray{T} , region) where {T <: AbstractFloats } = DummyiDCTPlan {T,true} ()
196
217
197
218
plan_fft (x:: StridedArray{T} , region) where {T <: AbstractFloats } = DummyFFTPlan {Complex{real(T)},false} ()
198
219
plan_ifft (x:: StridedArray{T} , region) where {T <: AbstractFloats } = DummyiFFTPlan {Complex{real(T)},false} ()
199
- plan_rfft (x:: StridedArray{T} , region) where {T <: AbstractFloats } = DummyrFFTPlan {Complex{real(T)},false} ()
200
- plan_irfft (x:: StridedArray{T} ,n:: Integer ) where {T <: AbstractFloats } = DummyirFFTPlan {Complex{real(T)},false} ()
220
+ plan_rfft (x:: StridedArray{T} , region) where {T <: AbstractFloats } = DummyrFFTPlan {Complex{real(T)},false} (length (x) )
221
+ plan_irfft (x:: StridedArray{T} , n:: Integer , region ) where {T <: AbstractFloats } = DummyirFFTPlan {Complex{real(T)},false} (n )
201
222
plan_dct (x:: StridedArray{T} , region) where {T <: AbstractFloats } = DummyDCTPlan {T,false} ()
202
223
plan_idct (x:: StridedArray{T} , region) where {T <: AbstractFloats } = DummyiDCTPlan {T,false} ()
203
224
0 commit comments