Skip to content

Commit 491e4a4

Browse files
committed
work on cone
1 parent aee1d90 commit 491e4a4

File tree

3 files changed

+46
-32
lines changed

3 files changed

+46
-32
lines changed

Project.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name = "MultivariateOrthogonalPolynomials"
22
uuid = "4f6956fd-4f93-5457-9149-7bfc4b2ce06d"
3+
version = "0.0.1"
34

45
[deps]
56
ApproxFun = "28f2ccd6-bb30-5033-b560-165f7b14dc2f"
@@ -17,25 +18,27 @@ InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
1718
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
1819
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
1920
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
21+
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
2022
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2123
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
24+
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
2225
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
2326
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
2427
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
2528
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2629

2730
[compat]
2831
ApproxFun = "0.11"
29-
ApproxFunBase = "≥ 0.0.3"
32+
ApproxFunBase = "0.1"
3033
BandedMatrices = "0.9"
3134
BlockArrays = "0.8"
32-
DomainSets = "0.0.1"
35+
DomainSets = "0.0.2"
3336
FastGaussQuadrature = "≥ 0.3.0"
3437
FastTransforms = "≥ 0.4.1"
3538
FillArrays = "≥ 0.5"
36-
InfiniteArrays = "0.0.3"
39+
InfiniteArrays = "0.1"
3740
LazyArrays = "0.8"
3841
RecipesBase = "≥ 0.5.0"
3942
SpecialFunctions = "≥ 0.6.0"
4043
StaticArrays = "≥ 0.3.0"
41-
julia = "0.7.0"
44+
julia = "0.7, 1"

src/Cone/Cone.jl

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,40 @@ function evaluate(cfs::AbstractVector, S::DuffyCone, txy::Vec{3})
5858
Fun(rectspace(S), cfs)(t,θ)
5959
end
6060

61-
62-
function _coefficients(triangleplan, v::AbstractVector{T}, ::DuffyCone, ::LegendreCone) where T
63-
F = totensor(rectspace(DuffyCone()), v)
64-
F = pad(F, :, 2size(F,1)-1)
61+
function duffy2legendrecone!(triangleplan, F::AbstractMatrix)
6562
Fc = F[:,1:2:end]
6663
c_execute_tri_lo2hi(triangleplan, Fc)
6764
F[:,1:2:end] .= Fc
6865
# ignore first column
6966
Fc[:,2:end] .= F[:,2:2:end]
7067
c_execute_tri_lo2hi(triangleplan, Fc)
7168
F[:,2:2:end] .= Fc[:,2:end]
72-
fromtensor(LegendreCone(), F)
69+
F
7370
end
7471

75-
function _coefficients(triangleplan, v::AbstractVector{T}, ::LegendreCone, ::DuffyCone) where T
76-
F = totensor(LegendreCone(), v)
77-
F = pad(F, :, 2size(F,1)-1)
72+
function legendre2duffycone!(triangleplan, F::AbstractMatrix)
7873
Fc = F[:,1:2:end]
7974
c_execute_tri_hi2lo(triangleplan, Fc)
8075
F[:,1:2:end] .= Fc
8176
# ignore first column
8277
Fc[:,2:end] .= F[:,2:2:end]
8378
c_execute_tri_hi2lo(triangleplan, Fc)
8479
F[:,2:2:end] .= Fc[:,2:end]
85-
fromtensor(DuffyCone(), F)
80+
F
81+
end
82+
83+
function _coefficients(triangleplan, v::AbstractVector{T}, ::DuffyCone, ::LegendreCone) where T
84+
F = totensor(rectspace(DuffyCone()), v)
85+
F = pad(F, :, 2size(F,1)-1)
86+
duffy2legendrecone!(triangleplan, F)
87+
fromtensor(LegendreCone(), F)
88+
end
89+
90+
function _coefficients(triangleplan, v::AbstractVector{T}, ::LegendreCone, ::DuffyCone) where T
91+
F = totensor(LegendreCone(), v)
92+
F = pad(F, :, 2size(F,1)-1)
93+
legendre2duffycone!(triangleplan, F)
94+
fromtensor(rectspace(DuffyCone()), F)
8695
end
8796

8897
function coefficients(cfs::AbstractVector{T}, CD::DuffyCone, ZD::LegendreCone) where T

test/test_cone.jl

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using ApproxFun, MultivariateOrthogonalPolynomials, Test
2-
import MultivariateOrthogonalPolynomials: rectspace, totensor
2+
import MultivariateOrthogonalPolynomials: rectspace, totensor, duffy2legendrecone!, legendre2duffycone!, c_plan_rottriangle, plan_transform
33

44
@testset "DuffyCone" begin
55
f = Fun((t,x,y) -> 1, DuffyCone(), 10)
@@ -26,28 +26,31 @@ import MultivariateOrthogonalPolynomials: rectspace, totensor
2626
@test g(t,x,y) f((t,x,y))
2727
end
2828

29-
@testset "LegendreConePlan" begin
30-
m,ℓ = (1,1)
31-
f = (txy) -> ((t,x,y) = txy; θ = atan(y,x); Fun(NormalizedJacobi(0,2m+1,Segment(1,0)),[zeros(ℓ);1])(t) * 2^m * t^m * cos(m*θ))
32-
p = points(LegendreCone(), 10)
33-
P = plan_transform(LegendreCone(), f.(p))
34-
@test P.duffyplan*f.(p) Fun(f, DuffyCone()).coefficients[1:12]
35-
coefficients(g, LegendreCone())
36-
g = Fun(f, LegendreCone(), 20)
37-
t,x,y = sqrt(0.1^2+0.2^2),0.1,0.2
38-
@test g(t,x,y) f((t,x,y))
39-
end
40-
4129
@testset "Legendre<>DuffyCone" begin
42-
a = randn(10)
43-
F = totensor(rectspace(DuffyCone()), a)
44-
30+
for k = 0:10
31+
a = [zeros(k); 1.0; zeros(5)]
32+
F = totensor(rectspace(DuffyCone()), a)
33+
F = pad(F, :, 2size(F,1)-1)
34+
T = eltype(a)
35+
P = c_plan_rottriangle(size(F,1), zero(T), zero(T), zero(T))
36+
@test legendre2duffycone!(P, duffy2legendrecone!(P, copy(F))) F
37+
38+
b = coefficients(a, LegendreCone(), DuffyCone())
39+
@test a coefficients(b, DuffyCone(), LegendreCone())[1:length(a)]
40+
end
41+
end
4542

46-
b = coefficients(a, LegendreCone(), DuffyCone())
4743

48-
coefficients(b, DuffyCone(), LegendreCone())
44+
@testset "LegendreConePlan" begin
45+
for (m,ℓ) in ((0,0), (0,1), (0,2), (1,1), (1,2), (2,2))
46+
f = (txy) -> ((t,x,y) = txy; θ = atan(y,x); Fun(NormalizedJacobi(0,2m+1,Segment(1,0)),[zeros(ℓ);1])(t) * 2^m * t^m * cos(m*θ))
47+
g = Fun(f, LegendreCone())
48+
t,x,y = sqrt(0.1^2+0.2^2),0.1,0.2
49+
@test g(t,x,y) f((t,x,y))
50+
end
4951
end
5052

53+
5154
@testset "LegendreCone" begin
5255
f = Fun((t,x,y) -> 1, LegendreCone(), 10)
5356
@test f.coefficients [1; zeros(ncoefficients(f)-1)]
@@ -58,6 +61,5 @@ end
5861
f = Fun((t,x,y) -> 1+t+x+y, LegendreCone(), 10)
5962
@test f(sqrt(0.1^2+0.2^2),0.1,0.2) 1+sqrt(0.1^2+0.2^2)+0.1+0.2
6063

61-
6264
@time Fun((t,x,y) -> 1+t+x+y, LegendreCone(), 1000)
6365
end

0 commit comments

Comments
 (0)