本文整理汇总了C++中arma::Col::rows方法的典型用法代码示例。如果您正苦于以下问题:C++ Col::rows方法的具体用法?C++ Col::rows怎么用?C++ Col::rows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arma::Col
的用法示例。
在下文中一共展示了Col::rows方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: childDistances
inline void
CoverTree<MetricType, StatisticType, MatType, RootPointPolicy>::CreateChildren(
arma::Col<size_t>& indices,
arma::vec& distances,
size_t nearSetSize,
size_t& farSetSize,
size_t& usedSetSize)
{
// Determine the next scale level. This should be the first level where there
// are any points in the far set. So, if we know the maximum distance in the
// distances array, this will be the largest i such that
// maxDistance > pow(base, i)
// and using this for the scale factor should guarantee we are not creating an
// implicit node. If the maximum distance is 0, every point in the near set
// will be created as a leaf, and a child to this node. We also do not need
// to change the furthestChildDistance or furthestDescendantDistance.
const ElemType maxDistance = max(distances.rows(0,
nearSetSize + farSetSize - 1));
if (maxDistance == 0)
{
// Make the self child at the lowest possible level.
// This should not modify farSetSize or usedSetSize.
size_t tempSize = 0;
children.push_back(new CoverTree(*dataset, base, point, INT_MIN, this, 0,
indices, distances, 0, tempSize, usedSetSize, *metric));
distanceComps += children.back()->DistanceComps();
// Every point in the near set should be a leaf.
for (size_t i = 0; i < nearSetSize; ++i)
{
// farSetSize and usedSetSize will not be modified.
children.push_back(new CoverTree(*dataset, base, indices[i],
INT_MIN, this, distances[i], indices, distances, 0, tempSize,
usedSetSize, *metric));
distanceComps += children.back()->DistanceComps();
usedSetSize++;
}
// The number of descendants is just the number of children, because each of
// them are leaves and contain one point.
numDescendants = children.size();
// Re-sort the dataset. We have
// [ used | far | other used ]
// and we want
// [ far | all used ].
SortPointSet(indices, distances, 0, usedSetSize, farSetSize);
return;
}
const int nextScale = std::min(scale,
(int) ceil(log(maxDistance) / log(base))) - 1;
const ElemType bound = pow(base, nextScale);
// First, make the self child. We must split the given near set into the near
// set and far set for the self child.
size_t childNearSetSize =
SplitNearFar(indices, distances, bound, nearSetSize);
// Build the self child (recursively).
size_t childFarSetSize = nearSetSize - childNearSetSize;
size_t childUsedSetSize = 0;
children.push_back(new CoverTree(*dataset, base, point, nextScale, this, 0,
indices, distances, childNearSetSize, childFarSetSize, childUsedSetSize,
*metric));
// Don't double-count the self-child (so, subtract one).
numDescendants += children[0]->NumDescendants();
// The self-child can't modify the furthestChildDistance away from 0, but it
// can modify the furthestDescendantDistance.
furthestDescendantDistance = children[0]->FurthestDescendantDistance();
// Remove any implicit nodes we may have created.
RemoveNewImplicitNodes();
distanceComps += children[0]->DistanceComps();
// Now the arrays, in memory, look like this:
// [ childFar | childUsed | far | used ]
// but we need to move the used points past our far set:
// [ childFar | far | childUsed + used ]
// and keeping in mind that childFar = our near set,
// [ near | far | childUsed + used ]
// is what we are trying to make.
SortPointSet(indices, distances, childFarSetSize, childUsedSetSize,
farSetSize);
// Update size of near set and used set.
nearSetSize -= childUsedSetSize;
usedSetSize += childUsedSetSize;
// Now for each point in the near set, we need to make children. To save
// computation later, we'll create an array holding the points in the near
// set, and then after each run we'll check which of those (if any) were used
// and we will remove them. ...if that's faster. I think it is.
while (nearSetSize > 0)
{
size_t newPointIndex = nearSetSize - 1;
//.........这里部分代码省略.........