当前位置: 首页>>代码示例>>C++>>正文


C++ DblVector::push_back方法代码示例

本文整理汇总了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 <--");
}
开发者ID:TUDelftNAS,项目名称:DeSiNe,代码行数:32,代码来源:TopologyFactory.cpp

示例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;
}
开发者ID:TUDelftNAS,项目名称:DeSiNe,代码行数:50,代码来源:TopologyFactoryAdjacency.cpp

示例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);
}
开发者ID:genius2609,项目名称:care-o-bot,代码行数:8,代码来源:MathUtils.cpp

示例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]);
}
开发者ID:genius2609,项目名称:care-o-bot,代码行数:7,代码来源:MathUtils.cpp

示例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]);
}
开发者ID:genius2609,项目名称:care-o-bot,代码行数:7,代码来源:MathUtils.cpp

示例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);
}
开发者ID:genius2609,项目名称:care-o-bot,代码行数:8,代码来源:MathUtils.cpp

示例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;
}
开发者ID:vma13,项目名称:University,代码行数:17,代码来源:test.cpp

示例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]);
			}
		}
	}
}
开发者ID:genius2609,项目名称:care-o-bot,代码行数:16,代码来源:MathUtils.cpp

示例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;
}
开发者ID:genius2609,项目名称:care-o-bot,代码行数:23,代码来源:MathUtils.cpp

示例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();
//.........这里部分代码省略.........
开发者ID:Yanzqing,项目名称:cob_object_perception,代码行数:101,代码来源:SharedImageSequence.cpp

示例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 <--");
}
开发者ID:TUDelftNAS,项目名称:DeSiNe,代码行数:66,代码来源:TopolReader.cpp

示例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]);
}
开发者ID:genius2609,项目名称:care-o-bot,代码行数:6,代码来源:MathUtils.cpp

示例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]);
}
开发者ID:genius2609,项目名称:care-o-bot,代码行数:6,代码来源:MathUtils.cpp

示例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);
}
开发者ID:genius2609,项目名称:care-o-bot,代码行数:6,代码来源:MathUtils.cpp


注:本文中的DblVector::push_back方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。