1 #ifndef NPSTAT_INTERVAL_HH_
2 #define NPSTAT_INTERVAL_HH_
24 template <
typename Numeric>
68 inline void setBounds(
const Numeric minval,
const Numeric maxval,
const bool swapIfOutOfOrder =
false) {
69 if (maxval < minval && !swapIfOutOfOrder)
78 inline const Numeric
min()
const {
return min_; }
81 inline const Numeric
max()
const {
return max_; }
84 inline void getBounds(Numeric* pmin, Numeric* pmax)
const {
156 template <
typename Num2>
167 template <
typename Numeric>
170 template <
typename Numeric>
178 template <
typename Numeric>
183 else if (r.
max_ == min_)
185 else if (max_ > r.
min_ && r.
max_ > min_) {
192 template <
typename Numeric>
194 if (max_ > r.
min_ && r.
max_ > min_) {
195 const Numeric mn = min_ < r.
min_ ? r.
min_ : min_;
196 const Numeric mx = max_ < r.
max_ ? max_ : r.
max_;
202 template <
typename Numeric>
204 if (max_ > r.
min_ && r.
max_ > min_) {
205 const Numeric mn = min_ < r.
min_ ? r.
min_ : min_;
206 const Numeric mx = max_ < r.
max_ ? max_ : r.
max_;
207 return (mx - mn) * 1.0 / (max_ - min_);
212 template <
typename Numeric>
221 template <
typename Numeric>
223 const Numeric len = max_ - min_;
224 max_ = len /
static_cast<Numeric
>(2);
229 template <
typename Numeric>
231 const double r = fabs(ir);
233 const Numeric center(static_cast<Numeric>((max_ + min_) * 0.5));
234 min_ = center + (min_ - center) * r;
235 max_ = center + (max_ - center) * r;
240 template <
typename Numeric>
251 template <
typename Numeric>
258 template <
typename Numeric>
265 template <
typename Numeric>
266 template <
typename Num2>
272 const Num2 rmax(r.
max());
273 const Num2 rmin(r.
min());
274 *a =
static_cast<double>((rmax - rmin) * 1.0 / (max_ - min_));
275 *b =
static_cast<double>((rmax + rmin) - *a * (max_ + min_)) / 2.0;
279 template <
typename Numeric>
284 template <
typename Numeric>
289 #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)
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
void setMin(const Numeric value)
Interval & expand(double r)
bool operator!=(DTCELinkId const &lhs, DTCELinkId const &rhs)
Interval & operator*=(double r)
Interval(const Numeric max)
bool isInsideLower(const Numeric value) const
const Numeric min() const
Interval & operator/=(double r)
bool isInsideWithBounds(const Numeric value) const