Skip to content

Commit f89120b

Browse files
committed
Precompilation works
1 parent f85aff3 commit f89120b

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ version = "0.2.2"
55

66
[deps]
77
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
8+
ComputedFieldTypes = "459fdd68-db75-56b8-8c15-d717a790f88e"
89
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
910
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
11+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1012
MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221"
1113
Primes = "27ebfcd6-29c5-5fa9-bf4b-fb8fc14df3ae"
1214
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
15+
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1316

1417
[compat]
1518
DocStringExtensions = "0.8"

src/FFTA.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
module FFTA
22

3-
using Primes, DocStringExtensions, MuladdMacro, AbstractFFTs, ComputedFieldTypes
4-
export fft, bfft
3+
using Primes, DocStringExtensions, Reexport, MuladdMacro, ComputedFieldTypes, LinearAlgebra
4+
@reexport using AbstractFFTs
5+
6+
import AbstractFFTs: Plan
57

68
include("callgraph.jl")
79
include("algos.jl")
10+
include("plan.jl")
811

912
#=
1013
"""

src/plan.jl

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,37 @@
1-
@computed struct FFTAPlan{T} <: Plan{T} where {T <: Union{Real, Complex}}
2-
callgraph::CallGraph{(T<:Real) ? Complex{T} : T}
3-
pinv::FFTAPlan{T}
1+
struct FFTAInvPlan{T} <: Plan{T} end
2+
3+
@computed struct FFTAPlan{T<:Union{Real, Complex},N} <: Plan{T}
4+
callgraph::NTuple{N, CallGraph{(T<:Real) ? Complex{T} : T}}
5+
region::NTuple{N, Int}
6+
dir::Direction
7+
pinv::FFTAInvPlan{T}
48
end
59

6-
function AbstractFFTs.plan_fft(x::AbstractArray{T,N}, region; kwargs...)::FFTAPlan{T}
10+
function AbstractFFTs.plan_fft(x::AbstractArray{T}, region; kwargs...)::FFTAPlan{T} where T
11+
N = length(region)
712
@assert N <= 2 "Only supports vectors and matrices"
13+
if N == 1
14+
g = CallGraph{T}(size(x,region[]))
15+
pinv = FFTAInvPlan()
16+
return FFTAPlan{T,N}((g,), region, FFT_FORWARD, pinv)
17+
else
18+
g1 = CallGraph{T}(size(x,region[1]))
19+
g2 = CallGraph{T}(size(x,region[2]))
20+
pinv = FFTAInvPlan()
21+
return FFTAPlan{T,N}((g1,g2), region, FFT_FORWARD, pinv)
22+
end
23+
end
24+
25+
function AbstractFFTs.plan_bfft(p::FFTAPlan{T,N}) where {T,N}
26+
return FFTAPlan{T,N}(p.callgraph, p.region, -p.dir, p.pinv)
27+
end
28+
29+
function LinearAlgebra.mul!(y, p::FFTAPlan, x)
30+
fft!(y, x, 1, 1, p.dir, p.callgraph[1].type, p.callgraph, 1)
31+
end
32+
33+
function *(p::FFTAPlan, x)
34+
y = similar(x)
35+
LinearAlgebra.mul!(y, p, x)
36+
y
837
end

0 commit comments

Comments
 (0)