Skip to content

Commit dd1ce74

Browse files
committed
Fix README, remove Complex bound on T
1 parent d5780e3 commit dd1ce74

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# FFTA: Fastest Fourier Transform in my Apartment
22
## A library by Danny Sharp
33

4-
This is a *pure Julia* implementation of FFTs, with the goal that this could supplant other FFTs for applications that require odd Julia objects. Currently this supports `AbstractArray{T,N}` for `T<:Complex` and `N` in `{1,2}` (i.e. `AbstractVector` and `AbstractMatrix`). If you're looking for more performance, checkout `FFTW.jl`.
4+
This is a *pure Julia* implementation of FFTs, with the goal that this could supplant other FFTs for applications that require odd Julia objects. Currently this supports `AbstractArray{T,N}` where `N` in `{1,2}` (i.e. `AbstractVector` and `AbstractMatrix`). If you're looking for more performance, checkout `FFTW.jl`. The only functions that need to be defined with `T` (besides arithmetic) are `convert(T, x::ComplexF64)` and `one(T)`. This means that `T<:Real` probably doesn't work yet (see Path Forward).
55

66
Path Forward:
77
- Dispatch on `Real`

src/algos.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct CallGraph{T<:Complex}
5151
end
5252

5353
# Get the node in the graph at index i
54-
Base.getindex(g::CallGraph{T}, i::Int) where {T<:Complex} = g.nodes[i]
54+
Base.getindex(g::CallGraph{T}, i::Int) where {T} = g.nodes[i]
5555

5656
# Get the left child of the node at index `i`
5757
leftNode(g::CallGraph, i::Int) = g[i+g[i].left]
@@ -60,7 +60,7 @@ leftNode(g::CallGraph, i::Int) = g[i+g[i].left]
6060
rightNode(g::CallGraph, i::Int) = g[i+g[i].right]
6161

6262
# Recursively instantiate a set of `CallGraphNode`s
63-
function CallGraphNode!(nodes::Vector{CallGraphNode}, N::Int, workspace::Vector{Vector{T}})::Int where {T<:Complex}
63+
function CallGraphNode!(nodes::Vector{CallGraphNode}, N::Int, workspace::Vector{Vector{T}})::Int where {T}
6464
facs = factor(N)
6565
Ns = [first(x) for x in collect(facs) for _ in 1:last(x)]
6666
if length(Ns) == 1 || Ns[end] == 2
@@ -90,21 +90,21 @@ function CallGraphNode!(nodes::Vector{CallGraphNode}, N::Int, workspace::Vector{
9090
end
9191

9292
# Instantiate a CallGraph from a number `N`
93-
function CallGraph{T}(N::Int) where {T<:Complex}
93+
function CallGraph{T}(N::Int) where {T}
9494
nodes = CallGraphNode[]
9595
workspace = Vector{Vector{T}}()
9696
CallGraphNode!(nodes, N, workspace)
9797
CallGraph(nodes, workspace)
9898
end
9999

100-
function fft(x::AbstractVector{T}) where {T<:Complex}
100+
function fft(x::AbstractVector{T}) where {T}
101101
y = similar(x)
102102
g = CallGraph{T}(length(x))
103103
fft!(y, x, Val(FFT_FORWARD), g[1].type, g, 1)
104104
y
105105
end
106106

107-
function fft(x::AbstractMatrix{T}) where {T<:Complex}
107+
function fft(x::AbstractMatrix{T}) where {T}
108108
M,N = size(x)
109109
y1 = similar(x)
110110
y2 = similar(x)
@@ -121,14 +121,14 @@ function fft(x::AbstractMatrix{T}) where {T<:Complex}
121121
y2
122122
end
123123

124-
function bfft(x::AbstractVector{T}) where {T<:Complex}
124+
function bfft(x::AbstractVector{T}) where {T}
125125
y = similar(x)
126126
g = CallGraph{T}(length(x))
127127
fft!(y, x, Val(FFT_BACKWARD), g[1].type, g, 1)
128128
y
129129
end
130130

131-
function bfft(x::AbstractMatrix{T}) where {T<:Complex}
131+
function bfft(x::AbstractMatrix{T}) where {T}
132132
M,N = size(x)
133133
y1 = similar(x)
134134
y2 = similar(x)
@@ -155,7 +155,7 @@ function (g::CallGraph{T})(out::AbstractVector{T}, in::AbstractVector{T}, v::Val
155155
fft!(out, in, v, t, g, idx)
156156
end
157157

158-
function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_FORWARD}, ::CompositeFFT, g::CallGraph{T}, idx::Int) where {T<:Complex}
158+
function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_FORWARD}, ::CompositeFFT, g::CallGraph{T}, idx::Int) where {T}
159159
N = length(out)
160160
left = leftNode(g,idx)
161161
right = rightNode(g,idx)
@@ -180,7 +180,7 @@ function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_FORWARD},
180180
end
181181
end
182182

183-
function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACKWARD}, ::CompositeFFT, g::CallGraph{T}, idx::Int) where {T<:Complex}
183+
function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACKWARD}, ::CompositeFFT, g::CallGraph{T}, idx::Int) where {T}
184184
N = length(out)
185185
left = left(g,i)
186186
right = right(g,i)
@@ -205,19 +205,19 @@ function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACKWARD}
205205
end
206206
end
207207

208-
function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_FORWARD}, ::Pow2FFT, ::CallGraph{T}, ::Int) where {T<:Complex}
208+
function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_FORWARD}, ::Pow2FFT, ::CallGraph{T}, ::Int) where {T}
209209
fft_pow2!(out, in, Val(FFT_FORWARD))
210210
end
211211

212-
function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACKWARD}, ::Pow2FFT, ::CallGraph{T}, ::Int) where {T<:Complex}
212+
function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACKWARD}, ::Pow2FFT, ::CallGraph{T}, ::Int) where {T}
213213
fft_pow2!(out, in, Val(FFT_BACKWARD))
214214
end
215215

216216
"""
217217
Power of 2 FFT in place, forward
218218
219219
"""
220-
function fft_pow2!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_FORWARD}) where {T<:Complex}
220+
function fft_pow2!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_FORWARD}) where {T}
221221
N = length(out)
222222
if N == 1
223223
out[1] = in[1]
@@ -241,7 +241,7 @@ end
241241
Power of 2 FFT in place, backward
242242
243243
"""
244-
function fft_pow2!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACKWARD}) where {T<:Complex}
244+
function fft_pow2!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACKWARD}) where {T}
245245
N = length(out)
246246
if N == 1
247247
out[1] = in[1]
@@ -261,7 +261,7 @@ function fft_pow2!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACK
261261
end
262262
end
263263

264-
function fft_dft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACKWARD}) where {T<:Complex}
264+
function fft_dft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACKWARD}) where {T}
265265
N = length(out)
266266
inc = 2*π/N
267267
wn² = wn = w = convert(T, cispi(2/N))
@@ -313,7 +313,7 @@ function fft_dft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACKW
313313
out[(N-halfN+2):end] .= conj.(out[halfN:-1:2])
314314
end
315315

316-
function fft_dft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_FORWARD}) where {T<:Complex}
316+
function fft_dft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_FORWARD}) where {T}
317317
N = length(out)
318318
wn² = wn = w = convert(T, cispi(-2/N))
319319
wn_1 = one(T)
@@ -365,10 +365,10 @@ function fft_dft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_FORWA
365365
end
366366

367367

368-
function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_FORWARD}, ::DFT, ::CallGraph{T}, ::Int) where {T<:Complex}
368+
function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_FORWARD}, ::DFT, ::CallGraph{T}, ::Int) where {T}
369369
fft_dft!(out, in, Val(FFT_FORWARD))
370370
end
371371

372-
function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACKWARD}, ::DFT, ::CallGraph{T}, ::Int) where {T<:Complex}
372+
function fft!(out::AbstractVector{T}, in::AbstractVector{T}, ::Val{FFT_BACKWARD}, ::DFT, ::CallGraph{T}, ::Int) where {T}
373373
fft_dft!(out, in, Val(FFT_BACKWARD))
374374
end

0 commit comments

Comments
 (0)