FAUST compiler  0.9.9.6b8
Classes | Functions
interval.hh File Reference
#include <math.h>
#include <iostream>
Include dependency graph for interval.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  interval

Functions

ostream & operator<< (ostream &dst, const interval &i)
double min (double x, double y)
double max (double x, double y)
double min4 (double a, double b, double c, double d)
double max4 (double a, double b, double c, double d)
interval reunion (const interval &x, const interval &y)
interval operator+ (const interval &x, const interval &y)
interval operator- (const interval &x, const interval &y)
interval operator* (const interval &x, const interval &y)
interval operator/ (const interval &x, const interval &y)
interval operator% (const interval &x, const interval &y)
int bitmask (double x)
 Convert a number 1bbb..b into a bit mask 1111..1 of same width.
interval operator& (const interval &x, const interval &y)
interval operator| (const interval &x, const interval &y)
interval operator^ (const interval &, const interval &)
interval operator<< (const interval &, const interval &)
interval operator>> (const interval &, const interval &)
interval operator< (const interval &, const interval &)
interval operator<= (const interval &, const interval &)
interval operator> (const interval &, const interval &)
interval operator>= (const interval &, const interval &)
interval operator== (const interval &, const interval &)
interval operator!= (const interval &, const interval &)
interval min (const interval &x, const interval &y)
interval max (const interval &x, const interval &y)
interval abs (const interval &x)

Function Documentation

interval abs ( const interval x) [inline]

Definition at line 213 of file interval.hh.

References interval::hi, interval::lo, max(), and interval::valid.

Referenced by mterm::complexity(), AbsPrim::computeSigOutput(), AbsPrim::infereSigType(), isExpPower(), and isPiPower().

{
    if (x.valid) {
        if (x.lo >= 0) {
            return x;
        } else if (x.hi < 0) {
            return interval(fabs(x.hi), fabs(x.lo));
        } else {
            return interval(0, max(fabs(x.lo), x.hi));
        }
    } else {
        return x;
    }
}       

Here is the call graph for this function:

Here is the caller graph for this function:

int bitmask ( double  x) [inline]

Convert a number 1bbb..b into a bit mask 1111..1 of same width.

Definition at line 114 of file interval.hh.

Referenced by operator&(), and operator|().

                                {
    int v = int(x);
    for (int i=1; i<32; i*=2)   { v |= v>>i; }
    return v;
}

Here is the caller graph for this function:

double max ( double  x,
double  y 
) [inline]
interval max ( const interval x,
const interval y 
) [inline]

Definition at line 208 of file interval.hh.

References interval::hi, interval::lo, and max().

{
    return interval(max(x.lo,y.lo), max(x.hi,y.hi));
}

Here is the call graph for this function:

double max4 ( double  a,
double  b,
double  c,
double  d 
) [inline]

Definition at line 62 of file interval.hh.

References max().

Referenced by operator*().

{ return max(max(a,b),max(c,d)); }

Here is the call graph for this function:

Here is the caller graph for this function:

double min ( double  x,
double  y 
) [inline]
interval min ( const interval x,
const interval y 
) [inline]

Definition at line 203 of file interval.hh.

References interval::hi, interval::lo, and min().

{
    return interval(min(x.lo,y.lo), min(x.hi,y.hi));
}

Here is the call graph for this function:

double min4 ( double  a,
double  b,
double  c,
double  d 
) [inline]

Definition at line 61 of file interval.hh.

References min().

Referenced by operator*().

{ return min(min(a,b),min(c,d)); }

Here is the call graph for this function:

Here is the caller graph for this function:

interval operator!= ( const interval ,
const interval  
) [inline]

Definition at line 196 of file interval.hh.

{
    return interval(0,1);
}
interval operator% ( const interval x,
const interval y 
) [inline]

Definition at line 104 of file interval.hh.

References interval::hi, interval::lo, and interval::valid.

{
    return (x.valid && y.valid && x.lo >= 0 && y.lo > 0) 
            ? interval(0,y.hi)
            : interval();
}
interval operator& ( const interval x,
const interval y 
) [inline]

Definition at line 122 of file interval.hh.

References bitmask(), interval::hi, interval::lo, and interval::valid.

{
    if (x.valid && y.valid) {
        if (x.lo >= 0 & y.lo >= 0) {
            return interval(0, bitmask(x.hi) & bitmask(y.hi));
        } else if (y.lo >= 0) {
            return interval(0, bitmask(y.hi));
        } else if (x.lo >= 0) {
            return interval(0, bitmask(y.hi));
        } else {
            return interval();
        }
    } else if (x.valid & x.lo >= 0) {
        return interval(0, bitmask(x.hi));
    } else if (y.valid & y.lo >= 0) {
        return interval(0, bitmask(y.hi));
    } else {
        return interval();
    }
}

Here is the call graph for this function:

interval operator* ( const interval x,
const interval y 
) [inline]

Definition at line 84 of file interval.hh.

References interval::hi, interval::lo, max4(), min4(), and interval::valid.

{ 
    if (x.valid&y.valid) {
        double a=x.lo*y.lo; 
        double b=x.lo*y.hi; 
        double c=x.hi*y.lo; 
        double d=x.hi*y.hi;
        return interval(min4(a,b,c,d), max4(a,b,c,d));
    } else {
        return interval();
    }
}

Here is the call graph for this function:

interval operator+ ( const interval x,
const interval y 
) [inline]

Definition at line 74 of file interval.hh.

References interval::hi, interval::lo, and interval::valid.

{ 
    return (x.valid&y.valid) ? interval(x.lo+y.lo, x.hi+y.hi) : interval(); 
}
interval operator- ( const interval x,
const interval y 
) [inline]

Definition at line 79 of file interval.hh.

References interval::hi, interval::lo, and interval::valid.

{ 
    return (x.valid & y.valid) ? interval(x.lo-y.hi, x.hi-y.lo) : interval();; 
}
interval operator/ ( const interval x,
const interval y 
) [inline]

Definition at line 97 of file interval.hh.

References interval::hi, interval::lo, and interval::valid.

{
    return (x.valid && y.valid && (y.lo > 0 | y.hi < 0)) 
            ? x * interval(1/y.hi,1/y.lo)
            : interval();
}
interval operator< ( const interval ,
const interval  
) [inline]

Definition at line 171 of file interval.hh.

{
    return interval(0,1);
}
ostream& operator<< ( ostream &  dst,
const interval i 
) [inline]

Definition at line 50 of file interval.hh.

References interval::hi, interval::lo, and interval::valid.

{ 
    if (i.valid) {
        return  dst << "interval(" << i.lo << ", " << i.hi << ")";
    } else {
        return  dst << "interval()";
    }
}
interval operator<< ( const interval ,
const interval  
) [inline]

Definition at line 157 of file interval.hh.

{
    return interval();
}
interval operator<= ( const interval ,
const interval  
) [inline]

Definition at line 176 of file interval.hh.

{
    return interval(0,1);
}
interval operator== ( const interval ,
const interval  
) [inline]

Definition at line 191 of file interval.hh.

{
    return interval(0,1);
}
interval operator> ( const interval ,
const interval  
) [inline]

Definition at line 181 of file interval.hh.

{
    return interval(0,1);
}
interval operator>= ( const interval ,
const interval  
) [inline]

Definition at line 186 of file interval.hh.

{
    return interval(0,1);
}
interval operator>> ( const interval ,
const interval  
) [inline]

Definition at line 162 of file interval.hh.

{
    return interval();
}
interval operator^ ( const interval ,
const interval  
) [inline]

Definition at line 152 of file interval.hh.

{
    return interval();
}
interval operator| ( const interval x,
const interval y 
) [inline]

Definition at line 143 of file interval.hh.

References bitmask(), interval::hi, interval::lo, and interval::valid.

{
    if (x.valid && y.valid && x.lo >= 0 && y.lo >= 0) {
        return interval(0, bitmask(x.hi) | bitmask(y.hi));
    } else {
        return interval();
    }
}

Here is the call graph for this function:

interval reunion ( const interval x,
const interval y 
) [inline]

Definition at line 64 of file interval.hh.

References interval::hi, interval::lo, max(), min(), and interval::valid.

Referenced by infereSigType(), and operator|().

{
    if (x.valid & y.valid) {
        return interval(min(x.lo,y.lo), max(x.hi,y.hi));
    } else {
        return interval();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function: