Skip to content

Commit

Permalink
Halfspace/Hyperplane: use Polymake.Vector instead of Matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
benlorenz committed Oct 1, 2021
1 parent 89b6e25 commit dbe9164
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Polytopes/Polyhedron/properties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -770,9 +770,9 @@ julia> print_constraints(cube(3))
"""
print_constraints(P::Polyhedron; trivial::Bool = false, io::IO = stdout) = print_constraints(halfspace_matrix_pair(facets(P))...; trivial = trivial, io = io)
print_constraints(H::Halfspace; trivial::Bool = false, io::IO = stdout) = print_constraints(H.a, [H.b]; trivial = trivial, io = io)
print_constraints(H::Halfspace; trivial::Bool = false, io::IO = stdout) = print_constraints(vcat(H.a'), [H.b]; trivial = trivial, io = io)
print_constraints(H::Hyperplane; trivial::Bool = false, io::IO = stdout) = print_constraints(H.a, [H.b]; trivial = trivial, io = io, cmp = "=")
print_constraints(H::Hyperplane; trivial::Bool = false, io::IO = stdout) = print_constraints(vcat(H.a'), [H.b]; trivial = trivial, io = io, cmp = "=")
function Base.show(io::IO, H::Halfspace)
n = length(H.a)
Expand Down
8 changes: 4 additions & 4 deletions src/Polytopes/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ One halfspace `H(a,b)` is given by a vector `a` and a value `b` such that
$$H(a,b) = \{ x | ax ≤ b \}.$$
"""
struct Halfspace
a::Polymake.Matrix{Polymake.Rational}
a::Polymake.Vector{Polymake.Rational}
b::Polymake.Rational
end

Halfspace(a::AbstractVector, b) = Halfspace(reshape(a, 1, :), b)
Halfspace(a::Union{MatElem, AbstractMatrix}, b=0) = Halfspace(vec(a), b)

Halfspace(a) = Halfspace(a, 0)

Expand All @@ -104,11 +104,11 @@ One hyperplane `H(a,b)` is given by a vector `a` and a value `b` such that
$$H(a,b) = \{ x | ax = b \}.$$
"""
struct Hyperplane
a::Polymake.Matrix{Polymake.Rational}
a::Polymake.Vector{Polymake.Rational}
b::Polymake.Rational
end

Hyperplane(a::AbstractVector, b) = Hyperplane(reshape(a, 1, :), b)
Hyperplane(a::Union{MatElem, AbstractMatrix}, b) = Hyperplane(vec(a), b)

Hyperplane(a) = Hyperplane(a, 0)

Expand Down
4 changes: 2 additions & 2 deletions test/Polytopes/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@

@test A != B

@test A.a == a'
@test A.a == a
@test A.b == 0

@test B.a == b'
@test B.a == b
@test B.b == 2

end
Expand Down

0 comments on commit dbe9164

Please sign in to comment.