Sophie

Sophie

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

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: mterm.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>mterm.cpp</h1><a href="mterm_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 &quot;<a class="code" href="mterm_8hh.html">mterm.hh</a>&quot;</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &quot;<a class="code" href="signals_8hh.html">signals.hh</a>&quot;</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include &quot;<a class="code" href="ppsig_8hh.html">ppsig.hh</a>&quot;</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00005"></a>00005 <span class="comment">//static void collectMulTerms (Tree&amp; coef, map&lt;Tree,int&gt;&amp; M, Tree t, bool invflag=false);</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="preprocessor">#undef TRACE</span>
<a name="l00008"></a>00008 <span class="preprocessor"></span>
<a name="l00009"></a>00009 <span class="keyword">using namespace </span>std;
<a name="l00010"></a>00010 
<a name="l00011"></a><a class="code" href="mterm_8cpp.html#a6e8e8e61bc8fed2501d51423078922a2">00011</a> <span class="keyword">typedef</span> map&lt;Tree,int&gt; <a class="code" href="mterm_8cpp.html#a6e8e8e61bc8fed2501d51423078922a2">MP</a>;
<a name="l00012"></a>00012 
<a name="l00013"></a><a class="code" href="classmterm.html#aa4dfb5d965e25d3cd29f8fa0ed1268e8">00013</a> <a class="code" href="classmterm.html#aa4dfb5d965e25d3cd29f8fa0ed1268e8" title="create a 0 mterm">mterm::mterm</a> ()                 : fCoef(<a class="code" href="signals_8cpp.html#a43ce107ac086c8ef608e0cd7aeb606a4" title="Signals.">sigInt</a>(0)) {}
<a name="l00014"></a><a class="code" href="classmterm.html#a94b494db2cd8280baf60253c6cb053ba">00014</a> <a class="code" href="classmterm.html#aa4dfb5d965e25d3cd29f8fa0ed1268e8" title="create a 0 mterm">mterm::mterm</a> (<span class="keywordtype">int</span> k)            : fCoef(<a class="code" href="signals_8cpp.html#a43ce107ac086c8ef608e0cd7aeb606a4" title="Signals.">sigInt</a>(k)) {}
<a name="l00015"></a><a class="code" href="classmterm.html#a7cb3dbd5ce42bc60fe058821b6d2d314">00015</a> <a class="code" href="classmterm.html#aa4dfb5d965e25d3cd29f8fa0ed1268e8" title="create a 0 mterm">mterm::mterm</a> (<span class="keywordtype">double</span> k)         : fCoef(<a class="code" href="signals_8cpp.html#a06d286e07f982addcce4b187e9b60374">sigReal</a>(k)) {}  <span class="comment">// cerr &lt;&lt; &quot;DOUBLE &quot; &lt;&lt; endl; }</span>
<a name="l00016"></a><a class="code" href="classmterm.html#adc9259455a70a306cda61897997e3950">00016</a> <a class="code" href="classmterm.html#aa4dfb5d965e25d3cd29f8fa0ed1268e8" title="create a 0 mterm">mterm::mterm</a> (<span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; m)   : fCoef(m.fCoef), fFactors(m.fFactors) {}
<a name="l00017"></a>00017 
<a name="l00021"></a><a class="code" href="classmterm.html#a1a8b989de783201955cc3b53fd48068d">00021</a> <a class="code" href="classmterm.html#aa4dfb5d965e25d3cd29f8fa0ed1268e8" title="create a 0 mterm">mterm::mterm</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) : fCoef(<a class="code" href="signals_8cpp.html#a43ce107ac086c8ef608e0cd7aeb606a4" title="Signals.">sigInt</a>(1))
<a name="l00022"></a>00022 {
<a name="l00023"></a>00023     <span class="comment">//cerr &lt;&lt; &quot;mterm::mterm (Tree t) : &quot; &lt;&lt; ppsig(t) &lt;&lt; endl;</span>
<a name="l00024"></a>00024     *<span class="keyword">this</span> *= t; 
<a name="l00025"></a>00025     <span class="comment">//cerr &lt;&lt; &quot;MTERM(&quot; &lt;&lt; ppsig(t) &lt;&lt; &quot;) -&gt; &quot; &lt;&lt; *this &lt;&lt; endl;</span>
<a name="l00026"></a>00026 }
<a name="l00027"></a>00027 
<a name="l00031"></a><a class="code" href="classmterm.html#a8c72d30bd49ba9cfe32f4a399b808c2f">00031</a> <span class="keywordtype">bool</span> <a class="code" href="classmterm.html#a8c72d30bd49ba9cfe32f4a399b808c2f" title="true if mterm doesn&amp;#39;t represent number 0">mterm::isNotZero</a>()<span class="keyword"> const</span>
<a name="l00032"></a>00032 <span class="keyword"></span>{
<a name="l00033"></a>00033     <span class="keywordflow">return</span> !<a class="code" href="signals_8hh.html#a73fa3ec5ebd4e47dc0fde2d24cc08c56">isZero</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>);
<a name="l00034"></a>00034 }
<a name="l00035"></a>00035 
<a name="l00039"></a><a class="code" href="classmterm.html#ade41b1583af893a4225b2e379aa4b155">00039</a> <span class="keywordtype">bool</span> <a class="code" href="classmterm.html#ade41b1583af893a4225b2e379aa4b155" title="true if mterm has a negative coefficient">mterm::isNegative</a>()<span class="keyword"> const</span>
<a name="l00040"></a>00040 <span class="keyword"></span>{
<a name="l00041"></a>00041     <span class="keywordflow">return</span> !<a class="code" href="signals_8hh.html#ae00358d412409bc13110732075b826e2">isGEZero</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>);
<a name="l00042"></a>00042 }
<a name="l00043"></a>00043 
<a name="l00047"></a><a class="code" href="classmterm.html#a6583aaf049ecff5c718a47b645fcfbf2">00047</a> ostream&amp; <a class="code" href="classmterm.html#a6583aaf049ecff5c718a47b645fcfbf2" title="print a mterm k*x1**n1*x2**n2...">mterm::print</a>(ostream&amp; dst)<span class="keyword"> const</span>
<a name="l00048"></a>00048 <span class="keyword"></span>{
<a name="l00049"></a>00049     <span class="keyword">const</span> <span class="keywordtype">char</span>* sep = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00050"></a>00050     <span class="keywordflow">if</span> (!<a class="code" href="signals_8hh.html#a4569e790c2e0a286bb8ee0f789b01d02">isOne</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>) || <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.empty()) { dst &lt;&lt; <a class="code" href="classppsig.html">ppsig</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>); sep = <span class="stringliteral">&quot; * &quot;</span>; }
<a name="l00051"></a>00051     <span class="comment">//if (true) { dst &lt;&lt; ppsig(fCoef); sep = &quot; * &quot;; }</span>
<a name="l00052"></a>00052     <span class="keywordflow">for</span> (MP::const_iterator p = <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.begin(); p != <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.end(); p++) {
<a name="l00053"></a>00053         dst &lt;&lt; sep &lt;&lt; <a class="code" href="classppsig.html">ppsig</a>(p-&gt;first);
<a name="l00054"></a>00054         <span class="keywordflow">if</span> (p-&gt;second != 1) dst &lt;&lt; <span class="stringliteral">&quot;**&quot;</span> &lt;&lt; p-&gt;second;
<a name="l00055"></a>00055         sep = <span class="stringliteral">&quot; * &quot;</span>;
<a name="l00056"></a>00056     }
<a name="l00057"></a>00057     <span class="keywordflow">return</span> dst;
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059 
<a name="l00064"></a><a class="code" href="classmterm.html#a693c15c5f4ed5f1aab26ef0910598508">00064</a> <span class="keywordtype">int</span> <a class="code" href="classmterm.html#a693c15c5f4ed5f1aab26ef0910598508" title="return an evaluation of the complexity">mterm::complexity</a>()<span class="keyword"> const</span>
<a name="l00065"></a>00065 <span class="keyword"></span>{
<a name="l00066"></a>00066     <span class="keywordtype">int</span> c = <a class="code" href="signals_8hh.html#a4569e790c2e0a286bb8ee0f789b01d02">isOne</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>) ? 0 : 1;
<a name="l00067"></a>00067     <span class="keywordflow">for</span> (MP::const_iterator p = <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.begin(); p != <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.end(); ++p) {
<a name="l00068"></a>00068         c += (1+<a class="code" href="sigorderrules_8cpp.html#a20942fac53773f763795775cfdcfb086" title="retrieve the order annotation (between 0 and 3) of a signal.">getSigOrder</a>(p-&gt;first))*<a class="code" href="interval_8hh.html#a466c6b7b96c9d292b7b4177fae8e0801">abs</a>(p-&gt;second);
<a name="l00069"></a>00069     }
<a name="l00070"></a>00070     <span class="keywordflow">return</span> c;
<a name="l00071"></a>00071 }
<a name="l00072"></a>00072 
<a name="l00073"></a>00073 
<a name="l00078"></a><a class="code" href="classmterm.html#acbae796c207ab237554ee7f6f4ee392a">00078</a> <span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; <a class="code" href="classmterm.html#acbae796c207ab237554ee7f6f4ee392a" title="multiply in place by a multiplicative exp">mterm::operator *= </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="l00079"></a>00079 {
<a name="l00080"></a>00080     <span class="keywordtype">int</span>     op;
<a name="l00081"></a>00081     <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;
<a name="l00082"></a>00082 
<a name="l00083"></a>00083     assert(t!=0);
<a name="l00084"></a>00084 
<a name="l00085"></a>00085     <span class="keywordflow">if</span> (<a class="code" href="signals_8hh.html#acd2773c99643a2dcc1c5409991c211e9">isNum</a>(t)) {
<a name="l00086"></a>00086         <a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a> = <a class="code" href="signals_8cpp.html#a3776e79cce66f0a453a7f9f9c0b121f9">mulNums</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>,t);
<a name="l00087"></a>00087 
<a name="l00088"></a>00088     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a8705584c3c319be54be73dc391d25634">isSigBinOp</a>(t, &amp;op, x, y) &amp;&amp; (op == <a class="code" href="binop_8hh.html#abc6126af1d45847bc59afa0aa3216b04ab8488ea0c4c9fd6bf85f12e3ad5eba18">kMul</a>)) {
<a name="l00089"></a>00089         *<span class="keyword">this</span> *= x;
<a name="l00090"></a>00090         *<span class="keyword">this</span> *= y;
<a name="l00091"></a>00091 
<a name="l00092"></a>00092     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a8705584c3c319be54be73dc391d25634">isSigBinOp</a>(t, &amp;op, x, y) &amp;&amp; (op == <a class="code" href="binop_8hh.html#abc6126af1d45847bc59afa0aa3216b04aef0a0af82a04caacbdd669707bfe3ab1">kDiv</a>)) {
<a name="l00093"></a>00093         *<span class="keyword">this</span> *= x;
<a name="l00094"></a>00094         *<span class="keyword">this</span> /= y;
<a name="l00095"></a>00095 
<a name="l00096"></a>00096     } <span class="keywordflow">else</span> {
<a name="l00097"></a>00097         <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> tnorm = t; <span class="comment">//= simplify(t);</span>
<a name="l00098"></a>00098         <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>[tnorm] += 1;
<a name="l00099"></a>00099     }
<a name="l00100"></a>00100     <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102 
<a name="l00107"></a><a class="code" href="classmterm.html#a00c303e748117461a6711a55146ec28d">00107</a> <span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; <a class="code" href="classmterm.html#a00c303e748117461a6711a55146ec28d" title="divide in place by a multiplicative exp">mterm::operator /= </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="l00108"></a>00108 {
<a name="l00109"></a>00109     <span class="comment">//cerr &lt;&lt; &quot;division en place : &quot; &lt;&lt; *this &lt;&lt; &quot; / &quot; &lt;&lt; ppsig(t) &lt;&lt; endl;</span>
<a name="l00110"></a>00110     <span class="keywordtype">int</span>     op;
<a name="l00111"></a>00111     <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;
<a name="l00112"></a>00112 
<a name="l00113"></a>00113     assert(t!=0);
<a name="l00114"></a>00114 
<a name="l00115"></a>00115     <span class="keywordflow">if</span> (<a class="code" href="signals_8hh.html#acd2773c99643a2dcc1c5409991c211e9">isNum</a>(t)) {
<a name="l00116"></a>00116         <a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a> = <a class="code" href="signals_8cpp.html#aba38f7c9a8eeef0df2a7473c760bf66b">divExtendedNums</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>,t);
<a name="l00117"></a>00117 
<a name="l00118"></a>00118     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a8705584c3c319be54be73dc391d25634">isSigBinOp</a>(t, &amp;op, x, y) &amp;&amp; (op == <a class="code" href="binop_8hh.html#abc6126af1d45847bc59afa0aa3216b04ab8488ea0c4c9fd6bf85f12e3ad5eba18">kMul</a>)) {
<a name="l00119"></a>00119         *<span class="keyword">this</span> /= x;
<a name="l00120"></a>00120         *<span class="keyword">this</span> /= y;
<a name="l00121"></a>00121 
<a name="l00122"></a>00122     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8cpp.html#a8705584c3c319be54be73dc391d25634">isSigBinOp</a>(t, &amp;op, x, y) &amp;&amp; (op == <a class="code" href="binop_8hh.html#abc6126af1d45847bc59afa0aa3216b04aef0a0af82a04caacbdd669707bfe3ab1">kDiv</a>)) {
<a name="l00123"></a>00123         *<span class="keyword">this</span> /= x;
<a name="l00124"></a>00124         *<span class="keyword">this</span> *= y;
<a name="l00125"></a>00125 
<a name="l00126"></a>00126     } <span class="keywordflow">else</span> {
<a name="l00127"></a>00127         <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>[t] -= 1;
<a name="l00128"></a>00128     }
<a name="l00129"></a>00129     <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00130"></a>00130 }
<a name="l00131"></a>00131 
<a name="l00135"></a><a class="code" href="classmterm.html#a3f5e96fff55d267109e505c35d864935">00135</a> <span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; <a class="code" href="classmterm.html#a3f5e96fff55d267109e505c35d864935" title="replace the content with a copy of m">mterm::operator = </a>(<span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; m)
<a name="l00136"></a>00136 {
<a name="l00137"></a>00137     <a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a> = m.<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>;
<a name="l00138"></a>00138     <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a> = m.<a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>;
<a name="l00139"></a>00139     <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00140"></a>00140 }
<a name="l00141"></a>00141 
<a name="l00145"></a><a class="code" href="classmterm.html#a44217f3cde3aca6ad383892f7817ec2d">00145</a> <span class="keywordtype">void</span> <a class="code" href="classmterm.html#a44217f3cde3aca6ad383892f7817ec2d" title="remove usued factors">mterm::cleanup</a>()
<a name="l00146"></a>00146 {
<a name="l00147"></a>00147     <span class="keywordflow">if</span> (<a class="code" href="signals_8hh.html#a73fa3ec5ebd4e47dc0fde2d24cc08c56">isZero</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>)) {
<a name="l00148"></a>00148         <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.clear();
<a name="l00149"></a>00149     } <span class="keywordflow">else</span> {
<a name="l00150"></a>00150         <span class="keywordflow">for</span> (MP::iterator p = <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.begin(); p != <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.end(); ) {
<a name="l00151"></a>00151             <span class="keywordflow">if</span> (p-&gt;second == 0) {
<a name="l00152"></a>00152                 <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.erase(p++);
<a name="l00153"></a>00153             } <span class="keywordflow">else</span> {
<a name="l00154"></a>00154                 p++;
<a name="l00155"></a>00155             }
<a name="l00156"></a>00156         }
<a name="l00157"></a>00157     }
<a name="l00158"></a>00158 }
<a name="l00159"></a>00159 
<a name="l00164"></a><a class="code" href="classmterm.html#a6ff1a10da12a077065b506a7f72aa00e">00164</a> <span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; <a class="code" href="classmterm.html#a6ff1a10da12a077065b506a7f72aa00e" title="add in place an mterm of same signature">mterm::operator += </a>(<span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; m)
<a name="l00165"></a>00165 {
<a name="l00166"></a>00166     <span class="keywordflow">if</span> (<a class="code" href="signals_8hh.html#a73fa3ec5ebd4e47dc0fde2d24cc08c56">isZero</a>(m.<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>)) {
<a name="l00167"></a>00167         <span class="comment">// nothing to do</span>
<a name="l00168"></a>00168     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8hh.html#a73fa3ec5ebd4e47dc0fde2d24cc08c56">isZero</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>))   {
<a name="l00169"></a>00169         <span class="comment">// copy of m</span>
<a name="l00170"></a>00170         <a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a> = m.<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>;
<a name="l00171"></a>00171         <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a> = m.<a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>;
<a name="l00172"></a>00172     } <span class="keywordflow">else</span> {
<a name="l00173"></a>00173         <span class="comment">// only add mterms of same signature</span>
<a name="l00174"></a>00174         assert(<a class="code" href="classmterm.html#a9577faff72c619359db27cbbd00a1752" title="return a signature (a normalized tree)">signatureTree</a>() == m.<a class="code" href="classmterm.html#a9577faff72c619359db27cbbd00a1752" title="return a signature (a normalized tree)">signatureTree</a>());
<a name="l00175"></a>00175         <a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a> = <a class="code" href="signals_8cpp.html#a369bad070ca89f4e4317d20a2414804a">addNums</a>(fCoef, m.<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>);
<a name="l00176"></a>00176     }
<a name="l00177"></a>00177     <a class="code" href="classmterm.html#a44217f3cde3aca6ad383892f7817ec2d" title="remove usued factors">cleanup</a>();
<a name="l00178"></a>00178     <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00179"></a>00179 }
<a name="l00180"></a>00180 
<a name="l00185"></a><a class="code" href="classmterm.html#a2a089dec86947829b7fcdd9c1ca01813">00185</a> <span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; <a class="code" href="classmterm.html#a2a089dec86947829b7fcdd9c1ca01813" title="add in place an mterm of same signature">mterm::operator -= </a>(<span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; m)
<a name="l00186"></a>00186 {
<a name="l00187"></a>00187     <span class="keywordflow">if</span> (<a class="code" href="signals_8hh.html#a73fa3ec5ebd4e47dc0fde2d24cc08c56">isZero</a>(m.<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>)) {
<a name="l00188"></a>00188         <span class="comment">// nothing to do</span>
<a name="l00189"></a>00189     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8hh.html#a73fa3ec5ebd4e47dc0fde2d24cc08c56">isZero</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>))   {
<a name="l00190"></a>00190         <span class="comment">// minus of m</span>
<a name="l00191"></a>00191         <a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a> = <a class="code" href="signals_8cpp.html#a977348aaa96d81b46d68860a901986da">minusNum</a>(m.<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>);
<a name="l00192"></a>00192         <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a> = m.<a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>;
<a name="l00193"></a>00193     } <span class="keywordflow">else</span> {
<a name="l00194"></a>00194         <span class="comment">// only add mterms of same signature</span>
<a name="l00195"></a>00195         assert(<a class="code" href="classmterm.html#a9577faff72c619359db27cbbd00a1752" title="return a signature (a normalized tree)">signatureTree</a>() == m.<a class="code" href="classmterm.html#a9577faff72c619359db27cbbd00a1752" title="return a signature (a normalized tree)">signatureTree</a>());
<a name="l00196"></a>00196         <a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a> = <a class="code" href="signals_8cpp.html#a0f08d686c84af5dcbb014481cd6b6d80">subNums</a>(fCoef, m.<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>);
<a name="l00197"></a>00197     }
<a name="l00198"></a>00198     <a class="code" href="classmterm.html#a44217f3cde3aca6ad383892f7817ec2d" title="remove usued factors">cleanup</a>();
<a name="l00199"></a>00199     <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00200"></a>00200 }
<a name="l00201"></a>00201 
<a name="l00205"></a><a class="code" href="classmterm.html#a155634973bf382817c5b26466045733c">00205</a> <span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; <a class="code" href="classmterm.html#acbae796c207ab237554ee7f6f4ee392a" title="multiply in place by a multiplicative exp">mterm::operator *= </a>(<span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; m)
<a name="l00206"></a>00206 {
<a name="l00207"></a>00207     <a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a> = <a class="code" href="signals_8cpp.html#a3776e79cce66f0a453a7f9f9c0b121f9">mulNums</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>,m.<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>);
<a name="l00208"></a>00208     <span class="keywordflow">for</span> (MP::const_iterator p = m.<a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.begin(); p != m.<a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.end(); p++) {
<a name="l00209"></a>00209         <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>[p-&gt;first] += p-&gt;second;
<a name="l00210"></a>00210     }
<a name="l00211"></a>00211     <a class="code" href="classmterm.html#a44217f3cde3aca6ad383892f7817ec2d" title="remove usued factors">cleanup</a>();
<a name="l00212"></a>00212     <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00213"></a>00213 }
<a name="l00214"></a>00214 
<a name="l00218"></a><a class="code" href="classmterm.html#aed9a20576f5fb84cfc8602164d4f499b">00218</a> <span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; <a class="code" href="classmterm.html#a00c303e748117461a6711a55146ec28d" title="divide in place by a multiplicative exp">mterm::operator /= </a>(<span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; m)
<a name="l00219"></a>00219 {
<a name="l00220"></a>00220     <span class="comment">//cerr &lt;&lt; &quot;division en place : &quot; &lt;&lt; *this &lt;&lt; &quot; / &quot; &lt;&lt; m &lt;&lt; endl;</span>
<a name="l00221"></a>00221     <a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a> = <a class="code" href="signals_8cpp.html#aba38f7c9a8eeef0df2a7473c760bf66b">divExtendedNums</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>,m.<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>);
<a name="l00222"></a>00222     <span class="keywordflow">for</span> (MP::const_iterator p = m.<a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.begin(); p != m.<a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.end(); p++) {
<a name="l00223"></a>00223         <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>[p-&gt;first] -= p-&gt;second;
<a name="l00224"></a>00224     }
<a name="l00225"></a>00225     <a class="code" href="classmterm.html#a44217f3cde3aca6ad383892f7817ec2d" title="remove usued factors">cleanup</a>();
<a name="l00226"></a>00226     <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00227"></a>00227 }
<a name="l00228"></a>00228 
<a name="l00232"></a><a class="code" href="classmterm.html#ab809f391f059aaa6f9697b334038e0ce">00232</a> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a> <a class="code" href="classmterm.html#ab809f391f059aaa6f9697b334038e0ce" title="mterms multiplication">mterm::operator * </a>(<span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; m)<span class="keyword"> const</span>
<a name="l00233"></a>00233 <span class="keyword"></span>{
<a name="l00234"></a>00234     <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a> r(*<span class="keyword">this</span>);
<a name="l00235"></a>00235     r *= m;
<a name="l00236"></a>00236     <span class="keywordflow">return</span> r;
<a name="l00237"></a>00237 }
<a name="l00238"></a>00238 
<a name="l00242"></a><a class="code" href="classmterm.html#a45be51dbecf9c0933ea2469c1c2cb759">00242</a> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a> <a class="code" href="classmterm.html#a45be51dbecf9c0933ea2469c1c2cb759" title="mterms division">mterm::operator / </a>(<span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; m)<span class="keyword"> const</span>
<a name="l00243"></a>00243 <span class="keyword"></span>{
<a name="l00244"></a>00244     <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a> r(*<span class="keyword">this</span>);
<a name="l00245"></a>00245     r /= m;
<a name="l00246"></a>00246     <span class="keywordflow">return</span> r;
<a name="l00247"></a>00247 }
<a name="l00248"></a>00248 
<a name="l00252"></a><a class="code" href="mterm_8cpp.html#a0756b2c1f2950a0099b062bde262abed">00252</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="mterm_8cpp.html#a0756b2c1f2950a0099b062bde262abed" title="return the &amp;quot;common quantity&amp;quot; of two numbers">common</a>(<span class="keywordtype">int</span> a, <span class="keywordtype">int</span> b)
<a name="l00253"></a>00253 {
<a name="l00254"></a>00254     <span class="keywordflow">if</span> (a &gt; 0 &amp; b &gt; 0) {
<a name="l00255"></a>00255         <span class="keywordflow">return</span> <a class="code" href="interval_8hh.html#a2f8edc4561e9744ed4233b205fa7ec32">min</a>(a,b);
<a name="l00256"></a>00256     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (a &lt; 0 &amp; b &lt; 0) {
<a name="l00257"></a>00257         <span class="keywordflow">return</span> <a class="code" href="interval_8hh.html#a1c45761573e6cbc97cfacac78d905016">max</a>(a,b);
<a name="l00258"></a>00258     } <span class="keywordflow">else</span> {
<a name="l00259"></a>00259         <span class="keywordflow">return</span> 0;
<a name="l00260"></a>00260     }
<a name="l00261"></a>00261 }
<a name="l00262"></a>00262 
<a name="l00263"></a>00263 
<a name="l00267"></a><a class="code" href="mterm_8cpp.html#a385a9a70763e3f9d9b1c6df07a58d4a2">00267</a> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a> <a class="code" href="mterm_8cpp.html#a385a9a70763e3f9d9b1c6df07a58d4a2" title="return a mterm that is the greatest common divisor of two mterms">gcd</a> (<span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; m1, <span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; m2)
<a name="l00268"></a>00268 {
<a name="l00269"></a>00269     <span class="comment">//cerr &lt;&lt; &quot;GCD of &quot; &lt;&lt; m1 &lt;&lt; &quot; and &quot; &lt;&lt; m2 &lt;&lt; endl;</span>
<a name="l00270"></a>00270 
<a name="l00271"></a>00271     <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> c = (m1.<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a> == m2.<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>) ? m1.<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a> : <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(1);       <span class="comment">// common coefficient (real gcd not needed)</span>
<a name="l00272"></a>00272     <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a> R(c);
<a name="l00273"></a>00273     <span class="keywordflow">for</span> (MP::const_iterator p1 = m1.<a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.begin(); p1 != m1.<a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.end(); p1++) {
<a name="l00274"></a>00274         <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 = p1-&gt;first;
<a name="l00275"></a>00275         MP::const_iterator p2 = m2.<a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.find(t);
<a name="l00276"></a>00276         <span class="keywordflow">if</span> (p2 != m2.<a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.end()) {
<a name="l00277"></a>00277             <span class="keywordtype">int</span> v1 = p1-&gt;second;
<a name="l00278"></a>00278             <span class="keywordtype">int</span> v2 = p2-&gt;second;
<a name="l00279"></a>00279             <span class="keywordtype">int</span> c = <a class="code" href="mterm_8cpp.html#a0756b2c1f2950a0099b062bde262abed" title="return the &amp;quot;common quantity&amp;quot; of two numbers">common</a>(v1,v2);
<a name="l00280"></a>00280             <span class="keywordflow">if</span> (c != 0) {
<a name="l00281"></a>00281                 R.<a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>[t] = c;
<a name="l00282"></a>00282             }
<a name="l00283"></a>00283         }
<a name="l00284"></a>00284     }
<a name="l00285"></a>00285     <span class="comment">//cerr &lt;&lt; &quot;GCD of &quot; &lt;&lt; m1 &lt;&lt; &quot; and &quot; &lt;&lt; m2 &lt;&lt; &quot; is : &quot; &lt;&lt; R &lt;&lt; endl;</span>
<a name="l00286"></a>00286     <span class="keywordflow">return</span> R;
<a name="l00287"></a>00287 }
<a name="l00288"></a>00288 
<a name="l00293"></a><a class="code" href="mterm_8cpp.html#ab40b9c37818acb439b805fd70315bad2">00293</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="mterm_8cpp.html#ab40b9c37818acb439b805fd70315bad2" title="We say that a &amp;quot;contains&amp;quot; b if a/b &amp;gt; 0.">contains</a>(<span class="keywordtype">int</span> a, <span class="keywordtype">int</span> b)
<a name="l00294"></a>00294 {
<a name="l00295"></a>00295     <span class="keywordflow">return</span> (b == 0) || (a/b &gt; 0);
<a name="l00296"></a>00296 }
<a name="l00297"></a>00297 
<a name="l00305"></a><a class="code" href="classmterm.html#af2c39e6a83ada2076d5be06a83b92fdd">00305</a> <span class="keywordtype">bool</span> <a class="code" href="classmterm.html#af2c39e6a83ada2076d5be06a83b92fdd" title="return true if this can be divided by n">mterm::hasDivisor</a> (<span class="keyword">const</span> <a class="code" href="classmterm.html" title="Implements a multiplicative term, a term of type k*x^n*y^m*.">mterm</a>&amp; n)<span class="keyword"> const</span>
<a name="l00306"></a>00306 <span class="keyword"></span>{
<a name="l00307"></a>00307     <span class="keywordflow">for</span> (MP::const_iterator p1 = n.<a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.begin(); p1 != n.<a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.end(); p1++) {
<a name="l00308"></a>00308         <span class="comment">// for each factor f**q of m</span>
<a name="l00309"></a>00309         <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 = p1-&gt;first;  
<a name="l00310"></a>00310         <span class="keywordtype">int</span>     v = p1-&gt;second;
<a name="l00311"></a>00311         
<a name="l00312"></a>00312         <span class="comment">// check that f is also a factor of *this</span>
<a name="l00313"></a>00313         MP::const_iterator p2 = <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.find(f);
<a name="l00314"></a>00314         <span class="keywordflow">if</span> (p2 == <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.end()) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00315"></a>00315         
<a name="l00316"></a>00316         <span class="comment">// analyze quantities</span>
<a name="l00317"></a>00317         <span class="keywordtype">int</span> u = p2-&gt;second;
<a name="l00318"></a>00318         <span class="keywordflow">if</span> (! <a class="code" href="mterm_8cpp.html#ab40b9c37818acb439b805fd70315bad2" title="We say that a &amp;quot;contains&amp;quot; b if a/b &amp;gt; 0.">contains</a>(u,v) ) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00319"></a>00319     }
<a name="l00320"></a>00320     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00321"></a>00321 }
<a name="l00322"></a>00322 
<a name="l00330"></a><a class="code" href="mterm_8cpp.html#a989a51a835beba670bf40439995d9643">00330</a> <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="l00331"></a>00331 {
<a name="l00332"></a>00332     assert(f);
<a name="l00333"></a>00333     assert(q&gt;0);
<a name="l00334"></a>00334     <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> r = f;
<a name="l00335"></a>00335     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> c=2; c&lt;=q; c++) { r = <a class="code" href="signals_8hh.html#a333591913e073c3acd6b891b6da85298">sigMul</a>(r,f); }
<a name="l00336"></a>00336     assert(r);
<a name="l00337"></a>00337     <span class="keywordflow">return</span> r;
<a name="l00338"></a>00338 }
<a name="l00339"></a>00339 
<a name="l00343"></a><a class="code" href="mterm_8cpp.html#aaf3bf9f31ee2676c6a38c698191e1f12">00343</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="mterm_8cpp.html#aaf3bf9f31ee2676c6a38c698191e1f12" title="Combine R and A doing R = R*A or R = A.">combineMulLeft</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>&amp; R, <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)
<a name="l00344"></a>00344 {
<a name="l00345"></a>00345     <span class="keywordflow">if</span> (R &amp;&amp; A)     R = <a class="code" href="signals_8hh.html#a333591913e073c3acd6b891b6da85298">sigMul</a>(R,A);
<a name="l00346"></a>00346     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (A)     R = A;
<a name="l00347"></a>00347 }
<a name="l00348"></a>00348 
<a name="l00352"></a><a class="code" href="mterm_8cpp.html#a071cd18b4fc8aca551d99b5523601328">00352</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="mterm_8cpp.html#a071cd18b4fc8aca551d99b5523601328" title="Combine R and A doing R = R*A or R = A.">combineDivLeft</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>&amp; R, <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)
<a name="l00353"></a>00353 {
<a name="l00354"></a>00354     <span class="keywordflow">if</span> (R &amp;&amp; A)     R = <a class="code" href="signals_8hh.html#aa355af5e231f2e25ed43fa2f3bf6c72f">sigDiv</a>(R,A);
<a name="l00355"></a>00355     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (A)     R = <a class="code" href="signals_8hh.html#aa355af5e231f2e25ed43fa2f3bf6c72f">sigDiv</a>(<a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(1.0f),A);
<a name="l00356"></a>00356 }
<a name="l00357"></a>00357 
<a name="l00361"></a><a class="code" href="mterm_8cpp.html#a964193592967662b693d5bc1f028092f">00361</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="mterm_8cpp.html#a964193592967662b693d5bc1f028092f" title="Do M = M * f**q or D = D * f**-q.">combineMulDiv</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>&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>&amp; D, <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="l00362"></a>00362 {
<a name="l00363"></a>00363 <span class="preprocessor">    #ifdef TRACE</span>
<a name="l00364"></a>00364 <span class="preprocessor"></span>    cerr &lt;&lt; <span class="stringliteral">&quot;combineMulDiv (&quot;</span> &lt;&lt; M &lt;&lt; <span class="stringliteral">&quot;/&quot;</span>  &lt;&lt; D &lt;&lt; <span class="stringliteral">&quot;*&quot;</span> &lt;&lt; <a class="code" href="classppsig.html">ppsig</a>(f)&lt;&lt; <span class="stringliteral">&quot;**&quot;</span> &lt;&lt; q &lt;&lt; endl;
<a name="l00365"></a>00365 <span class="preprocessor">    #endif</span>
<a name="l00366"></a>00366 <span class="preprocessor"></span>    <span class="keywordflow">if</span> (f) {
<a name="l00367"></a>00367         <span class="keywordflow">if</span> (q &gt; 0) {
<a name="l00368"></a>00368             <a class="code" href="mterm_8cpp.html#aaf3bf9f31ee2676c6a38c698191e1f12" title="Combine R and A doing R = R*A or R = A.">combineMulLeft</a>(M, <a class="code" href="mterm_8cpp.html#a989a51a835beba670bf40439995d9643" title="produce the canonical tree correspoding to a mterm">buildPowTerm</a>(f,q));
<a name="l00369"></a>00369         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (q &lt; 0) {
<a name="l00370"></a>00370             <a class="code" href="mterm_8cpp.html#aaf3bf9f31ee2676c6a38c698191e1f12" title="Combine R and A doing R = R*A or R = A.">combineMulLeft</a>(D, <a class="code" href="mterm_8cpp.html#a989a51a835beba670bf40439995d9643" title="produce the canonical tree correspoding to a mterm">buildPowTerm</a>(f,-q));
<a name="l00371"></a>00371         }
<a name="l00372"></a>00372     }
<a name="l00373"></a>00373 }   
<a name="l00374"></a>00374     
<a name="l00375"></a>00375             
<a name="l00380"></a><a class="code" href="classmterm.html#a9577faff72c619359db27cbbd00a1752">00380</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="classmterm.html#a9577faff72c619359db27cbbd00a1752" title="return a signature (a normalized tree)">mterm::signatureTree</a>()<span class="keyword"> const</span>
<a name="l00381"></a>00381 <span class="keyword"></span>{
<a name="l00382"></a>00382     <span class="keywordflow">return</span> <a class="code" href="classmterm.html#a6aaebc7c5e6ace53d4ff3e996701a99f" title="return the normalized tree of the mterm">normalizedTree</a>(<span class="keyword">true</span>);
<a name="l00383"></a>00383 }
<a name="l00384"></a>00384     
<a name="l00391"></a><a class="code" href="classmterm.html#a6aaebc7c5e6ace53d4ff3e996701a99f">00391</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="classmterm.html#a6aaebc7c5e6ace53d4ff3e996701a99f" title="return the normalized tree of the mterm">mterm::normalizedTree</a>(<span class="keywordtype">bool</span> signatureMode, <span class="keywordtype">bool</span> negativeMode)<span class="keyword"> const</span>
<a name="l00392"></a>00392 <span class="keyword"></span>{
<a name="l00393"></a>00393     <span class="keywordflow">if</span> (<a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.empty() || <a class="code" href="signals_8hh.html#a73fa3ec5ebd4e47dc0fde2d24cc08c56">isZero</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>)) {
<a name="l00394"></a>00394         <span class="comment">// it&#39;s a pure number</span>
<a name="l00395"></a>00395         <span class="keywordflow">if</span> (signatureMode)  <span class="keywordflow">return</span> <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(1);
<a name="l00396"></a>00396         <span class="keywordflow">if</span> (negativeMode)   <span class="keywordflow">return</span> <a class="code" href="signals_8cpp.html#a977348aaa96d81b46d68860a901986da">minusNum</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>);
<a name="l00397"></a>00397         <span class="keywordflow">else</span>                <span class="keywordflow">return</span> <a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>;
<a name="l00398"></a>00398     } <span class="keywordflow">else</span> {
<a name="l00399"></a>00399         <span class="comment">// it&#39;s not a pure number, it has factors</span>
<a name="l00400"></a>00400         <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[4], B[4];
<a name="l00401"></a>00401         
<a name="l00402"></a>00402         <span class="comment">// group by order</span>
<a name="l00403"></a>00403         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> order = 0; order &lt; 4; order++) {
<a name="l00404"></a>00404             A[order] = 0; B[order] = 0;
<a name="l00405"></a>00405             <span class="keywordflow">for</span> (MP::const_iterator p = <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.begin(); p != <a class="code" href="classmterm.html#a9147de42ca9a68d4b755409479cafa83" title="non constant terms and their power">fFactors</a>.end(); p++) {
<a name="l00406"></a>00406                 <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 = p-&gt;first;       <span class="comment">// f = factor</span>
<a name="l00407"></a>00407                 <span class="keywordtype">int</span>     q = p-&gt;second;      <span class="comment">// q = power of f</span>
<a name="l00408"></a>00408                 <span class="keywordflow">if</span> (f &amp;&amp; q &amp;&amp; <a class="code" href="sigorderrules_8cpp.html#a20942fac53773f763795775cfdcfb086" title="retrieve the order annotation (between 0 and 3) of a signal.">getSigOrder</a>(f)==order) {
<a name="l00409"></a>00409                     
<a name="l00410"></a>00410                     <a class="code" href="mterm_8cpp.html#a964193592967662b693d5bc1f028092f" title="Do M = M * f**q or D = D * f**-q.">combineMulDiv</a> (A[order], B[order], f, q);
<a name="l00411"></a>00411                 }
<a name="l00412"></a>00412             }
<a name="l00413"></a>00413         }
<a name="l00414"></a>00414         <span class="keywordflow">if</span> (A[0] != 0) cerr &lt;&lt; <span class="stringliteral">&quot;A[0] == &quot;</span> &lt;&lt; *A[0] &lt;&lt; endl; 
<a name="l00415"></a>00415         <span class="keywordflow">if</span> (B[0] != 0) cerr &lt;&lt; <span class="stringliteral">&quot;B[0] == &quot;</span> &lt;&lt; *B[0] &lt;&lt; endl; 
<a name="l00416"></a>00416         <span class="comment">// en principe ici l&#39;order zero est vide car il correspond au coef numerique</span>
<a name="l00417"></a>00417         assert(A[0] == 0);
<a name="l00418"></a>00418         assert(B[0] == 0);
<a name="l00419"></a>00419         
<a name="l00420"></a>00420         <span class="comment">// we only use a coeficient if it differes from 1 and if we are not in signature mode</span>
<a name="l00421"></a>00421         <span class="keywordflow">if</span> (! (signatureMode | <a class="code" href="signals_8hh.html#a4569e790c2e0a286bb8ee0f789b01d02">isOne</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>))) {
<a name="l00422"></a>00422             A[0] = (negativeMode) ? <a class="code" href="signals_8cpp.html#a977348aaa96d81b46d68860a901986da">minusNum</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>) : <a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>;
<a name="l00423"></a>00423         }
<a name="l00424"></a>00424         
<a name="l00425"></a>00425         <span class="keywordflow">if</span> (signatureMode) {
<a name="l00426"></a>00426             A[0] = 0;
<a name="l00427"></a>00427         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (negativeMode) {
<a name="l00428"></a>00428             <span class="keywordflow">if</span> (<a class="code" href="signals_8hh.html#afb3b5b685a0984a488b5f3cce80ccf80">isMinusOne</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>)) { A[0] = 0; } <span class="keywordflow">else</span> { A[0] = <a class="code" href="signals_8cpp.html#a977348aaa96d81b46d68860a901986da">minusNum</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>); }
<a name="l00429"></a>00429         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="signals_8hh.html#a4569e790c2e0a286bb8ee0f789b01d02">isOne</a>(<a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>)) {
<a name="l00430"></a>00430             A[0] = 0;
<a name="l00431"></a>00431         } <span class="keywordflow">else</span> {
<a name="l00432"></a>00432             A[0] = <a class="code" href="classmterm.html#acc0c29889a33734c89b3bcd81c2b7c07" title="constant part of the term (usually 1 or -1)">fCoef</a>;
<a name="l00433"></a>00433         }
<a name="l00434"></a>00434                     
<a name="l00435"></a>00435         <span class="comment">// combine each order separately : R[i] = A[i]/B[i]</span>
<a name="l00436"></a>00436         <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> RR = 0;
<a name="l00437"></a>00437         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> order = 0; order &lt; 4; order++) {
<a name="l00438"></a>00438             <span class="keywordflow">if</span> (A[order] &amp;&amp; B[order])   <a class="code" href="mterm_8cpp.html#aaf3bf9f31ee2676c6a38c698191e1f12" title="Combine R and A doing R = R*A or R = A.">combineMulLeft</a>(RR,<a class="code" href="signals_8hh.html#aa355af5e231f2e25ed43fa2f3bf6c72f">sigDiv</a>(A[order],B[order]));
<a name="l00439"></a>00439             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (A[order])          <a class="code" href="mterm_8cpp.html#aaf3bf9f31ee2676c6a38c698191e1f12" title="Combine R and A doing R = R*A or R = A.">combineMulLeft</a>(RR,A[order]);
<a name="l00440"></a>00440             <span class="keywordflow">else</span> <span class="keywordflow">if</span> (B[order])          <a class="code" href="mterm_8cpp.html#a071cd18b4fc8aca551d99b5523601328" title="Combine R and A doing R = R*A or R = A.">combineDivLeft</a>(RR,B[order]);
<a name="l00441"></a>00441         }
<a name="l00442"></a>00442         <span class="keywordflow">if</span> (RR == 0) RR = <a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(1); <span class="comment">// a verifier *******************</span>
<a name="l00443"></a>00443             
<a name="l00444"></a>00444         assert(RR);
<a name="l00445"></a>00445         <span class="comment">//cerr &lt;&lt; &quot;Normalized Tree of &quot; &lt;&lt; *this &lt;&lt; &quot; is &quot; &lt;&lt; ppsig(RR) &lt;&lt; endl;</span>
<a name="l00446"></a>00446         <span class="keywordflow">return</span> RR;
<a name="l00447"></a>00447     }
<a name="l00448"></a>00448 }
<a name="l00449"></a>00449 
</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>