mlpack  1.0.12
range.hpp
Go to the documentation of this file.
1 
14 #ifndef __MLPACK_CORE_MATH_RANGE_HPP
15 #define __MLPACK_CORE_MATH_RANGE_HPP
16 
17 namespace mlpack {
18 namespace math {
19 
23 class Range
24 {
25  private:
26  double lo;
27  double hi;
28 
29  public:
31  inline Range();
32 
33  /***
34  * Initialize a range to enclose only the given point (lo = point, hi =
35  * point).
36  *
37  * @param point Point that this range will enclose.
38  */
39  inline Range(const double point);
40 
47  inline Range(const double lo, const double hi);
48 
50  inline double Lo() const { return lo; }
52  inline double& Lo() { return lo; }
53 
55  inline double Hi() const { return hi; }
57  inline double& Hi() { return hi; }
58 
62  inline double Width() const;
63 
67  inline double Mid() const;
68 
74  inline Range& operator|=(const Range& rhs);
75 
81  inline Range operator|(const Range& rhs) const;
82 
89  inline Range& operator&=(const Range& rhs);
90 
97  inline Range operator&(const Range& rhs) const;
98 
104  inline Range& operator*=(const double d);
105 
111  inline Range operator*(const double d) const;
112 
118  friend inline Range operator*(const double d, const Range& r); // Symmetric.
119 
125  inline bool operator==(const Range& rhs) const;
126 
132  inline bool operator!=(const Range& rhs) const;
133 
140  inline bool operator<(const Range& rhs) const;
141 
148  inline bool operator>(const Range& rhs) const;
149 
155  inline bool Contains(const double d) const;
156 
164  inline bool Contains(const Range& r) const;
165 
169  inline std::string ToString() const;
170 
171 };
172 
173 }; // namespace math
174 }; // namespace mlpack
175 
176 // Include inlined implementation.
177 #include "range_impl.hpp"
178 
179 #endif // __MLPACK_CORE_MATH_RANGE_HPP
double Hi() const
Get the upper bound.
Definition: range.hpp:55
Range()
The upper bound.
double hi
The lower bound.
Definition: range.hpp:27
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:23
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:50
double & Hi()
Modify the upper bound.
Definition: range.hpp:57
bool operator==(const Range &rhs) const
Compare with another range for strict equality.
double & Lo()
Modify the lower bound.
Definition: range.hpp:52
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:23
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.