Skip to content

Commit 085eb7e

Browse files
authored
Adding more info in docs (#36)
* Adding stable badge for readme * Expanding on documentation Co-authored-by: Danny Sharp <[email protected]>
1 parent ccdf215 commit 085eb7e

File tree

5 files changed

+114
-29
lines changed

5 files changed

+114
-29
lines changed

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,23 @@
22
## A library by Danny Sharp
33

44
[![Github Action CI](https://github.com/dannys4/FFTA.jl/workflows/CI/badge.svg)](https://github.com/dannys4/FFTA.jl/actions)
5+
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://dannys4.github.io/FFTA.jl/stable/)
56

6-
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`. Regardless of `T`, `one(::Type{T})` must be defined. Additionally, if `T<:Complex`, then `convert(::Type{T},ComplexF64)` has to be defined and if `T<:Real`, then `convert(::Type{T}, Float64)` has to be defined.
7+
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`. Regardless of `T`, `one(::Type{T})` must be defined. Additionally, if `T<:Real`, then `convert(::Type{T}, Float64)` has to be defined. Otherwise, `convert(::Type{T},ComplexF64)` must be defined.
78

8-
Path Forward:
9-
- Make the code more readable.
10-
- Use `@inbounds`
11-
- Use `AbstractFFTs` interface
9+
Some ideas outside the feature requests in Issues:
10+
- Make the code more readable
1211
- Use `StaticArrays` for the workspace in small cases
1312
- Strictly generate code for certain cases
1413
- Create a SIMD type for Complex numbers
1514
- E-Graphs for the call-graph
16-
- Accelerate dynamic dispatching?
1715
- Other performance left on the table....
1816

1917
Interface:
20-
- `fft(x::AbstractVector{<:Union{Real,Complex})`-- Forward FFT
21-
- `fft(x::AbstractMatrix{<:Union{Real,Complex}})`-- Forward FFT
22-
- `bfft(x::AbstractVector{<:Union{Real,Complex}})`-- Backward FFT (unscaled inverse FFT)
23-
- `bfft(x::AbstractMatrix{<:Union{Real,Complex}})`-- Backward FFT (unscaled inverse FFT)
18+
- `fft(x::AbstractVector)`-- Forward FFT
19+
- `fft(x::AbstractMatrix})`-- Forward FFT
20+
- `bfft(x::AbstractVector})`-- Backward FFT (unscaled inverse FFT)
21+
- `bfft(x::AbstractMatrix})`-- Backward FFT (unscaled inverse FFT)
2422

2523
NOTE: Currently, my C++ code is actually faster than this, so "Fastest Fourier Transform in my Apartment" is a bit of a misnomer.
2624

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ using FFTA
44
makedocs(
55
sitename = "FFTA",
66
format = Documenter.HTML(),
7+
pages = ["Development Tools" => "dev.md"],
78
modules = [FFTA]
89
)
910

docs/src/dev.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Here is the documentation for key parts of the development side of the package.
2+
```@docs
3+
CallGraphNode
4+
CallGraph
5+
CallGraphNode!
6+
fft!
7+
fft_dft!
8+
fft_pow2!
9+
fft_pow3!
10+
fft_pow4!
11+
```

src/algos.jl

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ function (g::CallGraph{T})(out::AbstractVector{T}, in::AbstractVector{U}, start_
88
fft!(out, in, start_out, start_in, v, t, g, idx)
99
end
1010

11+
"""
12+
$(TYPEDSIGNATURES)
13+
Cooley-Tukey composite FFT, with a pre-computed call graph
14+
15+
# Arguments
16+
`out`: Output vector
17+
`in`: Input vector
18+
`start_out`: Index of the first element of the output vector
19+
`start_in`: Index of the first element of the input vector
20+
`d`: Direction of the transform
21+
`g`: Call graph for this transform
22+
`idx`: Index of the current transform in the call graph
23+
24+
"""
1125
function fft!(out::AbstractVector{T}, in::AbstractVector{U}, start_out::Int, start_in::Int, d::Direction, ::CompositeFFT, g::CallGraph{T}, idx::Int) where {T,U}
1226
root = g[idx]
1327
left_idx = idx + root.left
@@ -38,6 +52,21 @@ function fft!(out::AbstractVector{T}, in::AbstractVector{U}, start_out::Int, sta
3852
end
3953
end
4054

55+
"""
56+
$(TYPEDSIGNATURES)
57+
Discrete Fourier Transform, O(N^2) algorithm, in place.
58+
59+
# Arguments
60+
`out`: Output vector
61+
`in`: Input vector
62+
`N`: Size of the transform
63+
`start_out`: Index of the first element of the output vector
64+
`stride_out`: Stride of the output vector
65+
`start_in`: Index of the first element of the input vector
66+
`stride_in`: Stride of the input vector
67+
`d`: Direction of the transform
68+
69+
"""
4170
function fft_dft!(out::AbstractVector{T}, in::AbstractVector{T}, N::Int, start_out::Int, stride_out::Int, start_in::Int, stride_in::Int, d::Direction) where {T}
4271
tmp = in[start_in]
4372
@inbounds for j in 1:N-1
@@ -91,7 +120,18 @@ function fft!(out::AbstractVector{T}, in::AbstractVector{U}, start_out::Int, sta
91120
end
92121

93122
"""
94-
Power of 2 FFT in place
123+
$(TYPEDSIGNATURES)
124+
Power of 2 FFT, in place
125+
126+
# Arguments
127+
`out`: Output vector
128+
`in`: Input vector
129+
`N`: Size of the transform
130+
`start_out`: Index of the first element of the output vector
131+
`stride_out`: Stride of the output vector
132+
`start_in`: Index of the first element of the input vector
133+
`stride_in`: Stride of the input vector
134+
`d`: Direction of the transform
95135
96136
"""
97137
function fft_pow2!(out::AbstractVector{T}, in::AbstractVector{U}, N::Int, start_out::Int, stride_out::Int, start_in::Int, stride_in::Int, d::Direction) where {T, U}
@@ -126,7 +166,18 @@ function fft!(out::AbstractVector{T}, in::AbstractVector{U}, start_out::Int, sta
126166
end
127167

128168
"""
129-
Power of 4 FFT in place
169+
$(TYPEDSIGNATURES)
170+
Power of 4 FFT, in place
171+
172+
# Arguments
173+
`out`: Output vector
174+
`in`: Input vector
175+
`N`: Size of the transform
176+
`start_out`: Index of the first element of the output vector
177+
`stride_out`: Stride of the output vector
178+
`start_in`: Index of the first element of the input vector
179+
`stride_in`: Stride of the input vector
180+
`d`: Direction of the transform
130181
131182
"""
132183
function fft_pow4!(out::AbstractVector{T}, in::AbstractVector{U}, N::Int, start_out::Int, stride_out::Int, start_in::Int, stride_in::Int, d::Direction) where {T, U}
@@ -179,6 +230,23 @@ function fft!(out::AbstractVector{T}, in::AbstractVector{U}, start_out::Int, sta
179230
fft_pow4!(out, in, N, start_out, s_out, start_in, s_in, d)
180231
end
181232

233+
"""
234+
$(TYPEDSIGNATURES)
235+
Power of 3 FFT, in place
236+
237+
# Arguments
238+
out: Output vector
239+
in: Input vector
240+
N: Size of the transform
241+
start_out: Index of the first element of the output vector
242+
stride_out: Stride of the output vector
243+
start_in: Index of the first element of the input vector
244+
stride_in: Stride of the input vector
245+
d: Direction of the transform
246+
plus120: Depending on direction, perform either ±120° rotation
247+
minus120: Depending on direction, perform either ∓120° rotation
248+
249+
"""
182250
function fft_pow3!(out::AbstractVector{T}, in::AbstractVector{U}, N::Int, start_out::Int, stride_out::Int, start_in::Int, stride_in::Int, d::Direction, plus120::T, minus120::T) where {T, U}
183251
if N == 3
184252
@muladd out[start_out + 0] = in[start_in] + in[start_in + stride_in] + in[start_in + 2*stride_in]

src/callgraph.jl

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@ $(TYPEDSIGNATURES)
2323
Node of a call graph
2424
2525
# Arguments
26-
`left::Int`- Offset to the left child node
27-
`right::Int`- Offset to the right child node
28-
`type::AbstractFFTType`- Object representing the type of FFT
29-
`sz::Int`- Size of this FFT
30-
31-
# Examples
32-
```julia
33-
julia> CallGraphNode(0, 0, Pow2FFT(), 8)
34-
```
26+
`left`: Offset to the left child node
27+
`right`: Offset to the right child node
28+
`type`: Object representing the type of FFT
29+
`sz`: Size of this FFT
30+
3531
"""
3632
struct CallGraphNode
3733
left::Int
@@ -47,13 +43,9 @@ $(TYPEDSIGNATURES)
4743
Object representing a graph of FFT Calls
4844
4945
# Arguments
50-
`nodes::Vector{CallGraphNode}`- Nodes keeping track of the graph
51-
`workspace::Vector{Vector{T}}`- Preallocated Workspace
46+
`nodes`: Nodes keeping track of the graph
47+
`workspace`: Preallocated Workspace
5248
53-
# Examples
54-
```julia
55-
julia> CallGraph{ComplexF64}(CallGraphNode[], Vector{T}[])
56-
```
5749
"""
5850
struct CallGraph{T<:Complex}
5951
nodes::Vector{CallGraphNode}
@@ -96,7 +88,18 @@ function _ispow24(N::Int)
9688
return N < 3 ? Pow24(N) : nothing
9789
end
9890

99-
# Recursively instantiate a set of `CallGraphNode`s
91+
"""
92+
$(TYPEDSIGNATURES)
93+
Recursively instantiate a set of `CallGraphNode`s
94+
95+
# Arguments
96+
`nodes`: A vector (which gets expanded) of `CallGraphNode`s
97+
`N`: The size of the FFT
98+
`workspace`: A vector (which gets expanded) of preallocated workspaces
99+
`s_in`: The stride of the input
100+
`s_out`: The stride of the output
101+
102+
"""
100103
function CallGraphNode!(nodes::Vector{CallGraphNode}, N::Int, workspace::Vector{Vector{T}}, s_in::Int, s_out::Int)::Int where {T}
101104
if iseven(N)
102105
pow = _ispow24(N)
@@ -141,7 +144,11 @@ function CallGraphNode!(nodes::Vector{CallGraphNode}, N::Int, workspace::Vector{
141144
return 1 + left_len + right_len
142145
end
143146

144-
# Instantiate a CallGraph from a number `N`
147+
"""
148+
$(TYPEDSIGNATURES)
149+
Instantiate a CallGraph from a number `N`
150+
151+
"""
145152
function CallGraph{T}(N::Int) where {T}
146153
nodes = CallGraphNode[]
147154
workspace = Vector{Vector{T}}()

0 commit comments

Comments
 (0)