Skip to content

Commit 87530a6

Browse files
start with fmm_leg2cheb
1 parent d8ccedd commit 87530a6

File tree

3 files changed

+55
-10
lines changed

3 files changed

+55
-10
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ AbstractFFTs = "1.0"
2121
BandedMatrices = "1.5"
2222
FFTW = "1.7"
2323
FastGaussQuadrature = "0.4, 0.5, 1"
24-
FastTransforms_jll = "0.6.2"
24+
FastTransforms_jll = "0.6.3"
2525
FillArrays = "0.9, 0.10, 0.11, 0.12, 0.13, 1"
2626
GenericFFT = "0.1"
2727
Reexport = "0.2, 1.0"

src/FastTransforms.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,12 @@ include("toeplitzhankel.jl")
117117
include("SymmetricToeplitzPlusHankel.jl")
118118

119119
# following use libfasttransforms by default
120-
for f in (:jac2jac,
121-
:lag2lag, :jac2ultra, :ultra2jac, :jac2cheb,
122-
:cheb2jac, :ultra2cheb, :cheb2ultra, :associatedjac2jac,
123-
:modifiedjac2jac, :modifiedlag2lag, :modifiedherm2herm,
124-
:sph2fourier, :sphv2fourier, :disk2cxf, :ann2cxf,
125-
:rectdisk2cheb, :tri2cheb, :tet2cheb,
126-
:leg2cheb, :cheb2leg, :ultra2ultra)
120+
for f in (:leg2cheb, :cheb2leg, :ultra2ultra, :jac2jac,
121+
:lag2lag, :jac2ultra, :ultra2jac, :jac2cheb,
122+
:cheb2jac, :ultra2cheb, :cheb2ultra, :associatedjac2jac,
123+
:modifiedjac2jac, :modifiedlag2lag, :modifiedherm2herm,
124+
:sph2fourier, :sphv2fourier, :disk2cxf, :ann2cxf,
125+
:rectdisk2cheb, :tri2cheb, :tet2cheb, :fmm_leg2cheb)
127126
lib_f = Symbol("lib_", f)
128127
@eval $f(x::AbstractArray, y...; z...) = $lib_f(x, y...; z...)
129128
end

src/libfasttransforms.jl

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ end
144144
SPINSPHERESYNTHESIS
145145
SPINSPHEREANALYSIS
146146
SPHERICALISOMETRY
147+
FMMLEG2CHEB
147148
end
148149

149150
Transforms(t::Transforms) = t
@@ -187,7 +188,8 @@ let k2s = Dict(LEG2CHEB => "Legendre--Chebyshev",
187188
TETRAHEDRONANALYSIS => "FFTW Chebyshev analysis on the tetrahedron",
188189
SPINSPHERESYNTHESIS => "FFTW Fourier synthesis on the sphere (spin-weighted)",
189190
SPINSPHEREANALYSIS => "FFTW Fourier analysis on the sphere (spin-weighted)",
190-
SPHERICALISOMETRY => "Spherical isometry")
191+
SPHERICALISOMETRY => "Spherical isometry",
192+
FMMLEG2CHEB => "FMM Legendre--Chebyshev")
191193
global kind2string
192194
kind2string(k::Union{Integer, Transforms}) = k2s[Transforms(k)]
193195
end
@@ -314,6 +316,50 @@ destroy_plan(p::FTPlan{Complex{Float64}, 2, SPINSPHERESYNTHESIS}) = ccall((:ft_d
314316
destroy_plan(p::FTPlan{Complex{Float64}, 2, SPINSPHEREANALYSIS}) = ccall((:ft_destroy_spinsphere_fftw_plan, libfasttransforms), Cvoid, (Ptr{ft_plan_struct}, ), p)
315317
destroy_plan(p::FTPlan{Float64, 2, SPHERICALISOMETRY}) = ccall((:ft_destroy_sph_isometry_plan, libfasttransforms), Cvoid, (Ptr{ft_plan_struct}, ), p)
316318

319+
destroy_plan(p::FTPlan{Float32, 1, FMMLEG2CHEB}) = ccall((:ft_free_fmmf, libfasttransforms), Cvoid, (Ptr{ft_plan_struct}, ), p)
320+
destroy_plan(p::FTPlan{Float64, 1, FMMLEG2CHEB}) = ccall((:ft_free_fmm, libfasttransforms), Cvoid, (Ptr{ft_plan_struct}, ), p)
321+
322+
function plan_fmm_leg2cheb(::Type{Float64}, n::Integer)
323+
maxs = 64
324+
M = 18
325+
BOTH = 2
326+
lagrange = 0
327+
verbose = 2
328+
plan = ccall((:ft_create_fmm, libfasttransforms), Ptr{ft_plan_struct}, (Cint, Cint, Cint, Cint, Cint, Cint), n, maxs, M, BOTH, lagrange, verbose)
329+
return FTPlan{Float64, 1, FMMLEG2CHEB}(plan, n)
330+
end
331+
332+
function mul!(y::StridedVector{Float64}, p::FTPlan{Float64, 1, FMMLEG2CHEB}, x::StridedVector{Float64})
333+
checksize(p, x)
334+
checksize(p, y)
335+
checkstride(p, x)
336+
checkstride(p, y)
337+
L2C = 0
338+
flops = ccall((:ft_execute, libfasttransforms), Cint, (Ptr{Float64}, Ptr{Float64}, Ptr{ft_plan_struct}, Cint, Cint), x, y, p, L2C, 1)
339+
return y
340+
end
341+
function div!(y::StridedVector{Float64}, p::FTPlan{Float64, 1, FMMLEG2CHEB}, x::StridedVector{Float64})
342+
checksize(p, x)
343+
checksize(p, y)
344+
checkstride(p, x)
345+
checkstride(p, y)
346+
C2L = 1
347+
flops = ccall((:ft_execute, libfasttransforms), Cint, (Ptr{Float64}, Ptr{Float64}, Ptr{ft_plan_struct}, Cint, Cint), x, y, p, C2L, 1)
348+
return y
349+
end
350+
351+
function *(p::FTPlan{T, 1, FMMLEG2CHEB}, x::AbstractArray{T}) where T
352+
Ax = Array(x)
353+
y = zero(Ax)
354+
mul!(y, p, Ax)
355+
end
356+
function \(p::FTPlan{T, 1, FMMLEG2CHEB}, x::AbstractArray{T}) where T
357+
Ax = Array(x)
358+
y = zero(Ax)
359+
div!(y, p, Ax)
360+
end
361+
362+
317363
struct AdjointFTPlan{T, S, R}
318364
parent::S
319365
adjoint::R
@@ -433,7 +479,7 @@ for f in (:leg2cheb, :cheb2leg, :ultra2ultra, :jac2jac,
433479
:cheb2jac, :ultra2cheb, :cheb2ultra, :associatedjac2jac,
434480
:modifiedjac2jac, :modifiedlag2lag, :modifiedherm2herm,
435481
:sph2fourier, :sphv2fourier, :disk2cxf, :ann2cxf,
436-
:rectdisk2cheb, :tri2cheb, :tet2cheb)
482+
:rectdisk2cheb, :tri2cheb, :tet2cheb, :fmm_leg2cheb)
437483
plan_f = Symbol("plan_", f)
438484
lib_f = Symbol("lib_", f)
439485
@eval begin

0 commit comments

Comments
 (0)