FAUST compiler  0.9.9.6b8
Functions
normalize.cpp File Reference
#include <stdio.h>
#include <assert.h>
#include "tlib.hh"
#include "signals.hh"
#include "sigprint.hh"
#include "ppsig.hh"
#include "simplify.hh"
#include "normalize.hh"
#include "sigorderrules.hh"
#include <map>
#include <list>
#include "mterm.hh"
#include "aterm.hh"
Include dependency graph for normalize.cpp:

Go to the source code of this file.

Functions

Tree normalizeAddTerm (Tree t)
 Compute the Add-Normal form of a term t. More...
 
Tree normalizeDelay1Term (Tree s)
 Compute the normal form of a 1-sample delay term s'. More...
 
Tree normalizeFixedDelayTerm (Tree s, Tree d)
 Compute the normal form of a fixed delay term (s). More...
 

Function Documentation

Tree normalizeAddTerm ( Tree  t)

Compute the Add-Normal form of a term t.

Parameters
tthe term to be normalized
Returns
the normalized term

Definition at line 32 of file normalize.cpp.

References mterm::complexity(), aterm::factorize(), aterm::greatestDivisor(), mterm::isNotZero(), and aterm::normalizedTree().

Referenced by simplification().

33 {
34 #ifdef TRACE
35  cerr << "START normalizeAddTerm : " << ppsig(t) << endl;
36 #endif
37 
38  aterm A(t);
39  //cerr << "ATERM IS : " << A << endl;
40  mterm D = A.greatestDivisor();
41  while (D.isNotZero() && D.complexity() > 0) {
42  //cerr << "GREAT DIV : " << D << endl;
43  A = A.factorize(D);
44  D = A.greatestDivisor();
45  }
46  return A.normalizedTree();
47 }
Implements a multiplicative term, a term of type k*x^n*y^m*...
Definition: mterm.hh:21
Definition: ppsig.hh:48
bool isNotZero() const
true if mterm doesn't represent number 0
Definition: mterm.cpp:32
Tree normalizedTree(bool sign=false, bool neg=false) const
return the normalized tree of the mterm
Definition: mterm.cpp:427
int complexity() const
return an evaluation of the complexity
Definition: mterm.cpp:65
Implements a additive term, a set of mterms added together m1 + m2 + m3 + ...
Definition: aterm.hh:23

Here is the call graph for this function:

Here is the caller graph for this function:

Tree normalizeDelay1Term ( Tree  s)

Compute the normal form of a 1-sample delay term s'.

The normalisation rules are : 0' -> 0 /// INACTIVATE dec07 bug recursion (k*s)' -> k*s' (s/k)' -> s'/k

Parameters
sthe term to be delayed by 1 sample
Returns
the normalized term

Definition at line 59 of file normalize.cpp.

References normalizeFixedDelayTerm(), and tree().

Referenced by simplification().

60 {
61  return normalizeFixedDelayTerm(s, tree(1));
62 }
Tree normalizeFixedDelayTerm(Tree s, Tree d)
Compute the normal form of a fixed delay term (s).
Definition: normalize.cpp:81
Tree tree(const Node &n)
Definition: tree.hh:186

Here is the call graph for this function:

Here is the caller graph for this function:

Tree normalizeFixedDelayTerm ( Tree  s,
Tree  d 
)

Compute the normal form of a fixed delay term (s).

The normalisation rules are : s@0 -> s 0 -> 0 (k*s) -> k*(s) (s/k) -> (s)/k (s
) -> 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
    Parameters
    sthe term to be delayed
    dthe value of the delay
    Returns
    the normalized term

Definition at line 81 of file normalize.cpp.

References getSigOrder(), isProj(), isSigDiv(), isSigFixDelay(), isSigMul(), isZero(), normalizeFixedDelayTerm(), sigAdd(), sigDiv(), sigFixDelay(), sigMul(), and simplify().

Referenced by normalizeDelay1Term(), normalizeFixedDelayTerm(), and simplification().

82 {
83  Tree x, y, r;
84  int i;
85 
86  if (isZero(d) && ! isProj(s, &i, r)) {
87 
88  return s;
89 
90  } else if (isZero(s)) {
91 
92  return s;
93 
94  } else if (isSigMul(s, x, y)) {
95 
96  if (getSigOrder(x) < 2) {
97  return /*simplify*/(sigMul(x,normalizeFixedDelayTerm(y,d)));
98  } else if (getSigOrder(y) < 2) {
99  return /*simplify*/(sigMul(y,normalizeFixedDelayTerm(x,d)));
100  } else {
101  return sigFixDelay(s,d);
102  }
103 
104  } else if (isSigDiv(s, x, y)) {
105 
106  if (getSigOrder(y) < 2) {
107  return /*simplify*/(sigDiv(normalizeFixedDelayTerm(x,d),y));
108  } else {
109  return sigFixDelay(s,d);
110  }
111 
112  } else if (isSigFixDelay(s, x, y)) {
113  // (x@n)@m = x@(n+m)
114 // return sigFixDelay(x,tree(tree2int(d)+tree2int(y)));
115  return normalizeFixedDelayTerm(x,simplify(sigAdd(d,y)));
116 
117  } else {
118 
119  return sigFixDelay(s,d);
120  }
121 }
bool isZero(Tree a)
Definition: signals.hh:188
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
bool isSigFixDelay(Tree t, Tree &t0, Tree &t1)
Definition: signals.cpp:62
Tree simplify(Tree sig)
Definition: simplify.cpp:76
Tree normalizeFixedDelayTerm(Tree s, Tree d)
Compute the normal form of a fixed delay term (s).
Definition: normalize.cpp:81
int getSigOrder(Tree sig)
retrieve the order annotation (between 0 and 3) of a signal.
Tree sigAdd(Tree x, Tree y)
Definition: signals.hh:152
Tree sigFixDelay(Tree t0, Tree t1)
Definition: signals.cpp:61
bool isSigDiv(Tree a, Tree &x, Tree &y)
Definition: signals.cpp:362
Tree sigMul(Tree x, Tree y)
Definition: signals.hh:154
bool isSigMul(Tree a, Tree &x, Tree &y)
Definition: signals.cpp:350
bool isProj(Tree t, int *i, Tree &rgroup)
Definition: signals.cpp:151
Tree sigDiv(Tree x, Tree y)
Definition: signals.hh:155

Here is the call graph for this function:

Here is the caller graph for this function: