本文整理汇总了C++中Linked::last方法的典型用法代码示例。如果您正苦于以下问题:C++ Linked::last方法的具体用法?C++ Linked::last怎么用?C++ Linked::last使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Linked
的用法示例。
在下文中一共展示了Linked::last方法的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)
{
//.........这里部分代码省略.........
示例2: evaluate
void Interstitial::evaluate(const ISO& iso, const Symmetry& symmetry, int numPointsPerAtom, double tol, double scale)
{
// Clear space
clear();
// Output
Output::newline();
Output::print("Searching for interstitial sites using ");
Output::print(numPointsPerAtom);
Output::print(" starting point");
if (numPointsPerAtom != 1)
Output::print("s");
Output::print(" per atom and a scale of ");
Output::print(scale);
Output::increase();
// Constants used in generating points on sphere around each atom
double phiScale = Constants::pi * (3 - sqrt(5));
double yScale = 2.0 / numPointsPerAtom;
// Loop over unique atoms in the structure
int i, j, k;
int count = 0;
double y;
double r;
double phi;
double curDistance;
double nearDistance;
double startDistance;
Vector3D curPoint;
Linked<Vector3D > points;
for (i = 0; i < symmetry.orbits().length(); ++i)
{
// Get the distance to nearest atom in the structure
nearDistance = -1;
for (j = 0; j < iso.atoms().length(); ++j)
{
for (k = 0; k < iso.atoms()[j].length(); ++k)
{
curDistance = iso.basis().distance(symmetry.orbits()[i].atoms()[0]->fractional(), FRACTIONAL, \
iso.atoms()[j][k].fractional(), FRACTIONAL);
if (curDistance > 0)
{
if ((nearDistance == -1) || (curDistance < nearDistance))
nearDistance = curDistance;
}
}
}
// Set the starting distance away from atom
startDistance = nearDistance / 2;
// Loop over starting points
for (j = 0; j < numPointsPerAtom; ++j)
{
// Check if running current point on current processor
if ((++count + Multi::rank()) % Multi::worldSize() == 0)
{
// Get current starting point
y = j * yScale - 1 + (yScale / 2);
r = sqrt(1 - y*y);
phi = j * phiScale;
curPoint.set(symmetry.orbits()[i].atoms()[0]->cartesian()[0] + startDistance*r*cos(phi), \
symmetry.orbits()[i].atoms()[0]->cartesian()[1] + startDistance*y, \
symmetry.orbits()[i].atoms()[0]->cartesian()[2] + startDistance*r*sin(phi));
// Minimize the current point
if (!minimizePoint(curPoint, iso, scale))
continue;
// Save current point in fractional coordinates
points += iso.basis().getFractional(curPoint);
ISO::moveIntoCell(*points.last());
}
}
}
// Reduce list of points to unique ones
int m;
bool found;
int numLoops;
Vector3D rotPoint;
Vector3D equivPoint;
Vector3D origin(0.0);
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);
//.........这里部分代码省略.........