<!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 File Reference</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 Page</span></a></li> <li><a href="pages.html"><span>Related 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 List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> </div> <div class="contents"> <h1>normalize.cpp File Reference</h1><code>#include <stdio.h></code><br/> <code>#include <assert.h></code><br/> <code>#include "<a class="el" href="tlib_8hh_source.html">tlib.hh</a>"</code><br/> <code>#include "<a class="el" href="signals_8hh_source.html">signals.hh</a>"</code><br/> <code>#include "<a class="el" href="sigprint_8hh_source.html">sigprint.hh</a>"</code><br/> <code>#include "<a class="el" href="ppsig_8hh_source.html">ppsig.hh</a>"</code><br/> <code>#include "<a class="el" href="simplify_8hh_source.html">simplify.hh</a>"</code><br/> <code>#include "<a class="el" href="normalize_8hh_source.html">normalize.hh</a>"</code><br/> <code>#include "<a class="el" href="sigorderrules_8hh_source.html">sigorderrules.hh</a>"</code><br/> <code>#include <map></code><br/> <code>#include <list></code><br/> <code>#include "<a class="el" href="mterm_8hh_source.html">mterm.hh</a>"</code><br/> <code>#include "<a class="el" href="aterm_8hh_source.html">aterm.hh</a>"</code><br/> <div class="dynheader"> Include dependency graph for normalize.cpp:</div> <div class="dynsection"> </div> <p><a href="normalize_8cpp_source.html">Go to the source code of this file.</a></p> <table border="0" cellpadding="0" cellspacing="0"> <tr><td colspan="2"><h2>Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCTree.html">Tree</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="normalize_8cpp.html#a84f5cc6ddcbd1db7e6f442b3bdf71363">normalizeAddTerm</a> (<a class="el" href="classCTree.html">Tree</a> t)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Compute the Add-Normal form of a term t. <a href="#a84f5cc6ddcbd1db7e6f442b3bdf71363"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCTree.html">Tree</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="normalize_8cpp.html#abe85547196d79f5d315c81af052f8b2e">normalizeDelay1Term</a> (<a class="el" href="classCTree.html">Tree</a> s)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Compute the normal form of a 1-sample delay term s'. <a href="#abe85547196d79f5d315c81af052f8b2e"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCTree.html">Tree</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="normalize_8cpp.html#a6ab3c9ebcc665f2c194600f7e9077a34">normalizeFixedDelayTerm</a> (<a class="el" href="classCTree.html">Tree</a> s, <a class="el" href="classCTree.html">Tree</a> d)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Compute the normal form of a fixed delay term (s). <a href="#a6ab3c9ebcc665f2c194600f7e9077a34"></a><br/></td></tr> </table> <hr/><h2>Function Documentation</h2> <a class="anchor" id="a84f5cc6ddcbd1db7e6f442b3bdf71363"></a><!-- doxytag: member="normalize.cpp::normalizeAddTerm" ref="a84f5cc6ddcbd1db7e6f442b3bdf71363" args="(Tree t)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classCTree.html">Tree</a> normalizeAddTerm </td> <td>(</td> <td class="paramtype"><a class="el" href="classCTree.html">Tree</a> </td> <td class="paramname"> <em>t</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Compute the Add-Normal form of a term t. </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>t</em> </td><td>the term to be normalized </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>the normalized term </dd></dl> <p>Definition at line <a class="el" href="normalize_8cpp_source.html#l00032">32</a> of file <a class="el" href="normalize_8cpp_source.html">normalize.cpp</a>.</p> <p>References <a class="el" href="mterm_8cpp_source.html#l00064">mterm::complexity()</a>, <a class="el" href="aterm_8cpp_source.html#l00241">aterm::factorize()</a>, <a class="el" href="aterm_8cpp_source.html#l00218">aterm::greatestDivisor()</a>, <a class="el" href="mterm_8cpp_source.html#l00031">mterm::isNotZero()</a>, and <a class="el" href="aterm_8cpp_source.html#l00059">aterm::normalizedTree()</a>.</p> <p>Referenced by <a class="el" href="simplify_8cpp_source.html#l00080">simplification()</a>.</p> <p><div class="fragment"><pre class="fragment"><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 << <span class="stringliteral">"START normalizeAddTerm : "</span> << <a class="code" href="classppsig.html">ppsig</a>(t) << 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 << "ATERM IS : " << A << 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.greatestDivisor(); <a name="l00041"></a>00041 <span class="keywordflow">while</span> (D.<a class="code" href="classmterm.html#a8c72d30bd49ba9cfe32f4a399b808c2f" title="true if mterm doesn&#39;t represent number 0">isNotZero</a>() && D.<a class="code" href="classmterm.html#a693c15c5f4ed5f1aab26ef0910598508" title="return an evaluation of the complexity">complexity</a>() > 0) { <a name="l00042"></a>00042 <span class="comment">//cerr << "GREAT DIV : " << D << endl;</span> <a name="l00043"></a>00043 A = A.factorize(D); <a name="l00044"></a>00044 D = A.greatestDivisor(); <a name="l00045"></a>00045 } <a name="l00046"></a>00046 <span class="keywordflow">return</span> A.<a class="code" href="classmterm.html#a6aaebc7c5e6ace53d4ff3e996701a99f" title="return the normalized tree of the mterm">normalizedTree</a>(); <a name="l00047"></a>00047 } </pre></div></p> <p><div class="dynheader"> Here is the call graph for this function:</div> <div class="dynsection"> </div> </p> <p><div class="dynheader"> Here is the caller graph for this function:</div> <div class="dynsection"> </div> </p> </div> </div> <a class="anchor" id="abe85547196d79f5d315c81af052f8b2e"></a><!-- doxytag: member="normalize.cpp::normalizeDelay1Term" ref="abe85547196d79f5d315c81af052f8b2e" args="(Tree s)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classCTree.html">Tree</a> normalizeDelay1Term </td> <td>(</td> <td class="paramtype"><a class="el" href="classCTree.html">Tree</a> </td> <td class="paramname"> <em>s</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Compute the normal form of a 1-sample delay term s'. </p> <p>The normalisation rules are : 0' -> 0 /// INACTIVATE dec07 bug recursion (k*s)' -> k*s' (s/k)' -> s'/k </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>s</em> </td><td>the term to be delayed by 1 sample </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>the normalized term </dd></dl> <p>Definition at line <a class="el" href="normalize_8cpp_source.html#l00059">59</a> of file <a class="el" href="normalize_8cpp_source.html">normalize.cpp</a>.</p> <p>References <a class="el" href="normalize_8cpp_source.html#l00081">normalizeFixedDelayTerm()</a>, and <a class="el" href="tree_8hh_source.html#l00173">tree()</a>.</p> <p>Referenced by <a class="el" href="simplify_8cpp_source.html#l00080">simplification()</a>.</p> <p><div class="fragment"><pre class="fragment"><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 } </pre></div></p> <p><div class="dynheader"> Here is the call graph for this function:</div> <div class="dynsection"> </div> </p> <p><div class="dynheader"> Here is the caller graph for this function:</div> <div class="dynsection"> </div> </p> </div> </div> <a class="anchor" id="a6ab3c9ebcc665f2c194600f7e9077a34"></a><!-- doxytag: member="normalize.cpp::normalizeFixedDelayTerm" ref="a6ab3c9ebcc665f2c194600f7e9077a34" args="(Tree s, Tree d)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classCTree.html">Tree</a> normalizeFixedDelayTerm </td> <td>(</td> <td class="paramtype"><a class="el" href="classCTree.html">Tree</a> </td> <td class="paramname"> <em>s</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="classCTree.html">Tree</a> </td> <td class="paramname"> <em>d</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Compute the normal form of a fixed delay term (s). </p> <p>The normalisation rules are : s -> s 0 -> 0 (k*s) -> k*(s) (s/k) -> (s)/k (s<br/> ) -> s@(n+m) Note that the same rules can't be applied to + et - becaue the value of the first d samples would be wrong. We could also add delays such that </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>s</em> </td><td>the term to be delayed </td></tr> <tr><td valign="top"></td><td valign="top"><em>d</em> </td><td>the value of the delay </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>the normalized term </dd></dl> <p>Definition at line <a class="el" href="normalize_8cpp_source.html#l00081">81</a> of file <a class="el" href="normalize_8cpp_source.html">normalize.cpp</a>.</p> <p>References <a class="el" href="sigorderrules_8cpp_source.html#l00062">getSigOrder()</a>, <a class="el" href="signals_8cpp_source.html#l00151">isProj()</a>, <a class="el" href="signals_8cpp_source.html#l00357">isSigDiv()</a>, <a class="el" href="signals_8cpp_source.html#l00062">isSigFixDelay()</a>, <a class="el" href="signals_8cpp_source.html#l00345">isSigMul()</a>, <a class="el" href="signals_8hh_source.html#l00185">isZero()</a>, <a class="el" href="normalize_8cpp_source.html#l00081">normalizeFixedDelayTerm()</a>, <a class="el" href="signals_8hh_source.html#l00148">sigAdd()</a>, <a class="el" href="signals_8hh_source.html#l00151">sigDiv()</a>, <a class="el" href="signals_8cpp_source.html#l00061">sigFixDelay()</a>, <a class="el" href="signals_8hh_source.html#l00150">sigMul()</a>, and <a class="el" href="simplify_8cpp_source.html#l00072">simplify()</a>.</p> <p>Referenced by <a class="el" href="normalize_8cpp_source.html#l00059">normalizeDelay1Term()</a>, <a class="el" href="normalize_8cpp_source.html#l00081">normalizeFixedDelayTerm()</a>, and <a class="el" href="simplify_8cpp_source.html#l00080">simplification()</a>.</p> <p><div class="fragment"><pre class="fragment"><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) && ! <a class="code" href="signals_8cpp.html#a9b54e9177bb3726e06700649c3e5c05d">isProj</a>(s, &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) < 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) < 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) < 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 } </pre></div></p> <p><div class="dynheader"> Here is the call graph for this function:</div> <div class="dynsection"> </div> </p> <p><div class="dynheader"> Here is the caller graph for this function:</div> <div class="dynsection"> </div> </p> </div> </div> </div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Thu Apr 29 00:00:09 2010 for FAUST compiler by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>