Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace epsz by tol keyword #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/polyhedron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ Polyhedra.hvectortype(::Union{Polyhedron, Type{Polyhedron}}) = Polyhedra.hvector
Polyhedra.vvectortype(::Union{Polyhedron, Type{Polyhedron}}) = Polyhedra.vvectortype(Polyhedra.MixedMatVRep{Float64, Matrix{Float64}})

# Helpers
epsz = 1e-8

function qhull(p::Polyhedron, rep=:Auto)
if rep == :V || (rep == :Auto && (p.vrep !== nothing))
Expand Down Expand Up @@ -95,7 +94,7 @@ function qhull(h::Polyhedra.MixedMatVRep{T}, solver) where T
vnored, hnored, ch.area, ch.volume
end

function qhull(h::Polyhedra.MixedMatHRep{T}, solver) where {T<:Real}
function qhull(h::Polyhedra.MixedMatHRep{T}, solver; tol = Base.rtoldefault(T)) where {T<:Real}
linset = h.linset
if !isempty(linset)
error("Equalities are not supported.")
Expand All @@ -113,7 +112,7 @@ function qhull(h::Polyhedra.MixedMatHRep{T}, solver) where {T<:Real}
B = Matrix{T}(undef, m, N)
for i in 1:m
@assert !(i in linset)
if b[i] < epsz
if b[i] < tol
error("The origin should be in the interior of the polytope but the $(i)th inequality is not safisfied at the origin.")
end
B[i,:] = (@view A[i,:]) / b[i]
Expand All @@ -126,10 +125,10 @@ function qhull(h::Polyhedra.MixedMatHRep{T}, solver) where {T<:Real}
irays = BitSet()
ipoints = BitSet()
for i in 1:nvreps
if Vlift[i, N+1] > epsz
if Vlift[i, N+1] > tol
error("The origin should be in the interior of the convex hull")
end
if Vlift[i, N+1] > -epsz
if Vlift[i, N+1] > -tol
push!(irays, i)
else
push!(ipoints, i)
Expand Down
Loading