Пример #1
0
  //send the messages to all the factor nodes connected to this node
void Node::sendMessage()
{
  Link *link;
  Factor *factor;
  double cnt;
  double *msgs;
  double *outMsgs = new double[2];

  for (int lindex = 0; lindex < links_->size(); lindex++)
  {
    link = (*links_)[lindex];
    factor = link->getFactor();
    cnt = link->getCount(); (void) cnt;
      //subtract the msg recieved from this factor node
    msgs = (*msgsArr_)[lindex];
    for (int i = 0; i < 2; i++)
    {
      outMsgs[i] = msgProds_[i] - msgs[i];
    }

      //Assumes pass by value copy of the messages
    factor->receiveMessage(outMsgs, link);
  }
  delete [] outMsgs;
}
Пример #2
0
  //send the messages to all the auxiliary factor nodes connected to this node
void Node::sendAuxMessage()
{
  Link *link;
  Factor *factor;
  double cnt;
  //double *msgs;
  double *outMsgs = new double[2];

  for (int lindex = 0; lindex < auxLinks_->size(); lindex++)
  {
    link = (*auxLinks_)[lindex];
    factor = link->getFactor();
    cnt = link->getCount(); (void) cnt;
    for (int i = 0; i < 2; i++)
    {
      outMsgs[i] = msgProds_[i];
    }

      //Assumes pass by value copy of the messages
    factor->receiveMessage(outMsgs, link);
  }
  delete [] outMsgs;
}