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

Simple real-valued range. More...

Public Member Functions

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

Private Attributes

hi
 The lower bound. More...
 
lo
 

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.

Definition at line 21 of file range.hpp.

Constructor & Destructor Documentation

◆ RangeType() [1/3]

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

The upper bound.

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

◆ RangeType() [2/3]

template<typename T = double>
mlpack::math::RangeType< T >::RangeType ( const T  point)
inline

◆ RangeType() [3/3]

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

Initializes to specified range.

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

Member Function Documentation

◆ Contains() [1/2]

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

Determines if a point is contained within the range.

Parameters
dPoint to check.

Referenced by mlpack::math::RangeType< T >::Hi().

◆ Contains() [2/2]

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

Determines if another range overlaps with this one.

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

◆ Hi() [1/2]

template<typename T = double>
T mlpack::math::RangeType< T >::Hi ( ) const
inline

Get the upper bound.

Definition at line 68 of file range.hpp.

References mlpack::math::RangeType< T >::hi.

◆ Hi() [2/2]

template<typename T = double>
T& mlpack::math::RangeType< T >::Hi ( )
inline

◆ Lo() [1/2]

template<typename T = double>
T mlpack::math::RangeType< T >::Lo ( ) const
inline

Get the lower bound.

Definition at line 63 of file range.hpp.

References mlpack::math::RangeType< T >::lo.

◆ Lo() [2/2]

template<typename T = double>
T& mlpack::math::RangeType< T >::Lo ( )
inline

Modify the lower bound.

Definition at line 65 of file range.hpp.

References mlpack::math::RangeType< T >::lo.

◆ Mid()

template<typename T = double>
T mlpack::math::RangeType< T >::Mid ( ) const
inline

Gets the midpoint of this range.

Referenced by mlpack::math::RangeType< T >::Hi().

◆ 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.

Referenced by mlpack::math::RangeType< T >::Hi().

◆ 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.

Referenced by mlpack::math::RangeType< T >::Hi().

◆ operator!=()

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

Compare with another range for strict equality.

Parameters
rhsOther range.

Referenced by mlpack::math::RangeType< T >::Hi().

◆ operator*()

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

Scale the bounds by the given double.

Parameters
dScaling factor.

Referenced by mlpack::math::RangeType< T >::Hi().

◆ operator*=()

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

Scale the bounds by the given double.

Parameters
dScaling factor.

Referenced by mlpack::math::RangeType< T >::Hi().

◆ operator<()

template<typename T = double>
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.

Referenced by mlpack::math::RangeType< T >::Hi().

◆ operator==()

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

Compare with another range for strict equality.

Parameters
rhsOther range.

Referenced by mlpack::math::RangeType< T >::Hi().

◆ operator>()

template<typename T = double>
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.

Referenced by mlpack::math::RangeType< T >::Hi().

◆ operator|()

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

Expands this range to include another range.

Parameters
rhsRange to include.

Referenced by mlpack::math::RangeType< T >::Hi().

◆ operator|=()

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

Expands this range to include another range.

Parameters
rhsRange to include.

Referenced by mlpack::math::RangeType< T >::Hi().

◆ Serialize()

template<typename T = double>
template<typename Archive >
void mlpack::math::RangeType< T >::Serialize ( Archive &  ar,
const unsigned int  version 
)

Serialize the range object.

Referenced by mlpack::math::RangeType< T >::Hi().

◆ Width()

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

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

Referenced by mlpack::math::RangeType< T >::Hi().

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.

Member Data Documentation

◆ hi

template<typename T = double>
T mlpack::math::RangeType< T >::hi
private

The lower bound.

Definition at line 40 of file range.hpp.

Referenced by mlpack::math::RangeType< T >::Hi().

◆ lo

template<typename T = double>
T mlpack::math::RangeType< T >::lo
private

Definition at line 39 of file range.hpp.

Referenced by mlpack::math::RangeType< T >::Lo().


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