00001 #ifndef INDII_ML_AUX_DISTRIBUTEDPARTITIONER_HPP 00002 #define INDII_ML_AUX_DISTRIBUTEDPARTITIONER_HPP 00003 00004 #include "Partitioner.hpp" 00005 00006 namespace indii { 00007 namespace ml { 00008 namespace aux { 00009 /** 00010 * Partitions a distributed set of weighted points into two sets at the 00011 * \f$n\f$th component. 00012 * 00013 * @author Lawrence Murray <lawrence@indii.org> 00014 * @version $Rev: 489 $ 00015 * @date $Date: 2008-07-31 12:13:05 +0100 (Thu, 31 Jul 2008) $ 00016 * 00017 * The purpose of this partitioner is to evenly distribute components across 00018 * nodes for DiracMixturePdf::redistributeBySpace(). It is for internal 00019 * use only. 00020 */ 00021 class DistributedPartitioner : public Partitioner { 00022 public: 00023 /** 00024 * Constructor. 00025 * 00026 * @param nth No. components to be on left side of split. 00027 */ 00028 DistributedPartitioner(const unsigned int nth); 00029 00030 /** 00031 * Destructor. 00032 */ 00033 virtual ~DistributedPartitioner(); 00034 00035 virtual bool init(DiracMixturePdf* p, 00036 const std::vector<unsigned int>& is); 00037 00038 virtual Partitioner::Partition assign(const vector& x); 00039 00040 private: 00041 /** 00042 * No. components to be on left side of split. 00043 */ 00044 unsigned int nth; 00045 00046 /** 00047 * Index of the dimension on which to split. 00048 */ 00049 unsigned int index; 00050 00051 /** 00052 * Value along which to split. 00053 */ 00054 double value; 00055 00056 }; 00057 00058 } 00059 } 00060 } 00061 00062 inline indii::ml::aux::Partitioner::Partition 00063 indii::ml::aux::DistributedPartitioner::assign(const vector& x) { 00064 if (x(index) < value) { // <, not <=, important given how vlaue is selected 00065 return Partitioner::LEFT; 00066 } else { 00067 return Partitioner::RIGHT; 00068 } 00069 } 00070 00071 #endif 00072
1.5.3