Skip to content

Commit 1e949d9

Browse files
start annulus
need tests
1 parent 59774ab commit 1e949d9

File tree

5 files changed

+196
-24
lines changed

5 files changed

+196
-24
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ToeplitzMatrices = "c751599d-da0a-543b-9d20-d0a503d91d24"
2020
AbstractFFTs = "1.0"
2121
FFTW = "1"
2222
FastGaussQuadrature = "0.4, 0.5"
23-
FastTransforms_jll = "0.6.0"
23+
FastTransforms_jll = "0.6.1"
2424
FillArrays = "0.9, 0.10, 0.11, 0.12, 0.13"
2525
GenericFFT = "0.1"
2626
Reexport = "0.2, 1.0"

docs/src/dev.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ This lets the developer experiment with new features through `ccall`ing into ble
3737
To get from a C library release to a Julia package release, the developer needs to update Yggdrasil's [build_tarballs.jl](https://github.com/JuliaPackaging/Yggdrasil/blob/master/F/FastTransforms/build_tarballs.jl) script for the new version and its 256-bit SHA. On macOS, the SHA can be found by:
3838
3939
```julia
40-
shell> curl https://codeload.github.com/MikaelSlevinsky/FastTransforms/tar.gz/v0.6.0 --output FastTransforms.tar.gz
40+
shell> curl https://codeload.github.com/MikaelSlevinsky/FastTransforms/tar.gz/v0.6.1 --output FastTransforms.tar.gz
4141
% Total % Received % Xferd Average Speed Time Time Time Current
4242
Dload Upload Total Spent Left Speed
43-
100 162k 0 162k 0 0 252k 0 --:--:-- --:--:-- --:--:-- 252k
43+
100 168k 0 168k 0 0 429k 0 --:--:-- --:--:-- --:--:-- 429k
4444

4545
shell> shasum -a 256 FastTransforms.tar.gz
46-
ae2db2fa808ca17c5dc5ac25b079eba2dbe598d061b9b4e14c948680870abc3c FastTransforms.tar.gz
46+
4ee42f264626b335e3f8bed7a10935d54393589813d8558802f0eae9ca46d36e FastTransforms.tar.gz
4747

4848
shell> rm -f FastTransforms.tar.gz
4949

@@ -52,17 +52,17 @@ shell> rm -f FastTransforms.tar.gz
5252
Using [SHA.jl](https://github.com/JuliaCrypto/SHA.jl), the SHA can also be found by:
5353
5454
```julia
55-
shell> curl https://codeload.github.com/MikaelSlevinsky/FastTransforms/tar.gz/v0.6.0 --output FastTransforms.tar.gz
55+
shell> curl https://codeload.github.com/MikaelSlevinsky/FastTransforms/tar.gz/v0.6.1 --output FastTransforms.tar.gz
5656
% Total % Received % Xferd Average Speed Time Time Time Current
5757
Dload Upload Total Spent Left Speed
58-
100 156k 0 156k 0 0 443k 0 --:--:-- --:--:-- --:--:-- 443k
58+
100 168k 0 168k 0 0 442k 0 --:--:-- --:--:-- --:--:-- 443k
5959

6060
julia> using SHA
6161

6262
julia> open("FastTransforms.tar.gz") do f
6363
bytes2hex(sha256(f))
6464
end
65-
"ae2db2fa808ca17c5dc5ac25b079eba2dbe598d061b9b4e14c948680870abc3c"
65+
"4ee42f264626b335e3f8bed7a10935d54393589813d8558802f0eae9ca46d36e"
6666

6767
shell> rm -f FastTransforms.tar.gz
6868

examples/annulus.jl

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# # Integration on an annulus
2+
# In this example, we explore integration of the function:
3+
# ```math
4+
# f(x,y) = \frac{x^3}{x^2+y^2-\frac{1}{4}},
5+
# ```
6+
# over the annulus defined by $\{(r,\theta) : \frac{2}{3} < r < 1, 0 < \theta < 2\pi\}$.
7+
# We will calculate the integral:
8+
# ```math
9+
# \int_0^{2\pi}\int_{\frac{2}{3}}^1 f(r\cos\theta,r\sin\theta)^2r{\rm\,d}r{\rm\,d}\theta,
10+
# ```
11+
# by analyzing the function in an annulus polynomial series.
12+
# We analyze the function on an $N\times M$ tensor product grid defined by:
13+
# ```math
14+
# \begin{aligned}
15+
# r_n & = \sqrt{\cos^2\left[(n+\tfrac{1}{2})\pi/2N\right] + \rho^2 \sin^2\left[(n+\tfrac{1}{2})\pi/2N\right]},\quad{\rm for}\quad 0\le n < N,\quad{\rm and}\\
16+
# \theta_m & = 2\pi m/M,\quad{\rm for}\quad 0\le m < M;
17+
# \end{aligned}
18+
# ```
19+
# we convert the function samples to Chebyshev×Fourier coefficients using
20+
# `plan_annulus_analysis`; and finally, we transform the Chebyshev×Fourier
21+
# coefficients to annulus polynomial coefficients using `plan_ann2cxf`.
22+
#
23+
# For the storage pattern of the arrays, please consult the
24+
# [documentation](https://MikaelSlevinsky.github.io/FastTransforms).
25+
26+
using FastTransforms, LinearAlgebra, Plots
27+
const GENFIGS = joinpath(pkgdir(FastTransforms), "docs/src/generated")
28+
!isdir(GENFIGS) && mkdir(GENFIGS)
29+
plotlyjs()
30+
31+
# Our function $f$ on the annulus:
32+
f = (x,y) -> x^3/(x^2+y^2-1/4)
33+
34+
# The annulus polynomial degree:
35+
N = 8
36+
M = 4N-3
37+
38+
# The annulus inner radius:
39+
ρ = 2/3
40+
41+
# The radial grid:
42+
r = [begin t = (N-n-0.5)/(2N); ct2 = sinpi(t); st2 = cospi(t); sqrt(ct2^2+ρ^2*st2^2) end; for n in 0:N-1]
43+
44+
# The angular grid (mod $\pi$):
45+
θ = (0:M-1)*2/M
46+
47+
# On the mapped tensor product grid, our function samples are:
48+
F = [f(r*cospi(θ), r*sinpi(θ)) for r in r, θ in θ]
49+
50+
# We superpose a surface plot of $f$ on top of the grid:
51+
X = [r*cospi(θ) for r in r, θ in θ]
52+
Y = [r*sinpi(θ) for r in r, θ in θ]
53+
scatter3d(vec(X), vec(Y), vec(0F); markersize=0.75, markercolor=:red)
54+
surface!(X, Y, F; legend=false, xlabel="x", ylabel="y", zlabel="f")
55+
savefig(joinpath(GENFIGS, "annulus.html"))
56+
###```@raw html
57+
###<object type="text/html" data="../annulus.html" style="width:100%;height:400px;"></object>
58+
###```
59+
60+
# We precompute an Annulus--Chebyshev×Fourier plan:
61+
α, β, γ = 0, 0, 0
62+
P = plan_ann2cxf(F, α, β, γ, ρ)
63+
64+
# And an FFTW Chebyshev×Fourier analysis plan on the annulus:
65+
PA = plan_annulus_analysis(F, ρ)
66+
67+
# Its annulus coefficients are:
68+
U = P\(PA*F)
69+
70+
# The annulus coefficients are useful for integration.
71+
# The integral of $[f(x,y)]^2$ over the annulus is
72+
# approximately the square of the 2-norm of the coefficients:
73+
norm(U)^2, 5π/8*(1675/4536+9*log(3)/32-3*log(7)/32)

src/FastTransforms.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ export leg2cheb, cheb2leg, ultra2ultra, jac2jac,
3434
lag2lag, jac2ultra, ultra2jac, jac2cheb,
3535
cheb2jac, ultra2cheb, cheb2ultra, associatedjac2jac,
3636
modifiedjac2jac, modifiedlag2lag, modifiedherm2herm,
37-
sph2fourier, sphv2fourier, disk2cxf, rectdisk2cheb, tri2cheb, tet2cheb,
38-
fourier2sph, fourier2sphv, cxf2disk, cheb2rectdisk, cheb2tri, cheb2tet
37+
sph2fourier, sphv2fourier, disk2cxf, ann2cxf, rectdisk2cheb,
38+
tri2cheb, tet2cheb,fourier2sph, fourier2sphv, cxf2disk, cxf2ann,
39+
cheb2rectdisk, cheb2tri, cheb2tet
3940

4041
export plan_leg2cheb, plan_cheb2leg, plan_ultra2ultra, plan_jac2jac,
4142
plan_lag2lag, plan_jac2ultra, plan_ultra2jac, plan_jac2cheb,
@@ -44,6 +45,7 @@ export plan_leg2cheb, plan_cheb2leg, plan_ultra2ultra, plan_jac2jac,
4445
plan_sph2fourier, plan_sph_synthesis, plan_sph_analysis,
4546
plan_sphv2fourier, plan_sphv_synthesis, plan_sphv_analysis,
4647
plan_disk2cxf, plan_disk_synthesis, plan_disk_analysis,
48+
plan_ann2cxf, plan_annulus_synthesis, plan_annulus_analysis,
4749
plan_rectdisk2cheb, plan_rectdisk_synthesis, plan_rectdisk_analysis,
4850
plan_tri2cheb, plan_tri_synthesis, plan_tri_analysis,
4951
plan_tet2cheb, plan_tet_synthesis, plan_tet_analysis,

0 commit comments

Comments
 (0)