![]() |
aGrUM
0.21.0
a C++ library for (probabilistic) graphical models
|
Defines a discrete random variable over an integer interval. More...
#include <rangeVariable.h>
Public Member Functions | |
virtual const std::string | domain () const |
string represent the domain of the variable More... | |
Idx | operator[] (const std::string &label) const |
from the label to its index in var. 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... | |
Constructors / Destructors | |
RangeVariable (const std::string &aName, const std::string &aDesc, long minVal, long maxVal) | |
constructors More... | |
RangeVariable (const std::string &aName, const std::string &aDesc) | |
by de default min=0, max=1 More... | |
RangeVariable (const RangeVariable &aDRV) | |
Copy Constructor. More... | |
virtual | ~RangeVariable () |
destructor More... | |
virtual RangeVariable * | clone () const |
Copy Factory. More... | |
Accessors / Modifiers | |
virtual Size | domainSize () const |
returns the size of the random discrete variable domain More... | |
virtual VarType | varType () const |
returns the type of variable More... | |
virtual std::string | label (Idx index) const |
Get the index-th label. More... | |
virtual double | numerical (Idx index) const |
get a numerical representation of the index-the value. More... | |
long | minVal () const |
Returns the lower bound. More... | |
void | setMinVal (long minVal) |
Set a new value for the lower bound. More... | |
long | maxVal () const |
Returns the upper bound. More... | |
void | setMaxVal (long maxVal) |
Set a new value of the upper bound. More... | |
bool | belongs (long val) const |
Returns true if the param belongs to the variable's interval. More... | |
virtual Idx | index (const std::string &) const |
Operators | |
RangeVariable & | operator= (const RangeVariable &aRV) |
Copy operator. More... | |
Accessors / Modifiers | |
bool | empty () const |
std::vector< std::string > | labels () const |
vector of labels More... | |
Operators | |
virtual bool | operator== (const DiscreteVariable &aRV) const |
equality operator More... | |
virtual bool | operator!= (const DiscreteVariable &aRV) const |
inequality operator 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... | |
Defines a discrete random variable over an integer interval.
It is technically possible to create RangeVariable with minVal > maxVal (or modify in that way an already created RangeVariable). The result is an empty variable (i.e. empty() returns true). If maxVal - minVal < 0, then domainsize() = 0.
Definition at line 53 of file rangeVariable.h.
gum::RangeVariable::RangeVariable | ( | const std::string & | aName, |
const std::string & | aDesc, | ||
long | minVal, | ||
long | maxVal | ||
) |
constructors
Definition at line 40 of file rangeVariable.cpp.
References gum::Set< Key, Alloc >::emplace().
gum::RangeVariable::RangeVariable | ( | const std::string & | aName, |
const std::string & | aDesc | ||
) |
by de default min=0, max=1
Definition at line 49 of file rangeVariable.cpp.
References gum::Set< Key, Alloc >::emplace().
gum::RangeVariable::RangeVariable | ( | const RangeVariable & | aDRV | ) |
Copy Constructor.
If aDRV haves any listener, it will not be copied.
aDRV | the variable we copy |
Definition at line 59 of file rangeVariable.cpp.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
destructor
Definition at line 67 of file rangeVariable.cpp.
References gum::Set< Key, Alloc >::emplace().
INLINE bool gum::RangeVariable::belongs | ( | long | val | ) | const |
Returns true if the param belongs to the variable's interval.
Definition at line 88 of file rangeVariable_inl.h.
|
virtual |
Copy Factory.
Implements gum::DiscreteVariable.
Definition at line 37 of file rangeVariable_inl.h.
|
protectedinherited |
protected copy
aRV | to be copied |
|
inherited |
returns the description of the variable
|
virtual |
string represent the domain of the variable
Implements gum::DiscreteVariable.
Definition at line 72 of file rangeVariable.cpp.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
returns the size of the random discrete variable domain
(or modify in that way an already created RangeVariable). The result is an empty variable (i.e. empty() returns true). If maxVal - minVal < 0, then domainsize() = 0.maxVal
Implements gum::DiscreteVariable.
Definition at line 40 of file rangeVariable_inl.h.
|
inherited |
|
virtual |
NotFound |
Implements gum::DiscreteVariable.
Definition at line 64 of file rangeVariable_inl.h.
|
virtual |
Get the index-th label.
index | the index of the label we wish to return |
OutOfBound |
Implements gum::DiscreteVariable.
Definition at line 47 of file rangeVariable_inl.h.
|
inherited |
vector of labels
INLINE long gum::RangeVariable::maxVal | ( | ) | const |
INLINE long gum::RangeVariable::minVal | ( | ) | const |
|
inherited |
returns the name of the variable
get a numerical representation of the index-the value.
Implements gum::DiscreteVariable.
Definition at line 59 of file rangeVariable_inl.h.
inequality operator
Reimplemented in gum::IntegerVariable.
|
virtualinherited |
inequality operator
INLINE RangeVariable & gum::RangeVariable::operator= | ( | const RangeVariable & | aRV | ) |
Copy operator.
aRV | to be copied |
Definition at line 95 of file rangeVariable_inl.h.
equality operator
Reimplemented in gum::IntegerVariable.
|
virtualinherited |
equality operator
|
inlineinherited |
from the label to its index in var.
NotFound |
Definition at line 139 of file discreteVariable.h.
|
inherited |
sets the description of the variable
theValue |
INLINE void gum::RangeVariable::setMaxVal | ( | long | maxVal | ) |
Set a new value of the upper bound.
Definition at line 85 of file rangeVariable_inl.h.
INLINE void gum::RangeVariable::setMinVal | ( | long | minVal | ) |
Set a new value for the lower bound.
Definition at line 79 of file rangeVariable_inl.h.
|
inherited |
sets the name of the variable
theValue |
|
inherited |
string version of *this
|
inherited |
string version of *this using description attribute instead of name.
|
virtual |
returns the type of variable
Implements gum::DiscreteVariable.
Definition at line 101 of file rangeVariable_inl.h.
|
private |
The upper bound.
Definition at line 160 of file rangeVariable.h.
|
private |
The lower bound.
Definition at line 157 of file rangeVariable.h.