当前位置: 首页>>代码示例>>C++>>正文


C++ Factor::addLink方法代码示例

本文整理汇总了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);
    }
  }
}
开发者ID:aduitsis,项目名称:alchemy-2,代码行数:61,代码来源:node.cpp


注:本文中的Factor::addLink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。