Skip to content

Commit 584cad0

Browse files
authored
mod2pi in tocanonical (#40)
* mod2pi in tocanonical * version bump to v0.2.15
1 parent 6533da6 commit 584cad0

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunFourier"
22
uuid = "59844689-9c9d-51bf-9583-5b794ec66d30"
3-
version = "0.2.14"
3+
version = "0.2.15"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/Domains/Circle.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,18 @@ convert(::Type{Circle{T,V}},::AnyDomain) where {T<:Number,V<:Real} = Circle{T,V}
4343
convert(::Type{IT},::AnyDomain) where {IT<:Circle} = Circle(NaN,NaN)
4444

4545

46+
function _tocanonical(v)
47+
θ = atan(v[2]-0.0, v[1]) # -0.0 to get branch cut right
48+
mod2pi(θ)
49+
end
4650
function tocanonical(d::Circle{T},ζ) where T<:Number
4751
v=mappoint(d,Circle(),ζ)
48-
atan(imag(v)-0.0,real(v)) # -0.0 to get branch cut right
52+
_tocanonical(reim(v))
4953
end
5054

5155
function tocanonical(d::Circle{T},ζ) where T<:Vec
5256
v=mappoint(d,Circle((0.0,0.0),1.0),ζ)
53-
atan(v[2]-0.0,v[1]) # -0.0 to get branch cut right
57+
_tocanonical(v)
5458
end
5559

5660

test/runtests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,15 @@ end
165165

166166
@test norm(ApproxFunBase.Reverse(Fourier())*Fun(t->cos(cos(t-0.2)-0.1),Fourier()) - Fun(t->cos(cos(-t-0.2)-0.1),Fourier())) < 10eps()
167167
@test norm(ApproxFunBase.ReverseOrientation(Fourier())*Fun(t->cos(cos(t-0.2)-0.1),Fourier()) - Fun(t->cos(cos(t-0.2)-0.1),Fourier(PeriodicSegment(2π,0)))) < 10eps()
168+
169+
@testset "issue #741" begin
170+
c = Fun(cos, Fourier())
171+
@test roots(c) (1:2:3) * pi/2
172+
c = Fun(cos, Fourier(0..4pi))
173+
@test roots(c) (1:2:7) * pi/2
174+
c = Fun(cos, Fourier(-2pi..2pi))
175+
@test roots(c) (-3:2:3) * pi/2
176+
end
168177
end
169178

170179
@testset "Laurent" begin

0 commit comments

Comments
 (0)