Skip to content

Commit 14a1ad8

Browse files
committed
Improve printing
1 parent 13add33 commit 14a1ad8

File tree

1 file changed

+41
-27
lines changed

1 file changed

+41
-27
lines changed

src/doubledescription.jl

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,45 @@ Double description method revisited
3737
"""
3838
function doubledescription end
3939

40-
function doubledescription(h::HRepresentation; verbose=0)
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,32 +87,8 @@ function doubledescription(h::HRepresentation; verbose=0)
4987
h = removeduplicates(h)
5088
v = dualfullspace(h)
5189
checkvconsistency(v)
52-
for (i, hp) in enumerate(hyperplanes(h))
53-
if verbose >= 1
54-
println("Intersecting hyperplane $i/$(nhyperplanes(h))")
55-
end
56-
#v = removeduplicates(v ∩ hel)
57-
# removeduplicates is cheaper than removevredundancy since the latter
58-
# needs to go through all the hrep element
59-
v = removevredundancy(removeduplicates(v hp), h)
60-
#v = removevredundancy(v ∩ hel, h)
61-
if verbose >= 2
62-
println("After intersection: $(npoints(v)) points, $(nrays(v)) rays and $(nlines(v)) lines.")
63-
end
64-
end
65-
for (i, hs) in enumerate(halfspaces(h))
66-
if verbose >= 1
67-
println("Intersecting halfspace $i/$(nhalfspaces(h))")
68-
end
69-
#v = removeduplicates(v ∩ hel)
70-
# removeduplicates is cheaper than removevredundancy since the latter
71-
# needs to go through all the hrep element
72-
v = removevredundancy(removeduplicates(v hs), h)
73-
#v = removevredundancy(v ∩ hel, h)
74-
if verbose >= 2
75-
println("After intersection: $(npoints(v)) points, $(nrays(v)) rays and $(nlines(v)) lines.")
76-
end
77-
end
90+
v = intersect_and_remove_redundancy(v, hyperplanes(h), h; kws...)
91+
v = intersect_and_remove_redundancy(v, halfspaces(h), h; kws...)
7892
return v
7993
end
8094

0 commit comments

Comments
 (0)