⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kdtreeinternalnode.hpp

📁 dysii是一款非常出色的滤波函数库
💻 HPP
字号:
#ifndef INDII_ML_AUX_KDTREEINTERNALNODE_HPP#define INDII_ML_AUX_KDTREEINTERNALNODE_HPP#include "KDTreeNode.hpp"#include "Partitioner.hpp"#include "boost/serialization/split_member.hpp"namespace indii {  namespace ml {    namespace aux {/** * Internal node of a KD-tree. * * @author Lawrence Murray <lawrence@indii.org> * @version $Rev: 404 $ * @date $Date: 2008-03-05 14:52:55 +0000 (Wed, 05 Mar 2008) $ * * @param P Degree of the normed vector space (as in \f$\|\cdot\|_p\f$) on * which the tree is defined. * * @section PartitionTreeInternal_serialization Serialization * * This class supports serialization through the Boost.Serialization * library. */class KDTreeInternalNode : public KDTreeNode {public:  /**   * Default constructor.   *   * This should generally only be used when the object is to be   * restored from a serialization.   */  KDTreeInternalNode();  /**   * Constructor.   *   * @param left Left child node. Callee claims ownership.   * @param right Right child node. Callee claims ownership.   */  KDTreeInternalNode(KDTreeNode* left, KDTreeNode* right);  /**   * Destructor.   */  virtual ~KDTreeInternalNode();  virtual double getWeight();  virtual vector& getLower();  virtual vector& getUpper();  virtual vector nearestTo(const vector& x);  virtual double densityAt(const vector& x, Norm& N, Kernel& K);  virtual vector sample(const double u, Norm& N, Kernel& K);private:  /**   * The left child.   */  KDTreeNode* left;    /**   * The right child.   */  KDTreeNode* right;  /**   * The lower bound.   */  vector* lower;    /**   * The upper bound.   */  vector* upper;    /**   * Does object own the lower bound?   */  bool ownLower;    /**   * Does object own the upper bound?   */  bool ownUpper;  /**   * Cached weight of node.   */  double weight;    /**   * Has cached weight been calculated?   */  bool haveWeight;  /**   * Serialize.   */  template<class Archive>  void save(Archive& ar, const unsigned int version) const;  /**   * Restore from serialization.   */  template<class Archive>  void load(Archive& ar, const unsigned int version);  /*   * Boost.Serialization requirements.   */  BOOST_SERIALIZATION_SPLIT_MEMBER()  friend class boost::serialization::access;};    }  }}#include "KDTreeLeafNode.hpp"#include "boost/serialization/base_object.hpp"template<class Archive>void indii::ml::aux::KDTreeInternalNode::save(Archive& ar,    const unsigned int version) const {  ar & boost::serialization::base_object<KDTreeNode>(*this);  if (typeid(*left) == typeid(KDTreeInternalNode)) {    const bool isLeaf = false;    const KDTreeInternalNode* node =        static_cast<KDTreeInternalNode*>(left);    ar & isLeaf;    ar & node;  } else if (typeid(*left) == typeid(KDTreeLeafNode)) {    const bool isLeaf = true;    const KDTreeLeafNode* node =        static_cast<KDTreeLeafNode*>(left);    ar & isLeaf;    ar & node;  } else {    assert(false);  }  if (typeid(*right) == typeid(KDTreeInternalNode)) {    const bool isLeaf = false;    const KDTreeInternalNode* node =        static_cast<KDTreeInternalNode*>(right);    ar & isLeaf;    ar & node;  } else if (typeid(*right) == typeid(KDTreeLeafNode)) {    const bool isLeaf = true;    const KDTreeLeafNode* node =        static_cast<KDTreeLeafNode*>(right);    ar & isLeaf;    ar & node;  } else {    assert(false);  }  ar & lower;  ar & upper;  ar & ownLower;  ar & ownUpper;  ar & weight;  ar & haveWeight;}template<class Archive>void indii::ml::aux::KDTreeInternalNode::load(Archive& ar,    const unsigned int version) {  bool isLeaf;  if (left != NULL) {    delete left;    left = NULL;  }  if (right != NULL) {    delete right;    right = NULL;  }  ar & boost::serialization::base_object<PartitionTreeNode>(*this);  /* left child */  ar & isLeaf;    if (isLeaf) {    KDTreeLeafNode* node = new KDTreeLeafNode();    ar & node;    left = node;  } else {    KDTreeInternalNode* node = new KDTreeInternalNode();    ar & node;    left = node;  }  /* right child */  ar & isLeaf;  if (isLeaf) {    KDTreeLeafNode* node = new KDTreeLeafNode();    ar & node;    right = node;  } else {    KDTreeInternalNode* node = new KDTreeInternalNode();    ar & node;    right = node;  }  ar & lower;  ar & upper;  ar & ownLower;  ar & ownUpper;  ar & weight;  ar & haveWeight;}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -