@@ -37,7 +37,45 @@ Double description method revisited
3737"""
3838function doubledescription end
3939
40- function doubledescription (h:: HRepresentation )
40+ function print_v_summary (v:: VRep )
41+ print (" $(npoints (v)) points, $(nrays (v)) rays and $(nlines (v)) lines" )
42+ end
43+
44+ function intersect_and_remove_redundancy (v, hs, h; verbose= 0 )
45+ if eltype (hs) <: HalfSpace
46+ str = " halfspace"
47+ else
48+ str = " hyperplane"
49+ end
50+ for (i, hel) in enumerate (hs)
51+ if verbose >= 1
52+ println (" Intersecting $str $i /$(length (hs)) " )
53+ end
54+ v_int = v ∩ hel
55+ if verbose >= 3
56+ print (" Removing duplicates: " )
57+ print_v_summary (v_int)
58+ println (" ." )
59+ end
60+ # removeduplicates is cheaper than removevredundancy since the latter
61+ # needs to go through all the hrep element
62+ v_dup = removeduplicates (v_int)
63+ if verbose >= 3
64+ print (" Removing redundancy: " )
65+ print_v_summary (v_dup)
66+ println (" ." )
67+ end
68+ v = removevredundancy (v_dup, h)
69+ if verbose >= 2
70+ print (" After intersection: " )
71+ print_v_summary (v)
72+ println (" ." )
73+ end
74+ end
75+ return v
76+ end
77+
78+ function doubledescription (h:: HRepresentation ; kws... )
4179 # The redundancy of V-elements are measured using
4280 # the number of hyperplane they are in. If there are
4381 # redundant hyperplanes, it does not matter since no point
@@ -49,27 +87,15 @@ function doubledescription(h::HRepresentation)
4987 h = removeduplicates (h)
5088 v = dualfullspace (h)
5189 checkvconsistency (v)
52- for hp in hyperplanes (h)
53- # v = removeduplicates(v ∩ hel)
54- # removeduplicates is cheaper than removevredundancy since the latter
55- # needs to go through all the hrep element
56- v = removevredundancy (removeduplicates (v ∩ hp), h)
57- # v = removevredundancy(v ∩ hel, h)
58- end
59- for hs in halfspaces (h)
60- # v = removeduplicates(v ∩ hel)
61- # removeduplicates is cheaper than removevredundancy since the latter
62- # needs to go through all the hrep element
63- v = removevredundancy (removeduplicates (v ∩ hs), h)
64- # v = removevredundancy(v ∩ hel, h)
65- end
66- v
90+ v = intersect_and_remove_redundancy (v, hyperplanes (h), h; kws... )
91+ v = intersect_and_remove_redundancy (v, halfspaces (h), h; kws... )
92+ return v
6793end
6894
69- function doubledescription (v:: VRepresentation{T} ) where {T}
95+ function doubledescription (v:: VRepresentation{T} ; kws ... ) where {T}
7096 checkvconsistency (v)
7197 lv = convert (LiftedVRepresentation{T, Matrix{T}}, v)
7298 R = - lv. R
73- vl = doubledescription (MixedMatHRep {T} (R, zeros (T, size (R, 1 )), lv. linset))
99+ vl = doubledescription (MixedMatHRep {T} (R, zeros (T, size (R, 1 )), lv. linset); kws ... )
74100 LiftedHRepresentation {T} (vl. R, vl. Rlinset)
75101end
0 commit comments