13 #ifndef __defined_libdai_varset_h
14 #define __defined_libdai_varset_h
60 size_t calcLinearState(
const VarSet &vs,
const std::map<Var, size_t> &state );
85 std::map<Var, size_t>
calcState(
const VarSet &vs,
size_t linearState );
116 template <
typename VarIterator>
133 states *= (
BigInt)n->states();
144 os << (v != vs.
begin() ?
", " :
"") << *v;
151 std::stringstream ss;
std::string toString() const
Formats a VarSet as a string.
Definition: varset.h:150
VarSet()
Default constructor (constructs an empty set)
Definition: varset.h:99
size_t calcLinearState(const VarSet &vs, const std::map< Var, size_t > &state)
Calculates the linear index in the Cartesian product of the variables in vs that corresponds to a par...
Definition: varset.cpp:18
iterator end()
Returns iterator that points beyond the last element.
Definition: smallset.h:198
BigInt nrStates() const
Calculates the number of states of this VarSet, which is simply the number of possible joint states o...
Definition: varset.h:130
Defines class Var, which represents a discrete random variable.
iterator begin()
Returns iterator that points to the first element.
Definition: smallset.h:193
mpz_class BigInt
Arbitrary precision integer number.
Definition: util.h:101
std::vector< Var >::const_iterator const_iterator
Constant iterator over the elements.
Definition: smallset.h:182
VarSet(VarIterator begin, VarIterator end, size_t sizeHint=0)
Construct a VarSet from the range between begin and end.
Definition: varset.h:117
Represents a set of variables.
Definition: varset.h:94
Defines general utility functions and adds an abstraction layer for platform-dependent functionality...
VarSet(const Var &v)
Construct a VarSet with one element, v.
Definition: varset.h:105
Defines the SmallSet<> class, which represents a set (optimized for a small number of elements)...
VarSet(const SmallSet< Var > &x)
Construct from SmallSet x.
Definition: varset.h:102
Represents a discrete random variable.
Definition: var.h:37
Namespace for libDAI.
Definition: alldai.cpp:16
std::map< Var, size_t > calcState(const VarSet &vs, size_t linearState)
Calculates the joint assignment of the variables in vs corresponding to the linear index linearState...
Definition: varset.cpp:31
Represents a set; the implementation is optimized for a small number of elements. ...
Definition: smallset.h:32
VarSet(const Var &v1, const Var &v2)
Construct a VarSet with two elements, v1 and v2.
Definition: varset.h:108
friend std::ostream & operator<<(std::ostream &os, const VarSet &vs)
Writes a VarSet to an output stream.
Definition: varset.h:141