1+ """
2+ ContinuousPolynomial{0} is piecewise Legendre
3+ ContinuousPolynomial{1} is hat functions in first block and rest are bubble functions Ultraspherical(-1/2)
4+ ContinuousPolynomial{-1} is delta functions (non-boundary) and rest are Ultraspherical(1/2) == diff(Legendre())[:,2:end] in the interior of the elements.
5+ Between elements we are consistent with differentiating Legendre: we have delta functions of (-1)^k on the left and -1 on the right.
6+ """
17struct ContinuousPolynomial{order,T,P<: AbstractVector } <: AbstractPiecewisePolynomial{order,T,P}
28 points:: P
39end
@@ -11,8 +17,8 @@ ContinuousPolynomial{o}(P::ContinuousPolynomial) where {o} = ContinuousPolynomia
1117PiecewisePolynomial (P:: ContinuousPolynomial{o,T} ) where {o,T} = PiecewisePolynomial (Legendre {T} (), P. points)
1218
1319axes (B:: ContinuousPolynomial{0} ) = axes (PiecewisePolynomial (B))
14- axes (B:: ContinuousPolynomial{1} ) =
15- (Inclusion (first (B. points) .. last (B. points)), blockedrange (Vcat (length (B. points), Fill (length (B. points) - 1 , ∞))))
20+ axes (B:: ContinuousPolynomial{1} ) = ( Inclusion ( first (B . points) .. last (B . points)), blockedrange ( Vcat ( length (B . points), Fill ( length (B . points) - 1 , ∞))))
21+ axes (B :: ContinuousPolynomial{-1} ) = (Inclusion (first (B. points) .. last (B. points)), blockedrange (Vcat (length (B. points)- 2 , Fill (length (B. points) - 1 , ∞))))
1622
1723show (io:: IO , Q:: ContinuousPolynomial{λ} ) where λ = summary (io, Q)
1824summary (io:: IO , Q:: ContinuousPolynomial{λ} ) where λ = print (io, " ContinuousPolynomial{$λ }($(Q. points) )" )
@@ -45,6 +51,21 @@ function getindex(P::ContinuousPolynomial{1,T}, x::Number, Kk::BlockIndex{1}) wh
4551 end
4652end
4753
54+ function getindex (P:: ContinuousPolynomial{-1,T} , x:: Number , Kk:: BlockIndex{1} ) where {T}
55+ K, k = block (Kk), blockindex (Kk)
56+ if K == Block (1 )
57+ Spline {-1,T} (P. points)[x, k]
58+ else
59+ b = searchsortedlast (P. points, x)
60+ if b == k
61+ α, β = convert (T, P. points[b]), convert (T, P. points[b+ 1 ])
62+ Ultraspherical {T} (3 one (real (T))/ 2 )[affine (α.. β, ChebyshevInterval {real(T)} ())[x], Int (K)- 1 ]
63+ else
64+ zero (T)
65+ end
66+ end
67+ end
68+
4869
4970
5071factorize (V:: SubQuasiArray{T,N,<:ContinuousPolynomial{0},<:Tuple{Inclusion,BlockSlice}} , dims... ) where {T,N} =
@@ -214,6 +235,22 @@ function \(P::ContinuousPolynomial{0}, C::ContinuousPolynomial{1})
214235end
215236
216237
238+ @simplify function \ (D:: ContinuousPolynomial{-1} , P:: ContinuousPolynomial{0} )
239+ T = promote_type (eltype (D), eltype (P))
240+ @assert D. points == P. points
241+ N = length (P. points)
242+ R = Ultraspherical {T} (3 one (T)/ 2 )\ Legendre {T} ()
243+
244+ # The basis for D is defined in each element a..b as diff(legendre(a..b)) with delta functions. But note that
245+ # the delta functions don't change! We need to kill off the deltas in conversion.
246+ ArrowheadMatrix (_BandedMatrix (Vcat (Fill (- one (T),1 ,N- 1 ), Fill (one (T),1 ,N- 1 )), N- 2 , 0 , 1 ),
247+ (_BandedMatrix (Ones {T} (2 ,N- 1 ), N- 2 , 0 , 1 ),),
248+ (SquareEye {T} (N- 1 ),),
249+ Fill (R[:,2 : end ], N- 1 ))
250+ end
251+
252+
253+
217254
218255# #####
219256# Gram matrix
279316# ####
280317
281318function diff (C:: ContinuousPolynomial{1,T} ; dims= 1 ) where T
282- # Legendre() \ (D*Weighted(Jacobi(1,1 )))
319+ # Legendre() \ (D*Ultraspherical(3/2 )))
283320 r = C. points
284321 N = length (r)
285322 s = one (T) ./ (r[2 : end ]- r[1 : end - 1 ])
@@ -296,6 +333,18 @@ function diff(C::ContinuousPolynomial{1,T,<:AbstractRange}; dims=1) where T
296333 Fill (- 2 s* Eye {T} (∞), N- 1 ))
297334end
298335
336+ function diff (P:: ContinuousPolynomial{0,T,<:AbstractRange} ; dims= 1 ) where T
337+ r = P. points
338+ N = length (r)
339+ s = step (r)
340+
341+ ContinuousPolynomial {-1} (r) * ArrowheadMatrix (_BandedMatrix (Vcat (Fill (one (T),1 ,N- 1 ), Fill (- one (T),1 ,N- 1 )), N- 2 , 0 , 1 ),
342+ (),
343+ (),
344+ Fill (Eye {T} (∞) * (2 / s), N- 1 ))
345+ end
346+
347+
299348function weaklaplacian (C:: ContinuousPolynomial{1,T,<:AbstractRange} ) where T
300349 r = C. points
301350 N = length (r)
0 commit comments