mlpack
Public Member Functions | Friends | List of all members
mlpack::math::RangeType< T > Class Template Reference

Simple real-valued range. More...

#include <range.hpp>

Public Member Functions

 RangeType ()
 The upper bound. More...
 
 RangeType (const T point)
 Initialize a range to enclose only the given point.
 
 RangeType (const T lo, const T hi)
 Initializes to specified range. More...
 
Lo () const
 Get the lower bound.
 
T & Lo ()
 Modify the lower bound.
 
Hi () const
 Get the upper bound.
 
T & Hi ()
 Modify the upper bound.
 
Width () const
 Gets the span of the range (hi - lo). More...
 
Mid () const
 Gets the midpoint of this range.
 
RangeTypeoperator|= (const RangeType &rhs)
 Expands this range to include another range. More...
 
RangeType operator| (const RangeType &rhs) const
 Expands this range to include another range. More...
 
RangeTypeoperator &= (const RangeType &rhs)
 Shrinks this range to be the overlap with another range; this makes an empty set if there is no overlap. More...
 
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 overlap. More...
 
RangeTypeoperator*= (const T d)
 Scale the bounds by the given double. More...
 
RangeType operator* (const T d) const
 Scale the bounds by the given double. More...
 
bool operator== (const RangeType &rhs) const
 Compare with another range for strict equality. More...
 
bool operator!= (const RangeType &rhs) const
 Compare with another range for strict equality. More...
 
bool operator< (const RangeType &rhs) const
 Compare with another range. More...
 
bool operator> (const RangeType &rhs) const
 Compare with another range. More...
 
bool Contains (const T d) const
 Determines if a point is contained within the range. More...
 
bool Contains (const RangeType &r) const
 Determines if another range overlaps with this one. More...
 
template<typename Archive >
void serialize (Archive &ar, const uint32_t version)
 Serialize the range object. More...
 

Friends

template<typename TT >
RangeType< TT > operator* (const TT d, const RangeType< TT > &r)
 Scale the bounds by the given double. More...
 

Detailed Description

template<typename T = double>
class mlpack::math::RangeType< T >

Simple real-valued range.

It contains an upper and lower bound.

Note that until mlpack 3.0.0, this class is named RangeType<> and for the specification where T is double, you can use math::Range. As of mlpack 3.0.0, this class will be renamed math::Range<>.

Template Parameters
Ttype of element held by this range.

Constructor & Destructor Documentation

◆ RangeType() [1/2]

template<typename T >
mlpack::math::RangeType< T >::RangeType ( )
inline

The upper bound.

Initialize the range to 0.

Initialize to an empty set (where lo > hi).

◆ RangeType() [2/2]

template<typename T>
mlpack::math::RangeType< T >::RangeType ( const T  lo,
const T  hi 
)
inline

Initializes to specified range.

Initializes the range to the specified values.

Parameters
loLower bound of the range.
hiUpper bound of the range.

Member Function Documentation

◆ Contains() [1/2]

template<typename T>
bool mlpack::math::RangeType< T >::Contains ( const T  d) const
inline

Determines if a point is contained within the range.

Parameters
dPoint to check.

◆ Contains() [2/2]

template<typename T>
bool mlpack::math::RangeType< T >::Contains ( const RangeType< T > &  r) const
inline

Determines if another range overlaps with this one.

Determines if this range overlaps with another range.

Parameters
rOther range.
Returns
true if ranges overlap at all.

◆ operator &()

template<typename T = double>
RangeType mlpack::math::RangeType< T >::operator& ( const RangeType< T > &  rhs) const
inline

Shrinks this range to be the overlap with another range; this makes an empty set if there is no overlap.

Parameters
rhsOther range.

◆ operator &=()

template<typename T = double>
RangeType& mlpack::math::RangeType< T >::operator&= ( const RangeType< T > &  rhs)
inline

Shrinks this range to be the overlap with another range; this makes an empty set if there is no overlap.

Parameters
rhsOther range.

◆ operator!=()

template<typename T >
bool mlpack::math::RangeType< T >::operator!= ( const RangeType< T > &  rhs) const
inline

Compare with another range for strict equality.

Parameters
rhsOther range.

◆ operator*()

template<typename T>
RangeType< T > mlpack::math::RangeType< T >::operator* ( const T  d) const
inline

Scale the bounds by the given double.

Parameters
dScaling factor.

◆ operator*=()

template<typename T>
RangeType< T > & mlpack::math::RangeType< T >::operator*= ( const T  d)
inline

Scale the bounds by the given double.

Parameters
dScaling factor.

◆ operator<()

template<typename T >
bool mlpack::math::RangeType< T >::operator< ( const RangeType< T > &  rhs) const
inline

Compare with another range.

For Range objects x and y, x < y means that x is strictly less than y and does not overlap at all.

Parameters
rhsOther range.

For Range objects x and y, x < y means that x is strictly less than y and does not overlap at all.

◆ operator==()

template<typename T >
bool mlpack::math::RangeType< T >::operator== ( const RangeType< T > &  rhs) const
inline

Compare with another range for strict equality.

Parameters
rhsOther range.

◆ operator>()

template<typename T >
bool mlpack::math::RangeType< T >::operator> ( const RangeType< T > &  rhs) const
inline

Compare with another range.

For Range objects x and y, x < y means that x is strictly less than y and does not overlap at all.

Parameters
rhsOther range.

◆ operator|()

template<typename T >
RangeType< T > mlpack::math::RangeType< T >::operator| ( const RangeType< T > &  rhs) const
inline

Expands this range to include another range.

Parameters
rhsRange to include.

◆ operator|=()

template<typename T >
RangeType< T > & mlpack::math::RangeType< T >::operator|= ( const RangeType< T > &  rhs)
inline

Expands this range to include another range.

Expands range to include the other range.

Parameters
rhsRange to include.

◆ serialize()

template<typename T >
template<typename Archive >
void mlpack::math::RangeType< T >::serialize ( Archive &  ar,
const uint32_t  version 
)

Serialize the range object.

Serialize the range.

◆ Width()

template<typename T >
T mlpack::math::RangeType< T >::Width ( ) const
inline

Gets the span of the range (hi - lo).

Gets the span of the range, hi - lo.

Returns 0 if the range is negative.

Friends And Related Function Documentation

◆ operator*

template<typename T = double>
template<typename TT >
RangeType<TT> operator* ( const TT  d,
const RangeType< TT > &  r 
)
friend

Scale the bounds by the given double.

Parameters
dScaling factor.
rBounds range.

The documentation for this class was generated from the following files: