Skip to content

Commit aa59736

Browse files
add Proriol surface & grid plot
1 parent ecc0e59 commit aa59736

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

examples/triangle.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,18 @@
2323
# For the storage pattern of the arrays, please consult the
2424
# [documentation](https://MikaelSlevinsky.github.io/FastTransforms).
2525

26-
using FastTransforms, LinearAlgebra
26+
using FastTransforms, LinearAlgebra, Plots
27+
const GENFIGS = joinpath(dirname(dirname(pathof(FastTransforms))), "docs/src/generated")
28+
!isdir(GENFIGS) && mkdir(GENFIGS)
29+
plotlyjs()
2730

2831
# Our function $f$ and the Cartesian components of its gradient:
2932
f = (x,y) -> 1/(1+x^2+y^2)
3033
fx = (x,y) -> -2x/(1+x^2+y^2)^2
3134
fy = (x,y) -> -2y/(1+x^2+y^2)^2
3235

3336
# The polynomial degree:
34-
N = 10
37+
N = 15
3538
M = N
3639

3740
# The parameters of the Proriol series:
@@ -56,6 +59,16 @@ w = [sinpi((2M-2m-1)/(4M))^2 for m in 0:M-1]
5659
# On the mapped tensor product grid, our function samples are:
5760
F = [f(x[n+1], x[N-n]*w[m+1]) for n in 0:N-1, m in 0:M-1]
5861

62+
# We superpose a surface plot of $f$ on top of the grid:
63+
X = [x for x in x, w in w]
64+
Y = [x[N-n]*w[m+1] for n in 0:N-1, m in 0:M-1]
65+
scatter3d(vec(X), vec(Y), vec(0F); markersize=0.75, markercolor=:green, size=(800, 600))
66+
surface!(X, Y, F; legend=false, xlabel="x", ylabel="y", zlabel="f")
67+
savefig(joinpath(GENFIGS, "proriol.html"))
68+
###```@raw html
69+
###<object type="text/html" data="../proriol.html" style="width:100%;height:600px;"></object>
70+
###```
71+
5972
# We precompute a Proriol--Chebyshev² plan:
6073
P = plan_tri2cheb(F, α, β, γ)
6174

0 commit comments

Comments
 (0)