File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ function ifft_pow2(x::Vector{Complex{T}}) where T<:BigFloat
110
110
end
111
111
112
112
113
- function dct (a:: AbstractArray {Complex{BigFloat}} )
113
+ function dct (a:: AbstractVector {Complex{BigFloat}} )
114
114
N = big (length (a))
115
115
c = fft ([a; flipdim (a,1 )])
116
116
d = c[1 : N]
@@ -121,14 +121,14 @@ end
121
121
122
122
dct (a:: AbstractArray{BigFloat} ) = real (dct (complex (a)))
123
123
124
- function idct (a:: AbstractArray {Complex{BigFloat}} )
125
- N = big (length (a))
124
+ function idct (a:: AbstractVector {Complex{BigFloat}} )
125
+ N = big (length (a))
126
126
b = a * sqrt (2 * N)
127
127
b[1 ] = b[1 ] * sqrt (big (2 ))
128
- b .* = exp .((im * big (pi )) . * (0 : N - 1 ). / ( 2 * N))
129
- b = [b; 0 ; conj ( flipdim (b[2 : end ],1 ))]
128
+ shift = exp .(- im * 2 * big (pi ) * (N - big ( 1 ) / 2 ) * (0 : ( 2 N - 1 )) / ( 2 * N))
129
+ b = [b; 0 ; - flipdim (b[2 : end ],1 )] .* shift
130
130
c = ifft (b)
131
- c[1 : N]
131
+ flipdim ( c[1 : N], 1 )
132
132
end
133
133
134
134
idct (a:: AbstractArray{BigFloat} ) = real (idct (complex (a)))
Original file line number Diff line number Diff line change 17
17
@test norm (dct (c) - p* c) == 0
18
18
19
19
pi = plan_idct! (c)
20
- @test norm (pi * dct (c) - c) < 500 norm (c)* eps (BigFloat)
20
+ @test norm (pi * dct (c) - c) < 1000 norm (c)* eps (BigFloat)
21
21
22
22
@test norm (dct (c)- dct (map (Float64,c)),Inf ) < 10 eps ()
23
23
24
24
cc = cis .(c)
25
25
@test norm (dct (cc)- dct (map (Complex{Float64},cc)),Inf ) < 10 eps ()
26
+
27
+ c = big .(rand (100 )) + im* big .(rand (100 ))
28
+ @test norm (dct (c)- dct (map (ComplexF64,c)),Inf ) < 10 eps ()
29
+ @test norm (idct (c)- idct (map (ComplexF64,c)),Inf ) < 10 eps ()
30
+ @test norm (idct (dct (c))- c,Inf ) < 1000 eps (BigFloat)
31
+ @test norm (dct (idct (c))- c,Inf ) < 1000 eps (BigFloat)
26
32
end
You can’t perform that action at this time.
0 commit comments