From fb82733bb8651bfa8d050a615eb1e612c765a00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Sat, 22 Oct 2016 13:14:11 -0400 Subject: [PATCH] Refactoring --- src/matrix.jl | 2 +- src/polyhedron.jl | 39 ++++++++++++--------------------------- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/src/matrix.jl b/src/matrix.jl index dd73fbc..5c2c1bb 100644 --- a/src/matrix.jl +++ b/src/matrix.jl @@ -215,7 +215,7 @@ function extractrow(ine::CDDInequalityMatrix, i) end function extractrow{N,T}(ext::CDDGeneratorMatrix{N,T}, i) mat = unsafe_load(ext.matrix) - b = extractrow(unsafe_load(ext.matrix), i) + b = extractrow(mat, i) ispoint = b[1] @assert ispoint == zero(T) || ispoint == one(T) a = b[2:end] diff --git a/src/polyhedron.jl b/src/polyhedron.jl index a57dd15..fbe0bb9 100644 --- a/src/polyhedron.jl +++ b/src/polyhedron.jl @@ -171,35 +171,20 @@ end function gethrep{N, T}(p::CDDPolyhedron{N, T}) getine(p) end -nhreps(p::CDDPolyhedron) = nhreps(getine(p)) -starthrep(p::CDDPolyhedron) = starthrep(getine(p)) -donehrep(p::CDDPolyhedron, state) = donehrep(getine(p), state) -nexthrep(p::CDDPolyhedron, state) = nexthrep(getine(p), state) -nineqs(p::CDDPolyhedron) = nineqs(getine(p)) -startineq(p::CDDPolyhedron) = startineq(getine(p)) -doneineq(p::CDDPolyhedron, state) = doneineq(getine(p), state) -nextineq(p::CDDPolyhedron, state) = nextineq(getine(p), state) - -neqs(p::CDDPolyhedron) = neqs(getine(p)) -starteq(p::CDDPolyhedron) = starteq(getine(p)) -doneeq(p::CDDPolyhedron, state) = doneeq(getine(p), state) -nexteq(p::CDDPolyhedron, state) = nexteq(getine(p), state) - -nvreps(p::CDDPolyhedron) = nvreps(getext(p)) -startvrep(p::CDDPolyhedron) = startvrep(getext(p)) -donevrep(p::CDDPolyhedron, state) = donevrep(getext(p), state) -nextvrep(p::CDDPolyhedron, state) = nextvrep(getext(p), state) - -npoints(p::CDDPolyhedron) = npoints(getext(p)) -startpoint(p::CDDPolyhedron) = startpoint(getext(p)) -donepoint(p::CDDPolyhedron, state) = donepoint(getext(p), state) -nextpoint(p::CDDPolyhedron, state) = nextpoint(getext(p), state) +for f in [:nhreps, :starthrep, :nineqs, :startineq, :neqs, :starteq] + @eval $f(p::CDDPolyhedron) = $f(getine(p)) +end +for f in [:donehrep, :nexthrep, :doneineq, :nextineq, :doneeq, :nexteq] + @eval $f(p::CDDPolyhedron, state) = $f(getine(p), state) +end -nrays(p::CDDPolyhedron) = nrays(getext(p)) -startray(p::CDDPolyhedron) = startray(getext(p)) -doneray(p::CDDPolyhedron, state) = doneray(getext(p), state) -nextray(p::CDDPolyhedron, state) = nextray(getext(p), state) +for f in [:nvreps, :startvrep, :npoints, :startpoint, :nrays, :startray] + @eval $f(p::CDDPolyhedron) = $f(getext(p)) +end +for f in [:donevrep, :nextvrep, :donepoint, :nextpoint, :doneray, :nextray] + @eval $f(p::CDDPolyhedron, state) = $f(getext(p), state) +end function vrepiscomputed(p::CDDPolyhedron) !isnull(p.ext)