本文整理汇总了C++中Factor::addLink方法的典型用法代码示例。如果您正苦于以下问题:C++ Factor::addLink方法的具体用法?C++ Factor::addLink怎么用?C++ Factor::addLink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factor
的用法示例。
在下文中一共展示了Factor::addLink方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addFactors
//add the factors with appropriate counts, also add the node to the
//corresponding factor
void Node::addFactors(Array<Factor *> * const & allFactors,
LinkIdToTwoWayMessageMap* const & lidToTWMsg)
{
Factor *factor;
Link *link;
double cnt;
ClauseCounter * counter = (ClauseCounter *)superPred_->getClauseCounter();
int numFactors = counter->getNumClauses();
const Array<double> * cnts;
for (int findex = 0; findex < numFactors; findex++)
{
int fid = counter->getClauseId(findex);
cnts = counter->getClauseCounts(findex);
factor = (*allFactors)[fid];
//predIndex is the predicate index in the clause/factor
for (int predIndex = 0; predIndex < cnts->size(); predIndex++)
{
cnt = (*cnts)[predIndex];
if ((*cnts)[predIndex] == 0)
continue;
//index where this node would be stored in the list of factors
int reverseNodeIndex = factor->getNumLinks();
//index where this factor would be stored in the list of nodes
int reverseFactorIndex = getNumLinks();
link = new Link(this, factor, reverseNodeIndex, reverseFactorIndex,
predIndex, cnt);
//now find the messages from parent nodes
LinkId *lid;
TwoWayMessage *tmsg;
double *nodeToFactorMsgs, *factorToNodeMsgs;
LinkIdToTwoWayMessageMap::iterator lidToTMsgItr;
int parentSuperPredId = getParentSuperPredId();
int parentSuperClauseId = factor->getParentSuperClauseId();
lid = new LinkId(predId_, parentSuperPredId, parentSuperClauseId,
predIndex);
lidToTMsgItr = lidToTWMsg->find(lid);
delete lid;
if (lidToTMsgItr != lidToTWMsg->end())
{
tmsg = lidToTMsgItr->second;
nodeToFactorMsgs = tmsg->getNodeToFactorMessage();
factorToNodeMsgs = tmsg->getFactorToNodeMessage();
}
else
{
nodeToFactorMsgs = NULL;
factorToNodeMsgs = NULL;
}
this->addLink(link, nodeToFactorMsgs);
factor->addLink(link,factorToNodeMsgs);
}
}
}