本文整理汇总了C++中DblVector::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ DblVector::push_back方法的具体用法?C++ DblVector::push_back怎么用?C++ DblVector::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DblVector
的用法示例。
在下文中一共展示了DblVector::push_back方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build
//------------------------------------------------------------------------------
// void build(const NodePairDeque &nodepairs, Topology* topology)
//------------------------------------------------------------------------------
void TopologyFactory::build(const NodePairDeque &nodepairs, Topology* topology)
{
TRACE("TopologyFactory::build -->");
for(NodePairDeque::const_iterator iter = nodepairs.begin();
iter != nodepairs.end(); ++iter)
{
if (iter->source != iter->destination)
{
double link_cap = link_capacity == (RandomVar*) 0 ?
default_capacity : link_capacity->generate();
DblVector d;
d.push_back(iter->source); // source
d.push_back(iter->destination); // dest
d.push_back(0.0); // core
d.push_back(link_cap); // cap
topology->link_list->insert(d);
if (!topology->is_directed)
{
DblVector d2;
d2.push_back(iter->destination); // source
d2.push_back(iter->source); // dest
d2.push_back(0.0); // core
d2.push_back(link_cap); // cap
topology->link_list->insert(d2);
} //end: if (!topology->is_directed)
} //end: if (iter->source != iter->destination)
}
TRACE("TopologyFactory::build <--");
}
示例2: createTopologyAdjacency
Topology* TopologyFactory::createTopologyAdjacency(const TString &description)
{
TRACE("TopologyFactory::createTopologyAdjacency -->");
Topology* result = new Topology();
result->input_type = 0;
result->is_directed = false;
{ // First find number of nodes, which requires to read entire file
FileReader fr(description.at(1));
std::set<int> nodes;
TString line;
// read #nodes
for(bool cont = fr.firstLine(line); cont; cont = fr.nextLine(line))
{
nodes.insert(atoi(line.at(0).c_str()));
nodes.insert(atoi(line.at(1).c_str()));
}
result->number_of_nodes = nodes.size();
result->edge_nodes.assign(nodes.begin(), nodes.end());
} //end: block
result->number_of_qos = 0;
result->link_list = new LinkList(result->number_of_nodes);
{ // Build links
FileReader fr(description.at(1));
TString line;
// read #nodes
for(bool cont = fr.firstLine(line); cont; cont = fr.nextLine(line))
{
DblVector link;
link.push_back(atof(line.at(0).c_str())); // src
link.push_back(atof(line.at(1).c_str())); // dst
link.push_back(0.0); // core
link.push_back(atof(line.at(2).c_str())); // cap
result->link_list->insert(link);
if (!result->is_directed)
{
DblVector rlink(link);
rlink[0] = link[1];
rlink[1] = link[0];
result->link_list->insert(rlink);
} // end: if
} //end: for
} //end: block
TRACE("TopologyFactory::createTopologyAdjacency <--");
return result;
}
示例3: FitLine
// y = ax + b, x = 0, ..., Points.size()
int FitLine(const DblVector& PointsY, double& a, double& b)
{
DblVector PointsX;
for(unsigned int i=0; i<PointsY.size(); i++)
PointsX.push_back((double)i);
return FitLine(PointsY, PointsX, a, b);
}
示例4: MakeVec
void DblMatrix::MakeVec(DblVector& v) const
{
v.clear();
for(int j=0; j<GetHeight(); j++)
for(int i=0; i<GetWidth(); i++)
v.push_back((*this)[j][i]);
}
示例5: MulElem
void DblVector::MulElem(const DblVector& B, DblVector& Res) const
{
assert(this->size()==B.size());
Res.clear();
for(unsigned int i=0; i<this->size(); i++)
Res.push_back((*this)[i]*B[i]);
}
示例6: FitParabola
// y = ax^2+bx+c
int FitParabola(const DblVector& PointsY, double& a, double& b, double& c)
{
DblVector PointsX;
for(unsigned int i=0; i<PointsY.size(); i++)
PointsX.push_back((double)i);
return FitParabola(PointsY, PointsX, a, b, c);
}
示例7: main
int main() {
DblVector vect;
cout << vect << endl;
vect.push_back(1.2);
cout << "push_back(1.2)\n" << vect << endl;
vect.push_back(2.3);
cout << "push_back(2.3)\n" << vect << endl;
vect.push_back(3.4);
cout << "push_back(3.4)\n" << vect << endl;
vect.push_back(4.5);
cout << "push_back(4.5)\n" << vect << endl;
vect.insert(1, 2, 9.9);
cout << "insert(1, 2, 9.9)\n" << vect << endl;
vect.erase(2, 4);
cout << "erase(2, 4)\n" << vect << endl;
return 0;
}
示例8: GetVectorFromImage
void GetVectorFromImage(IplImage* Img, DblVector& v, CvScalar* Scale)
{
for (int c=0; c<Img->nChannels; c++)
{
for (int j=0; j<Img->height; j++)
{
for (int i=0; i<Img->width; i++)
{
CvScalar Val = cvGet2D(Img, j, i);
if(Scale!=NULL)
Val.val[c] /= Scale->val[c];
v.push_back(Val.val[c]);
}
}
}
}
示例9: SolveLinearCramer
// solve linear NxN equation system (cramer)
int DblMatrix::SolveLinearCramer(DblVector& Solution)
{
// get main determinant
DblMatrix DetMat;
double Det=0.0;
int w = GetWidth();
int h = GetHeight();
for(int i=0; i<h; i++)
{
DetMat.push_back(DblVector());
for(int j=0; j<w-1; j++)
DetMat[i].push_back((*this)[i][j]);
}
Det = DetMat.GetDeterminantNxN();
if(fabs(Det)<THE_EPS_DEF) return 0;
// get solutions
Solution.clear();
for(int k=0; k<h; k++)
Solution.push_back(this->GetHelpDeterminant(k)/Det);
return 1;
}
示例10: AlignSequence
void SharedImageSequence::AlignSequence(int noItMax, bool circular)
{
boost::progress_timer t(std::clog);
SharedImageSequence::iterator it0, it1, it2, it3, it4;
Mat3d rot; Vec3d trans;
DblVector maxRots;
DblVector maxTranss;
OrientAlongPrincipalAxises(true);
/// Main iteration
for(int i=0; i<noItMax; i++)
{
double maxRot=0, maxTrans=0, maxNorm=0, normSum = 0.0;
//std::cout << "\nIt " << i << std::endl;
int k=0, l=0;
bool flag=false;
for(it0=begin(); it0!=end(); it0++)
{
/// Update iterators
it1=it0;
it1++;
l=k+1;
if(it1==end())
{
OrientAlongPrincipalAxises(true);
if(circular)
{
it1=begin();
l=0;
flag = true;
}
else break;
}
/// Find the transformation between neighbors
if(it0->GetTransformation(*it1, &rot, &trans)==RET_FAILED) continue;
/// Output the strength of transformatiom
Frame F;
ConvertFrame(rot, trans, F);
//std::cout << "Views " << k << " " << l << std::endl;
double normTrans = Point3Dbl(F[0], F[1], F[2]).AbsVal();
double degRot = F[3]*180.0/THE_PI_DEF;
double norm = normTrans + F[3] * ROT_FACTOR;
normSum += norm;
if(norm>maxNorm) maxNorm = norm;
if(maxRot<degRot) maxRot=degRot;
if(maxTrans<normTrans) maxTrans=normTrans;
//std::cout << "Strength (rot, trans): " << degRot << " (deg) " << normTrans << " (mm) " << std::endl;
////std::cout << "Statistics (count, mean, sigma): " << noPoints << " " << mean[k] << " " << sigma[k] << std::endl;
/// Apply transformation to the tail and update means
if(!flag)
{
for(it2=it1; it2!=end(); it2++)
{
it2->ApplyTransformationToCoordImage(*it2, rot, trans);
}
}
else
{
double n=0;
for(it2=it1; it2!=end(); it2++, n++)
{
/// Get weight of transformation
Frame G=F;
Mat3d wRot; Vec3d wTrans;
double weight = 1.0/exp((double)n);//((double)size()-n)/(double)size();
/// Alter frame
G[0]*=weight; G[1]*=weight;
G[2]*=weight; G[3]*=weight;
ConvertFrameBack(G, wRot, wTrans);
it2->ApplyTransformationToCoordImage(*it2, wRot, wTrans);
}
}
//std::cout << std::endl;
k++;
}
//std::cout << "Max rot : " << maxRot << " (deg) " << std::endl;
//std::cout << "Max trans: " << maxTrans << " (mm) " << std::endl;
//std::cout << "Max norm: " << maxNorm << std::endl;
double avgNorm = normSum/(double)k;
//std::cout << "Avg norm: " << avgNorm << std::endl;
maxRots.push_back(maxRot);
maxTranss.push_back(maxTrans);
}
OrientAlongPrincipalAxises(true);
std::string rotStr = maxRots.ExportForPSTricks();
std::ofstream rotf("maxRotations.txt");
rotf << rotStr;
std::string transStr = maxTranss.ExportForPSTricks();
//.........这里部分代码省略.........
示例11: readTopology
//------------------------------------------------------------------------------
// void readTopology();
//------------------------------------------------------------------------------
void TopolReader::readTopology()
{
TRACE("TopolReader::readTopology -->");
{
TString line;
int number_of_edgenodes;
input_type = 0; // default topology type is 0, in case previous users use the
// old topology format
// read #nodes, #edgenodex, #qos
file_reader->firstLine(line);
number_of_nodes = atoi(line.at(0).c_str());
number_of_edgenodes = atoi(line.at(1).c_str());
number_of_qos = atoi(line.at(2).c_str());
if (line.size() > 3)
{
input_type = atoi(line.at(3).c_str());
}
if (line.size() > 4)
{
is_directed = (bool) atoi(line.at(4).c_str());
}
// read edgenodes list
if (number_of_edgenodes > 0)
{
file_reader->nextLine(line);
for(std::size_t index=0;index<line.size();++index)
{
edge_nodes.push_back(atoi(line.at(index).c_str() ));
}
}
}
// read links and traffic matrix
for (TString line; file_reader->nextLine(line); )
{
if (line.size() == 3) // traffic matrix
{
src.push_back(atoi(line.at(0).c_str()));
dest.push_back(atoi(line.at(1).c_str()));
reqc.push_back(atof(line.at(2).c_str()));
} // line,size == 3
else
{ // length = #values per link, i.e. src, dst, cost, capacity & #qos
DblVector link;
link.push_back(atof(line.at(0).c_str() )); // src
link.push_back(atof(line.at(1).c_str() )); // dst
cost.push_back(atoi(line.at(2).c_str() )); // cost
link.push_back(0.0); // core
for(std::size_t index= 3; index < line.size(); ++index)
{
link.push_back(atof( line.at(index).c_str() ));
}
link_values.push_back(link);
} // line.size != 3
}
TRACE("TopolReader::readTopology <--");
}
示例12: GetColumn
void DblMatrix::GetColumn(int i, DblVector& Column, int Step) const
{
Column.clear();
for(int j=0; j<(int)this->size(); j+=Step)
Column.push_back((*this)[j][i]);
}
示例13: GetLine
void DblMatrix::GetLine(int j, DblVector& Line, int Step) const
{
Line.clear();
for(int i=0; i<(int)this->size(); i+=Step)
Line.push_back((*this)[j][i]);
}
示例14: ScalarMul
void DblVector::ScalarMul(double s, DblVector& Res) const
{
Res.clear();
for(unsigned int i=0; i<this->size(); i++)
Res.push_back((*this)[i]*s);
}