Skip to content

Commit b2cad99

Browse files
authored
Fix construction of interval when mixing real and complex arguments (#611)
With the update it treats the real argument as having imaginary part zero. The previous behaviour was to only consider the imaginary part of the complex argument.
1 parent b8c0b2a commit b2cad99

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Diff for: src/intervals/construction.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,9 @@ end
481481
_interval_infsup(::Type{T}, a::Complex, b::Complex, d::Decoration = com) where {T<:NumTypes} =
482482
complex(_interval_infsup(T, real(a), real(b), d), _interval_infsup(T, imag(a), imag(b), d))
483483
_interval_infsup(::Type{T}, a::Complex, b, d::Decoration = com) where {T<:NumTypes} =
484-
complex(_interval_infsup(T, real(a), b, d), _interval_infsup(T, imag(a), imag(a), d))
484+
complex(_interval_infsup(T, real(a), real(b), d), _interval_infsup(T, imag(a), imag(b), d))
485485
_interval_infsup(::Type{T}, a, b::Complex, d::Decoration = com) where {T<:NumTypes} =
486-
complex(_interval_infsup(T, a, real(b), d), _interval_infsup(T, imag(b), imag(b), d))
486+
complex(_interval_infsup(T, real(a), real(b), d), _interval_infsup(T, imag(a), imag(b), d))
487487

488488
# midpoint constructors
489489

Diff for: test/interval_tests/complex.jl

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
@test isequal_interval(intersect_interval(c, hull(a, b)), complex(interval(0, 3), interval(1, 2)))
2121
@test isempty_interval(intersect_interval(a, b))
2222
@test isdisjoint_interval(a, b)
23+
24+
@test isequal_interval(interval(-1 - im, 0), interval(-1 - im, 0 + 0im))
25+
@test isequal_interval(interval(0, 1 + im), interval(0 + 0im, 1 + im))
2326
end
2427

2528
@testset "Inverse roots of unity" begin

0 commit comments

Comments
 (0)