3 This file is part of PolyLib.
5 PolyLib is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 PolyLib is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with PolyLib. If not, see <http://www.gnu.org/licenses/>.
20 #include <polylib/polylib.h>
28 Matrix
*a
=NULL
, *b
=NULL
, *c
, *d
, *e
, *f
;
29 Polyhedron
*A
, *B
, *C
, *D
, *last
, *tmp
;
30 int i
, nbPol
, nbMat
, func
;
35 ((sscanf(s
, "D %d", &nbPol
)<1) && (sscanf(s
, "M %d", &nbMat
)<1)) )
38 for (i
=0, A
=last
=(Polyhedron
*)0; i
<nbPol
; i
++) {
40 tmp
= Constraints2Polyhedron(a
,WS
);
42 if (!last
) A
= last
= tmp
;
50 { a
= Matrix_Read(); }
55 ((sscanf(s
, "D %d", &nbPol
)<1) && (sscanf(s
, "M %d", &nbMat
)<1)) )
58 for (i
=0, B
=last
=(Polyhedron
*)0; i
<nbPol
; i
++) {
60 tmp
= Constraints2Polyhedron(b
,WS
);
62 if (!last
) B
= last
= tmp
;
70 { b
= Matrix_Read(); }
73 while ((*s
=='#') || (sscanf(s
, "F %d", &func
)<1))
78 C
= DomainUnion(A
, B
, WS
);
79 D
= DomainConvex(C
, WS
);
80 d
= Polyhedron2Constraints(D
);
81 Matrix_Print(stdout
,P_VALUE_FMT
,d
);
87 D
= DomainSimplify(A
, B
, WS
);
88 d
= Polyhedron2Constraints(D
);
89 Matrix_Print(stdout
,P_VALUE_FMT
,d
);
94 a
= Polyhedron2Constraints(A
);
95 Matrix_Print(stdout
,P_VALUE_FMT
,a
);
96 b
= Polyhedron2Constraints(B
);
97 Matrix_Print(stdout
,P_VALUE_FMT
,b
);
100 a
= Polyhedron2Rays(A
);
101 Matrix_Print(stdout
,P_VALUE_FMT
,a
);
105 /* a = ec , da = c , ed = 1 */
106 right_hermite(a
,&c
,&d
,&e
);
107 Matrix_Print(stdout
,P_VALUE_FMT
,c
);
108 Matrix_Print(stdout
,P_VALUE_FMT
,d
);
109 Matrix_Print(stdout
,P_VALUE_FMT
,e
);
110 f
= Matrix_Alloc(e
->NbRows
,c
->NbColumns
);
111 Matrix_Product(e
,c
,f
);
112 Matrix_Print(stdout
,P_VALUE_FMT
,f
);
114 f
= Matrix_Alloc(d
->NbRows
,a
->NbColumns
);
115 Matrix_Product(d
,a
,f
);
116 Matrix_Print(stdout
,P_VALUE_FMT
,f
);
118 f
= Matrix_Alloc(e
->NbRows
, d
->NbColumns
);
119 Matrix_Product(e
,d
,f
);
120 Matrix_Print(stdout
,P_VALUE_FMT
,f
);
124 /* a = ce , ad = c , de = 1 */
125 left_hermite(a
,&c
,&d
,&e
);
126 Matrix_Print(stdout
,P_VALUE_FMT
,c
);
127 Matrix_Print(stdout
,P_VALUE_FMT
,d
);
128 Matrix_Print(stdout
,P_VALUE_FMT
,e
);
129 f
= Matrix_Alloc(c
->NbRows
, e
->NbColumns
);
130 Matrix_Product(c
,e
,f
);
131 Matrix_Print(stdout
,P_VALUE_FMT
,f
);
133 f
= Matrix_Alloc(a
->NbRows
, d
->NbColumns
);
134 Matrix_Product(a
,d
,f
);
135 Matrix_Print(stdout
,P_VALUE_FMT
,f
);
137 f
= Matrix_Alloc(d
->NbRows
, e
->NbColumns
);
138 Matrix_Product(d
,e
,f
);
139 Matrix_Print(stdout
,P_VALUE_FMT
,f
);
143 /* Polyhedron_Print(stdout,"%5d", A); */
144 /* Matrix_Print(stdout,"%4d", b); */
146 C
= Polyhedron_Image(A
, b
, WS
);
147 Polyhedron_Print(stdout
,P_VALUE_FMT
,C
);
152 Polyhedron_Not_Empty(A
,B
,WS
) ? "Not Empty" : "Empty");
156 i
= PolyhedronLTQ(A
,B
,1,0,WS
);
158 i
==-1 ? "A<B" : i
==1 ? "A>B" : i
==0 ? "A><B" : "error");
159 i
= PolyhedronLTQ(B
,A
,1,0,WS
);
161 i
==-1 ? "A<B" : i
==1 ? "A>B" : i
==0 ? "A><B" : "error");
164 i
= GaussSimplify(a
,b
);
165 Matrix_Print(stdout
,P_VALUE_FMT
,b
);
169 printf("? unknown function\n");