Merge ssh://repo.or.cz/srv/git/polylib
[polylib.git] / applications / pp.c
blob5279150ee635c94d06c2dc178f712b0775f5c33a
1 /*
2 This file is part of PolyLib.
4 PolyLib is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 PolyLib is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with PolyLib. If not, see <http://www.gnu.org/licenses/>.
18 #include <stdio.h>
19 #include <stdlib.h>
21 #include <polylib/polylib.h>
23 #define WS 0
25 int main() {
27 Matrix *a, *b;
28 Polyhedron *A, *B;
29 Param_Polyhedron *PA;
30 Param_Domain *P;
31 Param_Vertices *V;
32 int nbPV, i, j;
33 const char **param_name;
35 a = Matrix_Read();
36 if(!a || a->NbColumns == 0) {
37 fprintf(stderr,"Input error: empty matrix\n");
38 exit(0);
40 A = Constraints2Polyhedron(a, WS);
41 Matrix_Free(a);
42 b = Matrix_Read();
44 if(!b || b->NbColumns == 0) {
45 fprintf(stderr, "Input error: empty matrix\n");
46 exit(0);
48 B = Constraints2Polyhedron(b, WS);
49 Matrix_Free(b);
51 /* Read the name of the parameters */
52 param_name = Read_ParamNames(stdin, B->Dimension);
53 PA = Polyhedron2Param_Domain(A,B,WS);
54 if(!PA || PA->D==NULL) {
55 printf("---------------------------------------\n");
56 printf("Empty polyhedron\n");
57 return 0;
59 nbPV = PA->nbV;
60 Domain_Free(A);
61 Domain_Free(B);
63 if (PA->Rays->NbRows > 0) {
64 printf( "---------------------------------------\n" );
65 printf( "Overall rays :\n");
66 for (i = 0; i < PA->Rays->NbRows; i++) {
67 if (value_zero_p(PA->Rays->p[i][0]))
68 printf("Line: [");
69 else
70 printf("Ray: [");
71 for (j = 1; j < PA->Rays->NbColumns-1; j++) {
72 value_print(stdout,P_VALUE_FMT,PA->Rays->p[i][j]);
74 printf(" ]\n");
78 /*****************************/
79 /* Scan the validity domains */
80 for(P=PA->D;P;P=P->next) {
82 /* prints current val. dom. */
83 printf( "---------------------------------------\n" );
84 printf( "Domain :\n");
85 Print_Domain( stdout, P->Domain, param_name );
87 /* scan the vertices */
88 printf( "Vertices :\n");
89 FORALL_PVertex_in_ParamPolyhedron(V,P,PA) {
91 /* prints each vertex */
92 Print_Vertex( stdout, V->Vertex, param_name );
93 printf( "\n" );
95 END_FORALL_PVertex_in_ParamPolyhedron;
97 /*****************************/
99 Param_Polyhedron_Free( PA );
100 free(param_name);
102 return 0;
103 } /* main */