npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
npstat::Interval< Numeric > Class Template Reference

#include <Interval.hh>

Public Types

typedef Numeric value_type
 

Public Member Functions

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

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.

Constructor & Destructor Documentation

◆ Interval() [1/3]

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

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

◆ Interval() [2/3]

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().

◆ Interval() [3/3]

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).

Member Function Documentation

◆ expand()

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

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

◆ getBounds()

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

Return both bounds

◆ isInside() [1/2]

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)?

◆ isInside() [2/2]

template<typename Numeric >
bool npstat::Interval< Numeric >::isInside ( Numeric  value,
BoundaryInclusion  bi 
) const

Is the point inside the interval with the given boundary inclusion handling?

◆ isInsideLower()

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

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

◆ isInsideUpper()

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

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

◆ isInsideWithBounds()

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?

◆ length()

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

Interval length

◆ linearMap()

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

◆ logicalDifference()

template<typename Numeric >
std::pair<Interval,Interval> npstat::Interval< Numeric >::logicalDifference ( const Interval< Numeric > &  r) const

Which points are inside this interval but outside the argument interval? The result can have 0, 1, or 2 intervals. The default constructed empty interval will be substituted for the absence of the first and/or the second interval in the result.

◆ max()

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

Return the upper bound

◆ midpoint()

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

The middle point of the interval

◆ min()

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

Return the lower bound

◆ moveMidpointTo0()

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

Move the interval so that the midpoint ends up at 0

◆ operator*=()

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

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

◆ operator+=()

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

Shift both interval bounds by a constant

◆ overlap()

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

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

◆ overlapFraction()

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

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

◆ overlapLength()

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

Same as overlap.length() but a tad faster

◆ setBounds()

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

Set both interval bounds

◆ setMax()

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

Set the upper interval bound

◆ setMin()

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

Set the lower interval bound


The documentation for this class was generated from the following file: