|
28 | 28 |
|
29 | 29 | sum(w::UltrasphericalWeight{T}) where T = sqrt(convert(T,π))*exp(loggamma(one(T)/2 + w.λ)-loggamma(1+w.λ))
|
30 | 30 |
|
| 31 | +hasboundedendpoints(w::UltrasphericalWeight) = 2w.λ ≥ 1 |
| 32 | + |
31 | 33 |
|
32 | 34 | struct Ultraspherical{T,Λ} <: AbstractJacobi{T}
|
33 | 35 | λ::Λ
|
@@ -80,6 +82,19 @@ plan_transform(P::Ultraspherical{T}, szs::NTuple{N,Int}, dims...) where {T,N} =
|
80 | 82 | Jacobi(C::Ultraspherical{T}) where T = Jacobi(C.λ-one(T)/2,C.λ-one(T)/2)
|
81 | 83 |
|
82 | 84 |
|
| 85 | + |
| 86 | +###### |
| 87 | +# Weighted Gram Matrix |
| 88 | +###### |
| 89 | + |
| 90 | +# 2^(1-2λ)*π*gamma(n+2λ)/((n+λ)*gamma(λ)^2 * n!) |
| 91 | +function weightedgrammatrix(P::Ultraspherical{T}) where T |
| 92 | + λ = P.λ |
| 93 | + n = 0:∞ |
| 94 | + c = 2^(1-2λ) * convert(T,π)/gamma(λ)^2 |
| 95 | + Diagonal(c * exp.(loggamma.(n .+ 2λ) .- loggamma.(n .+ 1) ) ./ (n .+ λ)) |
| 96 | +end |
| 97 | + |
83 | 98 | ########
|
84 | 99 | # Jacobi Matrix
|
85 | 100 | ########
|
@@ -129,7 +144,11 @@ function diff(WS::Weighted{T,<:Ultraspherical}; dims=1) where T
|
129 | 144 | else
|
130 | 145 | n = (0:∞)
|
131 | 146 | A = _BandedMatrix((-one(T)/(2*(λ-1)) * ((n.+1) .* (n .+ (2λ-1))))', ℵ₀, 1,-1)
|
132 |
| - ApplyQuasiMatrix(*, Weighted(Ultraspherical{T}(λ-1)), A) |
| 147 | + if λ == 3/2 |
| 148 | + ApplyQuasiMatrix(*, Legendre{T}(), A) |
| 149 | + else |
| 150 | + ApplyQuasiMatrix(*, Weighted(Ultraspherical{T}(λ-1)), A) |
| 151 | + end |
133 | 152 | end
|
134 | 153 | end
|
135 | 154 |
|
@@ -174,6 +193,8 @@ function \(U::Ultraspherical{<:Any,<:Integer}, C::ChebyshevU)
|
174 | 193 | U\Ultraspherical(C)
|
175 | 194 | end
|
176 | 195 |
|
| 196 | + |
| 197 | + |
177 | 198 | \(T::Chebyshev, C::Ultraspherical) = inv(C \ T)
|
178 | 199 |
|
179 | 200 | function \(C2::Ultraspherical{<:Any,<:Integer}, C1::Ultraspherical{<:Any,<:Integer})
|
@@ -209,29 +230,48 @@ function \(C2::Ultraspherical, C1::Ultraspherical)
|
209 | 230 | end
|
210 | 231 | end
|
211 | 232 |
|
212 |
| -function \(w_A::WeightedUltraspherical, w_B::WeightedUltraspherical) |
213 |
| - wA,A = w_A.args |
214 |
| - wB,B = w_B.args |
| 233 | +function \(w_A::Weighted{<:Any,<:Ultraspherical}, w_B::Weighted{<:Any,<:Ultraspherical}) |
| 234 | + A = w_A.P |
| 235 | + B = w_B.P |
215 | 236 | T = promote_type(eltype(w_A),eltype(w_B))
|
216 | 237 |
|
217 |
| - if wA == wB |
218 |
| - A \ B |
219 |
| - elseif B.λ == A.λ+1 && wB.λ == wA.λ+1 # Lower |
| 238 | + if A == B |
| 239 | + SquareEye{T}(ℵ₀) |
| 240 | + elseif B.λ == A.λ+1 |
220 | 241 | λ = convert(T,A.λ)
|
221 | 242 | _BandedMatrix(Vcat(((2λ:∞) .* ((2λ+1):∞) ./ (4λ .* (λ+1:∞)))',
|
222 | 243 | Zeros{T}(1,∞),
|
223 | 244 | (-(1:∞) .* (2:∞) ./ (4λ .* (λ+1:∞)))'), ℵ₀, 2,0)
|
| 245 | + elseif B.λ > A.λ+1 |
| 246 | + J = Weighted(Ultraspherical(B.λ-1)) |
| 247 | + (w_A\J) * (J\w_B) |
224 | 248 | else
|
225 |
| - error("not implemented for $A and $wB") |
| 249 | + error("not implemented for $w_A and $w_B") |
226 | 250 | end
|
227 | 251 | end
|
228 | 252 |
|
229 |
| -\(w_A::Weighted{<:Any,<:Ultraspherical}, w_B::Weighted{<:Any,<:Ultraspherical}) = convert(WeightedBasis, w_A) \ convert(WeightedBasis, w_B) |
230 | 253 |
|
231 |
| -\(A::Legendre, wB::WeightedUltraspherical) = Ultraspherical(A) \ wB |
232 | 254 |
|
233 |
| -function \(A::Ultraspherical, w_B::WeightedUltraspherical) |
234 |
| - (UltrasphericalWeight(zero(A.λ)) .* A) \ w_B |
| 255 | +function \(w_A::WeightedUltraspherical, w_B::WeightedUltraspherical) |
| 256 | + wA,A = w_A.args |
| 257 | + wB,B = w_B.args |
| 258 | + T = promote_type(eltype(w_A),eltype(w_B)) |
| 259 | + |
| 260 | + if wA == wB |
| 261 | + A \ B |
| 262 | + elseif wA.λ == A.λ && wB.λ == B.λ # weighted |
| 263 | + Weighted(A) \ Weighted(B) |
| 264 | + elseif wB.λ ≥ wA.λ+1 # lower |
| 265 | + J = UltrasphericalWeight(wB.λ-1) .* Ultraspherical(B.λ-1) |
| 266 | + (w_A\J) * (J\w_B) |
| 267 | + else |
| 268 | + error("not implemented for $w_A and $w_B") |
| 269 | + end |
235 | 270 | end
|
236 | 271 |
|
| 272 | +\(w_A::WeightedUltraspherical, w_B::Weighted{<:Any,<:Ultraspherical}) = w_A \ convert(WeightedBasis,w_B) |
| 273 | +\(w_A::Weighted{<:Any,<:Ultraspherical}, w_B::WeightedUltraspherical) = convert(WeightedBasis,w_A) \ w_B |
| 274 | +\(A::Ultraspherical, w_B::Weighted{<:Any,<:Ultraspherical}) = A \ convert(WeightedBasis,w_B) |
| 275 | +\(A::Ultraspherical, w_B::WeightedUltraspherical) = (UltrasphericalWeight(one(A.λ)/2) .* A) \ w_B |
| 276 | +\(A::Legendre, wB::WeightedUltraspherical) = Ultraspherical(A) \ wB |
237 | 277 |
|
0 commit comments