use std::accumulate to calc the msg size

This commit is contained in:
Tiago Gomes 2012-05-28 20:59:39 +01:00
parent 57e32267fe
commit f489a59194
2 changed files with 4 additions and 8 deletions

View File

@ -264,10 +264,8 @@ BpSolver::calcFactorToVarMsg (SpLink* link)
const SpLinkSet& links = ninf(src)->getLinks();
// calculate the product of messages that were sent
// to factor `src', except from var `dst'
unsigned msgSize = 1;
for (size_t i = 0; i < links.size(); i++) {
msgSize *= links[i]->varNode()->range();
}
unsigned msgSize = std::accumulate (src->factor().ranges().begin(),
src->factor().ranges().end(), 1, std::multiplies<double>());
unsigned reps = 1;
Params msgProduct (msgSize, LogAware::multIdenty());
if (Globals::logDomain) {

View File

@ -207,10 +207,8 @@ CbpSolver::calcFactorToVarMsg (SpLink* _link)
const SpLinkSet& links = ninf(src)->getLinks();
// calculate the product of messages that were sent
// to factor `src', except from var `dst'
unsigned msgSize = 1;
for (size_t i = 0; i < links.size(); i++) {
msgSize *= links[i]->varNode()->range();
}
unsigned msgSize = std::accumulate (src->factor().ranges().begin(),
src->factor().ranges().end(), 1, std::multiplies<double>());
unsigned reps = 1;
Params msgProduct (msgSize, LogAware::multIdenty());
if (Globals::logDomain) {