aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::ContinuousVariable< GUM_SCALAR > Class Template Reference

Defines a continuous random variable. More...

#include <continuousVariable.h>

+ Inheritance diagram for gum::ContinuousVariable< GUM_SCALAR >:
+ Collaboration diagram for gum::ContinuousVariable< GUM_SCALAR >:

Public Member Functions

template<>
float operator[] (const std::string &str) const
 
template<>
double operator[] (const std::string &str) const
 
Constructors / Destructors
 ContinuousVariable (const std::string &aName, const std::string &aDesc, GUM_SCALAR lower_bound=-std::numeric_limits< GUM_SCALAR >::infinity(), GUM_SCALAR upper_bound=std::numeric_limits< GUM_SCALAR >::infinity())
 Default constructor. More...
 
 ContinuousVariable (const ContinuousVariable< GUM_SCALAR > &from)
 Copy Constructor. More...
 
template<typename TX_VAL >
 ContinuousVariable (const ContinuousVariable< TX_VAL > &from)
 generalized copy constructor More...
 
 ContinuousVariable (ContinuousVariable< GUM_SCALAR > &&from)
 move constructor More...
 
virtual ~ContinuousVariable ()
 destructor More...
 
virtual ContinuousVariable< GUM_SCALAR > * clone () const
 Copy Factory. More...
 
Operators
ContinuousVariable< GUM_SCALAR > & operator= (const ContinuousVariable< GUM_SCALAR > &from)
 copy operator More...
 
template<typename TX_VAL >
ContinuousVariable< GUM_SCALAR > & operator= (const ContinuousVariable< TX_VAL > &from)
 generalized copy operator More...
 
ContinuousVariable< GUM_SCALAR > & operator= (ContinuousVariable< GUM_SCALAR > &&from)
 move operator More...
 
GUM_SCALAR operator[] (const std::string &str) const
 returns the T_VAL corresponding to a string More...
 
Accessors / Modifiers
GUM_SCALAR lowerBound () const
 returns the lower bound of the domain of the variable More...
 
virtual double lowerBoundAsDouble () const
 returns the lower bound of the domain of the variable as a double More...
 
GUM_SCALAR upperBound () const
 returns the upper bound of the domain of the variable More...
 
virtual double upperBoundAsDouble () const
 returns the upper bound of the domain of the variable as a double More...
 
void setLowerBound (const GUM_SCALAR &new_bound)
 updates the lower bound of the domain of the variable More...
 
virtual void setLowerBoundFromDouble (const double new_bound)
 updates the lower bound of the domain of the variable More...
 
void setUpperBound (const GUM_SCALAR &new_bound)
 updates the lower bound of the domain of the variable More...
 
virtual void setUpperBoundFromDouble (const double new_bound)
 updates the lower bound of the domain of the variable More...
 
virtual std::string label (const GUM_SCALAR &value) const
 returns a string containing the value of the variable passed in argument More...
 
bool belongs (const GUM_SCALAR &value) const
 Returns true if the param belongs to the domain of the variable. More...
 
virtual const std::string domain () const
 returns the domain of the variable as a string More...
 
virtual VarType varType () const
 returns the type of the variable More...
 
std::string toString () const
 string version of *this More...
 
std::string toStringWithDescription () const
 string version of *this using description attribute instead of name. More...
 
Operators
virtual bool operator== (const Variable &aRV) const
 equality operator More...
 
virtual bool operator!= (const Variable &aRV) const
 inequality operator More...
 
Accessors / Modifiers
void setName (const std::string &theValue)
 sets the name of the variable More...
 
const std::string & name () const
 returns the name of the variable More...
 
void setDescription (const std::string &theValue) const
 sets the description of the variable More...
 
const std::string & description () const
 returns the description of the variable More...
 

Protected Member Functions

void copy_ (const Variable &aRV)
 protected copy More...
 

Friends

template<typename TX_VAL >
class ContinuousVariable
 

Detailed Description

template<typename GUM_SCALAR = float>
class gum::ContinuousVariable< GUM_SCALAR >

Defines a continuous random variable.

Definition at line 46 of file continuousVariable.h.

Constructor & Destructor Documentation

◆ ContinuousVariable() [1/4]

template<typename GUM_SCALAR = float>
gum::ContinuousVariable< GUM_SCALAR >::ContinuousVariable ( const std::string &  aName,
const std::string &  aDesc,
GUM_SCALAR  lower_bound = -std::numeric_limits< GUM_SCALAR >::infinity(),
GUM_SCALAR  upper_bound = std::numeric_limits< GUM_SCALAR >::infinity() 
)

Default constructor.

It is possible to create ContinuousVariable with lower_bound > upper_bound. In this case, the min and the max are swapped. By default, the range of the variable is (-inf,+inf).

◆ ContinuousVariable() [2/4]

template<typename GUM_SCALAR = float>
gum::ContinuousVariable< GUM_SCALAR >::ContinuousVariable ( const ContinuousVariable< GUM_SCALAR > &  from)

Copy Constructor.

◆ ContinuousVariable() [3/4]

template<typename GUM_SCALAR = float>
template<typename TX_VAL >
gum::ContinuousVariable< GUM_SCALAR >::ContinuousVariable ( const ContinuousVariable< TX_VAL > &  from)

generalized copy constructor

◆ ContinuousVariable() [4/4]

template<typename GUM_SCALAR = float>
gum::ContinuousVariable< GUM_SCALAR >::ContinuousVariable ( ContinuousVariable< GUM_SCALAR > &&  from)

move constructor

◆ ~ContinuousVariable()

template<typename GUM_SCALAR = float>
virtual gum::ContinuousVariable< GUM_SCALAR >::~ContinuousVariable ( )
virtual

destructor

Member Function Documentation

◆ belongs()

template<typename GUM_SCALAR = float>
bool gum::ContinuousVariable< GUM_SCALAR >::belongs ( const GUM_SCALAR &  value) const

Returns true if the param belongs to the domain of the variable.

◆ clone()

template<typename GUM_SCALAR = float>
virtual ContinuousVariable< GUM_SCALAR >* gum::ContinuousVariable< GUM_SCALAR >::clone ( ) const
virtual

Copy Factory.

Returns
Returns a pointer on a new copy of this.

Implements gum::IContinuousVariable.

◆ copy_()

void gum::Variable::copy_ ( const Variable aRV)
protectedinherited

protected copy

Parameters
aRVto be copied

◆ description()

const std::string& gum::Variable::description ( ) const
inherited

returns the description of the variable

◆ domain()

template<typename GUM_SCALAR = float>
virtual const std::string gum::ContinuousVariable< GUM_SCALAR >::domain ( ) const
virtual

returns the domain of the variable as a string

Implements gum::Variable.

◆ label()

template<typename GUM_SCALAR = float>
virtual std::string gum::ContinuousVariable< GUM_SCALAR >::label ( const GUM_SCALAR &  value) const
virtual

returns a string containing the value of the variable passed in argument

Parameters
valuethe value of the variable we wish to return
Exceptions
OutOfBoundsis raised if the value does not belong to the domain of the variable

◆ lowerBound()

template<typename GUM_SCALAR = float>
GUM_SCALAR gum::ContinuousVariable< GUM_SCALAR >::lowerBound ( ) const

returns the lower bound of the domain of the variable

◆ lowerBoundAsDouble()

template<typename GUM_SCALAR = float>
virtual double gum::ContinuousVariable< GUM_SCALAR >::lowerBoundAsDouble ( ) const
virtual

returns the lower bound of the domain of the variable as a double

Implements gum::IContinuousVariable.

◆ name()

const std::string& gum::Variable::name ( ) const
inherited

returns the name of the variable

◆ operator!=()

virtual bool gum::Variable::operator!= ( const Variable aRV) const
virtualinherited

inequality operator

◆ operator=() [1/3]

template<typename GUM_SCALAR = float>
ContinuousVariable< GUM_SCALAR >& gum::ContinuousVariable< GUM_SCALAR >::operator= ( const ContinuousVariable< GUM_SCALAR > &  from)

copy operator

◆ operator=() [2/3]

template<typename GUM_SCALAR = float>
template<typename TX_VAL >
ContinuousVariable< GUM_SCALAR >& gum::ContinuousVariable< GUM_SCALAR >::operator= ( const ContinuousVariable< TX_VAL > &  from)

generalized copy operator

◆ operator=() [3/3]

template<typename GUM_SCALAR = float>
ContinuousVariable< GUM_SCALAR >& gum::ContinuousVariable< GUM_SCALAR >::operator= ( ContinuousVariable< GUM_SCALAR > &&  from)

move operator

◆ operator==()

virtual bool gum::Variable::operator== ( const Variable aRV) const
virtualinherited

equality operator

◆ operator[]() [1/3]

template<typename GUM_SCALAR = float>
GUM_SCALAR gum::ContinuousVariable< GUM_SCALAR >::operator[] ( const std::string &  str) const

returns the T_VAL corresponding to a string

Exceptions
OutOfBoundsis raised if the value does not belong to the domain of the variable
TypeErrorif the string cannot be converted into a T_VAL

◆ operator[]() [2/3]

template<>
float gum::ContinuousVariable< float >::operator[] ( const std::string &  str) const

◆ operator[]() [3/3]

template<>
double gum::ContinuousVariable< double >::operator[] ( const std::string &  str) const

◆ setDescription()

void gum::Variable::setDescription ( const std::string &  theValue) const
inherited

sets the description of the variable

Warning
since description is mutable, setDescription() is const
Parameters
theValue

◆ setLowerBound()

template<typename GUM_SCALAR = float>
void gum::ContinuousVariable< GUM_SCALAR >::setLowerBound ( const GUM_SCALAR &  new_bound)

updates the lower bound of the domain of the variable

Exceptions
OutOfBoundsis raised if the new bound is higher than the current upper bound.

◆ setLowerBoundFromDouble()

template<typename GUM_SCALAR = float>
virtual void gum::ContinuousVariable< GUM_SCALAR >::setLowerBoundFromDouble ( const double  new_bound)
virtual

updates the lower bound of the domain of the variable

Exceptions
OutOfBoundsis raised if the new bound is higher than the current upper bound.

Implements gum::IContinuousVariable.

◆ setName()

void gum::Variable::setName ( const std::string &  theValue)
inherited

sets the name of the variable

Parameters
theValue

◆ setUpperBound()

template<typename GUM_SCALAR = float>
void gum::ContinuousVariable< GUM_SCALAR >::setUpperBound ( const GUM_SCALAR &  new_bound)

updates the lower bound of the domain of the variable

Exceptions
OutOfBoundsis raised if the new bound is lower than the current lower bound

◆ setUpperBoundFromDouble()

template<typename GUM_SCALAR = float>
virtual void gum::ContinuousVariable< GUM_SCALAR >::setUpperBoundFromDouble ( const double  new_bound)
virtual

updates the lower bound of the domain of the variable

Exceptions
OutOfBoundsis raised if the new bound is lower than the current lower bound

Implements gum::IContinuousVariable.

◆ toString()

template<typename GUM_SCALAR = float>
std::string gum::ContinuousVariable< GUM_SCALAR >::toString ( ) const

string version of *this

◆ toStringWithDescription()

template<typename GUM_SCALAR = float>
std::string gum::ContinuousVariable< GUM_SCALAR >::toStringWithDescription ( ) const

string version of *this using description attribute instead of name.

◆ upperBound()

template<typename GUM_SCALAR = float>
GUM_SCALAR gum::ContinuousVariable< GUM_SCALAR >::upperBound ( ) const

returns the upper bound of the domain of the variable

◆ upperBoundAsDouble()

template<typename GUM_SCALAR = float>
virtual double gum::ContinuousVariable< GUM_SCALAR >::upperBoundAsDouble ( ) const
virtual

returns the upper bound of the domain of the variable as a double

Implements gum::IContinuousVariable.

◆ varType()

template<typename GUM_SCALAR = float>
virtual VarType gum::ContinuousVariable< GUM_SCALAR >::varType ( ) const
virtual

returns the type of the variable

Implements gum::Variable.

Friends And Related Function Documentation

◆ ContinuousVariable

template<typename GUM_SCALAR = float>
template<typename TX_VAL >
friend class ContinuousVariable
friend

Definition at line 180 of file continuousVariable.h.

Member Data Documentation

◆ _lower_bound_

template<typename GUM_SCALAR = float>
GUM_SCALAR gum::ContinuousVariable< GUM_SCALAR >::_lower_bound_
private

Definition at line 174 of file continuousVariable.h.

◆ _upper_bound_

template<typename GUM_SCALAR = float>
GUM_SCALAR gum::ContinuousVariable< GUM_SCALAR >::_upper_bound_
private

Definition at line 177 of file continuousVariable.h.


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