Skip to content

Commit

Permalink
Simplify constructor with iterators
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Feb 18, 2018
1 parent 1586032 commit d53ac19
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ CDDInequalityMatrix(rep::Rep{N,T}) where {N,T} = CDDInequalityMatrix{N,polytypef

CDDInequalityMatrix(matrix::Ptr{Cdd_MatrixData{T}}) where {T} = CDDInequalityMatrix{unsafe_load(matrix).colsize-1, polytype(T), T}(matrix)

function CDDInequalityMatrix{N, T, S}(eqs::Polyhedra.ElemIt{<:HyperPlane{N, T}}, ineqs::Polyhedra.ElemIt{<:HalfSpace{N, T}}) where {N, T, S}
CDDInequalityMatrix(initmatrix(Polyhedra.FullDim{N}(), T, true, eqs, ineqs))
function CDDInequalityMatrix{N, T, S}(hits::Polyhedra.HIt{N, T}...) where {N, T, S}
CDDInequalityMatrix(initmatrix(Polyhedra.FullDim{N}(), T, true, hits...))
end

nhreps(matrix::CDDInequalityMatrix) = length(matrix)
Expand Down Expand Up @@ -264,8 +264,8 @@ function Base.copy(matrix::CDDGeneratorMatrix{N, T, S}) where {N, T, S}
CDDGeneratorMatrix{N, T, S}(dd_matrixcopy(matrix.matrix))
end

function CDDGeneratorMatrix{N,T,S}(sympoints::Polyhedra.ElemIt{<:SymPoint{N, T}}, points::Polyhedra.ElemIt{<:Polyhedra.MyPoint{N, T}}, lines::Polyhedra.ElemIt{<:Line{N, T}}, rays::Polyhedra.ElemIt{<:Ray{N, T}}) where {N, T, S}
CDDGeneratorMatrix(initmatrix(Polyhedra.FullDim{N}(), T, false, lines, sympoints, rays, points))
function CDDGeneratorMatrix{N,T,S}(vits::Polyhedra.VIt{N, T}...) where {N, T, S}
CDDGeneratorMatrix(initmatrix(Polyhedra.FullDim{N}(), T, false, vits...))
end

nvreps(matrix::CDDGeneratorMatrix) = length(matrix)
Expand Down
8 changes: 3 additions & 5 deletions src/polyhedron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function Polyhedra.polyhedron(hyperplanes::Polyhedra.ElemIt{<:HyperPlane{N}}, ha
T = polytypeforprecision(lib.precision)
CDDPolyhedron{N, T}(hyperplanes, halfspaces)
end
function Polyhedra.polyhedron(sympoints::Polyhedra.ElemIt{<:SymPoint{N}}, points::Polyhedra.ElemIt{<:Polyhedra.MyPoint{N}}, lines::Polyhedra.ElemIt{<:Line{N}}, rays::Polyhedra.ElemIt{<:Ray{N}}, lib::CDDLibrary) where N
function Polyhedra.polyhedron(vits::Polyhedra.ElemIt{<:SymPoint{N}}, points::Polyhedra.ElemIt{<:Polyhedra.MyPoint{N}}, lines::Polyhedra.ElemIt{<:Line{N}}, rays::Polyhedra.ElemIt{<:Ray{N}}, lib::CDDLibrary) where N
T = polytypeforprecision(lib.precision)
CDDPolyhedron{N, T}(sympoints, points, lines, rays)
end
Expand All @@ -140,10 +140,8 @@ getlibraryfor{T<:AbstractFloat}(::CDDPolyhedron, n::Int, ::Type{T}) = CDDLibrary
Base.convert{N, T}(::Type{CDDPolyhedron{N, T}}, rep::HRepresentation{N}) = CDDPolyhedron{N, T}(cddmatrix(T, rep))
Base.convert{N, T}(::Type{CDDPolyhedron{N, T}}, rep::VRepresentation{N}) = CDDPolyhedron{N, T}(cddmatrix(T, rep))

CDDPolyhedron{N, T}(hyperplanes::Polyhedra.ElemIt{<:HyperPlane{N, T}}, halfspaces::Polyhedra.ElemIt{<:HalfSpace{N, T}}) where {N, T} = CDDPolyhedron{N, T}(CDDInequalityMatrix{N, T, mytype(T)}(hyperplanes, halfspaces))
function CDDPolyhedron{N, T}(sympoints::Polyhedra.ElemIt{<:SymPoint{N, T}}, points::Polyhedra.ElemIt{<:Polyhedra.MyPoint{N, T}}, lines::Polyhedra.ElemIt{<:Line{N, T}}, rays::Polyhedra.ElemIt{<:Ray{N, T}}) where {N, T}
CDDPolyhedron{N, T}(CDDGeneratorMatrix{N, T, mytype(T)}(sympoints, points, lines, rays))
end
CDDPolyhedron{N, T}(hits::Polyhedra.HIt{N, T}...) where {N, T} = CDDPolyhedron{N, T}(CDDInequalityMatrix{N, T, mytype(T)}(hits...))
CDDPolyhedron{N, T}(vits::Polyhedra.VIt{N, T}...) where {N, T} = CDDPolyhedron{N, T}(CDDGeneratorMatrix{N, T, mytype(T)}(vits...))

function hrepiscomputed(p::CDDPolyhedron)
!isnull(p.ine)
Expand Down

0 comments on commit d53ac19

Please sign in to comment.