Implements a additive term, a set of mterms added together m1 + m2 + m3 + . More...
#include <aterm.hh>
Public Member Functions | |
aterm () | |
create an empty aterm (equivalent to 0) | |
aterm (Tree t) | |
create a aterm from an additive exp | |
aterm (const aterm &a) | |
create a copy of an aterm | |
const aterm & | operator+= (Tree t) |
add in place an additive expression tree | |
const aterm & | operator-= (Tree t) |
add in place an additive expression tree | |
const aterm & | operator+= (const mterm &m) |
add in place an mterm | |
const aterm & | operator-= (const mterm &m) |
add in place an mterm | |
Tree | normalizedTree () const |
return the corresponding normalized expression tree | |
ostream & | print (ostream &dst) const |
print a aterm m1 + m2 + m3 +... | |
mterm | greatestDivisor () const |
return the greatest divisor of any two mterms | |
aterm | factorize (const mterm &d) |
reorganize the aterm by factorizing d |
Implements a additive term, a set of mterms added together m1 + m2 + m3 + .
..
Definition at line 23 of file aterm.hh.
add in place an mterm
Add in place an mterm.
Definition at line 180 of file aterm.cpp.
References mterm::signatureTree().
00181 { 00182 #ifdef TRACE 00183 cerr << *this << " aterm::+= " << m << endl; 00184 #endif 00185 Tree sig = m.signatureTree(); 00186 #ifdef TRACE 00187 cerr << "signature " << *sig << endl; 00188 #endif 00189 SM::const_iterator p = fSig2MTerms.find(sig); 00190 if (p == fSig2MTerms.end()) { 00191 // its a new mterm 00192 fSig2MTerms.insert(make_pair(sig,m)); 00193 } else { 00194 fSig2MTerms[sig] += m; 00195 } 00196 return *this; 00197 }
add in place an additive expression tree
Add in place an additive expression tree Go down t recursively looking for additions and substractions.
Definition at line 127 of file aterm.cpp.
00128 { 00129 int op; 00130 Tree x,y; 00131 00132 assert(t!=0); 00133 00134 if (isSigBinOp(t, &op, x, y) && (op == kAdd)) { 00135 *this += x; 00136 *this += y; 00137 00138 } else if (isSigBinOp(t, &op, x, y) && (op == kSub)) { 00139 *this += x; 00140 *this -= y; 00141 00142 } else { 00143 mterm m(t); 00144 *this += m; 00145 } 00146 return *this; 00147 }
add in place an mterm
Substract in place an mterm.
Definition at line 203 of file aterm.cpp.
References mterm::signatureTree().
00204 { 00205 //cerr << *this << " aterm::-= " << m << endl; 00206 Tree sig = m.signatureTree(); 00207 //cerr << "signature " << *sig << endl; 00208 SM::const_iterator p = fSig2MTerms.find(sig); 00209 if (p == fSig2MTerms.end()) { 00210 // its a new mterm 00211 fSig2MTerms.insert(make_pair(sig,m*mterm(-1))); 00212 } else { 00213 fSig2MTerms[sig] -= m; 00214 } 00215 return *this; 00216 }
add in place an additive expression tree
Substract in place an additive expression tree Go down t recursively looking for additions and substractions.
Definition at line 154 of file aterm.cpp.
00155 { 00156 int op; 00157 Tree x,y; 00158 00159 assert(t!=0); 00160 00161 if (isSigBinOp(t, &op, x, y) && (op == kAdd)) { 00162 *this -= x; 00163 *this -= y; 00164 00165 } else if (isSigBinOp(t, &op, x, y) && (op == kSub)) { 00166 *this -= x; 00167 *this += y; 00168 00169 } else { 00170 mterm m(t); 00171 *this -= m; 00172 } 00173 return *this; 00174 }
ostream & aterm::print | ( | ostream & | dst | ) | const |