當前位置: 首頁>>代碼示例>>C++>>正文


C++ Linked::end方法代碼示例

本文整理匯總了C++中Linked::end方法的典型用法代碼示例。如果您正苦於以下問題:C++ Linked::end方法的具體用法?C++ Linked::end怎麽用?C++ Linked::end使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Linked的用法示例。


在下文中一共展示了Linked::end方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: voronoi

void Interstitial::voronoi(const ISO& iso, const Symmetry& symmetry, double tol)
{	
	
	// Clear space
	clear();
	
	// Output
	Output::newline();
	Output::print("Searching for interstitial sites using Voronoi method");
	Output::increase();
	
	// Set up image iterator
	ImageIterator images;
	images.setCell(iso.basis(), 12);
	
	// Loop over unique atoms in the structure
	int i, j, k;
	List<double> weights;
	OList<Vector3D> points;
	OList<Vector3D> vertices;
	Linked<Vector3D> intPoints;
	for (i = 0; i < symmetry.orbits().length(); ++i)
	{
		
		// Reset variables
		weights.length(0);
		points.length(0);
		vertices.length(0);
		
		// Loop over atoms in the structure
		for (j = 0; j < iso.atoms().length(); ++j)
		{
			for (k = 0; k < iso.atoms()[j].length(); ++k)
			{
				
				// Loop over images
				images.reset(symmetry.orbits()[i].atoms()[0]->fractional(), iso.atoms()[j][k].fractional());
				while (!images.finished())
				{
					
					// Skip if atoms are the same
					if (++images < 1e-8)
						continue;
					
					// Save current point
					points += symmetry.orbits()[i].atoms()[0]->cartesian() + images.cartVector();
					weights += 0.5;
				}
			}
		}
		
		// Calculate Voronoi volume
		symmetry.orbits()[i].atoms()[0]->cartesian().voronoi(points, weights, tol, &vertices);
		
		// Save points
		for (j = 0; j < vertices.length(); ++j)
		{
			intPoints += iso.basis().getFractional(vertices[j]);
			ISO::moveIntoCell(*intPoints.last());
		}
	}
	
	// Reduce points to unique ones
	bool found;
	double curDistance;
	Vector3D rotPoint;
	Vector3D equivPoint;
	Vector3D origin(0.0);
	Linked<double> distances;
	Linked<double>::iterator itDist;
	Linked<Vector3D>::iterator it;
	Linked<Vector3D> uniquePoints;
	Linked<Vector3D>::iterator itUnique;
	for (it = intPoints.begin(); it != intPoints.end(); ++it)
	{
		
		// Get current distance to origin
		curDistance = iso.basis().distance(*it, FRACTIONAL, origin, FRACTIONAL);
		
		// Loop over points that were already saved
		found = false;
		itDist = distances.begin();
		itUnique = uniquePoints.begin();
		for (; itDist != distances.end(); ++itDist, ++itUnique)
		{
			
			// Current points are not the same
			if (Num<double>::abs(curDistance - *itDist) <= tol)
			{
				if (iso.basis().distance(*it, FRACTIONAL, *itUnique, FRACTIONAL) <= tol)
				{
					found = true;
					break;
				}
			}
			
			// Loop over symmetry operations
			for (i = 0; i < symmetry.operations().length(); ++i)
			{
				
//.........這裏部分代碼省略.........
開發者ID:bbucior,項目名稱:mint,代碼行數:101,代碼來源:interstitial.cpp

示例2: evaluate


//.........這裏部分代碼省略.........
	Linked<double> distances;
	Linked<double>::iterator itDist;
	Linked<Vector3D> uniquePoints;
	Linked<Vector3D>::iterator it;
	Linked<Vector3D>::iterator itUnique;
	for (i = 0; i < Multi::worldSize(); ++i)
	{
		
		// Send number of points in list on current processor
		numLoops = points.length();
		Multi::broadcast(numLoops, i);
		
		// Loop over points
		if (i == Multi::rank())
			it = points.begin();
		for (j = 0; j < numLoops; ++j)
		{
			
			// Send out current point
			if (i == Multi::rank())
			{
				curPoint = *it;
				++it;
			}
			Multi::broadcast(curPoint, i);
			
			// Get current distance to origin
			curDistance = iso.basis().distance(curPoint, FRACTIONAL, origin, FRACTIONAL);
			
			// Loop over points that were already saved
			found = false;
			itDist = distances.begin();
			itUnique = uniquePoints.begin();
			for (; itDist != distances.end(); ++itDist, ++itUnique)
			{
				
				// Current points are not the same
				if (Num<double>::abs(curDistance - *itDist) <= tol)
				{
					if (iso.basis().distance(curPoint, FRACTIONAL, *itUnique, FRACTIONAL) <= tol)
					{
						found = true;
						break;
					}
				}
				
				// Loop over symmetry operations
				for (k = 0; k < symmetry.operations().length(); ++k)
				{
					
					// Loop over translations
					rotPoint = symmetry.operations()[k].rotation() * curPoint;
					for (m = 0; m < symmetry.operations()[k].translations().length(); ++m)
					{
						
						// Check if points are the same
						equivPoint = rotPoint;
						equivPoint += symmetry.operations()[k].translations()[m];
						if (iso.basis().distance(equivPoint, FRACTIONAL, *itUnique, FRACTIONAL) <= tol)
						{
							found = true;
							break;
						}
					}
					if (found)
						break;
開發者ID:bbucior,項目名稱:mint,代碼行數:67,代碼來源:interstitial.cpp


注:本文中的Linked::end方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。