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.
Tree normalizeDelay1Term (Tree s)
 Compute the normal form of a 1-sample delay term s'.
Tree normalizeFixedDelayTerm (Tree s, Tree d)
 Compute the normal form of a fixed delay term (s).

Function Documentation

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().

{
#ifdef TRACE
    cerr << "START normalizeAddTerm : " << ppsig(t) << endl;
#endif
    
    aterm A(t);
    //cerr << "ATERM IS : " << A << endl;
    mterm D = A.greatestDivisor();
    while (D.isNotZero() && D.complexity() > 0) {
        //cerr << "GREAT DIV : " << D << endl;
        A = A.factorize(D);
        D = A.greatestDivisor();
    }
    return A.normalizedTree();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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().

{
    return normalizeFixedDelayTerm(s, tree(1));
}

Here is the call graph for this function:

Here is the caller graph for this function:

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().

{
    Tree x, y, r;
    int i;

    if (isZero(d) && ! isProj(s, &i, r)) {

        return s;

    } else if (isZero(s)) {

        return s;

    } else if (isSigMul(s, x, y)) {

        if (getSigOrder(x) < 2) {
            return /*simplify*/(sigMul(x,normalizeFixedDelayTerm(y,d)));
        } else if (getSigOrder(y) < 2) {
            return /*simplify*/(sigMul(y,normalizeFixedDelayTerm(x,d)));
        } else {
            return sigFixDelay(s,d);
        }

    } else if (isSigDiv(s, x, y)) {

        if (getSigOrder(y) < 2) {
            return /*simplify*/(sigDiv(normalizeFixedDelayTerm(x,d),y));
        } else {
            return sigFixDelay(s,d);
        }

    } else if (isSigFixDelay(s, x, y)) {
        // (x@n)@m = x@(n+m)
//      return sigFixDelay(x,tree(tree2int(d)+tree2int(y)));
        return normalizeFixedDelayTerm(x,simplify(sigAdd(d,y))); 

    } else {

        return sigFixDelay(s,d);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function: