Skip to content

Commit 5a9d218

Browse files
add basic interface
expert interface unchanged Basically: x = 1.0./(1:10) norm(leg2cheb(cheb2leg(x)) - x) is small
1 parent ccb62a5 commit 5a9d218

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

deps/build.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
if Sys.isapple()
22
const libfasttransforms = joinpath(dirname(@__DIR__), "deps", "libfasttransforms.dylib")
33
download("https://github.com/MikaelSlevinsky/FastTransforms/releases/download/v0.2.3/libfasttransforms.dylib", libfasttransforms)
4+
elseif Sys.islinux()
5+
const libfasttransforms = joinpath(dirname(@__DIR__), "deps", "libfasttransforms.so")
6+
download("https://github.com/MikaelSlevinsky/FastTransforms/releases/download/v0.2.3/libfasttransforms.so", libfasttransforms)
47
else
5-
@warn "Didn't build properly"
8+
@warn "FastTransforms is not properly installed."
69
end

src/FastTransforms.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ import FFTW: dct, dct!, idct, idct!,
2020

2121
import LinearAlgebra: mul!, lmul!, ldiv!
2222

23+
export leg2cheb, cheb2leg, ultra2ultra, jac2jac,
24+
lag2lag, jac2ultra, ultra2jac, jac2cheb,
25+
cheb2jac, ultra2cheb, cheb2ultra,
26+
sph2fourier, sphv2fourier, disk2cxf, tri2cheb,
27+
fourier2sph, fourier2sphv, cxf2disk, cheb2tri
28+
2329
export plan_leg2cheb, plan_cheb2leg, plan_ultra2ultra, plan_jac2jac,
2430
plan_lag2lag, plan_jac2ultra, plan_ultra2jac, plan_jac2cheb,
2531
plan_cheb2jac, plan_ultra2cheb, plan_cheb2ultra,

src/libfasttransforms.jl

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
# Step 4: run `make` and check the tests by running `./test_drivers 3 3 0`.
1515
# All the errors should be roughly on the order of machine precision.
1616

17-
if Sys.isapple()
18-
const libfasttransforms = joinpath(dirname(@__DIR__), "deps", "libfasttransforms.dylib")
19-
else
17+
const libfasttransforms = joinpath(dirname(@__DIR__), "deps", "libfasttransforms")
18+
19+
if !(find_library(libfasttransforms) libfasttransforms)
2020
error("FastTransforms is not properly installed. Please run Pkg.build(\"FastTransforms\") ",
2121
"and restart Julia.")
2222
end
@@ -186,6 +186,25 @@ checksize(p::TransposeFTPlan, x) = checksize(p.parent, x)
186186
unsafe_convert(::Type{Ptr{ft_plan_struct}}, p::TransposeFTPlan{T, FTPlan{T, N, K}}) where {T, N, K} = unsafe_convert(Ptr{ft_plan_struct}, p.parent)
187187
unsafe_convert(::Type{Ptr{mpfr_t}}, p::TransposeFTPlan{T, FTPlan{T, N, K}}) where {T, N, K} = unsafe_convert(Ptr{mpfr_t}, p.parent)
188188

189+
for f in (:leg2cheb, :cheb2leg, :ultra2ultra, :jac2jac,
190+
:lag2lag, :jac2ultra, :ultra2jac, :jac2cheb,
191+
:cheb2jac, :ultra2cheb, :cheb2ultra,
192+
:sph2fourier, :sphv2fourier, :disk2cxf, :tri2cheb)
193+
plan_f = Symbol("plan_", f)
194+
@eval begin
195+
$plan_f(x::AbstractArray{T}, y...; z...) where T = $plan_f(T, size(x, 1), y...; z...)
196+
$f(x::AbstractArray{T}, y...; z...) where T = $plan_f(x, y...; z...)*x
197+
end
198+
end
199+
200+
for (f, plan_f) in ((:fourier2sph, :plan_sph2fourier), (:fourier2sphv, :plan_sphv2fourier),
201+
(:cxf2disk2, :plan_disk2cxf), (:cheb2tri, :plan_tri2cheb))
202+
@eval begin
203+
$f(x::AbstractArray{T}, y...; z...) where T = $plan_f(x, y...; z...)\x
204+
end
205+
end
206+
207+
189208
function plan_leg2cheb(::Type{Float32}, n::Integer; normleg::Bool=false, normcheb::Bool=false)
190209
plan = ccall((:ft_plan_legendre_to_chebyshevf, libfasttransforms), Ptr{ft_plan_struct}, (Cint, Cint, Cint), normleg, normcheb, n)
191210
return FTPlan{Float32, 1, LEG2CHEB}(plan, n)

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include("chebyshevtests.jl")
66

77
include("quadraturetests.jl")
88

9-
if Sys.isapple()
9+
if find_library(FastTransforms.libfasttransforms) FastTransforms.libfasttransforms
1010
include("libfasttransformstests.jl")
1111
else
1212
error("FastTransforms is not properly installed. Please run Pkg.build(\"FastTransforms\") ",

0 commit comments

Comments
 (0)