CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
npstat::Interval< Numeric > Class Template Reference

#include <Interval.h>

Public Member Functions

void getBounds (Numeric *pmin, Numeric *pmax) const
 
 Interval ()
 
 Interval (const Numeric max)
 
 Interval (const Numeric min, const Numeric max, const bool swapIfOutOfOrder=false)
 
bool isInside (const Numeric value) const
 
bool isInsideLower (const Numeric value) const
 
bool isInsideUpper (const Numeric value) const
 
bool isInsideWithBounds (const Numeric value) const
 
Numeric length () const
 
template<typename Num2 >
void linearMap (const Interval< Num2 > &r, double *a, double *b) const
 
const Numeric max () const
 
Numeric midpoint () const
 
const Numeric min () const
 
IntervalmoveMidpointTo0 ()
 
Interval overlap (const Interval &r) const
 
double overlapFraction (const Interval &r) const
 
Numeric overlapLength (const Interval &r) const
 
void setBounds (const Numeric minval, const Numeric maxval, const bool swapIfOutOfOrder=false)
 
void setMax (const Numeric value)
 
void setMin (const Numeric value)
 
Intervaloperator*= (double r)
 
Intervaloperator/= (double r)
 
Intervaloperator+= (const Numeric value)
 
Intervaloperator-= (const Numeric value)
 
Intervalexpand (double r)
 

Private Attributes

Numeric max_
 
Numeric min_
 

Detailed Description

template<typename Numeric>
class npstat::Interval< Numeric >

Representation of 1-d intervals. The following invariant is maintained: min() will not exceed max().

See BoxND class for rectangles, boxes, and hyperboxes.

Definition at line 25 of file Interval.h.

Constructor & Destructor Documentation

template<typename Numeric>
npstat::Interval< Numeric >::Interval ( )
inline

Both lower and upper interval bounds are set to Numeric()

Definition at line 29 of file Interval.h.

template<typename Numeric>
npstat::Interval< Numeric >::Interval ( const Numeric  max)
inlineexplicit

Minimum is set to Numeric(), maximum to the given argument. An exception is thrown if the argument is smaller than Numeric().

Definition at line 35 of file Interval.h.

template<typename Numeric>
npstat::Interval< Numeric >::Interval ( const Numeric  min,
const Numeric  max,
const bool  swapIfOutOfOrder = false 
)
inline

Constructor from both bounds. Set "swapIfOutOfOrder" argument to "true" if the minimum can be larger than the maximum (in this case the bounds will be swapped internally).

Definition at line 47 of file Interval.h.

Member Function Documentation

template<typename Numeric >
Interval< Numeric > & npstat::Interval< Numeric >::expand ( double  r)
inline

Scaling the bounds by a constant in such a way that the midpoint remains unchanged

Definition at line 257 of file Interval.h.

template<typename Numeric>
void npstat::Interval< Numeric >::getBounds ( Numeric *  pmin,
Numeric *  pmax 
) const
inline

Return both bounds

Definition at line 97 of file Interval.h.

template<typename Numeric>
bool npstat::Interval< Numeric >::isInside ( const Numeric  value) const
inline

Is the point completely inside the interval (and does not coincide with any bound)?

Definition at line 123 of file Interval.h.

template<typename Numeric>
bool npstat::Interval< Numeric >::isInsideLower ( const Numeric  value) const
inline

Is the point inside the interval or on the lower boundary?

Definition at line 108 of file Interval.h.

template<typename Numeric>
bool npstat::Interval< Numeric >::isInsideUpper ( const Numeric  value) const
inline

Is the point inside the interval or on the upper boundary?

Definition at line 112 of file Interval.h.

template<typename Numeric>
bool npstat::Interval< Numeric >::isInsideWithBounds ( const Numeric  value) const
inline

Is the point inside the interval or on one of the boundaries?

Definition at line 116 of file Interval.h.

template<typename Numeric>
Numeric npstat::Interval< Numeric >::length ( ) const
inline

Interval length

Definition at line 101 of file Interval.h.

template<typename Numeric >
template<typename Num2 >
void npstat::Interval< Numeric >::linearMap ( const Interval< Num2 > &  r,
double *  a,
double *  b 
) const

Derive the coefficients a and b such that the linear mapping y = a*x + b maps the lower limit of this interval into the lower limit of the argument interval and the upper limit of this interval into the upper limit of the argument interval

Definition at line 299 of file Interval.h.

template<typename Numeric>
const Numeric npstat::Interval< Numeric >::max ( ) const
inline

Return the upper bound

Definition at line 94 of file Interval.h.

Referenced by npstat::ArrayRange::operator<().

template<typename Numeric>
Numeric npstat::Interval< Numeric >::midpoint ( ) const
inline

The middle point of the interval

Definition at line 104 of file Interval.h.

template<typename Numeric>
const Numeric npstat::Interval< Numeric >::min ( ) const
inline

Return the lower bound

Definition at line 91 of file Interval.h.

Referenced by npstat::ArrayRange::operator<().

template<typename Numeric >
Interval< Numeric > & npstat::Interval< Numeric >::moveMidpointTo0 ( )
inline

Move the interval so that the midpoint ends up at 0

Definition at line 248 of file Interval.h.

template<typename Numeric >
Interval< Numeric > & npstat::Interval< Numeric >::operator*= ( double  r)
inline

Scaling of both the minimum and the maximum by a constant. Minimum and maximum will be swapped internally in case the constant is negative.

Definition at line 238 of file Interval.h.

template<typename Numeric >
Interval< Numeric > & npstat::Interval< Numeric >::operator+= ( const Numeric  value)
inline

Shift both interval bounds by a constant

Definition at line 282 of file Interval.h.

template<typename Numeric >
Interval< Numeric > & npstat::Interval< Numeric >::operator-= ( const Numeric  value)
inline

Definition at line 290 of file Interval.h.

template<typename Numeric >
Interval< Numeric > & npstat::Interval< Numeric >::operator/= ( double  r)
inline

Definition at line 270 of file Interval.h.

template<typename Numeric >
Interval< Numeric > npstat::Interval< Numeric >::overlap ( const Interval< Numeric > &  r) const
inline

The following function returns default-constructed empty interval in case this interval and the argument interval do not overlap

Definition at line 195 of file Interval.h.

template<typename Numeric >
double npstat::Interval< Numeric >::overlapFraction ( const Interval< Numeric > &  r) const
inline

Same as overlapLength(r)/length() but a tad faster

Definition at line 225 of file Interval.h.

template<typename Numeric >
Numeric npstat::Interval< Numeric >::overlapLength ( const Interval< Numeric > &  r) const
inline

Same as overlap.length() but a tad faster

Definition at line 212 of file Interval.h.

template<typename Numeric>
void npstat::Interval< Numeric >::setBounds ( const Numeric  minval,
const Numeric  maxval,
const bool  swapIfOutOfOrder = false 
)
inline

Set both interval bounds

Definition at line 78 of file Interval.h.

template<typename Numeric>
void npstat::Interval< Numeric >::setMax ( const Numeric  value)
inline

Set the upper interval bound

Definition at line 70 of file Interval.h.

template<typename Numeric>
void npstat::Interval< Numeric >::setMin ( const Numeric  value)
inline

Set the lower interval bound

Definition at line 62 of file Interval.h.

Member Data Documentation

template<typename Numeric>
Numeric npstat::Interval< Numeric >::max_
private

Definition at line 177 of file Interval.h.

template<typename Numeric>
Numeric npstat::Interval< Numeric >::min_
private

Definition at line 176 of file Interval.h.