fixed a small bug in eval ehrhart
[polylib.git] / doc / codeDoc / html / ehrhart__union_8c-source.html
blob895d1e140e10b1af9973e5da3eb976ec1595bdb7
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>ehrhart_union.c Source File</title>
4 <link href="doxygen.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.2.15 -->
7 <center>
8 <a class="qindex" href="main.html">Main Page</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center>
9 <hr><h1>ehrhart_union.c</h1><a href="ehrhart__union_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="preprocessor">#include &lt;stdio.h&gt;</font>
10 00002 <font class="preprocessor">#include &lt;string.h&gt;</font>
11 00003 <font class="preprocessor">#include &lt;stdlib.h&gt;</font>
12 00004
13 00005 <font class="preprocessor">#include &lt;polylib/polylib.h&gt;</font>
14 00006
15 00007
16 <a name="l00008"></a><a class="code" href="ehrhart__union_8c.html#a0">00008</a> <font class="keywordtype">void</font> <a class="code" href="ehrhart__union_8c.html#a0">Union_Read</a>( Polyhedron **P, Polyhedron **C, <font class="keywordtype">char</font> ***param_name )
17 00009 {
18 00010 Matrix *pm;
19 00011 Polyhedron *ptmp;
20 00012 <font class="keywordtype">unsigned</font> NbRows, NbColumns;
21 00013 <font class="keywordtype">char</font> s[1025], param[1025];
22 00014 <font class="keywordtype">int</font> i, j, c, f;
23 00015
24 00016 *P = NULL;
25 00017 pm = <a class="code" href="matrix_8c.html#a4">Matrix_Read</a>();
26 00018 f=1;
27 00019 <font class="keywordflow">while</font>( f )
28 00020 {
29 00021 <font class="keywordflow">do</font>
30 00022 {
31 00023 <font class="keywordflow">if</font>( fgets(s, 1024, stdin) == 0 )
32 00024 f=0;
33 00025 }
34 00026 <font class="keywordflow">while</font> ( (*s==<font class="charliteral">'#'</font> || *s==<font class="charliteral">'\n'</font>) &amp;&amp; f );
35 00027
36 00028 <font class="keywordflow">if</font>( f &amp;&amp; sscanf(s, <font class="stringliteral">"%d %d"</font>, &amp;NbRows, &amp;NbColumns)==2 )
37 00029 {
38 00030 <font class="comment">/* gets old pm and add it to the union */</font>
39 00031 <font class="keywordflow">if</font>( *P )
40 00032 <font class="keywordflow">if</font>( pm-&gt;NbColumns != ((*P)-&gt;Dimension)+2 )
41 00033 {
42 00034 fprintf( stderr,
43 00035 <font class="stringliteral">"Polyhedra must be in the same dimension space !\n"</font>);
44 00036 exit(0);
45 00037 }
46 00038 ptmp = <a class="code" href="polyhedron_8c.html#a24">Constraints2Polyhedron</a>(pm, 200);
47 00039 ptmp-&gt;next = *P;
48 00040 *P = ptmp;
49 00041 <a class="code" href="matrix_8c.html#a1">Matrix_Free</a>(pm);
50 00042
51 00043 <font class="comment">/* reads the new pm */</font>
52 00044 pm = <a class="code" href="matrix_8c.html#a0">Matrix_Alloc</a>(NbRows, NbColumns);
53 00045 <a class="code" href="matrix_8c.html#a3">Matrix_Read_Input</a>( pm );
54 00046 }
55 00047 <font class="keywordflow">else</font>
56 00048 <font class="keywordflow">break</font>;
57 00049 }
58 00050
59 00051 <font class="comment">/* Context : last read pm */</font>
60 00052 *C = <a class="code" href="polyhedron_8c.html#a24">Constraints2Polyhedron</a>(pm, 200);
61 00053 <a class="code" href="matrix_8c.html#a1">Matrix_Free</a>(pm);
62 00054
63 00055
64 00056 <font class="keywordflow">if</font>( f )
65 00057 {
66 00058 <font class="comment">/* read the parameter names */</font>
67 00059 *param_name = (<font class="keywordtype">char</font> **)malloc( (*C)-&gt;Dimension*<font class="keyword">sizeof</font>(<font class="keywordtype">char</font> *) );
68 00060 c = 0;
69 00061 <font class="keywordflow">for</font>( i=0 ; i&lt;(*C)-&gt;Dimension ; ++i )
70 00062 {
71 00063 j=0;
72 00064 <font class="keywordflow">for</font>( ; ; ++c )
73 00065 {
74 00066 <font class="keywordflow">if</font>( s[c]==<font class="charliteral">' '</font> || s[c]==<font class="charliteral">'\n'</font> || s[c]==0 ) {
75 00067 <font class="keywordflow">if</font>( j==0 )
76 00068 <font class="keywordflow">continue</font>;
77 00069 <font class="keywordflow">else</font>
78 00070 <font class="keywordflow">break</font>;
79 00071 }
80 00072 param[j++] = s[c];
81 00073 }
82 00074
83 00075 <font class="comment">/* else, no parameters (use default) */</font>
84 00076 <font class="keywordflow">if</font>( j==0 )
85 00077 <font class="keywordflow">break</font>;
86 00078 param[j] = 0;
87 00079 (*param_name)[i] = (<font class="keywordtype">char</font> *)malloc( j );
88 00080 strcpy( (*param_name)[i], param );
89 00081 }
90 00082 <font class="keywordflow">if</font>( i != (*C)-&gt;Dimension )
91 00083 {
92 00084 free( *param_name );
93 00085 *param_name = <a class="code" href="param_8c.html#a0">Read_ParamNames</a>(NULL,(*C)-&gt;Dimension);
94 00086 }
95 00087 }
96 00088 <font class="keywordflow">else</font>
97 00089 *param_name = <a class="code" href="param_8c.html#a0">Read_ParamNames</a>(NULL,(*C)-&gt;Dimension);
98 00090
99 00091 }
100 00092
101 00093
102 00094
103 <a name="l00095"></a><a class="code" href="ehrhart__union_8c.html#a1">00095</a> <font class="keywordtype">int</font> <a class="code" href="c2p_8c.html#a1">main</a>( <font class="keywordtype">int</font> argc, <font class="keywordtype">char</font> **argv)
104 00096 {
105 00097 Polyhedron *P, *C;
106 00098 <font class="keywordtype">char</font> **param_name;
107 00099 Enumeration *e, *en;
108 00100
109 00101 <font class="keywordflow">if</font>( argc != 1 )
110 00102 {
111 00103 fprintf( stderr, <font class="stringliteral">" Usage : %s [&lt; file]\n"</font>, argv[0] );
112 00104 <font class="keywordflow">return</font>( -1 );
113 00105 }
114 00106
115 00107 <a class="code" href="ehrhart__union_8c.html#a0">Union_Read</a>( &amp;P, &amp;C, &amp;param_name );
116 00108
117 00109 e = Domain_Enumerate( P, C, 200, param_name );
118 00110
119 00111 <font class="keywordflow">for</font>( en=e ; en ; en=en-&gt;next )
120 00112 {
121 00113 <a class="code" href="polyparam_8c.html#a39">Print_Domain</a>(stdout,en-&gt;ValidityDomain, param_name);
122 00114 print_evalue(stdout,&amp;en-&gt;EP, param_name);
123 00115 printf( <font class="stringliteral">"\n-----------------------------------\n"</font> );
124 00116 }
125 00117
126 00118 <font class="keywordflow">return</font>( 0 );
127 00119 }
128 00120
129 00121
130 00122
131 </pre></div><hr><address align="right"><small>Generated on Fri Nov 8 12:10:06 2002 for Polylib by
132 <a href="http://www.doxygen.org/index.html">
133 <img src="doxygen.png" alt="doxygen" align="middle" border=0
134 width=110 height=53></a>1.2.15 </small></address>
135 </body>
136 </html>