aGrUM 2.3.2
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

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

Protected Member Functions

void copy_ (const Variable &aRV)
 protected copy

Private Member Functions

bool _checkSameDomain_ (const Variable &aRV) const final
 check the domain

Private Attributes

GUM_SCALAR _lower_bound_
GUM_SCALAR _upper_bound_
std::string _name_
 the name of the variable
std::string _description_
 the description of the variable since description is not a characteristic of a variable, we allow the description to be changed even in a const reference.

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

References ContinuousVariable.

Here is the call graph for this function:

◆ 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

References ContinuousVariable.

Here is the call graph for this function:

◆ ContinuousVariable() [4/4]

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

move constructor

References ContinuousVariable.

Here is the call graph for this function:

◆ ~ContinuousVariable()

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

destructor

Member Function Documentation

◆ _checkSameDomain_()

template<typename GUM_SCALAR = float>
bool gum::ContinuousVariable< GUM_SCALAR >::_checkSameDomain_ ( const Variable & aRV) const
finalprivatevirtual

check the domain

this function use the assumption that the concrete type of the variable is the same as *this

Implements gum::Variable.

References _checkSameDomain_().

Referenced by _checkSameDomain_().

Here is the call graph for this function:
Here is the caller graph for this function:

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

References ContinuousVariable.

Here is the call graph for this function:

◆ copy_()

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

protected copy

Parameters
aRVto be copied

References Variable().

Here is the call graph for this function:

◆ description()

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

returns the description of the variable

◆ domain()

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

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

Referenced by gum::learning::IBNLearner::Database::Database(), gum::Estimator< GUM_SCALAR >::Estimator(), gum::MultiDimImplementation< double >::MultiDimImplementation(), gum::NumericalDiscreteVariable::NumericalDiscreteVariable(), gum::BNdistance< GUM_SCALAR >::_checkCompatibility_(), gum::BayesNet< double >::_copyTensors_(), gum::prm::PRMFactory< GUM_SCALAR >::_retrieveCommonType_(), gum::prm::PRMFactory< GUM_SCALAR >::_retrieveInputs_(), gum::BayesNetFactory< GUM_SCALAR >::_setCPTAndParents_(), gum::Instantiation::add(), gum::FMDP< double >::addCostForAction(), gum::FMDP< GUM_SCALAR >::addVariable(), gum::MultiDimICIModel< GUM_SCALAR >::causalWeight(), gum::Instantiation::chgVal(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::InfluenceDiagram< GUM_SCALAR >::copyStructureAndTables_(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscreteType(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscretizedType(), gum::BayesNetFactory< GUM_SCALAR >::endVariableDeclaration(), gum::FMDPFactory< GUM_SCALAR >::endVariableDeclaration(), gum::Tensor< GUM_SCALAR >::fillWith(), gum::BayesNetFragment< GUM_SCALAR >::nodeId(), gum::Estimator< GUM_SCALAR >::posterior(), gum::Estimator< GUM_SCALAR >::setFromBN(), gum::Instantiation::setValsFrom(), gum::BayesNetFactory< GUM_SCALAR >::setVariable(), gum::BayesNetFactory< GUM_SCALAR >::setVariableValuesUnchecked(), gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::toDot(), gum::RangeVariable::toFast(), gum::Estimator< GUM_SCALAR >::update(), and gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::varNodeListe().

◆ operator=() [1/3]

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

copy operator

References ContinuousVariable.

Here is the call graph for this function:

◆ 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

References ContinuousVariable.

Here is the call graph for this function:

◆ operator=() [3/3]

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

move operator

References ContinuousVariable.

Here is the call graph for this function:

◆ operator==()

bool gum::Variable::operator== ( const Variable & aRV) const
inherited

equality operator

References Variable().

Here is the call graph for this function:

◆ operator[]() [1/3]

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

References ContinuousVariable.

Here is the call graph for this function:

◆ operator[]() [2/3]

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

References ContinuousVariable.

Here is the call graph for this function:

◆ operator[]() [3/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

◆ 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

References toString().

Referenced by toString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toStringWithDescription()

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

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

References toStringWithDescription().

Referenced by toStringWithDescription().

Here is the call graph for this function:
Here is the caller graph for this function:

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

References varType().

Referenced by varType().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ContinuousVariable

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

Member Data Documentation

◆ _description_

std::string gum::Variable::_description_
mutableprivateinherited

the description of the variable since description is not a characteristic of a variable, we allow the description to be changed even in a const reference.

Definition at line 165 of file variable.h.

◆ _lower_bound_

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

Definition at line 201 of file continuousVariable.h.

◆ _name_

std::string gum::Variable::_name_
privateinherited

the name of the variable

Definition at line 160 of file variable.h.

◆ _upper_bound_

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

Definition at line 204 of file continuousVariable.h.


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