Merge ssh://repo.or.cz/srv/git/polylib
[polylib.git] / applications / example.c
blob87a815a1b8ba9c7974714f4b0be922ecb165a111
2 /*
3 main.c
4 This file along with Zpolyhedron.c, polyhedron.c, Lattice.c,
5 Matop.c SolveDio.c, matrix.c and vector.c does the following :
7 - Intersection of two Z-Domains.
8 - Difference of two Z-domains.
9 - Image of a Z-domain by a invertible,
10 affine rational function.
13 This file is part of PolyLib.
15 PolyLib is free software: you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
20 PolyLib is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with PolyLib. If not, see <http://www.gnu.org/licenses/>.
30 #include <polylib/polylib.h>
32 int main () {
34 Matrix *a, *b;
35 Polyhedron *P;
36 ZPolyhedron *Z1, *Z2, *Z3, *Z4;
38 a = Matrix_Read ();
39 b = Matrix_Read ();
40 P = Constraints2Polyhedron (b, 200);
41 Z1 = ZPolyhedron_Alloc (a, P);
43 Matrix_Free (a);
44 Matrix_Free (b);
45 Domain_Free (P);
47 a = Matrix_Read ();
48 b = Matrix_Read ();
49 P = Constraints2Polyhedron (b, 200);
50 Z2 = ZPolyhedron_Alloc (a, P);
52 Matrix_Free (a);
53 Matrix_Free (b);
54 Domain_Free (P);
56 Z3 = ZDomainIntersection (Z1, Z2);
57 printf ("\nZ3 = Z1 and Z2");
58 ZDomainPrint(stdout,P_VALUE_FMT, Z3);
60 a = Matrix_Read ();
61 Z4 = ZDomainImage (Z1, a);
62 printf ("\nZ4 = image (Z1 by a)");
63 ZDomainPrint (stdout,P_VALUE_FMT, Z4);
65 Matrix_Free (a);
66 ZDomain_Free (Z1);
67 ZDomain_Free (Z2);
68 ZDomain_Free (Z3);
69 ZDomain_Free (Z4);
71 return 0;
72 } /* main */