aterm Class Reference

Implements a additive term, a set of mterms added together m1 + m2 + m3 + . More...

#include <aterm.hh>

List of all members.

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 atermoperator+= (Tree t)
 add in place an additive expression tree
const atermoperator-= (Tree t)
 add in place an additive expression tree
const atermoperator+= (const mterm &m)
 add in place an mterm
const atermoperator-= (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

Detailed Description

Implements a additive term, a set of mterms added together m1 + m2 + m3 + .

..

Definition at line 23 of file aterm.hh.


Constructor & Destructor Documentation

aterm::aterm ( Tree  t  ) 

create a aterm from an additive exp

create a aterm from a tree expression

Definition at line 18 of file aterm.cpp.

00019 {
00020     #ifdef TRACE
00021     cerr << "aterm::aterm (" << ppsig(t)<< ")" << endl;
00022     #endif
00023     *this += t;
00024     #ifdef TRACE
00025     cerr << "aterm::aterm (" << ppsig(t)<< ") : -> " << *this << endl;
00026     #endif
00027 }


Member Function Documentation

const aterm & aterm::operator+= ( const mterm m  ) 

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 }

Here is the call graph for this function:

const aterm & aterm::operator+= ( Tree  t  ) 

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 }

const aterm & aterm::operator-= ( const mterm m  ) 

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 }

Here is the call graph for this function:

const aterm & aterm::operator-= ( Tree  t  ) 

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

print a aterm m1 + m2 + m3 +...

print an aterm in a human readable format

Definition at line 107 of file aterm.cpp.

00108 {
00109     if (fSig2MTerms.empty()) {
00110         dst << "AZERO";
00111     } else {
00112         const char* sep = "";
00113         for (SM::const_iterator p = fSig2MTerms.begin(); p != fSig2MTerms.end(); p++) {
00114             dst << sep << p->second;
00115             sep = " + ";
00116         }
00117     }
00118  
00119     return dst;
00120 }


The documentation for this class was generated from the following files:
Generated by  doxygen 1.6.2-20100208