@@ -294,4 +294,44 @@ Base.:*(p::WrapperTestPlan, x::AbstractArray) = p.plan * x
294
294
AbstractFFTs. plan_inv (p:: WrapperTestPlan ) = WrapperTestPlan (AbstractFFTs. plan_inv (p. plan))
295
295
Base. inv (p:: WrapperTestPlan ) = WrapperTestPlan (inv (p. plan))
296
296
297
+ # ####
298
+ # DCT tests, to test real-to-real plans.
299
+ # We implement DCT-I by using its equivalence to an
300
+ # fft applied to [x; reverse(x)[2:end-1]]
301
+ # ###
302
+ struct TestDCTIPlan{T,N,FFTPlan} <: Plan{T}
303
+ fftplan:: FFTPlan
304
+ sz:: NTuple{N,Int}
305
+ function TestPlan {T} (fftplan:: FFTPlan , sz:: NTuple{N,Int} ) where {T,N,FFTPlan}
306
+ return new {T,N,FFTPlan} (fftplan, sz)
307
+ end
308
+ end
309
+
310
+ Base. size (p:: TestDCTIPlan ) = p. sz
311
+ Base. ndims (:: TestDCTIPlan{T,N} ) where {T,N} = N
312
+
313
+
314
+ _doublesize ((n,):: Tuple{Int} , region) = (2 n- 2 ,)
315
+
316
+ function plan_dctI (x:: AbstractArray{T} , region; kwargs... ) where {T}
317
+ return TestDCTIPlan {T} (plan_fft (Array {complex(float(T))} (undef, _doublesize (size (x), region)),region; kwargs... ), size (x))
318
+ end
319
+
320
+ Base.:* (p:: TestDCTIPlan , x:: AbstractArray ) = mul! (similar (x, complex (float (eltype (x)))), p, x)
321
+ function LinearAlgebra. mul! (
322
+ y:: AbstractArray{<:Real,N} , p:: TestPlan , x:: AbstractArray{<:Real,N}
323
+ ) where {N}
324
+ size (y) == size (p) == size (x) || throw (DimensionMismatch ())
325
+ ret = Array {complex(float(eltype(y)))} (undef, size (p. fftplan))
326
+ tmp = similar (ret)
327
+ if N == 1
328
+ tmp[1 : length (x)] = x
329
+ tmp[length (x)+ 1 : end - 1 ] = x[end - 1 : - 1 : 2 ]
330
+ mul! (ret, p. fftplan, tmp)
331
+ copyto! (y, view (ret, 1 : length (y)))
332
+ else
333
+ error (" not implemented" )
334
+ end
335
+ end
336
+
297
337
end
0 commit comments