本文整理汇总了C++中Factor::sumOut方法的典型用法代码示例。如果您正苦于以下问题:C++ Factor::sumOut方法的具体用法?C++ Factor::sumOut怎么用?C++ Factor::sumOut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factor
的用法示例。
在下文中一共展示了Factor::sumOut方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Factor
void
VarElim::eliminate (VarId elimVar)
{
Factor* result = 0;
vector<size_t>& idxs = varFactors_.find (elimVar)->second;
for (size_t i = 0; i < idxs.size(); i++) {
size_t idx = idxs[i];
if (factorList_[idx]) {
if (result == 0) {
result = new Factor (*factorList_[idx]);
} else {
result->multiply (*factorList_[idx]);
}
delete factorList_[idx];
factorList_[idx] = 0;
}
}
totalFactorSize_ += result->size();
if (result->size() > largestFactorSize_) {
largestFactorSize_ = result->size();
}
if (result != 0 && result->nrArguments() != 1) {
result->sumOut (elimVar);
factorList_.push_back (result);
const VarIds& resultVarIds = result->arguments();
for (size_t i = 0; i < resultVarIds.size(); i++) {
vector<size_t>& idxs =
varFactors_.find (resultVarIds[i])->second;
idxs.push_back (factorList_.size() - 1);
}
}
}
示例2: f
void
FactorTest::testSummingOut()
{
VarIds vids = {0, 1, 2, 3};
Ranges ranges = {3, 2, 4, 3};
Params params = {
0.022757933283133, 0.0106825417145475, 0.0212115929862968,
0.0216271252738214, 0.0246935408909929, 0.00535101952882101,
0.00908008645423061, 0.0208088234425334, 0.00752400708452212,
0.0150052316136527, 0.0129311224551535, 0.0170340535302049,
0.00988081654256193, 0.0139063490493519, 0.025792784294836,
0.0248167234610076, 0.017219348482278, 0.0194292243637016,
0.00383554941557795, 0.0164407987747966, 0.00044152909395022,
0.00657900705816833, 0.00371715392294919, 0.0217825142487465,
0.00424392333677727, 0.0108602703755316, 0.00351559808401304,
0.00294727405145356, 0.0270575932871257, 0.005911864680038,
0.0138936584911577, 0.0227288019859002, 0.0165944064071987,
0.0080185268930961, 0.0172692026753632, 0.0142012227138332,
0.0133695464219171, 0.0263492891422071, 0.00792332157200822,
0.0208935535064392, 0.0142677961715013, 0.0208544440271617,
0.0108408824522857, 0.0241486127140633, 0.00767406849215521,
0.00954694217537661, 0.0218786116033257, 0.0248934169744332,
0.00188944195471982, 0.0257141610189036, 0.0142474911774847,
0.00233097104867004, 0.00520644350532678, 0.0179646451004339,
0.0241134853100298, 0.00945036684210405, 0.00173819089160705,
0.000542358809684406, 0.0123976408935576, 0.00170905959437435,
0.00645422348972241, 0.0262912993847153, 0.0244378615928878,
0.0230486298969212, 0.00722310170606624, 0.0146203396838926,
0.0101631280263959, 0.0205926481279833, 0.0138829042417413,
0.0180864495984042, 0.0143994770626774, 0.00106397584149748
};
Factor f (vids, ranges, params);
double sum = std::accumulate (f.params().begin(), f.params().end(), 0.0);
CPPUNIT_ASSERT (similiar (sum, 1.0));
f.sumOut (0);
f.sumOut (3);
f.sumOut (2);
sum = std::accumulate (f.params().begin(), f.params().end(), 0.0);
CPPUNIT_ASSERT (similiar (sum, 1.0));
}