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">
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>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
<stdio.h
></font>
10 00002 <font class=
"preprocessor">#include
<string.h
></font>
11 00003 <font class=
"preprocessor">#include
<stdlib.h
></font>
13 00005 <font class=
"preprocessor">#include
<polylib/polylib.h
></font>
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 )
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;
25 00017 pm =
<a class=
"code" href=
"matrix_8c.html#a4">Matrix_Read
</a>();
27 00019 <font class=
"keywordflow">while
</font>( f )
29 00021 <font class=
"keywordflow">do
</font>
31 00023 <font class=
"keywordflow">if
</font>( fgets(s,
1024, stdin) ==
0 )
34 00026 <font class=
"keywordflow">while
</font> ( (*s==
<font class=
"charliteral">'#'
</font> || *s==
<font class=
"charliteral">'\n'
</font>)
&& f );
36 00028 <font class=
"keywordflow">if
</font>( f
&& sscanf(s,
<font class=
"stringliteral">"%d %d"</font>,
&NbRows,
&NbColumns)==
2 )
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-
>NbColumns != ((*P)-
>Dimension)+
2 )
42 00034 fprintf( stderr,
43 00035 <font class=
"stringliteral">"Polyhedra must be in the same dimension space !\n"</font>);
46 00038 ptmp =
<a class=
"code" href=
"polyhedron_8c.html#a24">Constraints2Polyhedron
</a>(pm,
200);
47 00039 ptmp-
>next = *P;
49 00041 <a class=
"code" href=
"matrix_8c.html#a1">Matrix_Free
</a>(pm);
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 );
55 00047 <font class=
"keywordflow">else
</font>
56 00048 <font class=
"keywordflow">break
</font>;
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);
64 00056 <font class=
"keywordflow">if
</font>( f )
66 00058 <font class=
"comment">/* read the parameter names */
</font>
67 00059 *param_name = (
<font class=
"keywordtype">char
</font> **)malloc( (*C)-
>Dimension*
<font class=
"keyword">sizeof
</font>(
<font class=
"keywordtype">char
</font> *) );
69 00061 <font class=
"keywordflow">for
</font>( i=
0 ; i
<(*C)-
>Dimension ; ++i )
72 00064 <font class=
"keywordflow">for
</font>( ; ; ++c )
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>;
80 00072 param[j++] = s[c];
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>;
87 00079 (*param_name)[i] = (
<font class=
"keywordtype">char
</font> *)malloc( j );
88 00080 strcpy( (*param_name)[i], param );
90 00082 <font class=
"keywordflow">if
</font>( i != (*C)-
>Dimension )
92 00084 free( *param_name );
93 00085 *param_name =
<a class=
"code" href=
"param_8c.html#a0">Read_ParamNames
</a>(NULL,(*C)-
>Dimension);
96 00088 <font class=
"keywordflow">else
</font>
97 00089 *param_name =
<a class=
"code" href=
"param_8c.html#a0">Read_ParamNames
</a>(NULL,(*C)-
>Dimension);
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)
105 00097 Polyhedron *P, *C;
106 00098 <font class=
"keywordtype">char
</font> **param_name;
107 00099 Enumeration *e, *en;
109 00101 <font class=
"keywordflow">if
</font>( argc !=
1 )
111 00103 fprintf( stderr,
<font class=
"stringliteral">" Usage : %s [< file]\n"</font>, argv[
0] );
112 00104 <font class=
"keywordflow">return
</font>( -
1 );
115 00107 <a class=
"code" href=
"ehrhart__union_8c.html#a0">Union_Read
</a>(
&P,
&C,
&param_name );
117 00109 e = Domain_Enumerate( P, C,
200, param_name );
119 00111 <font class=
"keywordflow">for
</font>( en=e ; en ; en=en-
>next )
121 00113 <a class=
"code" href=
"polyparam_8c.html#a39">Print_Domain
</a>(stdout,en-
>ValidityDomain, param_name);
122 00114 print_evalue(stdout,
&en-
>EP, param_name);
123 00115 printf(
<font class=
"stringliteral">"\n-----------------------------------\n"</font> );
126 00118 <font class=
"keywordflow">return
</font>(
0 );
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>