Skip to content

Commit c9882d0

Browse files
committed
2 parents 09d78a1 + 491e4a4 commit c9882d0

File tree

3 files changed

+47
-32
lines changed

3 files changed

+47
-32
lines changed

Project.toml

Lines changed: 4 additions & 1 deletion
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,8 +18,10 @@ 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"
@@ -38,4 +41,4 @@ 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
@@ -204,31 +204,40 @@ function evaluate(cfs::AbstractVector, S::DuffyCone, txy::Vec{3})
204204
Fun(rectspace(S), cfs)(t,x/t,y/t)
205205
end
206206

207-
208-
function _coefficients(triangleplan, v::AbstractVector{T}, ::DuffyCone, ::LegendreCone) where T
209-
F = totensor(rectspace(DuffyCone()), v)
210-
F = pad(F, :, 2size(F,1)-1)
207+
function duffy2legendrecone!(triangleplan, F::AbstractMatrix)
211208
Fc = F[:,1:2:end]
212209
c_execute_tri_lo2hi(triangleplan, Fc)
213210
F[:,1:2:end] .= Fc
214211
# ignore first column
215212
Fc[:,2:end] .= F[:,2:2:end]
216213
c_execute_tri_lo2hi(triangleplan, Fc)
217214
F[:,2:2:end] .= Fc[:,2:end]
218-
fromtensor(LegendreCone(), F)
215+
F
219216
end
220217

221-
function _coefficients(triangleplan, v::AbstractVector{T}, ::LegendreCone, ::DuffyCone) where T
222-
F = totensor(LegendreCone(), v)
223-
F = pad(F, :, 2size(F,1)-1)
218+
function legendre2duffycone!(triangleplan, F::AbstractMatrix)
224219
Fc = F[:,1:2:end]
225220
c_execute_tri_hi2lo(triangleplan, Fc)
226221
F[:,1:2:end] .= Fc
227222
# ignore first column
228223
Fc[:,2:end] .= F[:,2:2:end]
229224
c_execute_tri_hi2lo(triangleplan, Fc)
230225
F[:,2:2:end] .= Fc[:,2:end]
231-
fromtensor(DuffyCone(), F)
226+
F
227+
end
228+
229+
function _coefficients(triangleplan, v::AbstractVector{T}, ::DuffyCone, ::LegendreCone) where T
230+
F = totensor(rectspace(DuffyCone()), v)
231+
F = pad(F, :, 2size(F,1)-1)
232+
duffy2legendrecone!(triangleplan, F)
233+
fromtensor(LegendreCone(), F)
234+
end
235+
236+
function _coefficients(triangleplan, v::AbstractVector{T}, ::LegendreCone, ::DuffyCone) where T
237+
F = totensor(LegendreCone(), v)
238+
F = pad(F, :, 2size(F,1)-1)
239+
legendre2duffycone!(triangleplan, F)
240+
fromtensor(rectspace(DuffyCone()), F)
232241
end
233242

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

test/test_cone.jl

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using ApproxFun, MultivariateOrthogonalPolynomials, Test
2-
import MultivariateOrthogonalPolynomials: rectspace, totensor
3-
import ApproxFunBase: plan_transform
2+
import MultivariateOrthogonalPolynomials: rectspace, totensor, duffy2legendreconic!, legendre2duffyconic!, c_plan_rottriangle, plan_transform
43

54
@testset "Conic" begin
65
@testset "DuffyConic" begin
@@ -28,31 +27,35 @@ import ApproxFunBase: plan_transform
2827
@test g(t,x,y) f((t,x,y))
2928
end
3029

31-
@testset "LegendreConicPlan" begin
32-
m,ℓ = (1,1)
33-
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*θ))
34-
p = points(LegendreConic(), 10)
35-
P = plan_transform(LegendreConic(), f.(p))
36-
@test P.duffyplan*f.(p) Fun(f, DuffyConic()).coefficients[1:12]
37-
g = Fun(f, LegendreConic(), 20)
38-
t,x,y = sqrt(0.1^2+0.2^2),0.1,0.2
39-
@test g(t,x,y) f((t,x,y))
40-
end
41-
42-
@testset "Legendre<>DuffyConic" begin
43-
a = randn(10)
30+
@testset "Legendre<>DuffyConic" begin
31+
for k = 0:10
32+
a = [zeros(k); 1.0; zeros(5)]
4433
F = totensor(rectspace(DuffyConic()), a)
45-
34+
F = pad(F, :, 2size(F,1)-1)
35+
T = eltype(a)
36+
P = c_plan_rottriangle(size(F,1), zero(T), zero(T), zero(T))
37+
@test legendre2duffyconic!(P, duffy2legendreconic!(P, copy(F))) F
4638

4739
b = coefficients(a, LegendreConic(), DuffyConic())
40+
@test a coefficients(b, DuffyConic(), LegendreConic())[1:length(a)]
41+
end
42+
end
4843

49-
coefficients(b, DuffyConic(), LegendreConic())
44+
45+
@testset "LegendreConicPlan" begin
46+
for (m,ℓ) in ((0,0), (0,1), (0,2), (1,1), (1,2), (2,2))
47+
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*θ))
48+
g = Fun(f, LegendreConic())
49+
t,x,y = sqrt(0.1^2+0.2^2),0.1,0.2
50+
@test g(t,x,y) f((t,x,y))
5051
end
52+
end
5153

52-
@testset "LegendreConic" begin
53-
f = Fun((t,x,y) -> 1, LegendreConic(), 10)
54-
@test f.coefficients [1; zeros(ncoefficients(f)-1)]
55-
@test f(sqrt(0.1^2+0.2^2),0.1,0.2) 1
54+
55+
@testset "LegendreConic" begin
56+
f = Fun((t,x,y) -> 1, LegendreConic(), 10)
57+
@test f.coefficients [1; zeros(ncoefficients(f)-1)]
58+
@test f(sqrt(0.1^2+0.2^2),0.1,0.2) 1
5659

5760
f = Fun((t,x,y) -> t, LegendreConic(), 10)
5861
@test f(sqrt(0.1^2+0.2^2),0.1,0.2) sqrt(0.1^2+0.2^2)
@@ -62,4 +65,4 @@ import ApproxFunBase: plan_transform
6265

6366
@time Fun((t,x,y) -> 1+t+x+y, LegendreConic(), 1000)
6467
end
65-
end
68+
end

0 commit comments

Comments
 (0)