13 #ifndef __defined_libdai_var_h
14 #define __defined_libdai_var_h
47 Var() : _label(0), _states(0) {}
67 return( _label < n.
_label );
76 return( _label > n.
_label );
85 return( _label <= n.
_label );
94 return( _label >= n.
_label );
103 return( _label != n.
_label );
112 return( _label == n.
_label );
117 return( os <<
"x" << n.
label() );
122 std::stringstream ss;
size_t & states()
Returns reference to number of states.
Definition: var.h:59
size_t _states
Number of possible values.
Definition: var.h:43
bool operator==(const Var &n) const
Equal-to operator (only compares labels)
Definition: var.h:107
bool operator>(const Var &n) const
Larger-than operator (only compares labels)
Definition: var.h:71
bool operator<(const Var &n) const
Smaller-than operator (only compares labels)
Definition: var.h:62
friend std::ostream & operator<<(std::ostream &os, const Var &n)
Writes a Var to an output stream.
Definition: var.h:116
Defines the Exception class and macros for throwing exceptions and doing assertions.
size_t & label()
Returns reference to label.
Definition: var.h:54
size_t states() const
Returns the number of states.
Definition: var.h:57
Var(size_t label, size_t states)
Constructs a variable with a given label and number of states.
Definition: var.h:49
Represents a discrete random variable.
Definition: var.h:37
Namespace for libDAI.
Definition: alldai.cpp:16
std::string toString() const
Formats a Var as a string.
Definition: var.h:121
#define DAI_ASSERT(condition)
Assertion mechanism, similar to the standard assert() macro. It is always active, even if NDEBUG is d...
Definition: exceptions.h:60
bool operator<=(const Var &n) const
Smaller-than-or-equal-to operator (only compares labels)
Definition: var.h:80
bool operator>=(const Var &n) const
Larger-than-or-equal-to operator (only compares labels)
Definition: var.h:89
size_t label() const
Returns the label.
Definition: var.h:52
Var()
Default constructor (creates a variable with label 0 and 0 states)
Definition: var.h:47
bool operator!=(const Var &n) const
Not-equal-to operator (only compares labels)
Definition: var.h:98
size_t _label
Label of the variable (its unique ID)
Definition: var.h:40