libDAI
Public Member Functions | Private Attributes | Friends | List of all members
dai::Var Class Reference

Represents a discrete random variable. More...

#include <dai/var.h>

Public Member Functions

 Var ()
 Default constructor (creates a variable with label 0 and 0 states) More...
 
 Var (size_t label, size_t states)
 Constructs a variable with a given label and number of states. More...
 
size_t label () const
 Returns the label. More...
 
size_t & label ()
 Returns reference to label. More...
 
size_t states () const
 Returns the number of states. More...
 
size_t & states ()
 Returns reference to number of states. More...
 
bool operator< (const Var &n) const
 Smaller-than operator (only compares labels) More...
 
bool operator> (const Var &n) const
 Larger-than operator (only compares labels) More...
 
bool operator<= (const Var &n) const
 Smaller-than-or-equal-to operator (only compares labels) More...
 
bool operator>= (const Var &n) const
 Larger-than-or-equal-to operator (only compares labels) More...
 
bool operator!= (const Var &n) const
 Not-equal-to operator (only compares labels) More...
 
bool operator== (const Var &n) const
 Equal-to operator (only compares labels) More...
 
std::string toString () const
 Formats a Var as a string. More...
 

Private Attributes

size_t _label
 Label of the variable (its unique ID) More...
 
size_t _states
 Number of possible values. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Var &n)
 Writes a Var to an output stream. More...
 

Detailed Description

Represents a discrete random variable.

A Var stores the label of the variable (an unsigned integer-valued unique ID) and the number of possible values (states) of that variable. Two Var objects with the same label are assumed to be identical (i.e., it is assumed that they have the same number of possible states).

In the documentation, we use the following notational conventions. The discrete random variable with label $l$ is denoted as $x_l$, and the number of possible values of this variable as $S_l$; this is represented in code by the object Var( $l$, $S_l$). The set of possible values of variable $x_l$ is denoted $X_l := \{0,1,\dots,S_l-1\}$.

Examples:
example_imagesegmentation.cpp, example_permute.cpp, example_sprinkler.cpp, and example_varset.cpp.

Constructor & Destructor Documentation

dai::Var::Var ( )
inline

Default constructor (creates a variable with label 0 and 0 states)

dai::Var::Var ( size_t  label,
size_t  states 
)
inline

Constructs a variable with a given label and number of states.

Member Function Documentation

size_t dai::Var::label ( ) const
inline

Returns the label.

size_t& dai::Var::label ( )
inline

Returns reference to label.

size_t dai::Var::states ( ) const
inline

Returns the number of states.

Examples:
example_varset.cpp.
size_t& dai::Var::states ( )
inline

Returns reference to number of states.

bool dai::Var::operator< ( const Var n) const
inline

Smaller-than operator (only compares labels)

bool dai::Var::operator> ( const Var n) const
inline

Larger-than operator (only compares labels)

bool dai::Var::operator<= ( const Var n) const
inline

Smaller-than-or-equal-to operator (only compares labels)

bool dai::Var::operator>= ( const Var n) const
inline

Larger-than-or-equal-to operator (only compares labels)

bool dai::Var::operator!= ( const Var n) const
inline

Not-equal-to operator (only compares labels)

bool dai::Var::operator== ( const Var n) const
inline

Equal-to operator (only compares labels)

std::string dai::Var::toString ( ) const
inline

Formats a Var as a string.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Var n 
)
friend

Writes a Var to an output stream.

Member Data Documentation

size_t dai::Var::_label
private

Label of the variable (its unique ID)

size_t dai::Var::_states
private

Number of possible values.


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