Skip to content

Commit 368dcb9

Browse files
switch to views
- these display the parent types, giving more information
1 parent 0af4a9e commit 368dcb9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

examples/semiclassical.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ qvals = k -> ichebyshevtransform(q(k))
3434
x = Fun(x->x, NormalizedJacobi(β, α))
3535
XP = SymTridiagonal(Symmetric(Multiplication(x, space(x))[1:n+1, 1:n+1]))
3636
XQ = FastTransforms.modified_jacobi_matrix(P, XP)
37-
SymTridiagonal(XQ.dv[1:10], XQ.ev[1:9])
37+
view(XQ, 1:7, 1:7)
3838

3939
# And we plot:
4040
x = chebyshevpoints(Float64, n+1, Val(1))
@@ -63,19 +63,19 @@ end
6363
P′ = plan_modifiedjac2jac(Float64, n+1, α+1, β+1, v.coefficients)
6464
DP = UpperTriangular(diagm(1=>[sqrt(n*(n+α+β+1)) for n in 1:n])) # The classical differentiation matrix representing 𝒟 P^{(α,β)}(x) = P^{(α+1,β+1)}(x) D_P.
6565
DQ = UpperTriangular(threshold!(P′\(DP*(P*I)), 100eps())) # The semi-classical differentiation matrix representing 𝒟 Q(x) = Q̂(x) D_Q.
66-
UpperTriangular(DQ[1:10, 1:10])
66+
UpperTriangular(DQ[1:9, 1:9])
6767

6868
# A faster method now exists via the `GramMatrix` architecture and its associated displacement equation. Given the modified orthogonal polynomial moments implied by the normalized Jacobi series for $u(x)$, we pad this vector to the necessary size and construct the `GramMatrix` with these moments, the multiplication operator, and the constant $\tilde{P}_0^{(\alpha,\beta)}(x)$:
6969
μ = PaddedVector(u.coefficients, 2n+1)
7070
x = Fun(x->x, NormalizedJacobi(β, α))
7171
XP2 = SymTridiagonal(Symmetric(Multiplication(x, space(x))[1:2n+1, 1:2n+1]))
7272
p0 = Fun(NormalizedJacobi(β, α), [1])(0)
7373
G = GramMatrix(μ, XP2, p0)
74-
G[1:10, 1:10]
74+
view(G, 1:7, 1:7)
7575

7676
# And compute its cholesky factorization. The upper-triangular Cholesky factor represents the connection between original Jacobi and semi-classical Jacobi as ${\bf P}^{(\alpha,\beta)}(x) = {\bf Q}(x) R$.
7777
R = cholesky(G).U
78-
R[1:10, 1:10]
78+
UpperTriangular(view(R, 1:7, 1:7))
7979

8080
# Every else works almost as before, including evaluation on a Chebyshev grid:
8181
q = k -> lmul!(P1, ldiv!(R, [zeros(k); 1.0; zeros(n-k)]))
@@ -110,4 +110,4 @@ G′ = GramMatrix(μ′, XP′, p0′)
110110
R′ = cholesky(G′).U
111111
DP = UpperTriangular(diagm(1=>[sqrt(n*(n+α+β+1)) for n in 1:n])) # The classical differentiation matrix representing 𝒟 P^{(α,β)}(x) = P^{(α+1,β+1)}(x) D_P.
112112
DQ = UpperTriangular(threshold!(R′*(DP*(R\I)), 100eps())) # The semi-classical differentiation matrix representing 𝒟 Q(x) = Q̂(x) D_Q.
113-
UpperTriangular(DQ[1:10, 1:10])
113+
UpperTriangular(DQ[1:9, 1:9])

0 commit comments

Comments
 (0)