Skip to content

Commit a6d2732

Browse files
committed
Remove obselete code, add custom matrix function
1 parent d0027eb commit a6d2732

File tree

2 files changed

+12
-127
lines changed

2 files changed

+12
-127
lines changed

src/FFTA.jl

Lines changed: 0 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -10,67 +10,6 @@ include("algos.jl")
1010
include("plan.jl")
1111

1212
#=
13-
"""
14-
$(TYPEDSIGNATURES)
15-
Perform a fast Fourier transform of a vector. Preserves types given by the
16-
user.
17-
18-
# Arguments
19-
x::AbstractVector: The vector to transform.
20-
21-
# Examples
22-
```julia
23-
julia> x = rand(ComplexF64, 10)
24-
25-
julia> y = fft(x)
26-
```
27-
"""
28-
function fft(x::AbstractVector{T}) where {T}
29-
y = similar(x)
30-
g = CallGraph{T}(length(x))
31-
fft!(y, x, 1, 1, FFT_FORWARD, g[1].type, g, 1)
32-
y
33-
end
34-
35-
function fft(x::AbstractVector{T}) where {T <: Real}
36-
y = similar(x, Complex{T})
37-
g = CallGraph{Complex{T}}(length(x))
38-
fft!(y, x, 1, 1, FFT_FORWARD, g[1].type, g, 1)
39-
y
40-
end
41-
42-
"""
43-
$(TYPEDSIGNATURES)
44-
Perform a fast Fourier transform of a matrix. Preserves types given by the
45-
user.
46-
47-
# Arguments
48-
x::AbstractMatrix: The matrix to transform (columnwise then rowwise).
49-
50-
# Examples
51-
```julia
52-
julia> x = rand(ComplexF64, 10, 10)
53-
54-
julia> y = fft(x)
55-
```
56-
"""
57-
function fft(x::AbstractMatrix{T}) where {T}
58-
M,N = size(x)
59-
y1 = similar(x)
60-
y2 = similar(x)
61-
g1 = CallGraph{T}(size(x,1))
62-
g2 = CallGraph{T}(size(x,2))
63-
64-
for k in 1:N
65-
@views fft!(y1[:,k], x[:,k], 1, 1, FFT_FORWARD, g1[1].type, g1, 1)
66-
end
67-
68-
for k in 1:M
69-
@views fft!(y2[k,:], y1[k,:], 1, 1, FFT_FORWARD, g2[1].type, g2, 1)
70-
end
71-
y2
72-
end
73-
7413
function fft(x::AbstractMatrix{T}) where {T <: Real}
7514
M,N = size(x)
7615
y1 = similar(x, Complex{T})
@@ -88,79 +27,13 @@ function fft(x::AbstractMatrix{T}) where {T <: Real}
8827
y2
8928
end
9029
91-
"""
92-
$(TYPEDSIGNATURES)
93-
Perform a backward fast Fourier transform of a vector, where "backward"
94-
indicates the same output signal down to a constant factor. Preserves types
95-
given by the user.
96-
97-
# Arguments
98-
x::AbstractVector: The vector to transform
99-
100-
# Examples
101-
```julia
102-
julia> x = rand(ComplexF64, 10)
103-
104-
julia> y = bfft(x)
105-
106-
julia> z = fft(y)
107-
108-
julia> x ≈ z/10
109-
true
110-
```
111-
"""
112-
function bfft(x::AbstractVector{T}) where {T}
113-
y = similar(x)
114-
g = CallGraph{T}(length(x))
115-
fft!(y, x, 1, 1, FFT_BACKWARD, g[1].type, g, 1)
116-
y
117-
end
118-
11930
function bfft(x::AbstractVector{T}) where {T <: Real}
12031
y = similar(x, Complex{T})
12132
g = CallGraph{Complex{T}}(length(x))
12233
fft!(y, x, 1, 1, FFT_BACKWARD, g[1].type, g, 1)
12334
y
12435
end
12536
126-
"""
127-
$(TYPEDSIGNATURES)
128-
Perform a backward fast Fourier transform of a matrix, where "backward"
129-
indicates the same output signal down to a constant factor. Preserves types
130-
given by the user.
131-
132-
# Arguments
133-
x::AbstractMatrix: The matrix to transform
134-
135-
# Examples
136-
```julia
137-
julia> x = rand(ComplexF64, 10, 10)
138-
139-
julia> y = bfft(x)
140-
141-
julia> z = fft(y)
142-
143-
julia> x ≈ z/100
144-
true
145-
```
146-
"""
147-
function bfft(x::AbstractMatrix{T}) where {T}
148-
M,N = size(x)
149-
y1 = similar(x)
150-
y2 = similar(x)
151-
g1 = CallGraph{T}(size(x,1))
152-
g2 = CallGraph{T}(size(x,2))
153-
154-
for k in 1:N
155-
@views fft!(y1[:,k], x[:,k], 1, 1, FFT_BACKWARD, g1[1].type, g1, 1)
156-
end
157-
158-
for k in 1:M
159-
@views fft!(y2[k,:], y1[k,:], 1, 1, FFT_BACKWARD, g2[1].type, g2, 1)
160-
end
161-
y2
162-
end
163-
16437
function bfft(x::AbstractMatrix{T}) where {T <: Real}
16538
M,N = size(x)
16639
y1 = similar(x, Complex{T})

src/plan.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ function LinearAlgebra.mul!(y::AbstractArray{T,N}, p::FFTAPlan{T,1}, x::Abstract
6060
end
6161
end
6262

63+
function LinearAlgebra.mul!(y::AbstractMatrix{T}, p::FFTAPlan{T,1}, x::AbstractMatrix{T}) where T
64+
rows,cols = size(x)[p.region]
65+
y_tmp = similar(y)
66+
for k in 1:cols
67+
@views fft!(y_tmp[:,k], x[:,k], 1, 1, p.dir, p.callgraph[2][1].type, p.callgraph[2], 1)
68+
end
69+
70+
for k in 1:rows
71+
@views fft!(y[k,:], y_tmp[k,:], 1, 1, p.dir, p.callgraph[1][1].type, p.callgraph[1], 1)
72+
end
73+
end
74+
6375
function LinearAlgebra.mul!(y::AbstractArray{T,N}, p::FFTAPlan{T,2}, x::AbstractArray{T,N}) where {T,N}
6476
R1 = CartesianIndices(size(x)[1:p.region[1]-1])
6577
R2 = CartesianIndices(size(x)[p.region[1]+1:p.region[2]-1])

0 commit comments

Comments
 (0)