-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75ff6ab
commit 72c1ceb
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from fractions import Fraction | ||
|
||
import cdd.gmp | ||
|
||
arr = [ | ||
[-Fraction(1, 20), 0, 0, 1, 0], | ||
[Fraction(3, 2), 0, 0, -1, 0], | ||
[0, 0, -Fraction(1, 3), -Fraction(32, 30), -Fraction(2, 3)], | ||
[0, 0, 1, 0, 0], | ||
[0, 0, 0, 0, 1], | ||
[0, -1, 0, Fraction(3, 10), 1], | ||
[0, 1, Fraction(2, 3), Fraction(16, 30), Fraction(1, 3)], | ||
[0, 1, 0, 0, 0], | ||
] | ||
|
||
|
||
def test_empty_v_rep() -> None: | ||
mat = cdd.gmp.matrix_from_array(arr, rep_type=cdd.RepType.INEQUALITY) | ||
lin_set, red_set, indices = cdd.gmp.matrix_canonicalize(mat) | ||
assert lin_set == {0, 1, 2, 3, 4, 5, 6, 7} | ||
assert not red_set | ||
assert indices == [0, 1, 2, 3, None, 4, None, None] | ||
assert mat.lin_set == {0, 1, 2, 3, 4} | ||
poly = cdd.gmp.polyhedron_from_matrix(mat) | ||
v_rep = cdd.gmp.copy_output(poly) | ||
assert not v_rep.array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import cdd | ||
|
||
arr = [ | ||
[-0.05, -0.0, -0.0, 1.0, -0.0], | ||
[1.5, -0.0, -0.0, -1.0, -0.0], | ||
[0.0, -0.0, -0.3333333333333333, -1.0666666666666667, -0.6666666666666666], | ||
[0.0, -0.0, 1.0, -0.0, -0.0], | ||
[0.0, -0.0, -0.0, -0.0, 1.0], | ||
[0.0, -1.0, -0.0, 0.3, 1.0], | ||
[0.0, 1.0, 0.6666666666666666, 0.5333333333333333, 0.3333333333333333], | ||
[0.0, 1.0, -0.0, -0.0, -0.0], | ||
] | ||
|
||
|
||
def test_empty_v_rep() -> None: | ||
mat = cdd.matrix_from_array(arr, rep_type=cdd.RepType.INEQUALITY) | ||
lin_set, red_set, indices = cdd.matrix_canonicalize(mat) | ||
assert lin_set == {0, 1, 2, 3, 4, 5, 6, 7} | ||
assert not red_set | ||
assert indices == [0, 1, 2, 3, None, 4, None, None] | ||
assert mat.lin_set == {0, 1, 2, 3, 4} | ||
poly = cdd.polyhedron_from_matrix(mat) | ||
v_rep = cdd.copy_output(poly) | ||
assert not v_rep.array |