Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > aaf33964de706a538481c929c1da6a44 > files > 4858

faust-doc-0.9.10-5mdv2010.1.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>FAUST compiler: normalize.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>normalize.cpp</h1><a href="normalize_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include &quot;<a class="code" href="tlib_8hh.html">tlib.hh</a>&quot;</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &quot;<a class="code" href="signals_8hh.html">signals.hh</a>&quot;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &quot;<a class="code" href="sigprint_8hh.html">sigprint.hh</a>&quot;</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include &quot;<a class="code" href="ppsig_8hh.html">ppsig.hh</a>&quot;</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include &quot;<a class="code" href="simplify_8hh.html">simplify.hh</a>&quot;</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &quot;<a class="code" href="normalize_8hh.html">normalize.hh</a>&quot;</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &quot;<a class="code" href="sigorderrules_8hh.html">sigorderrules.hh</a>&quot;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;map&gt;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;list&gt;</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 <span class="preprocessor">#include &quot;<a class="code" href="mterm_8hh.html">mterm.hh</a>&quot;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &quot;<a class="code" href="aterm_8hh.html">aterm.hh</a>&quot;</span>
<a name="l00015"></a>00015 
<a name="l00016"></a>00016 <span class="preprocessor">#if 0</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">void</span> countAddTerm (map&lt;Tree,Tree&gt;&amp; M, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> t, <span class="keywordtype">bool</span> invflag);
<a name="l00018"></a>00018 <span class="keyword">static</span> <span class="keywordtype">void</span> incTermCount (map&lt;Tree,int&gt;&amp; M, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> t, <span class="keywordtype">bool</span> invflag);
<a name="l00019"></a>00019 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="mterm_8cpp.html#a989a51a835beba670bf40439995d9643" title="produce the canonical tree correspoding to a mterm">buildPowTerm</a> (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> f, <span class="keywordtype">int</span> q);
<a name="l00020"></a>00020 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> simplifyingReorganizingMul(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> t1, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> t2);
<a name="l00021"></a>00021 <span class="keyword">static</span> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> reorganizingMul(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> k, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> t);
<a name="l00022"></a>00022 <span class="keyword">static</span> <span class="keywordtype">void</span> factorizeAddTerm(map&lt;Tree,Tree&gt;&amp; M);
<a name="l00023"></a>00023 <span class="preprocessor">#endif</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span>
<a name="l00025"></a>00025 <span class="preprocessor">#undef TRACE</span>
<a name="l00026"></a>00026 <span class="preprocessor"></span>
<a name="l00032"></a><a class="code" href="normalize_8hh.html#a84f5cc6ddcbd1db7e6f442b3bdf71363">00032</a> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="normalize_8cpp.html#a84f5cc6ddcbd1db7e6f442b3bdf71363" title="Compute the Add-Normal form of a term t.">normalizeAddTerm</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> t)
<a name="l00033"></a>00033 {
<a name="l00034"></a>00034 <span class="preprocessor">#ifdef TRACE</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span>    cerr &lt;&lt; <span class="stringliteral">&quot;START normalizeAddTerm : &quot;</span> &lt;&lt; <a class="code" href="classppsig.html">ppsig</a>(t) &lt;&lt; endl;
<a name="l00036"></a>00036 <span class="preprocessor">#endif</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span>    
<a name="l00038"></a>00038     <a class="code" href="classaterm.html" title="Implements a additive term, a set of mterms added together m1 + m2 + m3 + .">aterm</a> A(t);
<a name="l00039"></a>00039     <span class="comment">//cerr &lt;&lt; &quot;ATERM IS : &quot; &lt;&lt; A &lt;&lt; endl;</span>
<a name="l00040"></a>00040     <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a> D = A.<a class="code" href="classaterm.html#a52130183f30e9b4e998532ca36536dc7" title="return the greatest divisor of any two mterms">greatestDivisor</a>();
<a name="l00041"></a>00041     <span class="keywordflow">while</span> (D.<a class="code" href="classmterm.html#a8c72d30bd49ba9cfe32f4a399b808c2f" title="true if mterm doesn&amp;#39;t represent number 0">isNotZero</a>() &amp;&amp; D.<a class="code" href="classmterm.html#a693c15c5f4ed5f1aab26ef0910598508" title="return an evaluation of the complexity">complexity</a>() &gt; 0) {
<a name="l00042"></a>00042         <span class="comment">//cerr &lt;&lt; &quot;GREAT DIV : &quot; &lt;&lt; D &lt;&lt; endl;</span>
<a name="l00043"></a>00043         A = A.<a class="code" href="classaterm.html#ae6906479134fa7fac1486aa8f1fccd31" title="reorganize the aterm by factorizing d">factorize</a>(D);
<a name="l00044"></a>00044         D = A.<a class="code" href="classaterm.html#a52130183f30e9b4e998532ca36536dc7" title="return the greatest divisor of any two mterms">greatestDivisor</a>();
<a name="l00045"></a>00045     }
<a name="l00046"></a>00046     <span class="keywordflow">return</span> A.<a class="code" href="classaterm.html#a793687477fd756925c4db2914d8a5820" title="return the corresponding normalized expression tree">normalizedTree</a>();
<a name="l00047"></a>00047 }
<a name="l00048"></a>00048 
<a name="l00049"></a>00049 
<a name="l00059"></a><a class="code" href="normalize_8hh.html#abe85547196d79f5d315c81af052f8b2e">00059</a> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="normalize_8cpp.html#abe85547196d79f5d315c81af052f8b2e" title="Compute the normal form of a 1-sample delay term s&amp;#39;.">normalizeDelay1Term</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> s)
<a name="l00060"></a>00060 {
<a name="l00061"></a>00061     <span class="keywordflow">return</span> <a class="code" href="normalize_8cpp.html#a6ab3c9ebcc665f2c194600f7e9077a34" title="Compute the normal form of a fixed delay term (s).">normalizeFixedDelayTerm</a>(s, <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(1));
<a name="l00062"></a>00062 }
<a name="l00063"></a>00063 
<a name="l00064"></a>00064 
<a name="l00081"></a><a class="code" href="normalize_8hh.html#a6ab3c9ebcc665f2c194600f7e9077a34">00081</a> <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> <a class="code" href="normalize_8cpp.html#a6ab3c9ebcc665f2c194600f7e9077a34" title="Compute the normal form of a fixed delay term (s).">normalizeFixedDelayTerm</a>(<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> s, <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> d)
<a name="l00082"></a>00082 {
<a name="l00083"></a>00083     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> x, y, r;
<a name="l00084"></a>00084     <span class="keywordtype">int</span> i;
<a name="l00085"></a>00085 
<a name="l00086"></a>00086     <span class="keywordflow">if</span> (<a class="code" href="signals_8hh.html#a73fa3ec5ebd4e47dc0fde2d24cc08c56">isZero</a>(d) &amp;&amp; ! <a class="code" href="signals_8cpp.html#a9b54e9177bb3726e06700649c3e5c05d">isProj</a>(s, &amp;i, r)) {
<a name="l00087"></a>00087 
<a name="l00088"></a>00088         <span class="keywordflow">return</span> s;
<a name="l00089"></a>00089 
<a name="l00090"></a>00090     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8hh.html#a73fa3ec5ebd4e47dc0fde2d24cc08c56">isZero</a>(s)) {
<a name="l00091"></a>00091 
<a name="l00092"></a>00092         <span class="keywordflow">return</span> s;
<a name="l00093"></a>00093 
<a name="l00094"></a>00094     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a83cfe7606cdddce154e2e4c79a9256f3">isSigMul</a>(s, x, y)) {
<a name="l00095"></a>00095 
<a name="l00096"></a>00096         <span class="keywordflow">if</span> (<a class="code" href="sigorderrules_8cpp.html#a20942fac53773f763795775cfdcfb086" title="retrieve the order annotation (between 0 and 3) of a signal.">getSigOrder</a>(x) &lt; 2) {
<a name="l00097"></a>00097             <span class="keywordflow">return</span> <a class="code" href="simplify_8cpp.html#aa58ab1a209023cba186f077cfdcc5339">simplify</a>(<a class="code" href="signals_8hh.html#a333591913e073c3acd6b891b6da85298">sigMul</a>(x,<a class="code" href="normalize_8cpp.html#a6ab3c9ebcc665f2c194600f7e9077a34" title="Compute the normal form of a fixed delay term (s).">normalizeFixedDelayTerm</a>(y,d)));
<a name="l00098"></a>00098         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="sigorderrules_8cpp.html#a20942fac53773f763795775cfdcfb086" title="retrieve the order annotation (between 0 and 3) of a signal.">getSigOrder</a>(y) &lt; 2) {
<a name="l00099"></a>00099             <span class="keywordflow">return</span> <a class="code" href="simplify_8cpp.html#aa58ab1a209023cba186f077cfdcc5339">simplify</a>(<a class="code" href="signals_8hh.html#a333591913e073c3acd6b891b6da85298">sigMul</a>(y,<a class="code" href="normalize_8cpp.html#a6ab3c9ebcc665f2c194600f7e9077a34" title="Compute the normal form of a fixed delay term (s).">normalizeFixedDelayTerm</a>(x,d)));
<a name="l00100"></a>00100         } <span class="keywordflow">else</span> {
<a name="l00101"></a>00101             <span class="keywordflow">return</span> <a class="code" href="signals_8cpp.html#ae4887b59dd1461bfacc431147c78ebb8">sigFixDelay</a>(s,d);
<a name="l00102"></a>00102         }
<a name="l00103"></a>00103 
<a name="l00104"></a>00104     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#ab86d4703fc4e3b9469171745e4781575">isSigDiv</a>(s, x, y)) {
<a name="l00105"></a>00105 
<a name="l00106"></a>00106         <span class="keywordflow">if</span> (<a class="code" href="sigorderrules_8cpp.html#a20942fac53773f763795775cfdcfb086" title="retrieve the order annotation (between 0 and 3) of a signal.">getSigOrder</a>(y) &lt; 2) {
<a name="l00107"></a>00107             <span class="keywordflow">return</span> <a class="code" href="simplify_8cpp.html#aa58ab1a209023cba186f077cfdcc5339">simplify</a>(<a class="code" href="signals_8hh.html#aa355af5e231f2e25ed43fa2f3bf6c72f">sigDiv</a>(<a class="code" href="normalize_8cpp.html#a6ab3c9ebcc665f2c194600f7e9077a34" title="Compute the normal form of a fixed delay term (s).">normalizeFixedDelayTerm</a>(x,d),y));
<a name="l00108"></a>00108         } <span class="keywordflow">else</span> {
<a name="l00109"></a>00109             <span class="keywordflow">return</span> <a class="code" href="signals_8cpp.html#ae4887b59dd1461bfacc431147c78ebb8">sigFixDelay</a>(s,d);
<a name="l00110"></a>00110         }
<a name="l00111"></a>00111 
<a name="l00112"></a>00112     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#af55cdefee258834b3b8f6c070d4970c9">isSigFixDelay</a>(s, x, y)) {
<a name="l00113"></a>00113         <span class="comment">// (x@n)@m = x@(n+m)</span>
<a name="l00114"></a>00114 <span class="comment">//      return sigFixDelay(x,tree(tree2int(d)+tree2int(y)));</span>
<a name="l00115"></a>00115         <span class="keywordflow">return</span> <a class="code" href="normalize_8cpp.html#a6ab3c9ebcc665f2c194600f7e9077a34" title="Compute the normal form of a fixed delay term (s).">normalizeFixedDelayTerm</a>(x,<a class="code" href="simplify_8cpp.html#aa58ab1a209023cba186f077cfdcc5339">simplify</a>(<a class="code" href="signals_8hh.html#ab914de7e6da0eea04636dd51ad35240a">sigAdd</a>(d,y))); 
<a name="l00116"></a>00116 
<a name="l00117"></a>00117     } <span class="keywordflow">else</span> {
<a name="l00118"></a>00118 
<a name="l00119"></a>00119         <span class="keywordflow">return</span> <a class="code" href="signals_8cpp.html#ae4887b59dd1461bfacc431147c78ebb8">sigFixDelay</a>(s,d);
<a name="l00120"></a>00120     }
<a name="l00121"></a>00121 }
<a name="l00122"></a>00122 
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Apr 28 23:59:59 2010 for FAUST compiler by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>