indii/ml/aux/PartitionFunctor.hpp

00001 #ifndef INDII_ML_AUX_PARTITIONFUNCTOR_HPP
00002 #define INDII_ML_AUX_PARTITIONFUNCTOR_HPP
00003 
00004 #include "DiracMixturePdf.hpp"
00005 
00006 namespace indii {
00007   namespace ml {
00008     namespace aux {
00009 /**
00010  * Predicate functor for nth element partition. 
00011  *
00012  * @author Lawrence Murray <lawrence@indii.org>
00013  * @version $Rev: 489 $
00014  * @date $Date: 2008-07-31 12:13:05 +0100 (Thu, 31 Jul 2008) $
00015  *
00016  * Internal use only, by DistributedPartitioner.
00017  */
00018 class PartitionFunctor {
00019 public:
00020   /**
00021    * Constructor.
00022    *
00023    * @param p Weighted sample set.
00024    * @param index Dimension on which to split.
00025    * @param value Value on which to split.
00026    */
00027   PartitionFunctor(const DiracMixturePdf& p, const unsigned int index, 
00028       const double value);
00029 
00030   /**
00031    * Destructor.
00032    */
00033   virtual ~PartitionFunctor();
00034       
00035   /**
00036    * Apply function.
00037    *
00038    * @param i Index of the component in the weighted sample set.
00039    *
00040    * @return True if dimension @p index of component @p i is then than
00041    * @p value.
00042    */
00043   bool operator()(const unsigned int i);
00044   
00045 private:
00046   /**
00047    * The weighted sample set.
00048    */
00049   const DiracMixturePdf& p;
00050   
00051   /**
00052    * Dimension on which to split.
00053    */
00054   const unsigned int index;
00055   
00056   /**
00057    * Value on which to split.
00058    */
00059   const double value;
00060   
00061 };
00062 
00063     }
00064   }
00065 }
00066 
00067 inline bool indii::ml::aux::PartitionFunctor::operator()(
00068     const unsigned int i) {
00069   return p.get(i)[index] < value;
00070 }
00071 
00072 #endif
00073 

Generated on Wed Dec 17 15:11:57 2008 for dysii Dynamical Systems Library by  doxygen 1.5.3