本文整理汇总了C++中Algebra::replace方法的典型用法代码示例。如果您正苦于以下问题:C++ Algebra::replace方法的具体用法?C++ Algebra::replace怎么用?C++ Algebra::replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Algebra
的用法示例。
在下文中一共展示了Algebra::replace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
R PPForest<L>::maxScore(const Algebra<R,L> &alg, size_type i, size_type j) const
{
R down, over;
if(j==0)
return 0;
if(isLeave(i))
{
over=maxScore(alg,rb(i),j-1);
return alg.replace(label(i),0,label(i),over);
}
else
{
down=maxScore(alg,i+1,noc(i));
over=maxScore(alg,rb(i),j-1);
return alg.replace(label(i),down,label(i),over);
}
}
示例2: getMtrxVal
void Alignment<R,L,AL>::calculateGlobal(const PPForest<L> *ppfx, const PPForest<L> *ppfy, const Algebra<R,L> &alg, bool noSpeedup)
{
assert(ppfx != NULL);
assert(ppfy != NULL);
Ulong m,n,h,cols;
long i,k;
Uint j,l,r;
R score,h_score;
// alloc space for the score matrix, backtrack structure and , if wanted, for the calculation-order-matrix
m_mtrxSize=ppfx->getNumCSFs()*ppfy->getNumCSFs();
m_mtrx=new R[m_mtrxSize];
m_rowStart=new Ulong[ppfx->getNumCSFs()];
m_ppfx = new PPForest<L>(*ppfx); // copy the ppforests
m_ppfy = new PPForest<L>(*ppfy);
m_alg=&alg;
m_rnaAlg=NULL;
m_localOptimum=alg.worst_score();
// initialize variables
m=ppfx->size();
n=ppfy->size();
cols=ppfy->getNumCSFs();
m_rowStart[0]=0;
for(h=1;h<ppfx->getNumCSFs();h++)
m_rowStart[h]=m_rowStart[h-1]+cols;
// align forests fx and fy
// the easiest case ..
setMtrxVal(0,0,alg.empty());
// align fx to the empty forest (fill first row of array)
for(i=m-1;i>=0;i--) // for all nodes in fx
{
for(j=1;j<=ppfx->getMaxLength(i);j++) // for all non empty csfs induced by i
{
score = alg.del(ppfx->label(i),
getMtrxVal(ppfx->down(i),0),
getMtrxVal(ppfx->over(i,j),0));
setMtrxVal(ppfx->indexpos(i,j),0,score);
}
}
// align fy to the empty forest (fill first column of array)
for(k=n-1;k>=0;k--) // for all nodes in fx
{
for(l=1;l<=ppfy->getMaxLength(k);l++) // for all non empty csfs induced by k
{
score = alg.insert(getMtrxVal(0,ppfy->down(k)),
ppfy->label(k),
getMtrxVal(0,ppfy->over(k,l)));
setMtrxVal(0,ppfy->indexpos(k,l),score);
}
}
// align the rest
for(i=m-1;i>=0;i--) // for all nodes in fx
for(k=n-1;k>=0;k--) // for all nodes in fx
{
j=ppfx->getMaxLength(i);
for(l=1;l<=ppfy->getMaxLength(k);l++) // for all non empty csfs induced by k
{
// replace
score = alg.replace(ppfx->label(i),
getMtrxVal(ppfx->down(i),ppfy->down(k)),
ppfy->label(k),
getMtrxVal(ppfx->over(i,j),ppfy->over(k,l)));
// delete
if(ppfx->noc(i)==0 && !noSpeedup) // no child
{
h_score = alg.del(ppfx->label(i),0,
getMtrxVal(ppfx->over(i,j),ppfy->indexpos(k,l)));
score=alg.choice(score,h_score);
}
else
{
if(ppfx->rb(i)==0 && !noSpeedup) // no right brother
{
h_score = alg.del(ppfx->label(i),
getMtrxVal(ppfx->down(i),ppfy->indexpos(k,l)),
0);
score=alg.choice(score,h_score);
}
else
{
h=k; // h is the node where the suffix of the split begins
for(r=0;r<=l;r++) // for all splits of fy
{
//.........这里部分代码省略.........