MLPACK  1.0.7
range.hpp
Go to the documentation of this file.
1 
22 #ifndef __MLPACK_CORE_MATH_RANGE_HPP
23 #define __MLPACK_CORE_MATH_RANGE_HPP
24 
25 namespace mlpack {
26 namespace math {
27 
31 class Range
32 {
33  private:
34  double lo;
35  double hi;
36 
37  public:
39  inline Range();
40 
41  /***
42  * Initialize a range to enclose only the given point (lo = point, hi =
43  * point).
44  *
45  * @param point Point that this range will enclose.
46  */
47  inline Range(const double point);
48 
55  inline Range(const double lo, const double hi);
56 
58  inline double Lo() const { return lo; }
60  inline double& Lo() { return lo; }
61 
63  inline double Hi() const { return hi; }
65  inline double& Hi() { return hi; }
66 
70  inline double Width() const;
71 
75  inline double Mid() const;
76 
82  inline Range& operator|=(const Range& rhs);
83 
89  inline Range operator|(const Range& rhs) const;
90 
97  inline Range& operator&=(const Range& rhs);
98 
105  inline Range operator&(const Range& rhs) const;
106 
112  inline Range& operator*=(const double d);
113 
119  inline Range operator*(const double d) const;
120 
126  friend inline Range operator*(const double d, const Range& r); // Symmetric.
127 
133  inline bool operator==(const Range& rhs) const;
134 
140  inline bool operator!=(const Range& rhs) const;
141 
148  inline bool operator<(const Range& rhs) const;
149 
156  inline bool operator>(const Range& rhs) const;
157 
163  inline bool Contains(const double d) const;
164 
172  inline bool Contains(const Range& r) const;
173 
177  inline std::string ToString() const;
178 
179 };
180 
181 }; // namespace math
182 }; // namespace mlpack
183 
184 // Include inlined implementation.
185 #include "range_impl.hpp"
186 
187 #endif // __MLPACK_CORE_MATH_RANGE_HPP
double Hi() const
Get the upper bound.
Definition: range.hpp:63
Range()
The upper bound.
double hi
The lower bound.
Definition: range.hpp:35
Range operator*(const double d) const
Scale the bounds by the given double.
Range & operator|=(const Range &rhs)
Expands this range to include another range.
double Lo() const
Get the lower bound.
Definition: range.hpp:58
double & Hi()
Modify the upper bound.
Definition: range.hpp:65
bool operator==(const Range &rhs) const
Compare with another range for strict equality.
double & Lo()
Modify the lower bound.
Definition: range.hpp:60
std::string ToString() const
Returns a string representation of an object.
bool operator!=(const Range &rhs) const
Compare with another range for strict equality.
double Mid() const
Gets the midpoint of this range.
Range operator|(const Range &rhs) const
Expands this range to include another range.
bool Contains(const double d) const
Determines if a point is contained within the range.
double Width() const
Gets the span of the range (hi - lo).
bool operator>(const Range &rhs) const
Compare with another range.
Range operator&(const Range &rhs) const
Shrinks this range to be the overlap with another range; this makes an empty set if there is no overl...
Simple real-valued range.
Definition: range.hpp:31
Range & operator&=(const Range &rhs)
Shrinks this range to be the overlap with another range; this makes an empty set if there is no overl...
bool operator<(const Range &rhs) const
Compare with another range.
Range & operator*=(const double d)
Scale the bounds by the given double.