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

📄 densitytreeinternal.hpp

📁 dysii是一款非常出色的滤波函数库
💻 HPP
字号:
#ifndef INDII_ML_AUX_DENSITYTREEINTERNAL_HPP#define INDII_ML_AUX_DENSITYTREEINTERNAL_HPP#include "DensityTreeNode.hpp"namespace indii {  namespace ml {    namespace aux {/** * Internal node of a density tree. * * @author Lawrence Murray <lawrence@indii.org> * @version $Rev: 401 $ * @date $Date: 2008-03-05 13:54:28 +0000 (Wed, 05 Mar 2008) $ * * @section DensityTreeInternal_serialization Serialization * * This class supports serialization through the Boost.Serialization * library. */class DensityTreeInternal : public DensityTreeNode {public:  /**   * Default constructor.   *   * This should generally only be used when the object is to be   * restored from a serialization.   */  DensityTreeInternal();  /**   * Constructor.   *   * @param lower Lower bound on the node.   * @param upper Upper bound on the node.   * @param splitIndex Index of the split dimension.   * @param splitValue Value at which to split.   * @param left Left branch. Callee assumes ownership.   * @param right Right branch. Callee assumes ownership.   */  DensityTreeInternal(const vector& lower, const vector& upper,      const unsigned int splitIndex, const double splitValue,      DensityTreeNode* left, DensityTreeNode* right);  /**   * Copy constructor.   */  DensityTreeInternal(const DensityTreeInternal& o);  /**   * Destructor.   */  virtual ~DensityTreeInternal();    /**   * Assignment operator.   */  DensityTreeInternal& operator=(const DensityTreeInternal& o);    virtual vector sumExpectation();  virtual symmetric_matrix sumCovariance();  virtual vector sample(const double u);  virtual double densityAt(const vector& x);private:   /**   * Index of the split dimension.   */  unsigned int splitIndex;    /**   * Value at the split.   */  double splitValue;  /**   * Left branch.   */  DensityTreeNode* left;    /**   * Right branch.   */  DensityTreeNode* right;  /**   * 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 "DensityTreeLeaf.hpp"template<class Archive>void indii::ml::aux::DensityTreeInternal::save(Archive& ar,    const unsigned int version) const {  ar & boost::serialization::base_object<DensityTreeNode>(*this);  ar & splitIndex;  ar & splitValue;    if (typeid(*left) == typeid(DensityTreeInternal)) {    const bool isLeaf = false;    const DensityTreeInternal* node =        static_cast<DensityTreeInternal*>(left);    ar & isLeaf;    ar & *node;  } else if (typeid(*left) == typeid(DensityTreeLeaf)) {    const bool isLeaf = true;    const DensityTreeLeaf* node =        static_cast<DensityTreeLeaf*>(left);    ar & isLeaf;    ar & *node;  } else {    assert(false);  }  if (typeid(*right) == typeid(DensityTreeInternal)) {    const bool isLeaf = false;    const DensityTreeInternal* node =        static_cast<DensityTreeInternal*>(right);    ar & isLeaf;    ar & *node;  } else if (typeid(*right) == typeid(DensityTreeLeaf)) {    const bool isLeaf = true;    const DensityTreeLeaf* node =        static_cast<DensityTreeLeaf*>(right);    ar & isLeaf;    ar & *node;  } else {    assert(false);  }}template<class Archive>void indii::ml::aux::DensityTreeInternal::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<DensityTreeNode>(*this);  ar & splitIndex;  ar & splitValue;  ar & isLeaf;    if (isLeaf) {    DensityTreeLeaf* node = new DensityTreeLeaf();    ar & *node;    left = node;  } else {    DensityTreeInternal* node = new DensityTreeInternal();    ar & *node;    left = node;  }  ar & isLeaf;  if (isLeaf) {    DensityTreeLeaf* node = new DensityTreeLeaf();    ar & *node;    right = node;  } else {    DensityTreeInternal* node = new DensityTreeInternal();    ar & *node;    right = node;  }}#endif

⌨️ 快捷键说明

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