Skip to content

Commit 683a7d3

Browse files
committed
introduce halfspace_matrix_pair(ZZ, ...)
1 parent 766e1b3 commit 683a7d3

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Diff for: src/PolyhedralGeometry/type_functions.jl

+37
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,43 @@ function halfspace_matrix_pair(
6363
end
6464
end
6565

66+
function halfspace_matrix_pair(
67+
R::ZZRing,
68+
iter::SubObjectIterator{
69+
<:Union{
70+
Halfspace{QQFieldElem},
71+
Hyperplane{QQFieldElem},
72+
Polyhedron{QQFieldElem},
73+
Cone{QQFieldElem},
74+
Pair{Matrix{QQFieldElem},QQFieldElem},
75+
}
76+
};
77+
integral_bias::Bool=true,
78+
)
79+
if integral_bias
80+
try
81+
h = Polymake.common.primitive(affine_matrix_for_polymake(iter))
82+
return (A=matrix(ZZ, h[:, 2:end]), b=[ZZ(x) for x in -h[:, 1]])
83+
catch e
84+
throw(ArgumentError("Halfspace-Matrix-Pair not defined in this context."))
85+
end
86+
else
87+
try
88+
h = affine_matrix_for_polymake(iter)
89+
hm = Polymake.common.primitive(h[:, 2:end])
90+
bv = Vector{QQFieldElem}(undef, size(hm, 1))
91+
for i in 1:size(hm, 1)
92+
j = findfirst(!is_zero, hm[i, :])
93+
r = hm[i, j]//h[i, j + 1]
94+
bv[i] = -QQ(h[i, 1] * r)
95+
end
96+
return (A=matrix(ZZ, hm), b=bv)
97+
catch e
98+
throw(ArgumentError("Halfspace-Matrix-Pair not defined in this context."))
99+
end
100+
end
101+
end
102+
66103
for fun in (cones, faces, facets, maximal_cones, maximal_polyhedra, rays, vertices)
67104
F = Symbol(fun)
68105
@eval $F(::Type{IncidenceMatrix}, x...) = IncidenceMatrix($F(x...))

0 commit comments

Comments
 (0)