本文整理汇总了C++中Mutator::Q方法的典型用法代码示例。如果您正苦于以下问题:C++ Mutator::Q方法的具体用法?C++ Mutator::Q怎么用?C++ Mutator::Q使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mutator
的用法示例。
在下文中一共展示了Mutator::Q方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
void process(const WorkUnit *workUnit, WorkResult *workResult, const bool &stop) {
ImageBlock *result = static_cast<ImageBlock *>(workResult);
const SeedWorkUnit *wu = static_cast<const SeedWorkUnit *>(workUnit);
Path *current = new Path(), *proposed = new Path();
Spectrum relWeight(0.0f);
result->clear();
/// Reconstruct the seed path
m_pathSampler->reconstructPath(wu->getSeed(), m_config.importanceMap, *current);
relWeight = current->getRelativeWeight();
BDAssert(!relWeight.isZero());
DiscreteDistribution suitabilities(m_mutators.size());
MutationRecord muRec, currentMuRec(Mutator::EMutationTypeCount,0,0,0,Spectrum(0.f));
ref<Timer> timer = new Timer();
size_t consecRejections = 0;
Float accumulatedWeight = 0;
#if defined(MTS_DEBUG_FP)
enableFPExceptions();
#endif
#if defined(MTS_BD_DEBUG_HEAVY)
std::ostringstream oss;
Path backup;
#endif
for (size_t mutationCtr=0; mutationCtr < m_config.nMutations
&& !stop; ++mutationCtr) {
if (wu->getTimeout() > 0 && (mutationCtr % 8192) == 0 &&
(int) timer->getMilliseconds() > wu->getTimeout())
break;
/* Query all mutators for their suitability */
suitabilities.clear();
for (size_t j=0; j<m_mutators.size(); ++j)
suitabilities.append(m_mutators[j]->suitability(*current));
#if defined(MTS_BD_DEBUG_HEAVY)
current->clone(backup, *m_pool);
#endif
size_t mutatorIdx = 0;
bool success = false;
Mutator *mutator = NULL;
if (suitabilities.normalize() == 0) {
/* No mutator can handle this path -- give up */
size_t skip = m_config.nMutations - mutationCtr;
accumulatedWeight += skip;
consecRejections += skip;
break;
}
mutatorIdx = suitabilities.sample(m_sampler->next1D());
mutator = m_mutators[mutatorIdx].get();
/* Sample a mutated path */
success = mutator->sampleMutation(*current, *proposed, muRec, currentMuRec);
#if defined(MTS_BD_DEBUG_HEAVY)
if (backup != *current)
Log(EError, "Detected an unexpected path modification after a "
"mutation of type %s (k=%i)!", muRec.toString().c_str(),
current->length());
if (success) {
bool fail = false;
for (int i=0; i<muRec.l; ++i)
if (*backup.vertex(i) != *proposed->vertex(i))
fail = true;
for (int i=1; i <= backup.length() - muRec.m; ++i)
if (*backup.vertex(muRec.m+i) != *proposed->vertex(muRec.l+muRec.ka+i))
fail = true;
if (fail)
Log(EError, "Detected an unexpected path modification outside of the "
"specified range after a mutation of type %s (k=%i)!",
muRec.toString().c_str(), current->length());
}
backup.release(*m_pool);
#endif
statsAccepted.incrementBase(1);
if (success) {
Float Qxy = mutator->Q(*current, *proposed, muRec) * suitabilities[mutatorIdx];
suitabilities.clear();
for (size_t j=0; j<m_mutators.size(); ++j)
suitabilities.append(m_mutators[j]->suitability(*proposed));
suitabilities.normalize();
Float Qyx = mutator->Q(*proposed, *current, muRec.reverse()) * suitabilities[mutatorIdx];
Float a;
if (!m_config.importanceMap) {
if(Qxy > RCPOVERFLOW)
a = std::min((Float) 1, Qyx / Qxy);
else
a = 0.f;
} else {
const Float *luminanceValues = m_config.importanceMap->getFloatData();
const Point2 &curPos = current->getSamplePosition();
//.........这里部分代码省略.........