bpp::Interval Class Reference

An interval, either bounded or not. More...

#include <Bpp/Numeric/Constraints.h>

Inheritance diagram for bpp::Interval:
Inheritance graph
[legend]
Collaboration diagram for bpp::Interval:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Interval ()
 Interval (double lowerBound, double upperBound, bool inclLower, bool inclUpper, double precision=NumConstants::TINY)
virtual ~Interval ()
Intervalclone () const
 Create a copy of this object and send a pointer to it.
void setLowerBound (double lowerBound, bool strict)
void setUpperBound (double upperBound, bool strict)
double getLowerBound () const
double getUpperBound () const
bool strictLowerBound () const
bool strictUpperBound () const
bool includes (double min, double max) const
 Tell if all the values in a given interval are correct.
virtual bool isCorrect (double value) const
 Tell if a given value is correct.
bool operator< (double value) const
bool operator> (double value) const
bool operator<= (double value) const
bool operator>= (double value) const
double getLimit (double value) const
 Give the nearest limit for a bad value.
double getAcceptedLimit (double value) const
 Give the nearest accepted limit for a bad value.
double getPrecision () const
std::string getDescription () const
 Give a short description on the type of constraint.
Constraintoperator& (const Constraint &c) const
 Intersect this Interval with another one.
Intervaloperator&= (const Constraint &c)
 Intersect this Interval with another one.
bool operator== (const Interval &i) const
 Tells if this interval equals another one.
bool operator!= (const Interval &i) const
 Tells if this interval is different from another one.
bool operator<= (const Interval &i) const
 Tells if this interval is included or equal in another one.

Protected Attributes

double lowerBound_
 The boundaries of the interval.
double upperBound_
bool inclLowerBound_
 Boolean flags are true if the boundaries are included.
bool inclUpperBound_
double precision_
 the accepted precision on the boundary (default: 1e-12)

Detailed Description

An interval, either bounded or not.

Definition at line 123 of file Constraints.h.


Constructor & Destructor Documentation

bpp::Interval::Interval (  )  [inline]

Definition at line 146 of file Constraints.h.

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

bpp::Interval::Interval ( double  lowerBound,
double  upperBound,
bool  inclLower,
bool  inclUpper,
double  precision = NumConstants::TINY 
) [inline]

Definition at line 152 of file Constraints.h.

virtual bpp::Interval::~Interval (  )  [inline, virtual]

Definition at line 159 of file Constraints.h.


Member Function Documentation

Interval* bpp::Interval::clone (  )  const [inline, virtual]
double bpp::Interval::getAcceptedLimit ( double  value  )  const [inline, virtual]

Give the nearest accepted limit for a bad value.

The difference with getLimit() is when the Constraint is open at the limit, in which case the retruned value is the limit +- 1e-12.

Parameters:
value The bad value.
Returns:
The nearer limit.

Implements bpp::Constraint.

Definition at line 211 of file Constraints.h.

References isCorrect(), lowerBound_, precision_, strictLowerBound(), strictUpperBound(), and upperBound_.

std::string bpp::Interval::getDescription (  )  const [inline, virtual]

Give a short description on the type of constraint.

Returns:
A string which describes the constraint.

Implements bpp::Constraint.

Definition at line 224 of file Constraints.h.

References inclLowerBound_, inclUpperBound_, lowerBound_, bpp::TextTools::toString(), upperBound_, and bpp::NumConstants::VERY_BIG.

double bpp::Interval::getLimit ( double  value  )  const [inline, virtual]

Give the nearest limit for a bad value.

Parameters:
value The bad value.
Returns:
The nearer limit.

Implements bpp::Constraint.

Definition at line 205 of file Constraints.h.

References isCorrect(), lowerBound_, and upperBound_.

double bpp::Interval::getLowerBound (  )  const [inline]
double bpp::Interval::getPrecision (  )  const [inline]

Definition at line 219 of file Constraints.h.

References precision_.

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

double bpp::Interval::getUpperBound (  )  const [inline]
bool bpp::Interval::includes ( double  min,
double  max 
) const [inline, virtual]

Tell if all the values in a given interval are correct.

Parameters:
min,max The bounds of the interval.
Returns:
True is the value is correct.

Implements bpp::Constraint.

Definition at line 173 of file Constraints.h.

References getLowerBound(), getUpperBound(), inclLowerBound_, and inclUpperBound_.

virtual bool bpp::Interval::isCorrect ( double  value  )  const [inline, virtual]
bool bpp::Interval::operator!= ( const Interval i  )  const [inline]

Tells if this interval is different from another one.

Parameters:
i the compared Interval

Definition at line 336 of file Constraints.h.

References inclLowerBound_, inclUpperBound_, lowerBound_, and upperBound_.

Constraint* bpp::Interval::operator& ( const Constraint c  )  const [inline, virtual]

Intersect this Interval with another one.

Parameters:
c the intersected Interval
Returns:
the intersection, or NULL if c is not an Interval. The resulting precision is the maximum of both precisions.

Implements bpp::Constraint.

Definition at line 240 of file Constraints.h.

References getPrecision(), inclLowerBound_, inclUpperBound_, Interval(), lowerBound_, precision_, and upperBound_.

Interval& bpp::Interval::operator&= ( const Constraint c  )  [inline]

Intersect this Interval with another one.

Parameters:
c the intersected Interval
Returns:
this Interval modified, or not modified if c is not an Interval. The precision is set to the maximum of bith precisions.

Definition at line 284 of file Constraints.h.

References getPrecision(), inclLowerBound_, inclUpperBound_, lowerBound_, precision_, and upperBound_.

bool bpp::Interval::operator< ( double  value  )  const [inline]

Definition at line 185 of file Constraints.h.

References inclUpperBound_, and upperBound_.

bool bpp::Interval::operator<= ( const Interval i  )  const [inline]

Tells if this interval is included or equal in another one.

Parameters:
i the compared Interval

Definition at line 349 of file Constraints.h.

References lowerBound_, and upperBound_.

bool bpp::Interval::operator<= ( double  value  )  const [inline]

Definition at line 195 of file Constraints.h.

References upperBound_.

bool bpp::Interval::operator== ( const Interval i  )  const [inline]

Tells if this interval equals another one.

Parameters:
i the compared Interval

Definition at line 323 of file Constraints.h.

References inclLowerBound_, inclUpperBound_, lowerBound_, and upperBound_.

bool bpp::Interval::operator> ( double  value  )  const [inline]

Definition at line 190 of file Constraints.h.

References inclLowerBound_, and lowerBound_.

bool bpp::Interval::operator>= ( double  value  )  const [inline]

Definition at line 200 of file Constraints.h.

References lowerBound_.

void bpp::Interval::setLowerBound ( double  lowerBound,
bool  strict 
) [inline]
void bpp::Interval::setUpperBound ( double  upperBound,
bool  strict 
) [inline]
bool bpp::Interval::strictLowerBound (  )  const [inline]

Definition at line 170 of file Constraints.h.

References inclLowerBound_.

Referenced by bpp::AbstractDiscreteDistribution::discretize(), and getAcceptedLimit().

bool bpp::Interval::strictUpperBound (  )  const [inline]

Definition at line 171 of file Constraints.h.

References inclUpperBound_.

Referenced by bpp::AbstractDiscreteDistribution::discretize(), and getAcceptedLimit().


Member Data Documentation

Boolean flags are true if the boundaries are included.

Definition at line 136 of file Constraints.h.

Referenced by getDescription(), includes(), isCorrect(), operator!=(), operator&(), operator&=(), operator==(), operator>(), setLowerBound(), and strictLowerBound().

double bpp::Interval::lowerBound_ [protected]
double bpp::Interval::precision_ [protected]

the accepted precision on the boundary (default: 1e-12)

Definition at line 142 of file Constraints.h.

Referenced by getAcceptedLimit(), getPrecision(), operator&(), and operator&=().

double bpp::Interval::upperBound_ [protected]

The documentation for this class was generated from the following file:
Generated on Wed Feb 29 14:48:24 2012 for bpp-core by  doxygen 1.6.3