本文整理汇总了C++中CoverTree::Children方法的典型用法代码示例。如果您正苦于以下问题:C++ CoverTree::Children方法的具体用法?C++ CoverTree::Children怎么用?C++ CoverTree::Children使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoverTree
的用法示例。
在下文中一共展示了CoverTree::Children方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveNewImplicitNodes
inline void CoverTree<MetricType, StatisticType, MatType, RootPointPolicy>::
RemoveNewImplicitNodes()
{
// If we created an implicit node, take its self-child instead (this could
// happen multiple times).
while (children[children.size() - 1]->NumChildren() == 1)
{
CoverTree* old = children[children.size() - 1];
children.erase(children.begin() + children.size() - 1);
// Now take its child.
children.push_back(&(old->Child(0)));
// Set its parent and parameters correctly, and rebuild the statistic.
old->Child(0).Parent() = this;
old->Child(0).ParentDistance() = old->ParentDistance();
old->Child(0).DistanceComps() = old->DistanceComps();
old->Child(0).Stat() = StatisticType(old->Child(0));
// Remove its child (so it doesn't delete it).
old->Children().erase(old->Children().begin() + old->Children().size() - 1);
// Now delete it.
delete old;
}
}
示例2: distances
CoverTree<MetricType, StatisticType, MatType, RootPointPolicy>::CoverTree(
MatType&& data,
MetricType& metric,
const ElemType base) :
dataset(new MatType(std::move(data))),
point(RootPointPolicy::ChooseRoot(dataset)),
scale(INT_MAX),
base(base),
numDescendants(0),
parent(NULL),
parentDistance(0),
furthestDescendantDistance(0),
localMetric(false),
localDataset(true),
metric(&metric),
distanceComps(0)
{
// If there is only one point or zero points in the dataset... uh, we're done.
// Technically, if the dataset has zero points, our node is not correct...
if (dataset->n_cols <= 1)
return;
// Kick off the building. Create the indices array and the distances array.
arma::Col<size_t> indices = arma::linspace<arma::Col<size_t> >(1,
dataset->n_cols - 1, dataset->n_cols - 1);
// This is now [1 2 3 4 ... n]. We must be sure that our point does not
// occur.
if (point != 0)
indices[point - 1] = 0; // Put 0 back into the set; remove what was there.
arma::vec distances(dataset->n_cols - 1);
// Build the initial distances.
ComputeDistances(point, indices, distances, dataset->n_cols - 1);
// Create the children.
size_t farSetSize = 0;
size_t usedSetSize = 0;
CreateChildren(indices, distances, dataset->n_cols - 1, farSetSize,
usedSetSize);
// If we ended up creating only one child, remove the implicit node.
while (children.size() == 1)
{
// Prepare to delete the implicit child node.
CoverTree* old = children[0];
// Now take its children and set their parent correctly.
children.erase(children.begin());
for (size_t i = 0; i < old->NumChildren(); ++i)
{
children.push_back(&(old->Child(i)));
// Set its parent correctly, and rebuild the statistic.
old->Child(i).Parent() = this;
old->Child(i).Stat() = StatisticType(old->Child(i));
}
// Remove all the children so they don't get erased.
old->Children().clear();
// Reduce our own scale.
scale = old->Scale();
// Now delete it.
delete old;
}
// Use the furthest descendant distance to determine the scale of the root
// node.
scale = (int) ceil(log(furthestDescendantDistance) / log(base));
// Initialize statistic.
stat = StatisticType(*this);
Log::Info << distanceComps << " distance computations during tree "
<< "construction." << std::endl;
}