mlpack 3.4.2
range.hpp
Go to the documentation of this file.
1
12#ifndef MLPACK_CORE_MATH_RANGE_HPP
13#define MLPACK_CORE_MATH_RANGE_HPP
14
15namespace mlpack {
16namespace math {
17
18template<typename T>
19class RangeType;
20
23
33template<typename T = double>
35{
36 private:
37 T lo;
38 T hi;
39
40 public:
42 inline RangeType();
43
44 /***
45 * Initialize a range to enclose only the given point (lo = point, hi =
46 * point).
47 *
48 * @param point Point that this range will enclose.
49 */
50 inline RangeType(const T point);
51
58 inline RangeType(const T lo, const T hi);
59
61 inline T Lo() const { return lo; }
63 inline T& Lo() { return lo; }
64
66 inline T Hi() const { return hi; }
68 inline T& Hi() { return hi; }
69
73 inline T Width() const;
74
78 inline T Mid() const;
79
85 inline RangeType& operator|=(const RangeType& rhs);
86
92 inline RangeType operator|(const RangeType& rhs) const;
93
100 inline RangeType& operator&=(const RangeType& rhs);
101
108 inline RangeType operator&(const RangeType& rhs) const;
109
115 inline RangeType& operator*=(const T d);
116
122 inline RangeType operator*(const T d) const;
123
130 template<typename TT>
131 friend inline RangeType<TT> operator*(const TT d, const RangeType<TT>& r);
132
138 inline bool operator==(const RangeType& rhs) const;
139
145 inline bool operator!=(const RangeType& rhs) const;
146
153 inline bool operator<(const RangeType& rhs) const;
154
161 inline bool operator>(const RangeType& rhs) const;
162
168 inline bool Contains(const T d) const;
169
177 inline bool Contains(const RangeType& r) const;
178
182 template<typename Archive>
183 void serialize(Archive& ar, const unsigned int version);
184};
185
186} // namespace math
187} // namespace mlpack
188
189// Include inlined implementation.
190#include "range_impl.hpp"
191
192#endif // MLPACK_CORE_MATH_RANGE_HPP
Simple real-valued range.
Definition: range.hpp:35
bool Contains(const RangeType &r) const
Determines if another range overlaps with this one.
RangeType operator*(const T d) const
Scale the bounds by the given double.
friend RangeType< TT > operator*(const TT d, const RangeType< TT > &r)
Scale the bounds by the given double.
RangeType & operator*=(const T d)
Scale the bounds by the given double.
T & Lo()
Modify the lower bound.
Definition: range.hpp:63
T Lo() const
Get the lower bound.
Definition: range.hpp:61
bool operator!=(const RangeType &rhs) const
Compare with another range for strict equality.
RangeType operator&(const RangeType &rhs) const
Shrinks this range to be the overlap with another range; this makes an empty set if there is no overl...
RangeType & operator|=(const RangeType &rhs)
Expands this range to include another range.
bool operator==(const RangeType &rhs) const
Compare with another range for strict equality.
bool Contains(const T d) const
Determines if a point is contained within the range.
T Mid() const
Gets the midpoint of this range.
void serialize(Archive &ar, const unsigned int version)
Serialize the range object.
T & Hi()
Modify the upper bound.
Definition: range.hpp:68
RangeType(const T lo, const T hi)
Initializes to specified range.
RangeType & operator&=(const RangeType &rhs)
Shrinks this range to be the overlap with another range; this makes an empty set if there is no overl...
RangeType(const T point)
RangeType operator|(const RangeType &rhs) const
Expands this range to include another range.
T Width() const
Gets the span of the range (hi - lo).
RangeType()
The upper bound.
bool operator<(const RangeType &rhs) const
Compare with another range.
T Hi() const
Get the upper bound.
Definition: range.hpp:66
bool operator>(const RangeType &rhs) const
Compare with another range.
RangeType< double > Range
3.0.0 TODO: break reverse-compatibility by changing RangeType to Range.
Definition: range.hpp:19
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1