libDAI
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
include
dai
varset.h
Go to the documentation of this file.
1
/* This file is part of libDAI - http://www.libdai.org/
2
*
3
* Copyright (c) 2006-2011, The libDAI authors. All rights reserved.
4
*
5
* Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
6
*/
7
8
11
12
13
#ifndef __defined_libdai_varset_h
14
#define __defined_libdai_varset_h
15
16
17
#include <vector>
18
#include <map>
19
#include <ostream>
20
#include <
dai/var.h
>
21
#include <
dai/util.h
>
22
#include <
dai/smallset.h
>
23
24
25
namespace
dai {
26
27
28
// Predefine for definitions of calcLinearState() and calcState()
29
class
VarSet;
30
31
33
60
size_t
calcLinearState
(
const
VarSet &vs,
const
std::map<Var, size_t> &state );
61
62
64
85
std::map<Var, size_t>
calcState
(
const
VarSet &vs,
size_t
linearState );
86
87
89
94
class
VarSet
:
public
SmallSet
<Var> {
95
public
:
97
98
99
VarSet
() :
SmallSet
<
Var
>() {}
100
102
VarSet
(
const
SmallSet<Var>
&x ) :
SmallSet
<
Var
>(x) {}
103
105
VarSet
(
const
Var
&v ) :
SmallSet
<
Var
>(v) {}
106
108
VarSet
(
const
Var
&v1,
const
Var
&v2 ) :
SmallSet
<
Var
>(v1,v2) {}
109
111
116
template
<
typename
VarIterator>
117
VarSet
( VarIterator
begin
, VarIterator
end
,
size_t
sizeHint=0 ) :
SmallSet
<
Var
>(begin,end,sizeHint) {}
119
121
122
123
130
BigInt
nrStates
()
const
{
131
BigInt
states = 1;
132
for
(
VarSet::const_iterator
n =
begin
(); n !=
end
(); n++ )
133
states *= (
BigInt
)n->states();
134
return
states;
135
}
137
139
140
141
friend
std::ostream&
operator<<
( std::ostream &os,
const
VarSet
&vs ) {
142
os <<
"{"
;
143
for
(
VarSet::const_iterator
v = vs.
begin
(); v != vs.
end
(); v++ )
144
os << (v != vs.
begin
() ?
", "
:
""
) << *v;
145
os <<
"}"
;
146
return
( os );
147
}
149
};
150
151
152
}
// end of namespace dai
153
154
165
#endif
Generated on Mon Sep 17 2012 12:30:35 for libDAI by
1.8.1.2