|
40 | 40 |
|
41 | 41 | size(P::HierarchicalPlanWithParity) = (size(P.even, 1)+size(P.odd, 1), size(P.even, 2)+size(P.odd, 2))
|
42 | 42 |
|
43 |
| -evenlength(v::Vector) = (L = length(v); iseven(L) ? L÷2 : (L+1)÷2) |
44 |
| -oddlength(v::Vector) = (L = length(v); iseven(L) ? L÷2 : (L-1)÷2) |
| 43 | +evensize(v::AbstractVecOrMat, d) = (L = size(v, d); iseven(L) ? L÷2 : (L+1)÷2) |
| 44 | +oddsize(v::AbstractVecOrMat, d) = (L = size(v, d); iseven(L) ? L÷2 : (L-1)÷2) |
45 | 45 |
|
46 | 46 | UpperTriangularHierarchicalMatrix{T}(::Type{T}, f::Function, bd::Int64) = UpperTriangularHierarchicalMatrix(T, f, bd, bd)
|
47 | 47 | UpperTriangularHierarchicalMatrix{T}(::Type{T}, f::Function, b::Int64, d::Int64) = UpperTriangularHierarchicalMatrix(T, f, 1, b, 1, d)
|
@@ -154,21 +154,6 @@ function getindex(P::ChebyshevToLegendrePlan, i::Int, j::Int)
|
154 | 154 | end
|
155 | 155 | end
|
156 | 156 |
|
157 |
| -LegendreToChebyshevPlan(v::Vector) = LegendreToChebyshevPlan(plan_even_leg2cheb(v), plan_odd_leg2cheb(v)) |
158 |
| -ChebyshevToLegendrePlan(v::Vector) = ChebyshevToLegendrePlan(plan_even_cheb2leg(v), plan_odd_cheb2leg(v)) |
159 |
| - |
160 |
| -plan_leg2cheb(v::Vector) = LegendreToChebyshevPlan(v) |
161 |
| -plan_cheb2leg(v::Vector) = ChebyshevToLegendrePlan(v) |
162 |
| - |
163 |
| -plan_even_leg2cheb(v::Vector) = UpperTriangularHierarchicalMatrix(eltype(v), Meven, evenlength(v)) |
164 |
| -plan_odd_leg2cheb(v::Vector) = UpperTriangularHierarchicalMatrix(eltype(v), Modd, oddlength(v)) |
165 |
| - |
166 |
| -plan_even_cheb2leg(v::Vector) = UpperTriangularHierarchicalMatrix(eltype(v), Leven, evenlength(v)) |
167 |
| -plan_odd_cheb2leg(v::Vector) = UpperTriangularHierarchicalMatrix(eltype(v), Lodd, oddlength(v)) |
168 |
| - |
169 |
| -leg2cheb(v::Vector) = plan_leg2cheb(v)*v |
170 |
| -cheb2leg(v::Vector) = plan_cheb2leg(v)*v |
171 |
| - |
172 | 157 | function A_mul_B!(y::Vector, P::LegendreToChebyshevPlan, x::AbstractVector)
|
173 | 158 | HierarchicalMatrices.A_mul_B!(y, P.even, x, 1, 1, 2, 2)
|
174 | 159 | HierarchicalMatrices.A_mul_B!(y, P.odd, x, 2, 2, 2, 2)
|
@@ -271,21 +256,6 @@ function getindex(P::ChebyshevToNormalizedLegendrePlan, i::Int, j::Int)
|
271 | 256 | end
|
272 | 257 | end
|
273 | 258 |
|
274 |
| -NormalizedLegendreToChebyshevPlan(v::Vector) = NormalizedLegendreToChebyshevPlan(plan_even_normleg2cheb(v), plan_odd_normleg2cheb(v), eltype(v)[sqrt(j-0.5) for j in 1:length(v)]) |
275 |
| -ChebyshevToNormalizedLegendrePlan(v::Vector) = ChebyshevToNormalizedLegendrePlan(plan_even_cheb2normleg(v), plan_odd_cheb2normleg(v), eltype(v)[sqrt(i-0.5) for i in 1:length(v)]) |
276 |
| - |
277 |
| -plan_normleg2cheb(v::Vector) = NormalizedLegendreToChebyshevPlan(v) |
278 |
| -plan_cheb2normleg(v::Vector) = ChebyshevToNormalizedLegendrePlan(v) |
279 |
| - |
280 |
| -plan_even_normleg2cheb(v::Vector) = UpperTriangularHierarchicalMatrix(eltype(v), Mevennorm, evenlength(v)) |
281 |
| -plan_odd_normleg2cheb(v::Vector) = UpperTriangularHierarchicalMatrix(eltype(v), Moddnorm, oddlength(v)) |
282 |
| - |
283 |
| -plan_even_cheb2normleg(v::Vector) = UpperTriangularHierarchicalMatrix(eltype(v), Levennorm, evenlength(v)) |
284 |
| -plan_odd_cheb2normleg(v::Vector) = UpperTriangularHierarchicalMatrix(eltype(v), Loddnorm, oddlength(v)) |
285 |
| - |
286 |
| -normleg2cheb(v::Vector) = plan_normleg2cheb(v)*v |
287 |
| -cheb2normleg(v::Vector) = plan_cheb2normleg(v)*v |
288 |
| - |
289 | 259 | function A_mul_B!!(y::Vector, P::NormalizedLegendreToChebyshevPlan, x::AbstractVector)
|
290 | 260 | unsafe_broadcasttimes!(x, P.scl)
|
291 | 261 | HierarchicalMatrices.A_mul_B!(y, P.even, x, 1, 1, 2, 2)
|
@@ -394,21 +364,6 @@ function getindex(P::Chebyshev2ToNormalizedLegendre1Plan, i::Int, j::Int)
|
394 | 364 | end
|
395 | 365 | end
|
396 | 366 |
|
397 |
| -NormalizedLegendre1ToChebyshev2Plan(v::Vector) = NormalizedLegendre1ToChebyshev2Plan(plan_even_normleg12cheb2(v), plan_odd_normleg12cheb2(v), eltype(v)[sqrt((j+0.5)/(j*(j+1))) for j in 1:length(v)]) |
398 |
| -Chebyshev2ToNormalizedLegendre1Plan(v::Vector) = Chebyshev2ToNormalizedLegendre1Plan(plan_even_cheb22normleg1(v), plan_odd_cheb22normleg1(v), eltype(v)[sqrt(i*(i+1)/(i+0.5)) for i in 1:length(v)]) |
399 |
| - |
400 |
| -plan_normleg12cheb2(v::Vector) = NormalizedLegendre1ToChebyshev2Plan(v) |
401 |
| -plan_cheb22normleg1(v::Vector) = Chebyshev2ToNormalizedLegendre1Plan(v) |
402 |
| - |
403 |
| -plan_even_normleg12cheb2(v::Vector) = UpperTriangularHierarchicalMatrix(eltype(v), Mnormeven, evenlength(v)) |
404 |
| -plan_odd_normleg12cheb2(v::Vector) = UpperTriangularHierarchicalMatrix(eltype(v), Mnormodd, oddlength(v)) |
405 |
| - |
406 |
| -plan_even_cheb22normleg1(v::Vector) = UpperTriangularHierarchicalMatrix(eltype(v), Lnormeven, evenlength(v)) |
407 |
| -plan_odd_cheb22normleg1(v::Vector) = UpperTriangularHierarchicalMatrix(eltype(v), Lnormodd, oddlength(v)) |
408 |
| - |
409 |
| -normleg12cheb2(v::Vector) = plan_normleg12cheb2(v)*v |
410 |
| -cheb22normleg1(v::Vector) = plan_cheb22normleg1(v)*v |
411 |
| - |
412 | 367 | function A_mul_B!!(y::Vector, P::NormalizedLegendre1ToChebyshev2Plan, x::AbstractVector)
|
413 | 368 | unsafe_broadcasttimes!(x, P.scl)
|
414 | 369 | HierarchicalMatrices.A_mul_B!(y, P.even, x, 1, 1, 2, 2)
|
@@ -456,3 +411,31 @@ function A_mul_B_col_J!(Y::Matrix, P::Chebyshev2ToNormalizedLegendre1Plan, X::Ma
|
456 | 411 | HierarchicalMatrices.A_mul_B!(Y, P.odd, X, 2+COLSHIFT, 2+COLSHIFT, 2, 2)
|
457 | 412 | scale_col_J!(P.scl, Y, J)
|
458 | 413 | end
|
| 414 | + |
| 415 | +### API |
| 416 | + |
| 417 | +for (f, T, feven, fodd) in ((:leg2cheb, :LegendreToChebyshevPlan, :Meven, :Modd), |
| 418 | + (:cheb2leg, :ChebyshevToLegendrePlan, :Leven, :Lodd), |
| 419 | + (:normleg2cheb, :NormalizedLegendreToChebyshevPlan, :Mevennorm, :Moddnorm), |
| 420 | + (:cheb2normleg, :ChebyshevToNormalizedLegendrePlan, :Levennorm, :Loddnorm), |
| 421 | + (:normleg12cheb2, :NormalizedLegendre1ToChebyshev2Plan, :Mnormeven, :Mnormodd), |
| 422 | + (:cheb22normleg1, :Chebyshev2ToNormalizedLegendre1Plan, :Lnormeven, :Lnormodd)) |
| 423 | + plan_f = parse("plan_"*string(f)) |
| 424 | + plan_even_f = parse("plan_even_"*string(f)) |
| 425 | + plan_odd_f = parse("plan_odd_"*string(f)) |
| 426 | + @eval begin |
| 427 | + $plan_f(v::VecOrMat) = $T(v) |
| 428 | + $f(v::VecOrMat) = $plan_f(v)*v |
| 429 | + $plan_even_f(v::VecOrMat) = UpperTriangularHierarchicalMatrix(eltype(v), $feven, evensize(v, 1)) |
| 430 | + $plan_odd_f(v::VecOrMat) = UpperTriangularHierarchicalMatrix(eltype(v), $fodd, oddsize(v, 1)) |
| 431 | + end |
| 432 | +end |
| 433 | + |
| 434 | +LegendreToChebyshevPlan(v::VecOrMat) = LegendreToChebyshevPlan(plan_even_leg2cheb(v), plan_odd_leg2cheb(v)) |
| 435 | +ChebyshevToLegendrePlan(v::VecOrMat) = ChebyshevToLegendrePlan(plan_even_cheb2leg(v), plan_odd_cheb2leg(v)) |
| 436 | + |
| 437 | +NormalizedLegendreToChebyshevPlan(v::VecOrMat) = NormalizedLegendreToChebyshevPlan(plan_even_normleg2cheb(v), plan_odd_normleg2cheb(v), eltype(v)[sqrt(j-0.5) for j in 1:size(v, 1)]) |
| 438 | +ChebyshevToNormalizedLegendrePlan(v::VecOrMat) = ChebyshevToNormalizedLegendrePlan(plan_even_cheb2normleg(v), plan_odd_cheb2normleg(v), eltype(v)[sqrt(i-0.5) for i in 1:size(v, 1)]) |
| 439 | + |
| 440 | +NormalizedLegendre1ToChebyshev2Plan(v::VecOrMat) = NormalizedLegendre1ToChebyshev2Plan(plan_even_normleg12cheb2(v), plan_odd_normleg12cheb2(v), eltype(v)[sqrt((j+0.5)/(j*(j+1))) for j in 1:size(v, 1)]) |
| 441 | +Chebyshev2ToNormalizedLegendre1Plan(v::VecOrMat) = Chebyshev2ToNormalizedLegendre1Plan(plan_even_cheb22normleg1(v), plan_odd_cheb22normleg1(v), eltype(v)[sqrt(i*(i+1)/(i+0.5)) for i in 1:size(v, 1)]) |
0 commit comments