Skip to content

Commit

Permalink
Add matrix append
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Mar 22, 2016
1 parent 353c1b6 commit aefc8d4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
16 changes: 16 additions & 0 deletions src/operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ function Base.push!{N, T<:MyType,S<:Real}(poly::CDDPolyhedra{N, T}, desc::Repres
Base.push!(poly, convert(CDDMatrix{N, T}, desc))
end

function dd_matrixappend(matrix1::Ptr{Cdd_MatrixData{Cdouble}}, matrix2::Ptr{Cdd_MatrixData{Cdouble}})
@ddf_ccall MatrixAppend Ptr{Cdd_MatrixData{Cdouble}} (Ptr{Cdd_MatrixData{Cdouble}}, Ptr{Cdd_MatrixData{Cdouble}}) matrix1 matrix2
end
function dd_matrixappend(matrix1::Ptr{Cdd_MatrixData{GMPRational}}, matrix2::Ptr{Cdd_MatrixData{GMPRational}})
@dd_ccall MatrixAppend Ptr{Cdd_MatrixData{GMPRational}} (Ptr{Cdd_MatrixData{GMPRational}}, Ptr{Cdd_MatrixData{GMPRational}}) matrix1 matrix2
end
function matrixappend{N, T}(matrix1::CDDInequalityMatrix{N, T}, matrix2::CDDInequalityMatrix{N, T})
CDDInequalityMatrix{N, T}(dd_matrixappend(matrix1.matrix, matrix2.matrix))
end
function matrixappend{N, T}(matrix1::CDDGeneratorMatrix{N, T}, matrix2::CDDGeneratorMatrix{N, T})
CDDGeneratorMatrix{N, T}(dd_matrixappend(matrix1.matrix, matrix2.matrix))
end
function matrixappend{N, S, T}(matrix::CDDMatrix{N, T}, repr::Representation{S})
matrixappend(matrix, convert(CDDMatrix{N, T}, repr))
end

# Redundant
function dd_redundant(matrix::Ptr{Cdd_MatrixData{Cdouble}}, i::Cdd_rowrange, len::Int)
err = Ref{Cdd_ErrorType}(0)
Expand Down
10 changes: 6 additions & 4 deletions src/polyhedron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,14 @@ function removeredundantgenerators!(p::CDDPolyhedron)
end

function Base.push!(p::CDDPolyhedron, ine::HRepresentation)
push!(getpoly(p, true), ine)
updatepoly!(p, getpoly(p)) # invalidate others
updateine!(p, matrixappend(getine(p), ine))
#push!(getpoly(p, true), ine) # too slow because it computes double description
#updatepoly!(p, getpoly(p)) # invalidate others
end
function Base.push!(p::CDDPolyhedron, ext::VRepresentation)
push!(getpoly(p, false), ext)
updatepoly!(p, getpoly(p)) # invalidate others
updateext!(p, matrixappend(getext(p), ext))
#push!(getpoly(p, false), ext) # too slow because it computes double description
#updatepoly!(p, getpoly(p)) # invalidate others
end

function isredundantinequality(p::CDDPolyhedron, i::Integer)
Expand Down

0 comments on commit aefc8d4

Please sign in to comment.