本文整理汇总了C++中DistanceMatrix::addElement方法的典型用法代码示例。如果您正苦于以下问题:C++ DistanceMatrix::addElement方法的具体用法?C++ DistanceMatrix::addElement怎么用?C++ DistanceMatrix::addElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DistanceMatrix
的用法示例。
在下文中一共展示了DistanceMatrix::addElement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testUpdateDistanceMatrix
void testUpdateDistanceMatrix()
{
PeakListCollection PLC = SamplePeakListCollection();
DistanceMatrix DM = PLC.buildDistanceMatrix_(200., 0.5, 0, 0.);
DistanceMatrix Ref = PLC.buildDistanceMatrix_(200., 0.5, 0, 0.);
DM.addElement(99.); //Add a dummy element, we will delete it again
unsigned int merged_lower = 4; //last two elements
unsigned int merged_upper = 5;
PLC.plContent_.clear();
PLC.plContent_.resize(6,1);
PLC.updateDistanceMatrix_(DM, merged_lower, merged_upper, 200., 0.5, 0, 0.);
//Size should still be 5
shouldEqual((int)DM.size(),5);
//Matrix should be the same as the original matrix Ref
for(unsigned int i = 0; i < 5; i++){
for(unsigned int j = 0; j < i; j++){
shouldEqualTolerance(DM(i,j),Ref(i,j),TOL);
}
}
return;
}
示例2: buildDistanceMatrix_
//build a distance matrix out of all PeakLists
DistanceMatrix PeakListCollection::buildDistanceMatrix_(double drt, double dmz, double dz, double dint = 0.)
{
//number of Peaklists
unsigned int numPl = c_.size();
DistanceMatrix DM;
//Add new elements to the Distance Matrix
for(unsigned int i = 0; i<numPl; i++){
DM.addElement();
//Calculate distance to the other elements / the cost of merging them
for(unsigned int j = 0; j<i; j++){
StableMarriage sm(c_[i],c_[j],drt,dmz,dz,dint);
sm.setLimit(1.);
DM(i,j) = sm.getCost();
}
}
return DM;
}
示例3: updateDistanceMatrix_
//Update the Distance Matrix
void PeakListCollection::updateDistanceMatrix_(DistanceMatrix& D, unsigned int merged_lower, unsigned int merged_upper,
double drt, double dmz, double dz, double dint = 0.)
{
//remove distances of merged PeakLists from distance matrix
D.deleteElement(merged_upper);
D.deleteElement(merged_lower);
//add a new column for the merged PeakList
D.addElement();
//fill distances
unsigned int sz = D.size();
for(unsigned int i = 0; i<sz-1; i++){
StableMarriage sm(c_[i],c_[sz-1],drt,dmz,dz,dint);
sm.setLimit(1.);
D(i,sz-1) = sm.getCost();
}
return;
}