|
FAUST compiler
0.9.9.6b8
|
Implements a multiplicative term, a term of type k*x^n*y^m*... More...
#include <mterm.hh>

Public Member Functions | |
| mterm () | |
| create a 0 mterm More... | |
| mterm (int k) | |
| create a simple integer mterm More... | |
| mterm (double k) | |
| create a simple float mterm More... | |
| mterm (Tree t) | |
| create a mterm from a multiplicative exp More... | |
| mterm (const mterm &m) | |
| create a copy of a mterm More... | |
| void | cleanup () |
| remove usued factors More... | |
| bool | isNotZero () const |
| true if mterm doesn't represent number 0 More... | |
| bool | isNegative () const |
| true if mterm has a negative coefficient More... | |
| const mterm & | operator= (const mterm &m) |
| replace the content with a copy of m More... | |
| const mterm & | operator*= (Tree m) |
| multiply in place by a multiplicative exp More... | |
| const mterm & | operator/= (Tree m) |
| divide in place by a multiplicative exp More... | |
| const mterm & | operator+= (const mterm &m) |
| add in place an mterm of same signature More... | |
| const mterm & | operator-= (const mterm &m) |
| add in place an mterm of same signature More... | |
| const mterm & | operator*= (const mterm &m) |
| multiply in place by a mterm More... | |
| const mterm & | operator/= (const mterm &m) |
| divide in place by a mterm More... | |
| mterm | operator* (const mterm &m) const |
| mterms multiplication More... | |
| mterm | operator/ (const mterm &m) const |
| mterms division More... | |
| ostream & | print (ostream &dst) const |
| print a mterm k*x1**n1*x2**n2... More... | |
| int | complexity () const |
| return an evaluation of the complexity More... | |
| Tree | normalizedTree (bool sign=false, bool neg=false) const |
| return the normalized tree of the mterm More... | |
| Tree | signatureTree () const |
| return a signature (a normalized tree) More... | |
| bool | hasDivisor (const mterm &n) const |
| return true if this can be divided by n More... | |
Private Attributes | |
| Tree | fCoef |
| constant part of the term (usually 1 or -1) More... | |
| map< Tree, int > | fFactors |
| non constant terms and their power More... | |
Friends | |
| mterm | gcd (const mterm &m1, const mterm &m2) |
| return a mterm that is the greatest common divisor of two mterms More... | |
Implements a multiplicative term, a term of type k*x^n*y^m*...
and its arithmetic
| mterm::mterm | ( | Tree | t | ) |
| void mterm::cleanup | ( | ) |
remove usued factors
Clean a mterm by removing x**0 factors.
Definition at line 177 of file mterm.cpp.
References fCoef, fFactors, and isZero().
Referenced by operator*=(), operator+=(), operator-=(), and operator/=().


| int mterm::complexity | ( | ) | const |
return an evaluation of the complexity
Compute the "complexity" of a mterm, that is the number of factors it contains (weighted by the importance of these factors)
Definition at line 65 of file mterm.cpp.
References abs(), fCoef, fFactors, getSigOrder(), and isOne().
Referenced by aterm::greatestDivisor(), and normalizeAddTerm().


| bool mterm::hasDivisor | ( | const mterm & | n | ) | const |
return true if this can be divided by n
Check if M accept N has a divisor.
We can say that N is a divisor of M if M = N*Q and the complexity is preserved : complexity(M) = complexity(N)+complexity(Q) x**u has divisor x**v if u >= v x**-u has divisor x**-v if -u <= -v
Definition at line 337 of file mterm.cpp.
References contains(), and fFactors.
Referenced by aterm::factorize().


| bool mterm::isNegative | ( | ) | const |
true if mterm has a negative coefficient
true if mterm doesn't represent number 0
Definition at line 40 of file mterm.cpp.
References fCoef, and isGEZero().
Referenced by aterm::normalizedTree().


| bool mterm::isNotZero | ( | ) | const |
true if mterm doesn't represent number 0
Definition at line 32 of file mterm.cpp.
References fCoef, and isZero().
Referenced by normalizeAddTerm().


| Tree mterm::normalizedTree | ( | bool | sign = false, |
| bool | neg = false |
||
| ) | const |
return the normalized tree of the mterm
returns a normalized (canonical) tree expression of structure : ((k*(v1/v2))*(c1/c2))*(s1/s2) In signature mode the fCoef factor is ommited In negativeMode the sign of the fCoef factor is inverted
Definition at line 427 of file mterm.cpp.
References combineDivLeft(), combineMulDiv(), combineMulLeft(), fCoef, fFactors, getSigOrder(), isMinusOne(), isOne(), isZero(), minusNum(), sigDiv(), and tree().
Referenced by aterm::factorize(), aterm::normalizedTree(), and signatureTree().


multiply in place by a multiplicative exp
Multiple a mterm by an expression tree t.
Go down recursively looking for multiplications and divisions
Definition at line 103 of file mterm.cpp.
References fCoef, fFactors, isNum(), isSigBinOp(), isSigPow(), kDiv, kMul, and mulNums().

add in place an mterm of same signature
Add in place an mterm.
As we want the result to be a mterm therefore essentially mterms of same signature can be added
Definition at line 196 of file mterm.cpp.
References addNums(), cleanup(), fCoef, fFactors, isZero(), and signatureTree().

add in place an mterm of same signature
Substract in place an mterm.
As we want the result to be a mterm therefore essentially mterms of same signature can be substracted
Definition at line 217 of file mterm.cpp.
References cleanup(), fCoef, fFactors, isZero(), minusNum(), signatureTree(), and subNums().

divide in place by a multiplicative exp
Divide a mterm by an expression tree t.
Go down recursively looking for multiplications and divisions
Definition at line 135 of file mterm.cpp.
References divExtendedNums(), fCoef, fFactors, isNum(), isSigBinOp(), isSigPow(), kDiv, and kMul.

| ostream & mterm::print | ( | ostream & | dst | ) | const |
print a mterm k*x1**n1*x2**n2...
print a mterm in a human readable format
Definition at line 48 of file mterm.cpp.
References fCoef, fFactors, and isOne().
Referenced by operator<<().


| Tree mterm::signatureTree | ( | ) | const |
return a signature (a normalized tree)
returns a normalized (canonical) tree expression of structure : ((v1/v2)*(c1/c2))*(s1/s2)
Definition at line 416 of file mterm.cpp.
References normalizedTree().
Referenced by aterm::operator+=(), operator+=(), aterm::operator-=(), and operator-=().


return a mterm that is the greatest common divisor of two mterms
Definition at line 299 of file mterm.cpp.
|
private |
constant part of the term (usually 1 or -1)
Definition at line 24 of file mterm.hh.
Referenced by cleanup(), complexity(), gcd(), isNegative(), isNotZero(), normalizedTree(), operator*=(), operator+=(), operator-=(), operator/=(), operator=(), and print().
|
private |
non constant terms and their power
Definition at line 25 of file mterm.hh.
Referenced by cleanup(), complexity(), gcd(), hasDivisor(), normalizedTree(), operator*=(), operator+=(), operator-=(), operator/=(), operator=(), and print().
1.8.7