Skip to content

Commit

Permalink
flatten logic
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreySarnoff committed Aug 4, 2018
1 parent 8140e1f commit 1068f7b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/values/compare.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,25 @@ function (=>)(x::ArbFloat{P}, y::ArbFloat{P}) where {P}
end

function (<)(x::ArbReal{P}, y::ArbReal{P}) where {P}
upperbound(x) < lowerbound(y)
x = upperbound(x)
y = lowerbound(y)
0 != ccall(@libarb(arb_lt), Cint, (Ref{ArbReal}, Ref{ArbReal}), y, x)
end

function (>)(x::ArbReal{P}, y::ArbReal{P}) where {P}
lowerbound(x) > upperbound(y)
x = lowerbound(x)
y = upperbound(y)
0 != ccall(@libarb(arb_gt), Cint, (Ref{ArbReal}, Ref{ArbReal}), y, x)
end

function (<=)(x::ArbReal{P}, y::ArbReal{P}) where {P}
upperbound(x) < lowerbound(y) ||
0 != ccall(@libarb(arb_contains), Cint, (Ref{ArbReal}, Ref{ArbReal}), y, x)
x < y ||
0 != ccall(@libarb(arb_contains), Cint, (Ref{ArbReal}, Ref{ArbReal}), x, y)
end

function (>=)(x::ArbReal{P}, y::ArbReal{P}) where {P}
upperbound(y) < lowerbound(x) ||
0 != ccall(@libarb(arb_contains), Cint, (Ref{ArbReal}, Ref{ArbReal}), x, y)
x > y ||
0 != ccall(@libarb(arb_contains), Cint, (Ref{ArbReal}, Ref{ArbReal}), y, x)
end

# ArbComplex comparisons < > <= >=
Expand Down

0 comments on commit 1068f7b

Please sign in to comment.