本文整理汇总了C++中TreeType::NumChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeType::NumChildren方法的具体用法?C++ TreeType::NumChildren怎么用?C++ TreeType::NumChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeType
的用法示例。
在下文中一共展示了TreeType::NumChildren方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DualTreeKMeansStatistic
DualTreeKMeansStatistic(TreeType& node) :
neighbor::NeighborSearchStat<neighbor::NearestNeighborSort>(),
upperBound(DBL_MAX),
lowerBound(DBL_MAX),
owner(size_t(-1)),
pruned(size_t(-1)),
staticPruned(false),
staticUpperBoundMovement(0.0),
staticLowerBoundMovement(0.0),
trueParent(node.Parent())
{
// Empirically calculate the centroid.
centroid.zeros(node.Dataset().n_rows);
for (size_t i = 0; i < node.NumPoints(); ++i)
{
// Correct handling of cover tree: don't double-count the point which
// appears in the children.
if (tree::TreeTraits<TreeType>::HasSelfChildren && i == 0 &&
node.NumChildren() > 0)
continue;
centroid += node.Dataset().col(node.Point(i));
}
for (size_t i = 0; i < node.NumChildren(); ++i)
centroid += node.Child(i).NumDescendants() *
node.Child(i).Stat().Centroid();
centroid /= node.NumDescendants();
// Set the true children correctly.
trueChildren.resize(node.NumChildren());
for (size_t i = 0; i < node.NumChildren(); ++i)
trueChildren[i] = &node.Child(i);
}
示例2: CleanTree
void CleanTree(TreeType& node)
{
node.Stat().LastDistance() = 0.0;
for (size_t i = 0; i < node.NumChildren(); ++i)
CleanTree(node.Child(i));
}
示例3: distances
void NeighborSearchRules<
SortPolicy,
MetricType,
TreeType>::
UpdateAfterRecursion(TreeType& queryNode, TreeType& /* referenceNode */)
{
// Find the worst distance that the children found (including any points), and
// update the bound accordingly.
double worstDistance = SortPolicy::BestDistance();
// First look through children nodes.
for (size_t i = 0; i < queryNode.NumChildren(); ++i)
{
if (SortPolicy::IsBetter(worstDistance, queryNode.Child(i).Stat().Bound()))
worstDistance = queryNode.Child(i).Stat().Bound();
}
// Now look through children points.
for (size_t i = 0; i < queryNode.NumPoints(); ++i)
{
if (SortPolicy::IsBetter(worstDistance,
distances(distances.n_rows - 1, queryNode.Point(i))))
worstDistance = distances(distances.n_rows - 1, queryNode.Point(i));
}
// Take the worst distance from all of these, and update our bound to reflect
// that.
queryNode.Stat().Bound() = worstDistance;
}
示例4: FastMKSStat
FastMKSStat(const TreeType& node) :
bound(-DBL_MAX),
lastKernel(0.0),
lastKernelNode(NULL)
{
// Do we have to calculate the centroid?
if (tree::TreeTraits<TreeType>::FirstPointIsCentroid)
{
// If this type of tree has self-children, then maybe the evaluation is
// already done. These statistics are built bottom-up, so the child stat
// should already be done.
if ((tree::TreeTraits<TreeType>::HasSelfChildren) &&
(node.NumChildren() > 0) &&
(node.Point(0) == node.Child(0).Point(0)))
{
selfKernel = node.Child(0).Stat().SelfKernel();
}
else
{
selfKernel = sqrt(node.Metric().Kernel().Evaluate(
node.Dataset().col(node.Point(0)),
node.Dataset().col(node.Point(0))));
}
}
else
{
// Calculate the centroid.
arma::vec center;
node.Center(center);
selfKernel = sqrt(node.Metric().Kernel().Evaluate(center, center));
}
}
示例5: DTBStat
DTBStat(const TreeType& node) :
maxNeighborDistance(DBL_MAX),
minNeighborDistance(DBL_MAX),
bound(DBL_MAX),
componentMembership(
((node.NumPoints() == 1) && (node.NumChildren() == 0)) ?
node.Point(0) : -1) { }
示例6: CheckHierarchy
void CheckHierarchy(const TreeType& tree)
{
for (size_t i = 0; i < tree.NumChildren(); i++)
{
BOOST_REQUIRE_EQUAL(&tree, tree.Child(i).Parent());
CheckHierarchy(tree.Child(i));
}
}
示例7: CheckFills
void CheckFills(const TreeType& tree)
{
if (tree.IsLeaf())
{
BOOST_REQUIRE(tree.Count() >= tree.MinLeafSize() || tree.Parent() == NULL);
BOOST_REQUIRE(tree.Count() <= tree.MaxLeafSize());
}
else
{
for (size_t i = 0; i < tree.NumChildren(); i++)
{
BOOST_REQUIRE(tree.NumChildren() >= tree.MinNumChildren() ||
tree.Parent() == NULL);
BOOST_REQUIRE(tree.NumChildren() <= tree.MaxNumChildren());
CheckFills(*tree.Children()[i]);
}
}
}
示例8: CheckContainment
void CheckContainment(const TreeType& tree)
{
if (tree.NumChildren() == 0)
{
for (size_t i = 0; i < tree.Count(); i++)
BOOST_REQUIRE(tree.Bound().Contains(
tree.Dataset().unsafe_col(tree.Points()[i])));
}
else
{
for (size_t i = 0; i < tree.NumChildren(); i++)
{
for (size_t j = 0; j < tree.Bound().Dim(); j++)
BOOST_REQUIRE(tree.Bound()[j].Contains(tree.Children()[i]->Bound()[j]));
CheckContainment(*(tree.Children()[i]));
}
}
}
示例9: CheckExactContainment
void CheckExactContainment(const TreeType& tree)
{
if (tree.NumChildren() == 0)
{
for (size_t i = 0; i < tree.Bound().Dim(); i++)
{
double min = DBL_MAX;
double max = -1.0 * DBL_MAX;
for(size_t j = 0; j < tree.Count(); j++)
{
if (tree.LocalDataset().col(j)[i] < min)
min = tree.LocalDataset().col(j)[i];
if (tree.LocalDataset().col(j)[i] > max)
max = tree.LocalDataset().col(j)[i];
}
BOOST_REQUIRE_EQUAL(max, tree.Bound()[i].Hi());
BOOST_REQUIRE_EQUAL(min, tree.Bound()[i].Lo());
}
}
else
{
for (size_t i = 0; i < tree.Bound().Dim(); i++)
{
double min = DBL_MAX;
double max = -1.0 * DBL_MAX;
for (size_t j = 0; j < tree.NumChildren(); j++)
{
if(tree.Child(j).Bound()[i].Lo() < min)
min = tree.Child(j).Bound()[i].Lo();
if(tree.Child(j).Bound()[i].Hi() > max)
max = tree.Child(j).Bound()[i].Hi();
}
BOOST_REQUIRE_EQUAL(max, tree.Bound()[i].Hi());
BOOST_REQUIRE_EQUAL(min, tree.Bound()[i].Lo());
}
for (size_t i = 0; i < tree.NumChildren(); i++)
CheckExactContainment(tree.Child(i));
}
}
示例10: GetAllPointsInTree
std::vector<arma::vec*> GetAllPointsInTree(const TreeType& tree)
{
std::vector<arma::vec*> vec;
if (tree.NumChildren() > 0)
{
for (size_t i = 0; i < tree.NumChildren(); i++)
{
std::vector<arma::vec*> tmp = GetAllPointsInTree(*(tree.Children()[i]));
vec.insert(vec.begin(), tmp.begin(), tmp.end());
}
}
else
{
for (size_t i = 0; i < tree.Count(); i++)
{
arma::vec* c = new arma::vec(tree.Dataset().col(tree.Points()[i]));
vec.push_back(c);
}
}
return vec;
}
示例11:
inline double DTBRules<MetricType, TreeType>::CalculateBound(
TreeType& queryNode) const
{
double worstPointBound = -DBL_MAX;
double bestPointBound = DBL_MAX;
double worstChildBound = -DBL_MAX;
double bestChildBound = DBL_MAX;
// Now, find the best and worst point bounds.
for (size_t i = 0; i < queryNode.NumPoints(); ++i)
{
const size_t pointComponent = connections.Find(queryNode.Point(i));
const double bound = neighborsDistances[pointComponent];
if (bound > worstPointBound)
worstPointBound = bound;
if (bound < bestPointBound)
bestPointBound = bound;
}
// Find the best and worst child bounds.
for (size_t i = 0; i < queryNode.NumChildren(); ++i)
{
const double maxBound = queryNode.Child(i).Stat().MaxNeighborDistance();
if (maxBound > worstChildBound)
worstChildBound = maxBound;
const double minBound = queryNode.Child(i).Stat().MinNeighborDistance();
if (minBound < bestChildBound)
bestChildBound = minBound;
}
// Now calculate the actual bounds.
const double worstBound = std::max(worstPointBound, worstChildBound);
const double bestBound = std::min(bestPointBound, bestChildBound);
// We must check that bestBound != DBL_MAX; otherwise, we risk overflow.
const double bestAdjustedBound = (bestBound == DBL_MAX) ? DBL_MAX :
bestBound + 2 * queryNode.FurthestDescendantDistance();
// Update the relevant quantities in the node.
queryNode.Stat().MaxNeighborDistance() = worstBound;
queryNode.Stat().MinNeighborDistance() = bestBound;
queryNode.Stat().Bound() = std::min(worstBound, bestAdjustedBound);
return queryNode.Stat().Bound();
}
示例12: GetMinLevel
int GetMinLevel(const TreeType& tree)
{
int min = 1;
if (!tree.IsLeaf())
{
int m = INT_MAX;
for (size_t i = 0; i < tree.NumChildren(); i++)
{
int n = GetMinLevel(*tree.Children()[i]);
if (n < m)
m = n;
}
min += m;
}
return min;
}
示例13: GetMaxLevel
int GetMaxLevel(const TreeType& tree)
{
int max = 1;
if (!tree.IsLeaf())
{
int m = 0;
for (size_t i = 0; i < tree.NumChildren(); i++)
{
int n = GetMaxLevel(*tree.Children()[i]);
if (n > m)
m = n;
}
max += m;
}
return max;
}
示例14: DualTreeKMeansStatistic
DualTreeKMeansStatistic(TreeType& node) :
closestQueryNode(NULL),
minQueryNodeDistance(DBL_MAX),
maxQueryNodeDistance(DBL_MAX),
clustersPruned(0),
iteration(size_t() - 1)
{
// Empirically calculate the centroid.
centroid.zeros(node.Dataset().n_rows);
for (size_t i = 0; i < node.NumPoints(); ++i)
centroid += node.Dataset().col(node.Point(i));
for (size_t i = 0; i < node.NumChildren(); ++i)
centroid += node.Child(i).NumDescendants() *
node.Child(i).Stat().Centroid();
centroid /= node.NumDescendants();
}
示例15: CheckSync
void CheckSync(const TreeType& tree)
{
if (tree.IsLeaf())
{
for (size_t i = 0; i < tree.Count(); i++)
{
for (size_t j = 0; j < tree.LocalDataset().n_rows; j++)
{
BOOST_REQUIRE_EQUAL(tree.LocalDataset().col(i)[j],
tree.Dataset().col(tree.Points()[i])[j]);
}
}
}
else
{
for (size_t i = 0; i < tree.NumChildren(); i++)
CheckSync(*tree.Children()[i]);
}
}