Skip to content

Commit ee3b13c

Browse files
committed
DuffyCone works
1 parent 1f4d91c commit ee3b13c

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/Cone/Cone.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ function points(sp::DuffyCone,n)
183183
N = ceil(Int, n^(1/3))
184184
pts=Array{float(eltype(domain(sp)))}(undef,0)
185185
a,b = rectspace(sp).spaces
186-
for y in points(a,N), x in points(b,N^2)
186+
for y in points(b,N^2), x in points(a,N)
187187
push!(pts,Vec(x...,y...))
188188
end
189189
conemap.(pts)
@@ -249,7 +249,13 @@ evaluate(cfs::AbstractVector, S::LegendreCone, txy) = evaluate(coefficients(cfs,
249249
function evaluate(cfs::AbstractVector, S::DuffyCone, txy::Vec{3})
250250
t,x,y = txy
251251
@assert x^2+y^2  t^2
252-
Fun(rectspace(S), cfs)(t,x/t,y/t)
252+
a,b = rectspace(S).spaces
253+
mat = totensor(S, cfs)
254+
for j = 1:size(mat,2)
255+
# in place since totensor makes copy
256+
mat[1,j] = Fun(a, view(mat,:,j))(t)
257+
end
258+
Fun(b, view(mat,1,:))(x/t,y/t)
253259
end
254260

255261
function duffy2legendrecone!(triangleplan, F::AbstractMatrix)

test/test_cone.jl

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,20 @@ end
8686
@test f.coefficients [1.2533141373154997; Zeros(164)]
8787
@test f(0.3,0.1,0.2) 1
8888

89-
f = Fun((t,x,y) -> t, DuffyConic(), 10)
90-
@test f(sqrt(0.1^2+0.2^2),0.1,0.2) sqrt(0.1^2+0.2^2)
89+
f = Fun((t,x,y) -> t, DuffyCone(), 10)
90+
@test f(0.3,0.1,0.2) 0.3
9191

92-
f = Fun((t,x,y) -> x, DuffyConic(), 10)
92+
f = Fun((t,x,y) -> x, DuffyCone(), 10)
93+
@test f(0.3,0.1,0.2) 0.1
9394

94-
@test f(sqrt(0.1^2+0.2^2),0.1,0.2) 0.1
95-
96-
f = Fun((t,x,y) -> exp(cos(t*x)*y), DuffyConic(), 1000)
97-
@test f(sqrt(0.1^2+0.2^2),0.1,0.2) exp(cos(sqrt(0.1^2+0.2^2)*0.1)*0.2)
95+
f = Fun((t,x,y) -> y, DuffyCone(), 10)
96+
@test f(0.3,0.1,0.2) 0.2
9897

99-
f = Fun((t,x,y) -> exp(cos(t*x)*y), DuffyConic())
100-
@test f(sqrt(0.1^2+0.2^2),0.1,0.2) exp(cos(sqrt(0.1^2+0.2^2)*0.1)*0.2)
98+
f = Fun((t,x,y) -> exp(cos(t*x)*y), DuffyCone(), 2000)
99+
@test f(0.3,0.1,0.2) exp(cos(0.3*0.1)*0.2)
101100

102-
m,ℓ = (1,1)
103-
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*θ))
104-
g = Fun(f, DuffyConic())
105-
t,x,y = sqrt(0.1^2+0.2^2),0.1,0.2
106-
@test g(t,x,y) f((t,x,y))
101+
f = Fun((t,x,y) -> exp(cos(t*x)*y), DuffyCone())
102+
@test f(0.3,0.1,0.2) exp(cos(0.3*0.1)*0.2)
107103
end
108104

109105
@testset "Legendre<>DuffyConic" begin

0 commit comments

Comments
 (0)