1 #ifndef NPSTAT_INTERVAL_HH_ 2 #define NPSTAT_INTERVAL_HH_ 24 template <
typename Numeric>
39 "In npstat::Interval constructor: invalid limits");
48 const bool swapIfOutOfOrder =
false)
57 "In npstat::Interval constructor: invalid limits");
65 "In npstat::Interval::setMin: argument above max");
73 "In npstat::Interval::setMax: argument below min");
78 inline void setBounds(
const Numeric minval,
const Numeric maxval,
79 const bool swapIfOutOfOrder =
false)
81 if (maxval < minval && !swapIfOutOfOrder)
83 "In npstat::Interval::setBounds: invalid limits");
91 inline const Numeric
min()
const {
return min_;}
94 inline const Numeric
max()
const {
return max_;}
97 inline void getBounds(Numeric* pmin, Numeric* pmax)
const 105 {
return static_cast<Numeric
>((
max_ +
min_)*0.5);}
109 {
return value >=
min_ && value <
max_;}
113 {
return value >
min_ && value <=
max_;}
117 {
return value >=
min_ && value <=
max_;}
124 {
return value >
min_ && value <
max_;}
172 template <
typename Num2>
183 template <
typename Numeric>
186 template <
typename Numeric>
194 template <
typename Numeric>
211 template <
typename Numeric>
224 template <
typename Numeric>
237 template <
typename Numeric>
247 template <
typename Numeric>
251 max_ = len/
static_cast<Numeric
>(2);
256 template <
typename Numeric>
259 const double r = fabs(ir);
262 const Numeric center(static_cast<Numeric>((
max_ +
min_)*0.5));
264 max_ = center + (max_ - center)*r;
269 template <
typename Numeric>
273 "In npstat::Interval::operator/=: division by zero");
281 template <
typename Numeric>
289 template <
typename Numeric>
297 template <
typename Numeric>
298 template <
typename Num2>
303 "In npstat::Interval::linearMap: zero length interval");
306 const Num2 rmax(r.
max());
307 const Num2 rmin(r.
min());
308 *a =
static_cast<double>((rmax - rmin)*1.0/(
max_ -
min_));
309 *b =
static_cast<double>((rmax + rmin) - *a*(
max_ +
min_))/2.0;
313 template <
typename Numeric>
319 template <
typename Numeric>
326 #endif // NPSTAT_INTERVAL_HH_
Interval(const Numeric min, const Numeric max, const bool swapIfOutOfOrder=false)
Interval overlap(const Interval &r) const
Interval & moveMidpointTo0()
Interval & operator+=(const Numeric value)
Interval & operator-=(const Numeric value)
bool isInside(const Numeric value) const
void getBounds(Numeric *pmin, Numeric *pmax) const
void setBounds(const Numeric minval, const Numeric maxval, const bool swapIfOutOfOrder=false)
void linearMap(const Interval< Num2 > &r, double *a, double *b) const
void setMax(const Numeric value)
const Numeric max() const
bool isInsideUpper(const Numeric value) const
Exceptions for the npstat namespace.
Numeric overlapLength(const Interval &r) const
double overlapFraction(const Interval &r) const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void setMin(const Numeric value)
Interval & expand(double r)
bool operator==(const npstat::Interval< Numeric > &l, const npstat::Interval< Numeric > &r)
Interval & operator*=(double r)
Interval(const Numeric max)
bool isInsideLower(const Numeric value) const
const Numeric min() const
Interval & operator/=(double r)
bool operator!=(const npstat::Interval< Numeric > &l, const npstat::Interval< Numeric > &r)
bool isInsideWithBounds(const Numeric value) const