Skip to content

Commit a66335c

Browse files
committed
Update Project.toml
Signed-off-by: ErikQQY <[email protected]>
1 parent f343419 commit a66335c

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "FractionalTransforms"
22
uuid = "e50ca838-b4f0-4a10-ad18-4b920bf1ae5c"
33
authors = ["Qingyu Qu <[email protected]>"]
4-
version = "0.1.1"
4+
version = "0.1.2"
55

66
[deps]
77
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"

src/frft.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using FFTW, DSP
2+
13
"""
24
frft(signal, α)
35
@@ -37,23 +39,23 @@ function frft(signal, α)::Vector{ComplexF64}
3739
y = reverse(signal, dims=1)
3840
return y
3941
elseif α == 3
40-
y = fft([signal[M+1:N]; signal[1:M]])*sqrt(N)
41-
y = [y[M+2 : N]; y[1:M+1]]
42+
y = ifft([signal[M+1:N]; signal[1:M]])*sqrt(N)
43+
y = [y[M+2:N]; y[1:M+1]]
4244
return y
4345
end
4446

4547
if α > 2
4648
signal = reverse(signal, dims=1)
4749
α = α-2
4850
end
49-
if 1.5 < α < 2
50-
y = fft([signal[M+1:N]; signal[1:M]]) ./sqrt(N)
51-
y = [y[M+2 : N]; y[1:M+1]]
51+
if α > 1.5
52+
signal = fft([signal[M+1:N]; signal[1:M]]) ./sqrt(N)
53+
signal = [signal[M+2 : N]; signal[1:M+1]]
5254
α = α-1
5355
end
5456
if α < 0.5
55-
y = fft([signal[M+1:N]; signal[1:M]]) .*sqrt(N)
56-
y = [y[M+2 : N]; y[1:M+1]]
57+
signal = ifft([signal[M+1:N]; signal[1:M]]) .*sqrt(N)
58+
signal = [signal[M+2:N]; signal[1:M+1]]
5759
α = α+1
5860
end
5961

@@ -126,4 +128,6 @@ function sinc_interp(x, rate)
126128
h = sinc.(collect(-(N-1-1/rate):1/rate:(N-1-1/rate)))
127129
out = conv(y, h)
128130
out = out[(rate*N-rate):(end-rate*N+rate+1)]
129-
end
131+
end
132+
133+
frft([2, 2, 2], 0.3)

test/frft.jl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,25 @@ using FractionalTransforms
22
using Test
33

44
@testset "Test FRFT" begin
5-
@test isapprox(real(frft([1,2,3], 0.5)), [0.100464613588213, 3.07460010423315, 1.31566432887283], atol=1e-5)
6-
@test isapprox(imag(frft([1,2,3], 0.5)), [-0.259409480977277, 0.199349381540632, -0.93645356561191], atol=1e-5)
5+
@test isapprox(real(frft([1, 2, 3], 0.5)), [0.100464613588213, 3.07460010423315, 1.31566432887283], atol=1e-5)
6+
@test isapprox(imag(frft([1, 2, 3], 0.5)), [-0.259409480977277, 0.199349381540632, -0.93645356561191], atol=1e-5)
7+
8+
@test isapprox(real(frft([1, 2, 3, 4, 5], 0.3)), [0.6219417958205868
9+
1.9285647455299149
10+
2.930147902457687
11+
4.781892308544647
12+
1.1657970121710457]; atol=1e-6)
13+
@test isapprox(imag(frft([1, 2, 3, 4, 5], 0.3)), [-0.620033106942918
14+
-0.3534712784226586
15+
1.0387260647856131
16+
-1.0039877236507386
17+
-3.2564984970643764]; atol=1e-6)
18+
19+
@test isapprox(real(frft([1, 2, 3, 4, 5], 1)), [0.0
20+
0.0
21+
6.7082039324993685
22+
0.0
23+
0.0]; atol=1e-6)
724
end
825

926
@testset "Test FRFT auxillary functions" begin

0 commit comments

Comments
 (0)