+* [Frederik Eaton] Removed unnecessary copy constructors and assignment
+ operators
* [Frederik Eaton] Change cout to cerr in warnings and error messages
* [Giuseppe Passino] Optimised maximum-residual BP by using a reversed ordered
- set instead of the linear search (which can yield enormous speedups - a factor
- 500 has been measured on a binary Ising grid with 128x128 variables!)
+ set instead of the linear search (which can yield enormous speedups - a
+ factor 500 has been measured on a binary Ising grid with 128x128 variables!)
* Added debug assertions to Var which check for inconsistent dimensions of
variables with the same labels
* [Giuseppe Passino] Added prefix ++ operator to State (State::operator++())
-* [Giuseppe Passino] Added iterators to FactorGraph (FactorGraph::begin, FactorGraph::end)
+* [Giuseppe Passino] Added iterators to FactorGraph (FactorGraph::begin,
+ FactorGraph::end)
* [Giuseppe Passino] Added iterators to TFactor (TFactor::begin, TFactor::end)
* [Giuseppe Passino] Added iterators to TProb (TProb::begin, TProb::end)
* [Giuseppe Passino] Added BP::findMaximum(), which can be used after running
/// Default constructor (creates an empty bipartite graph)
BipartiteGraph() : _nb1(), _nb2() {}
- /// Copy constructor (constructs a bipartite graph containing a copy of \c x)
- BipartiteGraph( const BipartiteGraph & x ) : _nb1(x._nb1), _nb2(x._nb2) {}
-
- /// Assignment operator (makes \c *this equal to \c x)
- BipartiteGraph & operator=( const BipartiteGraph & x ) {
- if( this != &x ) {
- _nb1 = x._nb1;
- _nb2 = x._nb2;
- }
- return *this;
- }
-
/// Constructs BipartiteGraph from a range of edges.
/** \tparam EdgeInputIterator Iterator that iterates over instances of BipartiteGraph::Edge.
* \param nr1 The number of nodes of type 1.
/// Construct from vector<VarSet>
ClusterGraph( const std::vector<VarSet> & cls );
- /// Copy constructor
- ClusterGraph( const ClusterGraph &x ) : G(x.G), vars(x.vars), clusters(x.clusters) {}
-
- /// Assignment operator
- ClusterGraph& operator=( const ClusterGraph &x ) {
- if( this != &x ) {
- G = x.G;
- vars = x.vars;
- clusters = x.clusters;
- }
- return *this;
- }
-
/// Returns true if cluster I is not contained in a larger cluster
bool isMaximal( size_t I ) const {
#ifdef DAI_DEBUG
/// Construct from GRM
DAIAlg( const GRM &grm ) : InfAlg(), GRM(grm) {}
- /// Copy constructor
- DAIAlg( const DAIAlg & x ) : InfAlg(x), GRM(x) {}
-
- /// Assignment operator
- DAIAlg & operator=( const DAIAlg &x ) {
- if( this != &x ) {
- InfAlg::operator=(x);
- GRM::operator=(x);
- }
- return *this;
- }
-
/// Save factor I
void backupFactor( size_t I ) { GRM::backupFactor( I ); }
/// Save Factors involving ns
/// Default constructor
ExactInf() : DAIAlgFG(), props(), _beliefsV(), _beliefsF(), _logZ(0) {}
- /// Copy constructor
- ExactInf( const ExactInf &x ) : DAIAlgFG(x), props(x.props), _beliefsV(x._beliefsV), _beliefsF(x._beliefsF), _logZ(x._logZ) {}
-
- /// Assignment operator
- ExactInf& operator=( const ExactInf &x ) {
- if( this != &x ) {
- DAIAlgFG::operator=( x );
- props = x.props;
- _beliefsV = x._beliefsV;
- _beliefsF = x._beliefsF;
- _logZ = x._logZ;
- }
- return *this;
- }
-
/// Construct from FactorGraph fg and PropertySet opts
ExactInf( const FactorGraph &fg, const PropertySet &opts ) : DAIAlgFG(fg), props(), _beliefsV(), _beliefsF(), _logZ() {
setProperties( opts );
/// Constructs TFactor depending on the variable n, with uniform distribution
TFactor( const Var& n ) : _vs(n), _p(n.states()) {}
- /// Copy constructor
- TFactor( const TFactor<T> &x ) : _vs(x._vs), _p(x._p) {}
-
- /// Assignment operator
- TFactor<T> & operator= (const TFactor<T> &x) {
- if( this != &x ) {
- _vs = x._vs;
- _p = x._p;
- }
- return *this;
- }
-
/// Returns const reference to value vector
const TProb<T> & p() const { return _p; }
/// Returns reference to value vector
/// Default constructor
FactorGraph() : G(), _vars(), _factors(), _backup() {}
- /// Copy constructor
- FactorGraph(const FactorGraph & x) : G(x.G), _vars(x._vars), _factors(x._factors), _backup(x._backup) {}
-
- /// Assignment operator
- FactorGraph & operator=(const FactorGraph & x) {
- if( this != &x ) {
- G = x.G;
- _vars = x._vars;
- _factors = x._factors;
- _backup = x._backup;
- }
- return *this;
- }
-
/// Constructs a FactorGraph from a vector of factors
FactorGraph(const std::vector<Factor> &P);
/// Default constructor
Gibbs() : DAIAlgFG(), _sample_count(0), _var_counts(), _factor_counts(), _state() {}
- /// Copy constructor
- Gibbs(const Gibbs & x) : DAIAlgFG(x), _sample_count(x._sample_count), _var_counts(x._var_counts), _factor_counts(x._factor_counts), _state(x._state) {}
-
- /// Assignment operator
- Gibbs& operator=( const Gibbs &x ) {
- if( this != &x ) {
- DAIAlgFG::operator=( x );
- _sample_count = x._sample_count;
- _var_counts = x._var_counts;
- _factor_counts = x._factor_counts;
- _state = x._state;
- }
- return *this;
- }
-
/// Construct from FactorGraph fg and PropertySet opts
Gibbs( const FactorGraph &fg, const PropertySet &opts ) : DAIAlgFG(fg), _sample_count(0), _var_counts(), _factor_counts(), _state() {
setProperties( opts );
/// Default constructor
HAK() : DAIAlgRG(), _Qa(), _Qb(), _muab(), _muba(), _maxdiff(0.0), _iters(0U), props() {}
- /// Copy constructor
- HAK( const HAK &x ) : DAIAlgRG(x), _Qa(x._Qa), _Qb(x._Qb), _muab(x._muab), _muba(x._muba), _maxdiff(x._maxdiff), _iters(x._iters), props(x.props) {}
-
- /// Assignment operator
- HAK& operator=( const HAK &x ) {
- if( this != &x ) {
- DAIAlgRG::operator=( x );
- _Qa = x._Qa;
- _Qb = x._Qb;
- _muab = x._muab;
- _muba = x._muba;
- _maxdiff = x._maxdiff;
- _iters = x._iters;
- props = x.props;
- }
- return *this;
- }
-
/// Construct from FactorGraph fg and PropertySet opts
HAK( const FactorGraph &fg, const PropertySet &opts );
_index = 0;
}
- /// Copy constructor
- IndexFor( const IndexFor & ind ) : _index(ind._index), _sum(ind._sum), _count(ind._count), _dims(ind._dims) {}
-
- /// Assignment operator
- IndexFor& operator=( const IndexFor &ind ) {
- if( this != &ind ) {
- _index = ind._index;
- _sum = ind._sum;
- _count = ind._count;
- _dims = ind._dims;
- }
- return *this;
- }
-
/// Sets the index back to zero
IndexFor& clear() {
fill( _count.begin(), _count.end(), 0 );
/// Initialize from vector of index dimensions
MultiFor( const std::vector<size_t> &d ) : _dims(d), _states(d.size(),0), _state(0) {}
- /// Copy constructor
- MultiFor( const MultiFor &x ) : _dims(x._dims), _states(x._states), _state(x._state) {}
-
- /// Assignment operator
- MultiFor& operator=( const MultiFor & x ) {
- if( this != &x ) {
- _dims = x._dims;
- _states = x._states;
- _state = x._state;
- }
- return *this;
- }
-
/// Return linear state
operator size_t() const {
assert( valid() );
assert( _dims.size() == _sigma.size() );
}
- /// Copy constructor
- Permute( const Permute &x ) : _dims(x._dims), _sigma(x._sigma) {}
-
- /// Assignment operator
- Permute& operator=( const Permute &x ) {
- if( this != &x ) {
- _dims = x._dims;
- _sigma = x._sigma;
- }
- return *this;
- }
-
/// Calculates a permuted linear index.
/** Converts the linear index li to a vector index
* corresponding with the dimensions in _dims, permutes it according to sigma,
states[*v] = 0;
}
- /// Copy constructor
- State( const State & x ) : state(x.state), states(x.states) {}
-
- /// Assignment operator
- State& operator=( const State &x ) {
- if( this != &x ) {
- state = x.state;
- states = x.states;
- }
- return *this;
- }
-
/// Return linear state
operator size_t() const {
assert( valid() );
/// Default constructor
JTree() : DAIAlgRG(), _mes(), _logZ(), RTree(), Qa(), Qb(), props() {}
- /// Copy constructor
- JTree( const JTree &x ) : DAIAlgRG(x), _mes(x._mes), _logZ(x._logZ), RTree(x.RTree), Qa(x.Qa), Qb(x.Qb), props(x.props) {}
-
- /// Assignment operator
- JTree& operator=( const JTree &x ) {
- if( this != &x ) {
- DAIAlgRG::operator=( x );
- _mes = x._mes;
- _logZ = x._logZ;
- RTree = x.RTree;
- Qa = x.Qa;
- Qb = x.Qb;
- props = x.props;
- }
- return *this;
- }
-
/// Construct from FactorGraph fg and PropertySet opts
JTree( const FactorGraph &fg, const PropertySet &opts, bool automatic=true );
/// Default constructor
LC() : DAIAlgFG(), _pancakes(), _cavitydists(), _phis(), _beliefs(), _maxdiff(), _iters(), props() {}
- /// Copy constructor
- LC( const LC &x ) : DAIAlgFG(x), _pancakes(x._pancakes), _cavitydists(x._cavitydists), _phis(x._phis), _beliefs(x._beliefs), _maxdiff(x._maxdiff), _iters(x._iters), props(x.props) {}
-
- /// Assignment operator
- LC& operator=( const LC &x ) {
- if( this != &x ) {
- DAIAlgFG::operator=( x );
- _pancakes = x._pancakes;
- _cavitydists = x._cavitydists;
- _phis = x._phis;
- _beliefs = x._beliefs;
- _maxdiff = x._maxdiff;
- _iters = x._iters;
- props = x.props;
- }
- return *this;
- }
-
/// Construct from FactorGraph fg and PropertySet opts
LC( const FactorGraph &fg, const PropertySet &opts );
/// Default constructor
MF() : DAIAlgFG(), _beliefs(), _maxdiff(0.0), _iters(0U), props() {}
- /// Copy constructor
- MF( const MF &x ) : DAIAlgFG(x), _beliefs(x._beliefs), _maxdiff(x._maxdiff), _iters(x._iters), props(x.props) {}
-
- /// Assignment operator
- MF& operator=( const MF &x ) {
- if( this != &x ) {
- DAIAlgFG::operator=( x );
- _beliefs = x._beliefs;
- _maxdiff = x._maxdiff;
- _iters = x._iters;
- props = x.props;
- }
- return *this;
- }
-
/// Construct from FactorGraph fg and PropertySet opts
MF( const FactorGraph &fg, const PropertySet &opts ) : DAIAlgFG(fg), _beliefs(), _maxdiff(0.0), _iters(0U), props() {
setProperties( opts );
/// Default constructor
MR() : DAIAlgFG(), supported(), con(), nb(), tJ(), theta(), M(), kindex(), cors(), N(), Mag(), _maxdiff(), _iters(), props() {}
- /// Copy constructor
- MR( const MR &x ) : DAIAlgFG(x), supported(x.supported), con(x.con), nb(x.nb), tJ(x.tJ), theta(x.theta), M(x.M), kindex(x.kindex), cors(x.cors), N(x.N), Mag(x.Mag), _maxdiff(x._maxdiff), _iters(x._iters), props(x.props) {}
-
- /// Assignment operator
- MR& operator=( const MR &x ) {
- if( this != &x ) {
- DAIAlgFG::operator=(x);
- supported = x.supported;
- con = x.con;
- nb = x.nb;
- tJ = x.tJ;
- theta = x.theta;
- M = x.M;
- kindex = x.kindex;
- cors = x.cors;
- N = x.N;
- Mag = x.Mag;
- _maxdiff = x._maxdiff;
- _iters = x._iters;
- props = x.props;
- }
- return *this;
- }
-
/// Construct from FactorGraph fg and PropertySet opts
MR( const FactorGraph &fg, const PropertySet &opts );
/// Construct Region from a VarSet and a counting number
Region(const VarSet & x, double c) : VarSet(x), _c(c) {}
- /// Copy constructor
- Region(const Region & x) : VarSet(x), _c(x._c) {}
-
- /// Assignment operator
- Region & operator=(const Region & x) {
- if( this != &x ) {
- VarSet::operator=(x);
- _c = x._c;
- }
- return *this;
- }
-
/// Provide read access to counting number
const double & c() const { return _c; }
/// Provide full access to counting number
/// Constructs FRegion from a Factor and a counting number
FRegion( const Factor & x, double c ) : Factor(x), _c(c) {}
- /// Copy constructor
- FRegion( const FRegion & x ) : Factor(x), _c(x._c) {}
-
- /// Assignment operator
- FRegion & operator=(const FRegion & x) {
- if( this != &x ) {
- Factor::operator=(x);
- _c = x._c;
- }
- return *this;
- }
-
/// Provide read access to counting number
const double & c() const { return _c; }
/// Provide full access to counting number
/// Constructs a RegionGraph from a FactorGraph and a vector of outer VarSets (CVM style)
RegionGraph( const FactorGraph &fg, const std::vector<VarSet> &cl );
- /// Copy constructor
- RegionGraph( const RegionGraph &x ) : FactorGraph(x), G(x.G), ORs(x.ORs), IRs(x.IRs), fac2OR(x.fac2OR) {}
-
- /// Assignment operator
- RegionGraph & operator=( const RegionGraph &x ) {
- if( this != &x ) {
- FactorGraph::operator=( x );
- G = x.G;
- ORs = x.ORs;
- IRs = x.IRs;
- fac2OR = x.fac2OR;
- }
- return *this;
- }
-
/// Clone *this (virtual copy constructor)
virtual RegionGraph* clone() const { return new RegionGraph(*this); }
_elements.erase( new_end, _elements.end() );
}
- /// Copy constructor
- SmallSet( const SmallSet &x ) : _elements( x._elements ) {}
-
- /// Assignment operator
- SmallSet & operator=( const SmallSet &x ) {
- if( this != &x ) {
- _elements = x._elements;
- }
- return *this;
- }
-
/// Set-minus operator: returns all elements in *this, except those in x
SmallSet operator/ ( const SmallSet& x ) const {
SmallSet res;
/// Default constructor
VarSet() : SmallSet<Var>() {}
- /// Copy constructor
- VarSet( const VarSet &x ) : SmallSet<Var>(x) {}
-
- /// Assignment operator
- VarSet& operator=( const VarSet &x ) {
- if( this != &x ) {
- SmallSet<Var>::operator=( x );
- }
- return *this;
- }
-
/// Construct from SmallSet<Var>
VarSet( const SmallSet<Var> &x ) : SmallSet<Var>(x) {}