polylib: pp.c Source File

- Main Page
- Classes
- Files

- File List
- File Members

# pp.c

Go to the documentation of this file.

    00001 /*
    00002     This file is part of PolyLib.
    00003
    00004     PolyLib is free software: you can redistribute it and/or modify
    00005     it under the terms of the GNU General Public License as published by
    00006     the Free Software Foundation, either version 3 of the License, or
    00007     (at your option) any later version.
    00008
    00009     PolyLib is distributed in the hope that it will be useful,
    00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012     GNU General Public License for more details.
    00013
    00014     You should have received a copy of the GNU General Public License
    00015     along with PolyLib.  If not, see <http://www.gnu.org/licenses/>.
    00016 */
    00017
    00018 #include <stdio.h>
    00019 #include <stdlib.h>
    00020
    00021 #include <polylib/polylib.h>
    00022
    00023 #define WS 0
    00024
    00025 int main() {
    00026
    00027   Matrix *a, *b;
    00028   Polyhedron *A, *B;
    00029   Param_Polyhedron *PA;
    00030   Param_Domain *P;
    00031   Param_Vertices *V;
    00032   int nbPV, i, j;
    00033   const char **param_name;
    00034
    00035   a = Matrix_Read();
    00036   if(!a || a->NbColumns == 0) {
    00037     fprintf(stderr,"Input error: empty matrix\n");
    00038     exit(0);
    00039   }
    00040   A = Constraints2Polyhedron(a, WS);
    00041   Matrix_Free(a);
    00042   b = Matrix_Read();
    00043
    00044   if(!b || b->NbColumns == 0) {
    00045     fprintf(stderr, "Input error: empty matrix\n");
    00046     exit(0);
    00047   }
    00048   B = Constraints2Polyhedron(b, WS);
    00049   Matrix_Free(b);
    00050
    00051   /* Read the name of the parameters */
    00052   param_name = Read_ParamNames(stdin, B->Dimension);
    00053   PA = Polyhedron2Param_Domain(A,B,WS);
    00054   if(!PA || PA->D==NULL) {
    00055     printf("---------------------------------------\n");
    00056     printf("Empty polyhedron\n");
    00057     return 0;
    00058   }
    00059   nbPV = PA->nbV;
    00060   Domain_Free(A);
    00061   Domain_Free(B);
    00062
    00063   if (PA->Rays->NbRows > 0) {
    00064     printf( "---------------------------------------\n" );
    00065     printf( "Overall rays :\n");
    00066     for (i = 0; i < PA->Rays->NbRows; i++) {
    00067       if (value_zero_p(PA->Rays->p[i][0]))
    00068         printf("Line:   [");
    00069       else
    00070         printf("Ray:    [");
    00071       for (j = 1; j < PA->Rays->NbColumns-1; j++) {
    00072         value_print(stdout,P_VALUE_FMT,PA->Rays->p[i][j]);
    00073       }
    00074       printf(" ]\n");
    00075     }
    00076   }
    00077
    00078   /*****************************/
    00079   /* Scan the validity domains */
    00080   for(P=PA->D;P;P=P->next) {
    00081
    00082     /* prints current val. dom. */
    00083     printf( "---------------------------------------\n" );
    00084     printf( "Domain :\n");
    00085     Print_Domain( stdout, P->Domain, param_name );
    00086
    00087     /* scan the vertices */
    00088     printf( "Vertices :\n");
    00089     FORALL_PVertex_in_ParamPolyhedron(V,P,PA) {
    00090
    00091       /* prints each vertex */
    00092       Print_Vertex( stdout, V->Vertex, param_name );
    00093       printf( "\n" );
    00094     }
    00095     END_FORALL_PVertex_in_ParamPolyhedron;
    00096   }
    00097   /*****************************/
    00098
    00099   Param_Polyhedron_Free( PA );
    00100   free(param_name);
    00101
    00102   return 0;
    00103 } /* main */
    00104