PLearn 0.1
Public Member Functions | Public Attributes
PLearn::RealRange Class Reference

represents a real range: i.e. one of ]low,high[ ; [low,high[; [low,high]; ]low,high] More...

#include <RealMapping.h>

Collaboration diagram for PLearn::RealRange:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RealRange ()
 RealRange (char leftbracket_, real low_, real high_, char rightbracket_)
real span ()
void checkbrackets () const
void print (ostream &out) const
void write (ostream &out) const
void read (PStream &in)
string getString () const
bool contains (real val) const
 Compare RealRange and real: the relation is either: Range `contains` real Range < real, if higher bound < real Range > real, if lower bound > real.
bool operator< (real x) const
bool operator> (real x) const
bool operator< (const RealRange &x) const
bool operator> (const RealRange &x) const
bool operator== (const RealRange &rr) const

Public Attributes

real low
real high
char leftbracket
char rightbracket

Detailed Description

represents a real range: i.e. one of ]low,high[ ; [low,high[; [low,high]; ]low,high]

Definition at line 53 of file RealMapping.h.


Constructor & Destructor Documentation

PLearn::RealRange::RealRange ( ) [inline]

Definition at line 62 of file RealMapping.h.

               : // default construvtor
        low(0), high(0), leftbracket(']'), rightbracket('[')
    {}
PLearn::RealRange::RealRange ( char  leftbracket_,
real  low_,
real  high_,
char  rightbracket_ 
) [inline]

Definition at line 67 of file RealMapping.h.

                                                                           :
        low(low_), high(high_), leftbracket(leftbracket_), rightbracket(rightbracket_)
    { checkbrackets(); } 

Member Function Documentation

void PLearn::RealRange::checkbrackets ( ) const [inline]

Definition at line 73 of file RealMapping.h.

References PLERROR.

Referenced by PLearn::operator>>().

    {
        if( (leftbracket!='[' && leftbracket!=']') || (rightbracket!='[' && rightbracket!=']') )
            PLERROR("In RealRange: Brackets must be either '[' or ']'"); 
    }

Here is the caller graph for this function:

bool PLearn::RealRange::contains ( real  val) const

Compare RealRange and real: the relation is either: Range `contains` real Range < real, if higher bound < real Range > real, if lower bound > real.

Definition at line 115 of file RealMapping.cc.

References PLearn::fast_exact_is_equal().

{ return (val>=low) && (val<=high)
                    && (!fast_exact_is_equal(val, low)  || leftbracket=='[')
                    && (!fast_exact_is_equal(val, high) || rightbracket==']');
}

Here is the call graph for this function:

string PLearn::RealRange::getString ( ) const

Definition at line 103 of file RealMapping.cc.

{
    ostringstream s;
    s << leftbracket << low << ' ' << high << rightbracket;
    return s.str();
//    
//    char s[50];
//    sprintf(s,"%c%f %f%c",leftbracket,low,high,rightbracket);
//    return s;
}  
bool PLearn::RealRange::operator< ( real  x) const

Definition at line 121 of file RealMapping.cc.

References PLearn::fast_exact_is_equal().

{ return high < x || (fast_exact_is_equal(high, x) && rightbracket == '['); }

Here is the call graph for this function:

bool PLearn::RealRange::operator< ( const RealRange x) const

Compare 2 RealRanges: This can be used to sort a list of RealRanges, or to build a map indexed by RealRanges. Note that ordering of ranges is only properly defined for ranges that do not overlap.

Definition at line 127 of file RealMapping.cc.

References PLearn::fast_exact_is_equal(), leftbracket, and low.

{ return high < x.low || (fast_exact_is_equal(high, x.low) && (rightbracket=='[' || x.leftbracket==']')); }

Here is the call graph for this function:

bool PLearn::RealRange::operator== ( const RealRange rr) const

Definition at line 133 of file RealMapping.cc.

References PLearn::fast_exact_is_equal(), high, leftbracket, low, and rightbracket.

{
    return (fast_exact_is_equal(rr.low, low)  && 
            fast_exact_is_equal(rr.high,high) && 
            rr.leftbracket == leftbracket     && 
            rr.rightbracket == rightbracket);
}

Here is the call graph for this function:

bool PLearn::RealRange::operator> ( real  x) const

Definition at line 124 of file RealMapping.cc.

References PLearn::fast_exact_is_equal().

{ return low > x || (fast_exact_is_equal(low, x) && leftbracket == ']'); }

Here is the call graph for this function:

bool PLearn::RealRange::operator> ( const RealRange x) const

Definition at line 130 of file RealMapping.cc.

References PLearn::fast_exact_is_equal(), high, and rightbracket.

{ return low > x.high || (fast_exact_is_equal(low, x.high) && (leftbracket==']' || x.rightbracket=='[')); }

Here is the call graph for this function:

void PLearn::RealRange::print ( ostream &  out) const [inline]

Definition at line 79 of file RealMapping.h.

Referenced by PLearn::operator<<().

    { out << leftbracket << low << ' ' << high << rightbracket; }

Here is the caller graph for this function:

void PLearn::RealRange::read ( PStream in) [inline]

Definition at line 85 of file RealMapping.h.

Referenced by PLearn::read(), and PLearn::RealMapping::read().

Here is the caller graph for this function:

real PLearn::RealRange::span ( ) [inline]

Definition at line 71 of file RealMapping.h.

References PLearn::abs().

{return abs(high-low);}

Here is the call graph for this function:

void PLearn::RealRange::write ( ostream &  out) const [inline]

Definition at line 82 of file RealMapping.h.

Referenced by PLearn::write().

    { out << leftbracket << low << ' ' << high << rightbracket; }

Here is the caller graph for this function:


Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines