CAPD DynSys Library  5.2.0
capd::intervals::Interval< T_Bound, T_Rnd > Class Template Reference

Definition of template class Interval. More...

#include <capd/intervals/minmax_interval.h>

Public Types

typedef T_Bound BoundType
 
typedef T_Rnd RoundingPolicy
 
typedef IntervalTraits< BoundType >::BoundContainer BoundContainer
 
typedef IntervalTraits< BoundType >::BoundReturnType BoundReturnType
 

Public Member Functions

 Interval ()
 
 Interval (const Interval &A_iv)
 copying constructor More...
 
 Interval (const BoundType &A_scalar)
 constructor from any class that can be coverted to BoundType More...
 
 Interval (const BoundType &A_left, const BoundType &A_right)
 constructor from any class that can be coverted to BoundType More...
 
 Interval (const char left[], const char right[])
 
 Interval (const std::string &left, const std::string &right)
 
BoundReturnType leftBound () const
 returns the left end of the interval More...
 
BoundReturnType rightBound () const
 returns the right end of the interval More...
 
void setLeftBound (const T_Bound &A_left)
 
void setRightBound (const T_Bound &A_right)
 
Interval left () const
 returns interval containing left end More...
 
Interval right () const
 returns interval containing right end More...
 
template<typename T_Scalar >
bool contains (const T_Scalar &A_X) const
 checks if interval contains given point X More...
 
bool contains (const Interval &A_iv) const
 checks if interval contains given interval iv More...
 
template<typename T_Scalar >
bool containsInInterior (const T_Scalar &A_X) const
 checks if interval contains in interior given point X More...
 
bool containsInInterior (const Interval &A_iv) const
 checks if interval contains in interior given interval iv More...
 
bool subset (const Interval &A_iv) const
 checks if interval is subset of iv More...
 
bool subsetInterior (const Interval &A_iv) const
 checks if interval is subset of interior of iv More...
 
Interval mid () const
 returns middle point of interval Splits interval into the form mid + remainder, where mid - is middle point More...
 
void split (Interval &A_rMid, Interval &A_rRemainder) const
 
void split (BoundType &A_rMid, Interval &A_rRemainder) const
 
void split (Interval &r)
 
Intervaloperator= (const Interval &A_iv)
 
Intervaloperator= (const BoundType &A_x)
 
Intervaloperator+= (const Interval &A_iv)
 
Intervaloperator-= (const Interval &A_iv)
 
Intervaloperator*= (const Interval &A_iv)
 
Intervaloperator/= (const Interval &A_iv)
 

Static Public Member Functions

static Interval pi ()
 returns pi constant More...
 
static Interval euler ()
 returns euler constant More...
 
static T_Bound computeExpError ()
 an estimation for the remainder term during computation of "exp" More...
 
static T_Bound computeSinError ()
 An estimation of the remainder term for "sin". More...
 
static T_Bound computeAtanError ()
 An estimation of the remainder term for "atan" for |x|<(sqrt(2)-1) More...
 

Static Public Attributes

static const int S_nExpTaylorOrder = 20
 Taylor series length used in the EXP function. More...
 
static const int S_nLogTaylorOrder = 40
 Taylor series length used in the LOG function, it MUST be an EVEN value. More...
 
static const int S_nSinTaylorOrder = 11
 Taylor series length used in the SIN function, it MUST be an ODD value. More...
 
static const int S_nAtanTaylorOrder = 21
 Taylor series length used in the ATAN function, it MUST be an ODD value. More...
 

Protected Attributes

BoundContainer m_left
 left end of an interval More...
 
BoundContainer m_right
 right end of an interval More...
 

Friends

bool subset (const Interval &A_iv1, const Interval &A_iv2)
 
bool subsetInterior (const Interval &A_iv1, const Interval &A_iv2)
 
bool operator== (const Interval &A_iv1, const Interval &A_iv2)
 
bool operator<= (const Interval &A_iv1, const Interval &A_iv2)
 
bool operator>= (const Interval &A_iv1, const Interval &A_iv2)
 
bool operator< (const Interval &A_iv1, const Interval &A_iv2)
 
bool operator> (const Interval &A_iv1, const Interval &A_iv2)
 
bool operator!= (const Interval &A_iv1, const Interval &A_iv2)
 
Interval operator- (const Interval &A_iv)
 
Interval operator+ (const Interval &A_iv1, const Interval &A_iv2)
 
Interval operator- (const Interval &A_iv1, const Interval &A_iv2)
 
Interval operator* (const Interval &A_iv1, const Interval &A_iv2)
 
Interval operator/ (const Interval &A_iv1, const Interval &A_iv2)
 
Interval operator^ (const Interval &A_iv1, int i)
 
std::ostream & operator<< (std::ostream &s, const Interval &A_iv)
 
std::istream & operator>> (std::istream &s, Interval &A_iv)
 
std::ostream & bitWrite (std::ostream &out, const Interval &iv)
 
std::istream & bitRead (std::istream &in, Interval &iv)
 
std::ostream & hexWrite (std::ostream &out, const Interval &iv)
 
std::istream & hexRead (std::istream &in, Interval &iv)
 
std::ostream & binWrite (std::ostream &out, const Interval &iv)
 
std::istream & binRead (std::istream &in, Interval &iv)
 

Detailed Description

template<typename T_Bound, typename T_Rnd>
class capd::intervals::Interval< T_Bound, T_Rnd >

Definition of template class Interval.

Template has two parameters:

  • T_Bound - type of interval ends,
  • T_Rnd - class that switches rounding (by default it is equal to T_Bound) .

T_Rnd has to provide methods that switch rounding mode:

  • roundUp,
  • roundDown,
  • roundNearest.

To provide full functionality of the class Interval and related functions class T_Bound has to provide methods:

  • constructors: from double, int.
  • relations == != < <= > >=
  • operators + - * / -(unary)
  • operator =
  • input, output operators << >>
  • log, sqrt.
  • capd::max, capd::min, capd::abs (to distinguish from standard template function)
Remarks
We do not assume that elementary function such sin, cos, tan, exp,... for BoundType are computed correctly and therefore we do not use them in interval version. If you have type of endpoint which guarantee correctness of up and down rounding you can write your own specialization of elementary functions e.g. taking advantage of monocity.
Author
Tomasz Kapela
Date
11-01-2006

Member Typedef Documentation

◆ BoundContainer

template<typename T_Bound , typename T_Rnd >
typedef IntervalTraits<BoundType>::BoundContainer capd::intervals::Interval< T_Bound, T_Rnd >::BoundContainer

◆ BoundReturnType

template<typename T_Bound , typename T_Rnd >
typedef IntervalTraits<BoundType>::BoundReturnType capd::intervals::Interval< T_Bound, T_Rnd >::BoundReturnType

◆ BoundType

template<typename T_Bound , typename T_Rnd >
typedef T_Bound capd::intervals::Interval< T_Bound, T_Rnd >::BoundType

◆ RoundingPolicy

template<typename T_Bound , typename T_Rnd >
typedef T_Rnd capd::intervals::Interval< T_Bound, T_Rnd >::RoundingPolicy

Constructor & Destructor Documentation

◆ Interval() [1/6]

template<typename T_Bound , typename T_Rnd >
capd::intervals::Interval< T_Bound, T_Rnd >::Interval
inline

◆ Interval() [2/6]

template<typename T_Bound , typename T_Rnd >
capd::intervals::Interval< T_Bound, T_Rnd >::Interval ( const Interval< T_Bound, T_Rnd > &  A_iv)
inline

copying constructor

◆ Interval() [3/6]

template<typename T_Bound , typename T_Rnd >
capd::intervals::Interval< T_Bound, T_Rnd >::Interval ( const BoundType A_scalar)
inline

constructor from any class that can be coverted to BoundType

◆ Interval() [4/6]

template<typename T_Bound , typename T_Rnd >
capd::intervals::Interval< T_Bound, T_Rnd >::Interval ( const BoundType A_left,
const BoundType A_right 
)

constructor from any class that can be coverted to BoundType

◆ Interval() [5/6]

template<typename T_Bound , typename T_Rnd >
capd::intervals::Interval< T_Bound, T_Rnd >::Interval ( const char  left[],
const char  right[] 
)
inline

◆ Interval() [6/6]

template<typename T_Bound , typename T_Rnd >
capd::intervals::Interval< T_Bound, T_Rnd >::Interval ( const std::string &  left,
const std::string &  right 
)
inline

Member Function Documentation

◆ computeAtanError()

template<typename T_Bound , typename T_Rnd >
T_Bound capd::intervals::Interval< T_Bound, T_Rnd >::computeAtanError
static

An estimation of the remainder term for "atan" for |x|<(sqrt(2)-1)

◆ computeExpError()

template<typename T_Bound , typename T_Rnd >
T_Bound capd::intervals::Interval< T_Bound, T_Rnd >::computeExpError
static

an estimation for the remainder term during computation of "exp"

◆ computeSinError()

template<typename T_Bound , typename T_Rnd >
T_Bound capd::intervals::Interval< T_Bound, T_Rnd >::computeSinError
static

An estimation of the remainder term for "sin".

◆ contains() [1/2]

template<typename T_Bound , typename T_Rnd >
bool capd::intervals::Interval< T_Bound, T_Rnd >::contains ( const Interval< T_Bound, T_Rnd > &  A_iv) const
inline

checks if interval contains given interval iv

◆ contains() [2/2]

template<typename T_Bound , typename T_Rnd >
template<typename T_Scalar >
bool capd::intervals::Interval< T_Bound, T_Rnd >::contains ( const T_Scalar &  A_X) const
inline

checks if interval contains given point X

◆ containsInInterior() [1/2]

template<typename T_Bound , typename T_Rnd >
bool capd::intervals::Interval< T_Bound, T_Rnd >::containsInInterior ( const Interval< T_Bound, T_Rnd > &  A_iv) const
inline

checks if interval contains in interior given interval iv

◆ containsInInterior() [2/2]

template<typename T_Bound , typename T_Rnd >
template<typename T_Scalar >
bool capd::intervals::Interval< T_Bound, T_Rnd >::containsInInterior ( const T_Scalar &  A_X) const
inline

checks if interval contains in interior given point X

◆ euler()

MpInterval capd::intervals::MpInterval::euler
inlinestatic

returns euler constant

◆ left()

template<typename T_Bound , typename T_Rnd >
Interval< T_Bound, T_Rnd > capd::intervals::Interval< T_Bound, T_Rnd >::left
inline

returns interval containing left end

◆ leftBound()

template<typename T_Bound , typename T_Rnd >
Interval< T_Bound, T_Rnd >::BoundReturnType capd::intervals::Interval< T_Bound, T_Rnd >::leftBound
inline

returns the left end of the interval

◆ mid()

template<typename T_Bound , typename T_Rnd >
Interval< T_Bound, T_Rnd > capd::intervals::Interval< T_Bound, T_Rnd >::mid
inline

returns middle point of interval Splits interval into the form mid + remainder, where mid - is middle point

◆ operator*=()

template<typename T_Bound , typename T_Rnd >
__INLINE__ Interval< T_Bound, T_Rnd > & capd::intervals::Interval< T_Bound, T_Rnd >::operator*= ( const Interval< T_Bound, T_Rnd > &  A_iv)

◆ operator+=()

template<typename T_Bound , typename T_Rnd >
__INLINE__ Interval< T_Bound, T_Rnd > & capd::intervals::Interval< T_Bound, T_Rnd >::operator+= ( const Interval< T_Bound, T_Rnd > &  A_iv)

◆ operator-=()

template<typename T_Bound , typename T_Rnd >
__INLINE__ Interval< T_Bound, T_Rnd > & capd::intervals::Interval< T_Bound, T_Rnd >::operator-= ( const Interval< T_Bound, T_Rnd > &  A_iv)

◆ operator/=()

template<typename T_Bound , typename T_Rnd >
__INLINE__ Interval< T_Bound, T_Rnd > & capd::intervals::Interval< T_Bound, T_Rnd >::operator/= ( const Interval< T_Bound, T_Rnd > &  A_iv)

(A_iv.m_left<=0 && A_iv.m_right>=0)

◆ operator=() [1/2]

template<typename T_Bound , typename T_Rnd >
__INLINE__ Interval< T_Bound, T_Rnd > & capd::intervals::Interval< T_Bound, T_Rnd >::operator= ( const BoundType A_x)

◆ operator=() [2/2]

template<typename T_Bound , typename T_Rnd >
__INLINE__ Interval< T_Bound, T_Rnd > & capd::intervals::Interval< T_Bound, T_Rnd >::operator= ( const Interval< T_Bound, T_Rnd > &  A_iv)

◆ pi()

MpInterval capd::intervals::MpInterval::pi
inlinestatic

returns pi constant

◆ right()

template<typename T_Bound , typename T_Rnd >
Interval< T_Bound, T_Rnd > capd::intervals::Interval< T_Bound, T_Rnd >::right
inline

returns interval containing right end

◆ rightBound()

template<typename T_Bound , typename T_Rnd >
Interval< T_Bound, T_Rnd >::BoundReturnType capd::intervals::Interval< T_Bound, T_Rnd >::rightBound
inline

returns the right end of the interval

◆ setLeftBound()

template<typename T_Bound , typename T_Rnd >
void capd::intervals::Interval< T_Bound, T_Rnd >::setLeftBound ( const T_Bound &  A_left)
inline

◆ setRightBound()

template<typename T_Bound , typename T_Rnd >
void capd::intervals::Interval< T_Bound, T_Rnd >::setRightBound ( const T_Bound &  A_right)
inline

◆ split() [1/3]

template<typename T_Bound , typename T_Rnd >
void capd::intervals::Interval< T_Bound, T_Rnd >::split ( BoundType A_rMid,
Interval< T_Bound, T_Rnd > &  A_rRemainder 
) const
inline

◆ split() [2/3]

template<typename T_Bound , typename T_Rnd >
void capd::intervals::Interval< T_Bound, T_Rnd >::split ( Interval< T_Bound, T_Rnd > &  A_rMid,
Interval< T_Bound, T_Rnd > &  A_rRemainder 
) const
inline

◆ split() [3/3]

template<typename T_Bound , typename T_Rnd >
void capd::intervals::Interval< T_Bound, T_Rnd >::split ( Interval< T_Bound, T_Rnd > &  r)
inline

◆ subset()

template<typename T_Bound , typename T_Rnd >
bool capd::intervals::Interval< T_Bound, T_Rnd >::subset ( const Interval< T_Bound, T_Rnd > &  A_iv) const
inline

checks if interval is subset of iv

◆ subsetInterior()

template<typename T_Bound , typename T_Rnd >
bool capd::intervals::Interval< T_Bound, T_Rnd >::subsetInterior ( const Interval< T_Bound, T_Rnd > &  A_iv) const
inline

checks if interval is subset of interior of iv

Friends And Related Function Documentation

◆ binRead

template<typename T_Bound , typename T_Rnd >
std::istream& binRead ( std::istream &  in,
Interval< T_Bound, T_Rnd > &  iv 
)
friend

◆ binWrite

template<typename T_Bound , typename T_Rnd >
std::ostream& binWrite ( std::ostream &  out,
const Interval< T_Bound, T_Rnd > &  iv 
)
friend

◆ bitRead

template<typename T_Bound , typename T_Rnd >
std::istream& bitRead ( std::istream &  in,
Interval< T_Bound, T_Rnd > &  iv 
)
friend

◆ bitWrite

template<typename T_Bound , typename T_Rnd >
std::ostream& bitWrite ( std::ostream &  out,
const Interval< T_Bound, T_Rnd > &  iv 
)
friend

◆ hexRead

template<typename T_Bound , typename T_Rnd >
std::istream& hexRead ( std::istream &  in,
Interval< T_Bound, T_Rnd > &  iv 
)
friend

◆ hexWrite

template<typename T_Bound , typename T_Rnd >
std::ostream& hexWrite ( std::ostream &  out,
const Interval< T_Bound, T_Rnd > &  iv 
)
friend

◆ operator!=

template<typename T_Bound , typename T_Rnd >
bool operator!= ( const Interval< T_Bound, T_Rnd > &  A_iv1,
const Interval< T_Bound, T_Rnd > &  A_iv2 
)
friend

◆ operator*

template<typename T_Bound , typename T_Rnd >
Interval operator* ( const Interval< T_Bound, T_Rnd > &  A_iv1,
const Interval< T_Bound, T_Rnd > &  A_iv2 
)
friend

◆ operator+

template<typename T_Bound , typename T_Rnd >
Interval operator+ ( const Interval< T_Bound, T_Rnd > &  A_iv1,
const Interval< T_Bound, T_Rnd > &  A_iv2 
)
friend

◆ operator- [1/2]

template<typename T_Bound , typename T_Rnd >
Interval operator- ( const Interval< T_Bound, T_Rnd > &  A_iv)
friend

◆ operator- [2/2]

template<typename T_Bound , typename T_Rnd >
Interval operator- ( const Interval< T_Bound, T_Rnd > &  A_iv1,
const Interval< T_Bound, T_Rnd > &  A_iv2 
)
friend

◆ operator/

template<typename T_Bound , typename T_Rnd >
Interval operator/ ( const Interval< T_Bound, T_Rnd > &  A_iv1,
const Interval< T_Bound, T_Rnd > &  A_iv2 
)
friend

◆ operator<

template<typename T_Bound , typename T_Rnd >
bool operator< ( const Interval< T_Bound, T_Rnd > &  A_iv1,
const Interval< T_Bound, T_Rnd > &  A_iv2 
)
friend

◆ operator<<

template<typename T_Bound , typename T_Rnd >
std::ostream& operator<< ( std::ostream &  s,
const Interval< T_Bound, T_Rnd > &  A_iv 
)
friend

◆ operator<=

template<typename T_Bound , typename T_Rnd >
bool operator<= ( const Interval< T_Bound, T_Rnd > &  A_iv1,
const Interval< T_Bound, T_Rnd > &  A_iv2 
)
friend

◆ operator==

template<typename T_Bound , typename T_Rnd >
bool operator== ( const Interval< T_Bound, T_Rnd > &  A_iv1,
const Interval< T_Bound, T_Rnd > &  A_iv2 
)
friend

◆ operator>

template<typename T_Bound , typename T_Rnd >
bool operator> ( const Interval< T_Bound, T_Rnd > &  A_iv1,
const Interval< T_Bound, T_Rnd > &  A_iv2 
)
friend

◆ operator>=

template<typename T_Bound , typename T_Rnd >
bool operator>= ( const Interval< T_Bound, T_Rnd > &  A_iv1,
const Interval< T_Bound, T_Rnd > &  A_iv2 
)
friend

◆ operator>>

template<typename T_Bound , typename T_Rnd >
std::istream& operator>> ( std::istream &  s,
Interval< T_Bound, T_Rnd > &  A_iv 
)
friend

◆ operator^

template<typename T_Bound , typename T_Rnd >
Interval operator^ ( const Interval< T_Bound, T_Rnd > &  A_iv1,
int  i 
)
friend

◆ subset

template<typename T_Bound , typename T_Rnd >
bool subset ( const Interval< T_Bound, T_Rnd > &  A_iv1,
const Interval< T_Bound, T_Rnd > &  A_iv2 
)
friend

◆ subsetInterior

template<typename T_Bound , typename T_Rnd >
bool subsetInterior ( const Interval< T_Bound, T_Rnd > &  A_iv1,
const Interval< T_Bound, T_Rnd > &  A_iv2 
)
friend

Member Data Documentation

◆ m_left

template<typename T_Bound , typename T_Rnd >
BoundContainer capd::intervals::Interval< T_Bound, T_Rnd >::m_left
protected

left end of an interval

◆ m_right

template<typename T_Bound , typename T_Rnd >
BoundContainer capd::intervals::Interval< T_Bound, T_Rnd >::m_right
protected

right end of an interval

◆ S_nAtanTaylorOrder

template<typename T_Bound , typename T_Rnd >
const int capd::intervals::Interval< T_Bound, T_Rnd >::S_nAtanTaylorOrder = 21
static

Taylor series length used in the ATAN function, it MUST be an ODD value.

◆ S_nExpTaylorOrder

template<typename T_Bound , typename T_Rnd >
const int capd::intervals::Interval< T_Bound, T_Rnd >::S_nExpTaylorOrder = 20
static

Taylor series length used in the EXP function.

◆ S_nLogTaylorOrder

template<typename T_Bound , typename T_Rnd >
const int capd::intervals::Interval< T_Bound, T_Rnd >::S_nLogTaylorOrder = 40
static

Taylor series length used in the LOG function, it MUST be an EVEN value.

◆ S_nSinTaylorOrder

template<typename T_Bound , typename T_Rnd >
const int capd::intervals::Interval< T_Bound, T_Rnd >::S_nSinTaylorOrder = 11
static

Taylor series length used in the SIN function, it MUST be an ODD value.