aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/dsa/VP_Tree.h
diff options
context:
space:
mode:
Diffstat (limited to 'meowpp/dsa/VP_Tree.h')
-rw-r--r--meowpp/dsa/VP_Tree.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/meowpp/dsa/VP_Tree.h b/meowpp/dsa/VP_Tree.h
index 75186e6..9c85930 100644
--- a/meowpp/dsa/VP_Tree.h
+++ b/meowpp/dsa/VP_Tree.h
@@ -15,13 +15,13 @@ namespace meow {
/*!
* @brief 跟KD_Tree很像歐
*
- * \c VP_Tree 用來維護由 \b N個K維度向量所成的集合 ,
+ * \c VP_Tree 用來維護由 \b N個K維度向量所成的集合 ,
* 並可於該set中查找 \b 前i個離給定向量最接近的向量* .
- * 不像 \c KD_Tree 二分樹每次都選擇一個維度去分, 分成小的跟大的,
+ * 不像 \c KD_Tree 二分樹每次都選擇一個維度去分, 分成小的跟大的,
* \c VP_Tree 每次選一個點, 將資料分成 離這個點近的, 跟離這個點遠的.
* 至於怎麼選呢...., 嘛還沒研究, 先random
*
- * 參考資料連結:
+ * 參考資料連結:
* - http://stevehanov.ca/blog/index.php?id=130
* - http://pnylab.com/pny/papers/vptree/vptree
*
@@ -33,7 +33,7 @@ namespace meow {
* |const | Vector|operator[] |(size_t \c n) | Scalar | 取得第\c n 維度量 |
* |const | Vector|operator= |(Vector \c v) | Vector& | copy operator |
* |const | Vector|operator< |(Vector \c v) | bool | 權重比較 |
- * |const | Scalar| 'Scalar' |(int \c n) | Scalar | 建構子,
+ * |const | Scalar| 'Scalar' |(int \c n) | Scalar | 建構子,
* 其中一定\c n=0or4 |
* |const | Scalar|operator* |(Scalar \c s) | Scalar | 相乘 |
* |const | Scalar|operator+ |(Scalar \c s) | Scalar | 相加 |
@@ -87,12 +87,12 @@ private:
};
typedef std::vector<Answer> AnswerV;
typedef std::priority_queue<Answer, AnswerV, AnswerCompare> Answers;
-
+
Vectors vectors_;
Node* root_;
size_t dimension_;
bool needRebuild_;
-
+
Scalar distance2(Vector const& v1, Vector const& v2) const {
Scalar ret(0);
for (size_t i = 0; i < dimension_; i++) ret += squ(v1[i] - v2[i]);
@@ -212,7 +212,7 @@ public:
VP_Tree(): root_(NULL), vectors_(0), dimension_(1), needRebuild_(false){
reset(0);
}
-
+
//! @brief constructor, 複製資料
VP_Tree(VP_Tree const& tree2):
vectors_(tree2.vectors_),
@@ -220,7 +220,7 @@ public:
dimension_(tree2.dimension_),
needRebuild_(tree2.needRebuild_) {
}
-
+
//! @brief constructor, 給定dimension
VP_Tree(size_t dimension):
vectors_(0),
@@ -229,12 +229,12 @@ public:
needRebuild_(false) {
reset(dimension);
}
-
+
//! @brief destructor
~VP_Tree() {
clear(root_);
}
-
+
/*!
* @brief 複製資料
*/
@@ -287,7 +287,7 @@ public:
}
/*!
- * @brief 查找
+ * @brief 查找
*
* 於set中找尋距離指定向量前 \c i 近的向量, 並依照由近而遠的順序排序.
* 如果有兩個向量\c v1,v2 距離一樣, 且 \c cmp 為\c true , 則直接依照
@@ -325,7 +325,7 @@ public:
dimension_ = std::max((size_t)1, dimension);
return dimension_;
}
-
+
//! @brief same as \c copyFrom(tree2)
VP_Tree& operator=(VP_Tree const& tree2) {
return copyFrom(tree2);