dai::Var Class Reference

Represents a discrete random variable. More...

#include <dai/var.h>

List of all members.

Public Member Functions

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

Private Attributes

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

Friends

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


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.

Examples:
example_sprinkler_gibbs.cpp.

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


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:

Generated on Thu Aug 5 19:04:08 2010 for libDAI by  doxygen 1.5.5