1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
2 <html><head><meta http-equiv=
"Content-Type" content=
"text/html;charset=iso-8859-1">
3 <title>polytest.c Source File
</title>
4 <link href=
"doxygen.css" rel=
"stylesheet" type=
"text/css">
6 <!-- Generated by Doxygen 1.2.15 -->
8 <a class=
"qindex" href=
"main.html">Main Page
</a> <a class=
"qindex" href=
"annotated.html">Compound List
</a> <a class=
"qindex" href=
"files.html">File List
</a> <a class=
"qindex" href=
"functions.html">Compound Members
</a> <a class=
"qindex" href=
"globals.html">File Members
</a> </center>
9 <hr><h1>polytest.c
</h1><a href=
"polytest_8c.html">Go to the documentation of this file.
</a><div class=
"fragment"><pre>00001 <font class=
"comment">/* polytest.c */
</font>
10 00002 <font class=
"preprocessor">#include
<stdio.h
></font>
11 00003 <font class=
"preprocessor">#include
<polylib/polylib.h
></font>
14 <a name=
"l00006"></a><a class=
"code" href=
"polytest_8c.html#a0">00006</a> <font class=
"keywordtype">char
</font> <a class=
"code" href=
"polytest_8c.html#a0">s
</a>[
128];
16 <a name=
"l00008"></a><a class=
"code" href=
"polytest_8c.html#a1">00008</a> <font class=
"keywordtype">int
</font> <a class=
"code" href=
"c2p_8c.html#a1">main
</a>() {
18 00010 Matrix *a=NULL, *b=NULL, *c, *d, *e, *f;
19 00011 Polyhedron *A, *B, *C, *D, *last, *tmp;
20 00012 <font class=
"keywordtype">int
</font> i, nbPol, nbMat, func;
22 00014 fgets(
<a class=
"code" href=
"polytest_8c.html#a0">s
</a>,
128, stdin);
23 00015 nbPol = nbMat =
0;
24 00016 <font class=
"keywordflow">while
</font> ((*
<a class=
"code" href=
"polytest_8c.html#a0">s
</a>==
<font class=
"charliteral">'#'
</font>) ||
25 00017 ((sscanf(
<a class=
"code" href=
"polytest_8c.html#a0">s
</a>,
<font class=
"stringliteral">"D %d"</font>,
&nbPol)
<1)
&& (sscanf(
<a class=
"code" href=
"polytest_8c.html#a0">s
</a>,
<font class=
"stringliteral">"M %d"</font>,
&nbMat)
<1)) )
26 00018 fgets(
<a class=
"code" href=
"polytest_8c.html#a0">s
</a>,
128, stdin);
28 00020 <font class=
"keywordflow">for
</font> (i=
0, A=last=(Polyhedron *)
0; i
<nbPol; i++) {
29 00021 a =
<a class=
"code" href=
"matrix_8c.html#a4">Matrix_Read
</a>();
30 00022 tmp =
<a class=
"code" href=
"polyhedron_8c.html#a24">Constraints2Polyhedron
</a>(a,
600);
31 00023 <a class=
"code" href=
"matrix_8c.html#a1">Matrix_Free
</a>(a);
32 00024 <font class=
"keywordflow">if
</font> (!last) A = last = tmp;
33 00025 <font class=
"keywordflow">else
</font> {
34 00026 last-
>next = tmp;
39 00031 <font class=
"keywordflow">if
</font> (nbMat)
40 00032 { a =
<a class=
"code" href=
"matrix_8c.html#a4">Matrix_Read
</a>(); }
42 00034 fgets(
<a class=
"code" href=
"polytest_8c.html#a0">s
</a>,
128,stdin);
43 00035 nbPol = nbMat =
0;
44 00036 <font class=
"keywordflow">while
</font> ( (*
<a class=
"code" href=
"polytest_8c.html#a0">s
</a>==
<font class=
"charliteral">'#'
</font>) ||
45 00037 ((sscanf(
<a class=
"code" href=
"polytest_8c.html#a0">s
</a>,
<font class=
"stringliteral">"D %d"</font>,
&nbPol)
<1)
&& (sscanf(
<a class=
"code" href=
"polytest_8c.html#a0">s
</a>,
<font class=
"stringliteral">"M %d"</font>,
&nbMat)
<1)) )
46 00038 fgets(
<a class=
"code" href=
"polytest_8c.html#a0">s
</a>,
128, stdin);
48 00040 <font class=
"keywordflow">for
</font> (i=
0, B=last=(Polyhedron *)
0; i
<nbPol; i++) {
49 00041 b =
<a class=
"code" href=
"matrix_8c.html#a4">Matrix_Read
</a>();
50 00042 tmp =
<a class=
"code" href=
"polyhedron_8c.html#a24">Constraints2Polyhedron
</a>(b,
200);
51 00043 <a class=
"code" href=
"matrix_8c.html#a1">Matrix_Free
</a>(b);
52 00044 <font class=
"keywordflow">if
</font> (!last) B = last = tmp;
53 00045 <font class=
"keywordflow">else
</font> {
54 00046 last-
>next = tmp;
59 00051 <font class=
"keywordflow">if
</font> (nbMat)
60 00052 { b =
<a class=
"code" href=
"matrix_8c.html#a4">Matrix_Read
</a>(); }
62 00054 fgets(
<a class=
"code" href=
"polytest_8c.html#a0">s
</a>,
128, stdin);
63 00055 <font class=
"keywordflow">while
</font> ((*
<a class=
"code" href=
"polytest_8c.html#a0">s
</a>==
<font class=
"charliteral">'#'
</font>) || (sscanf(
<a class=
"code" href=
"polytest_8c.html#a0">s
</a>,
<font class=
"stringliteral">"F %d"</font>,
&func)
<1))
64 00056 fgets(
<a class=
"code" href=
"polytest_8c.html#a0">s
</a>,
128, stdin);
66 00058 <font class=
"keywordflow">switch
</font> (func) {
67 00059 <font class=
"keywordflow">case
</font> 1:
68 00060 C =
<a class=
"code" href=
"polyhedron_8c.html#a44">DomainUnion
</a>(A, B,
200);
69 00061 D =
<a class=
"code" href=
"polyhedron_8c.html#a45">DomainConvex
</a>(C,
200);
70 00062 d =
<a class=
"code" href=
"polyhedron_8c.html#a25">Polyhedron2Constraints
</a>(D);
71 00063 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,d);
72 00064 <a class=
"code" href=
"matrix_8c.html#a1">Matrix_Free
</a>(d);
73 00065 <a class=
"code" href=
"polyhedron_8c.html#a19">Domain_Free
</a>(C);
74 00066 <a class=
"code" href=
"polyhedron_8c.html#a19">Domain_Free
</a>(D);
75 00067 <font class=
"keywordflow">break
</font>;
76 00068 <font class=
"keywordflow">case
</font> 2:
77 00069 D =
<a class=
"code" href=
"polyhedron_8c.html#a42">DomainSimplify
</a>(A, B,
200);
78 00070 d =
<a class=
"code" href=
"polyhedron_8c.html#a25">Polyhedron2Constraints
</a>(D);
79 00071 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,d);
80 00072 <a class=
"code" href=
"matrix_8c.html#a1">Matrix_Free
</a>(d);
81 00073 <a class=
"code" href=
"polyhedron_8c.html#a19">Domain_Free
</a>(D);
82 00074 <font class=
"keywordflow">break
</font>;
83 00075 <font class=
"keywordflow">case
</font> 3:
84 00076 a =
<a class=
"code" href=
"polyhedron_8c.html#a25">Polyhedron2Constraints
</a>(A);
85 00077 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,a);
86 00078 b =
<a class=
"code" href=
"polyhedron_8c.html#a25">Polyhedron2Constraints
</a>(B);
87 00079 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,b);
88 00080 <font class=
"keywordflow">break
</font>;
89 00081 <font class=
"keywordflow">case
</font> 4:
90 00082 a =
<a class=
"code" href=
"polyhedron_8c.html#a33">Polyhedron2Rays
</a>(A);
91 00083 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,a);
92 00084 <font class=
"keywordflow">break
</font>;
93 00085 <font class=
"keywordflow">case
</font> 5:
95 00087 <font class=
"comment">/* a = ec , da = c , ed =
1 */
</font>
96 00088 <a class=
"code" href=
"matrix_8c.html#a6">right_hermite
</a>(a,
&c,
&d,
&e);
97 00089 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,c);
98 00090 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,d);
99 00091 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,e);
100 00092 f =
<a class=
"code" href=
"matrix_8c.html#a0">Matrix_Alloc
</a>(e-
>NbRows,c-
>NbColumns);
101 00093 <a class=
"code" href=
"matrix_8c.html#a12">Matrix_Product
</a>(e,c,f);
102 00094 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,f);
103 00095 <a class=
"code" href=
"matrix_8c.html#a1">Matrix_Free
</a>(f);
104 00096 f =
<a class=
"code" href=
"matrix_8c.html#a0">Matrix_Alloc
</a>(d-
>NbRows,a-
>NbColumns);
105 00097 <a class=
"code" href=
"matrix_8c.html#a12">Matrix_Product
</a>(d,a,f);
106 00098 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,f);
107 00099 <a class=
"code" href=
"matrix_8c.html#a1">Matrix_Free
</a>(f);
108 00100 f =
<a class=
"code" href=
"matrix_8c.html#a0">Matrix_Alloc
</a>(e-
>NbRows, d-
>NbColumns);
109 00101 <a class=
"code" href=
"matrix_8c.html#a12">Matrix_Product
</a>(e,d,f);
110 00102 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,f);
111 00103 <font class=
"keywordflow">break
</font>;
112 00104 <font class=
"keywordflow">case
</font> 6:
114 00106 <font class=
"comment">/* a = ce , ad = c , de =
1 */
</font>
115 00107 <a class=
"code" href=
"matrix_8c.html#a7">left_hermite
</a>(a,
&c,
&d,
&e);
116 00108 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,c);
117 00109 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,d);
118 00110 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,e);
119 00111 f =
<a class=
"code" href=
"matrix_8c.html#a0">Matrix_Alloc
</a>(c-
>NbRows, e-
>NbColumns);
120 00112 <a class=
"code" href=
"matrix_8c.html#a12">Matrix_Product
</a>(c,e,f);
121 00113 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,f);
122 00114 <a class=
"code" href=
"matrix_8c.html#a1">Matrix_Free
</a>(f);
123 00115 f =
<a class=
"code" href=
"matrix_8c.html#a0">Matrix_Alloc
</a>(a-
>NbRows, d-
>NbColumns);
124 00116 <a class=
"code" href=
"matrix_8c.html#a12">Matrix_Product
</a>(a,d,f);
125 00117 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,f);
126 00118 <a class=
"code" href=
"matrix_8c.html#a1">Matrix_Free
</a>(f);
127 00119 f =
<a class=
"code" href=
"matrix_8c.html#a0">Matrix_Alloc
</a>(d-
>NbRows, e-
>NbColumns);
128 00120 <a class=
"code" href=
"matrix_8c.html#a12">Matrix_Product
</a>(d,e,f);
129 00121 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,f);
130 00122 <font class=
"keywordflow">break
</font>;
131 00123 <font class=
"keywordflow">case
</font> 7:
133 00125 <font class=
"comment">/* Polyhedron_Print(stdout,
"%5d", A); */
</font>
134 00126 <font class=
"comment">/* Matrix_Print(stdout,
"%4d", b); */
</font>
136 00128 C =
<a class=
"code" href=
"polyhedron_8c.html#a52">Polyhedron_Image
</a>(A, b,
400);
137 00129 <a class=
"code" href=
"polyhedron_8c.html#a20">Polyhedron_Print
</a>(stdout,P_VALUE_FMT,C);
138 00130 <font class=
"keywordflow">break
</font>;
139 00131 <font class=
"keywordflow">case
</font> 8:
141 00133 printf(
<font class=
"stringliteral">"%s\n"</font>,
142 00134 <a class=
"code" href=
"alpha_8c.html#a1">Polyhedron_Not_Empty
</a>(A,B,
600) ?
<font class=
"stringliteral">"Not Empty"</font> :
<font class=
"stringliteral">"Empty"</font>);
143 00135 <font class=
"keywordflow">break
</font>;
144 00136 <font class=
"keywordflow">case
</font> 9:
146 00138 i =
<a class=
"code" href=
"alpha_8c.html#a2">PolyhedronLTQ
</a>(A,B,
1,
0,
600);
147 00139 printf(
<font class=
"stringliteral">"%s\n"</font>,
148 00140 i==-
1 ?
<font class=
"stringliteral">"A<B"</font> : i==
1 ?
<font class=
"stringliteral">"A>B"</font> : i==
0 ?
<font class=
"stringliteral">"A><B"</font> :
<font class=
"stringliteral">"error"</font>);
149 00141 i =
<a class=
"code" href=
"alpha_8c.html#a2">PolyhedronLTQ
</a>(B,A,
1,
0,
600);
150 00142 printf(
<font class=
"stringliteral">"%s\n"</font>,
151 00143 i==-
1 ?
<font class=
"stringliteral">"A<B"</font> : i==
1 ?
<font class=
"stringliteral">"A>B"</font> : i==
0 ?
<font class=
"stringliteral">"A><B"</font> :
<font class=
"stringliteral">"error"</font>);
152 00144 <font class=
"keywordflow">break
</font>;
153 00145 <font class=
"keywordflow">case
</font> 10:
154 00146 i =
<a class=
"code" href=
"alpha_8c.html#a3">GaussSimplify
</a>(a,b);
155 00147 <a class=
"code" href=
"matrix_8c.html#a2">Matrix_Print
</a>(stdout,P_VALUE_FMT,b);
156 00148 <font class=
"keywordflow">break
</font>;
158 00150 <font class=
"keywordflow">default
</font>:
159 00151 printf(
<font class=
"stringliteral">"? unknown function\n"</font>);
162 00154 <a class=
"code" href=
"polyhedron_8c.html#a19">Domain_Free
</a>(A);
163 00155 <a class=
"code" href=
"polyhedron_8c.html#a19">Domain_Free
</a>(B);
165 00157 <font class=
"keywordflow">return
</font> 0;
169 </pre></div><hr><address align=
"right"><small>Generated on Fri Nov
8 12:
10:
07 2002 for Polylib by
170 <a href=
"http://www.doxygen.org/index.html">
171 <img src=
"doxygen.png" alt=
"doxygen" align=
"middle" border=
0
172 width=
110 height=
53></a>1.2.15 </small></address>