aGrUM 3.1.1
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[] (std::string_view str) const
double operator[] (std::string_view str) const
Constructors / Destructors
 ContinuousVariable (std::string_view aName, std::string_view 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
 ~ContinuousVariable () override
 destructor
ContinuousVariable< GUM_SCALAR > * clone () const override
 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[] (std::string_view 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
double lowerBoundAsDouble () const override
 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
double upperBoundAsDouble () const override
 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
void setLowerBoundFromDouble (const double new_bound) override
 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
void setUpperBoundFromDouble (const double new_bound) override
 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
VarType varType () const override
 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 (std::string_view theValue)
 sets the name of the variable
const std::string & name () const
 returns the name of the variable
void setDescription (std::string_view 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<GUM_Numeric TX_VAL>
class ContinuousVariable

Detailed Description

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

Defines a continuous random variable.

Definition at line 69 of file continuousVariable.h.

Constructor & Destructor Documentation

◆ ContinuousVariable() [1/4]

template<GUM_Numeric GUM_SCALAR = float>
gum::ContinuousVariable< GUM_SCALAR >::ContinuousVariable ( std::string_view aName,
std::string_view 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<GUM_Numeric 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<GUM_Numeric 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<GUM_Numeric 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<GUM_Numeric GUM_SCALAR = float>
gum::ContinuousVariable< GUM_SCALAR >::~ContinuousVariable ( )
override

destructor

Member Function Documentation

◆ _checkSameDomain_()

template<GUM_Numeric 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<GUM_Numeric 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<GUM_Numeric GUM_SCALAR = float>
ContinuousVariable< GUM_SCALAR > * gum::ContinuousVariable< GUM_SCALAR >::clone ( ) const
nodiscardoverridevirtual

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<GUM_Numeric 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<GUM_Numeric 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<GUM_Numeric GUM_SCALAR = float>
GUM_SCALAR gum::ContinuousVariable< GUM_SCALAR >::lowerBound ( ) const

returns the lower bound of the domain of the variable

◆ lowerBoundAsDouble()

template<GUM_Numeric GUM_SCALAR = float>
double gum::ContinuousVariable< GUM_SCALAR >::lowerBoundAsDouble ( ) const
overridevirtual

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::NumericalDiscreteVariable::NumericalDiscreteVariable(), gum::MultiDimImplementation< double >::~MultiDimImplementation(), gum::BNdistance< GUM_SCALAR >::_checkCompatibility_(), gum::ASTposteriorProba< GUM_SCALAR >::_compute_knw_from_bn(), gum::prm::PRMFactory< GUM_SCALAR >::_retrieveCommonType_(), gum::prm::PRMFactory< GUM_SCALAR >::_retrieveInputs_(), gum::BayesNetFactory< GUM_SCALAR >::_setCPTAndParents_(), gum::Instantiation::add(), gum::MultiDimImplementation< GUM_ELEMENT >::add(), gum::Instantiation::chgVal(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::InfluenceDiagram< GUM_SCALAR >::copyStructureAndTables_(), gum::FMDP< double >::cost(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscreteType(), gum::prm::PRMFactory< GUM_SCALAR >::endDiscretizedType(), gum::BayesNetFactory< GUM_SCALAR >::endVariableDeclaration(), gum::FMDPFactory< GUM_ELEMENT >::endVariableDeclaration(), gum::BayesNetFragment< GUM_SCALAR >::nodeId(), gum::IBayesNet< GUM_SCALAR >::operator==(), 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_ELEMENT, TerminalNodePolicy >::toDot(), gum::RangeVariable::toFast(), gum::Estimator< GUM_SCALAR >::update(), and gum::MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >::varNodeListe().

◆ operator=() [1/3]

template<GUM_Numeric 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<GUM_Numeric 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<GUM_Numeric 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[] ( std::string_view str) const

References ContinuousVariable.

Here is the call graph for this function:

◆ operator[]() [2/3]

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

References ContinuousVariable.

Here is the call graph for this function:

◆ operator[]() [3/3]

template<GUM_Numeric GUM_SCALAR = float>
GUM_SCALAR gum::ContinuousVariable< GUM_SCALAR >::operator[] ( std::string_view 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 ( std::string_view theValue) const
inherited

sets the description of the variable

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

◆ setLowerBound()

template<GUM_Numeric 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<GUM_Numeric GUM_SCALAR = float>
void gum::ContinuousVariable< GUM_SCALAR >::setLowerBoundFromDouble ( const double new_bound)
overridevirtual

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 ( std::string_view theValue)
inherited

sets the name of the variable

Parameters
theValue

◆ setUpperBound()

template<GUM_Numeric 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<GUM_Numeric GUM_SCALAR = float>
void gum::ContinuousVariable< GUM_SCALAR >::setUpperBoundFromDouble ( const double new_bound)
overridevirtual

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<GUM_Numeric 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<GUM_Numeric 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<GUM_Numeric GUM_SCALAR = float>
GUM_SCALAR gum::ContinuousVariable< GUM_SCALAR >::upperBound ( ) const

returns the upper bound of the domain of the variable

◆ upperBoundAsDouble()

template<GUM_Numeric GUM_SCALAR = float>
double gum::ContinuousVariable< GUM_SCALAR >::upperBoundAsDouble ( ) const
overridevirtual

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

Implements gum::IContinuousVariable.

◆ varType()

template<GUM_Numeric GUM_SCALAR = float>
VarType gum::ContinuousVariable< GUM_SCALAR >::varType ( ) const
overridevirtual

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<GUM_Numeric GUM_SCALAR = float>
template<GUM_Numeric 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 167 of file variable.h.

◆ _lower_bound_

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

Definition at line 203 of file continuousVariable.h.

◆ _name_

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

the name of the variable

Definition at line 162 of file variable.h.

◆ _upper_bound_

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

Definition at line 206 of file continuousVariable.h.


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