Skip to content

Commit f85aff3

Browse files
committed
[WIP] starting to integrate AbstractFFTs
2 parents 034a4db + b213f97 commit f85aff3

File tree

12 files changed

+261
-55
lines changed

12 files changed

+261
-55
lines changed

.github/workflows/Documentation.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags: '*'
8+
pull_request:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: julia-actions/setup-julia@latest
16+
with:
17+
version: '1.6'
18+
- name: Install dependencies
19+
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
20+
- name: Build and deploy
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
23+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key
24+
run: julia --project=docs/ docs/make.jl

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/Manifest.toml
2+
docs/build

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
name = "FFTA"
22
uuid = "b86e33f2-c0db-4aa1-a6e0-ab43e668529e"
33
authors = ["Danny Sharp <[email protected]> and contributors"]
4-
version = "0.2.1"
4+
version = "0.2.2"
55

66
[deps]
77
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
88
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
9-
LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
9+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
1010
MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221"
1111
Primes = "27ebfcd6-29c5-5fa9-bf4b-fb8fc14df3ae"
1212
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1313

1414
[compat]
1515
DocStringExtensions = "0.8"
16-
LoopVectorization = "0.12"
16+
Documenter = "0.27"
1717
MuladdMacro = "0.2"
1818
Primes = "0.5"
1919
julia = "1"

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,24 @@
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/)
6+
[![codecov](https://codecov.io/gh/dannys4/FFTA.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/dannys4/FFTA.jl)
57

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.
8+
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.
79

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

1918
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)
19+
- `fft(x::AbstractVector)`-- Forward FFT
20+
- `fft(x::AbstractMatrix})`-- Forward FFT
21+
- `bfft(x::AbstractVector})`-- Backward FFT (unscaled inverse FFT)
22+
- `bfft(x::AbstractMatrix})`-- Backward FFT (unscaled inverse FFT)
2423

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

docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/
2+
site/

docs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[deps]
2+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

docs/make.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Documenter
2+
using FFTA
3+
4+
makedocs(
5+
sitename = "FFTA",
6+
format = Documenter.HTML(),
7+
pages = ["Development Tools" => "dev.md"],
8+
modules = [FFTA]
9+
)
10+
11+
# Documenter can also automatically deploy documentation to gh-pages.
12+
# See "Hosting Documentation" and deploydocs() in the Documenter manual
13+
# for more information.
14+
deploydocs(
15+
repo = "github.com/dannys4/FFTA.jl.git"
16+
)

docs/src/dev.md

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

docs/src/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# FFTA.jl
2+
3+
Documentation for FFTA.jl
4+
5+
```@docs
6+
fft
7+
bfft
8+
```

src/FFTA.jl

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
11
module FFTA
22

3-
using Primes, DocStringExtensions, LoopVectorization, MuladdMacro, AbstractFFTs, ComputedFieldTypes
3+
using Primes, DocStringExtensions, MuladdMacro, AbstractFFTs, ComputedFieldTypes
44
export fft, bfft
55

66
include("callgraph.jl")
77
include("algos.jl")
88

9-
#= function fft(x::AbstractVector{T}) where {T}
9+
#=
10+
"""
11+
$(TYPEDSIGNATURES)
12+
Perform a fast Fourier transform of a vector. Preserves types given by the
13+
user.
14+
15+
# Arguments
16+
x::AbstractVector: The vector to transform.
17+
18+
# Examples
19+
```julia
20+
julia> x = rand(ComplexF64, 10)
21+
22+
julia> y = fft(x)
23+
```
24+
"""
25+
function fft(x::AbstractVector{T}) where {T}
1026
y = similar(x)
1127
g = CallGraph{T}(length(x))
1228
fft!(y, x, 1, 1, FFT_FORWARD, g[1].type, g, 1)
@@ -20,6 +36,21 @@ function fft(x::AbstractVector{T}) where {T <: Real}
2036
y
2137
end
2238
39+
"""
40+
$(TYPEDSIGNATURES)
41+
Perform a fast Fourier transform of a matrix. Preserves types given by the
42+
user.
43+
44+
# Arguments
45+
x::AbstractMatrix: The matrix to transform (columnwise then rowwise).
46+
47+
# Examples
48+
```julia
49+
julia> x = rand(ComplexF64, 10, 10)
50+
51+
julia> y = fft(x)
52+
```
53+
"""
2354
function fft(x::AbstractMatrix{T}) where {T}
2455
M,N = size(x)
2556
y1 = similar(x)
@@ -54,6 +85,27 @@ function fft(x::AbstractMatrix{T}) where {T <: Real}
5485
y2
5586
end
5687
88+
"""
89+
$(TYPEDSIGNATURES)
90+
Perform a backward fast Fourier transform of a vector, where "backward"
91+
indicates the same output signal down to a constant factor. Preserves types
92+
given by the user.
93+
94+
# Arguments
95+
x::AbstractVector: The vector to transform
96+
97+
# Examples
98+
```julia
99+
julia> x = rand(ComplexF64, 10)
100+
101+
julia> y = bfft(x)
102+
103+
julia> z = fft(y)
104+
105+
julia> x ≈ z/10
106+
true
107+
```
108+
"""
57109
function bfft(x::AbstractVector{T}) where {T}
58110
y = similar(x)
59111
g = CallGraph{T}(length(x))
@@ -68,6 +120,27 @@ function bfft(x::AbstractVector{T}) where {T <: Real}
68120
y
69121
end
70122
123+
"""
124+
$(TYPEDSIGNATURES)
125+
Perform a backward fast Fourier transform of a matrix, where "backward"
126+
indicates the same output signal down to a constant factor. Preserves types
127+
given by the user.
128+
129+
# Arguments
130+
x::AbstractMatrix: The matrix to transform
131+
132+
# Examples
133+
```julia
134+
julia> x = rand(ComplexF64, 10, 10)
135+
136+
julia> y = bfft(x)
137+
138+
julia> z = fft(y)
139+
140+
julia> x ≈ z/100
141+
true
142+
```
143+
"""
71144
function bfft(x::AbstractMatrix{T}) where {T}
72145
M,N = size(x)
73146
y1 = similar(x)

0 commit comments

Comments
 (0)