本文整理汇总了C++中TreeType类的典型用法代码示例。如果您正苦于以下问题:C++ TreeType类的具体用法?C++ TreeType怎么用?C++ TreeType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TreeType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CleanTree
void CleanTree(TreeType& node)
{
node.Stat().LastDistance() = 0.0;
for (size_t i = 0; i < node.NumChildren(); ++i)
CleanTree(node.Child(i));
}
开发者ID:Jacksonlark,项目名称:mlpack,代码行数:7,代码来源:range_search_test.cpp
示例2: pruneTree
void CARTTrainer::pruneTree(TreeType & tree){
//Calculate g of all the nodes
measureStrength(tree, 0, 0);
//Find the lowest g of the internal nodes
double g = std::numeric_limits<double>::max();
for(std::size_t i = 0; i != tree.size(); i++){
if(tree[i].leftNodeId > 0 && tree[i].g < g){
//Update g
g = tree[i].g;
}
}
//Prune the nodes with lowest g and make them terminal
for(std::size_t i=0; i != tree.size(); i++){
//Make the internal nodes with the smallest g terminal nodes and prune their children!
if( tree[i].leftNodeId > 0 && tree[i].g == g){
// pruneNode(tree, tree[i].leftNodeId);
// pruneNode(tree, tree[i].rightNodeId);
// //Make the node terminal
tree[i].leftNodeId = 0;
tree[i].rightNodeId = 0;
}
}
}
开发者ID:jakobht,项目名称:Shark,代码行数:25,代码来源:CARTTrainer.cpp
示例3: 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) { }
开发者ID:shenzebang,项目名称:mlpack,代码行数:7,代码来源:dtb_stat.hpp
示例4: 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));
}
}
开发者ID:darcyliu,项目名称:mlpack,代码行数:8,代码来源:rectangle_tree_test.cpp
示例5: CalculateBound
double FastMKSRules<KernelType, TreeType>::Rescore(TreeType& queryNode,
TreeType& /*referenceNode*/,
const double oldScore) const
{
queryNode.Stat().Bound() = CalculateBound(queryNode);
const double bestKernel = queryNode.Stat().Bound();
return ((1.0 / oldScore) > bestKernel) ? oldScore : DBL_MAX;
}
开发者ID:GABowers,项目名称:MinGW_libs,代码行数:9,代码来源:fastmks_rules_impl.hpp
示例6: 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));
}
}
开发者ID:YaweiZhao,项目名称:mlpack,代码行数:33,代码来源:fastmks_stat.hpp
示例7: GetSplitPolicy
static int GetSplitPolicy(const TreeType& child,
const size_t axis,
const typename TreeType::ElemType cut)
{
if (child.Bound()[axis].Hi() <= cut)
return AssignToFirstTree;
else if (child.Bound()[axis].Lo() >= cut)
return AssignToSecondTree;
return SplitRequired;
}
开发者ID:YaweiZhao,项目名称:mlpack,代码行数:11,代码来源:r_plus_tree_split_policy.hpp
示例8: pruneNode
/*
Removes branch with root node id nodeId, incl. the node itself
*/
void CARTTrainer::pruneNode(TreeType & tree, std::size_t nodeId){
std::size_t i = findNode(tree,nodeId);
if(tree[i].leftNodeId>0){
//Prune left branch
pruneNode(tree, tree[i].leftNodeId);
//Prune right branch
pruneNode(tree, tree[i].rightNodeId);
}
//Remove node
tree.erase(tree.begin()+i);
}
开发者ID:jakobht,项目名称:Shark,代码行数:15,代码来源:CARTTrainer.cpp
示例9: BaseCase
double RangeSearchRules<MetricType, TreeType>::Score(const size_t queryIndex,
TreeType& referenceNode)
{
// We must get the minimum and maximum distances and store them in this
// object.
math::Range distances;
if (tree::TreeTraits<TreeType>::FirstPointIsCentroid)
{
// In this situation, we calculate the base case. So we should check to be
// sure we haven't already done that.
double baseCase;
if (tree::TreeTraits<TreeType>::HasSelfChildren &&
(referenceNode.Parent() != NULL) &&
(referenceNode.Point(0) == referenceNode.Parent()->Point(0)))
{
// If the tree has self-children and this is a self-child, the base case
// was already calculated.
baseCase = referenceNode.Parent()->Stat().LastDistance();
lastQueryIndex = queryIndex;
lastReferenceIndex = referenceNode.Point(0);
}
else
{
// We must calculate the base case by hand.
baseCase = BaseCase(queryIndex, referenceNode.Point(0));
}
// This may be possibly loose for non-ball bound trees.
distances.Lo() = baseCase - referenceNode.FurthestDescendantDistance();
distances.Hi() = baseCase + referenceNode.FurthestDescendantDistance();
// Update last distance calculation.
referenceNode.Stat().LastDistance() = baseCase;
}
else
{
distances = referenceNode.RangeDistance(querySet.unsafe_col(queryIndex));
}
// If the ranges do not overlap, prune this node.
if (!distances.Contains(range))
return DBL_MAX;
// In this case, all of the points in the reference node will be part of the
// results.
if ((distances.Lo() >= range.Lo()) && (distances.Hi() <= range.Hi()))
{
AddResult(queryIndex, referenceNode);
return DBL_MAX; // We don't need to go any deeper.
}
// Otherwise the score doesn't matter. Recursion order is irrelevant in
// range search.
return 0.0;
}
开发者ID:gbkedar,项目名称:mlpack-gatech,代码行数:56,代码来源:range_search_rules_impl.hpp
示例10: UpdateAuxiliaryInfo
bool HilbertRTreeAuxiliaryInformation<TreeType, HilbertValueType>::
UpdateAuxiliaryInfo(TreeType* node)
{
if (node->IsLeaf()) // Should already be updated
return true;
TreeType* child = node->Children()[node->NumChildren() - 1];
if (hilbertValue.CompareWith(child->AuxiliaryInfo().hilbertValue()) < 0)
{
hilbertValue.Copy(node,child);
return true;
}
return false;
}
开发者ID:caomw,项目名称:mlpack,代码行数:14,代码来源:hilbert_r_tree_auxiliary_information_impl.hpp
示例11: SearchTree
void SearchTree(TreeType<T>& tree)
{
T input;
cout << "Enter item to search: ";
cin >> input;
tree.SearchItem(input);
}
开发者ID:barovig,项目名称:ComputerScience,代码行数:7,代码来源:CA_1A.cpp
示例12: DeleteFromTree
void DeleteFromTree(TreeType<T>& tree)
{
T input;
cout << "Enter item to delete: ";
cin >> input;
tree.DeleteItem(input);
}
开发者ID:barovig,项目名称:ComputerScience,代码行数:7,代码来源:CA_1A.cpp
示例13: InsertItem
void InsertItem(TreeType<T>& tree)
{
cout << "Enter number: ";
T num;
cin >> num;
tree.InsertItem(num);
}
开发者ID:barovig,项目名称:ComputerScience,代码行数:7,代码来源:CA_1A.cpp
示例14: 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;
}
开发者ID:darcyliu,项目名称:mlpack,代码行数:17,代码来源:rectangle_tree_test.cpp
示例15: 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;
}
开发者ID:darcyliu,项目名称:mlpack,代码行数:17,代码来源:rectangle_tree_test.cpp
示例16: UpdateAfterRecursion
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;
}
开发者ID:alexeyche,项目名称:alexeyche-junk,代码行数:29,代码来源:neighbor_search_rules_impl.hpp
示例17: CalculateBound
double DTBRules<MetricType, TreeType>::Score(TreeType& queryNode,
TreeType& referenceNode)
{
// If all the queries belong to the same component as all the references
// then we prune.
if ((queryNode.Stat().ComponentMembership() >= 0) &&
(queryNode.Stat().ComponentMembership() ==
referenceNode.Stat().ComponentMembership()))
return DBL_MAX;
++scores;
const double distance = queryNode.MinDistance(&referenceNode);
const double bound = CalculateBound(queryNode);
// If all the points in the reference node are farther than the candidate
// nearest neighbor for all queries in the node, we prune.
return (bound < distance) ? DBL_MAX : distance;
}
开发者ID:GABowers,项目名称:MinGW_libs,代码行数:18,代码来源:dtb_rules_impl.hpp
示例18: 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]));
}
}
}
开发者ID:darcyliu,项目名称:mlpack,代码行数:19,代码来源:rectangle_tree_test.cpp
示例19: Score
inline double KDERules<MetricType, KernelType, TreeType>::
Score(const size_t queryIndex, TreeType& referenceNode)
{
double score, maxKernel, minKernel, bound;
const arma::vec& queryPoint = querySet.unsafe_col(queryIndex);
const double minDistance = referenceNode.MinDistance(queryPoint);
bool newCalculations = true;
if (tree::TreeTraits<TreeType>::FirstPointIsCentroid &&
lastQueryIndex == queryIndex &&
traversalInfo.LastReferenceNode() != NULL &&
traversalInfo.LastReferenceNode()->Point(0) == referenceNode.Point(0))
{
// Don't duplicate calculations.
newCalculations = false;
lastQueryIndex = queryIndex;
lastReferenceIndex = referenceNode.Point(0);
}
else
{
// Calculations are new.
maxKernel = kernel.Evaluate(minDistance);
minKernel = kernel.Evaluate(referenceNode.MaxDistance(queryPoint));
bound = maxKernel - minKernel;
}
if (newCalculations &&
bound <= (absError + relError * minKernel) / referenceSet.n_cols)
{
// Estimate values.
double kernelValue;
// Calculate kernel value based on reference node centroid.
if (tree::TreeTraits<TreeType>::FirstPointIsCentroid)
{
kernelValue = EvaluateKernel(queryIndex, referenceNode.Point(0));
}
else
{
kde::KDEStat& referenceStat = referenceNode.Stat();
kernelValue = EvaluateKernel(queryPoint, referenceStat.Centroid());
}
densities(queryIndex) += referenceNode.NumDescendants() * kernelValue;
// Don't explore this tree branch.
score = DBL_MAX;
}
else
{
score = minDistance;
}
++scores;
traversalInfo.LastReferenceNode() = &referenceNode;
traversalInfo.LastScore() = score;
return score;
}
开发者ID:dasayan05,项目名称:mlpack,代码行数:58,代码来源:kde_rules_impl.hpp
示例20: nodeDepth
size_t nodeDepth(const TreeType& tree, const NodeType& node)
{
const auto* currentNode = &node;
size_t depth = 0;
while (!currentNode->isRoot()) {
currentNode = &tree.nodeAt(currentNode->parentNodeIndex);
depth++;
}
return depth;
}
开发者ID:OctiumBrowser,项目名称:octium-main,代码行数:10,代码来源:DisplayItemPropertyTreeBuilderTest.cpp
注:本文中的TreeType类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论