polylib: disjoint_union_sep.c Source File

- Main Page
- Classes
- Files

- File List
- File Members

# disjoint_union_sep.c

Go to the documentation of this file.

    00001 /*       Polyhedron disjoint intersections
    00002  */
    00003 /*
    00004     This file is part of PolyLib.
    00005
    00006     PolyLib is free software: you can redistribute it and/or modify
    00007     it under the terms of the GNU General Public License as published by
    00008     the Free Software Foundation, either version 3 of the License, or
    00009     (at your option) any later version.
    00010
    00011     PolyLib is distributed in the hope that it will be useful,
    00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00014     GNU General Public License for more details.
    00015
    00016     You should have received a copy of the GNU General Public License
    00017     along with PolyLib.  If not, see <http://www.gnu.org/licenses/>.
    00018 */
    00019
    00020
    00021 /*
    00022  disjoint_union_sep computes the disjoint union of the given list of domains.
    00023  input:
    00024     (integer) # of polyhedra
    00025     list of polyhedra in the usual matrix (constraints) format
    00026
    00027  output:
    00028     list of polyhedra (constraint matrices) having no integer point in common
    00029 */
    00030
    00031 #include <stdio.h>
    00032 #include <stdlib.h>
    00033
    00034 #include <polylib/polylib.h>
    00035
    00036 #define WS 0
    00037
    00038
    00039 /* Procedure to print constraints of a domain */
    00040 void AffContraintes(Polyhedron *p)
    00041 {
    00042         for( ;p;p=p->next)
    00043         {
    00044                 Polyhedron_PrintConstraints(stdout, P_VALUE_FMT, p );
    00045                 printf("\n");
    00046         }
    00047 }
    00048
    00049
    00050 int main() {
    00051
    00052         int np, i;
    00053
    00054         Matrix *a;
    00055         Polyhedron *A, *tmp, *DD;
    00056
    00057         scanf( "%d", &np );
    00058
    00059         A = NULL;
    00060         for( i=0 ; i<np ; i++ )
    00061         {
    00062                 a = Matrix_Read();
    00063                 tmp = Constraints2Polyhedron(a,WS);
    00064                 Matrix_Free(a);
    00065                 tmp ->next = A;
    00066                 A = tmp;
    00067         }
    00068
    00069
    00070         DD = Disjoint_Domain( A, 0, WS );
    00071
    00072         AffContraintes(DD);
    00073
    00074         Domain_Free( DD );
    00075         Domain_Free( A );
    00076
    00077         return 0;
    00078 }
    00079
    00080
    00081