indii/ml/aux/LengthPartitioner.cpp

00001 #include "LengthPartitioner.hpp"
00002 
00003 using namespace indii::ml::aux;
00004 
00005 LengthPartitioner::~LengthPartitioner() {
00006   //
00007 }
00008 
00009 bool LengthPartitioner::init(DiracMixturePdf* p,
00010     const std::vector<unsigned int>& is) {
00011   /* pre-condition */
00012   assert (is.size() >= 2);
00013 
00014   unsigned int i, j;
00015   vector lower(p->get(is[0]));
00016   vector upper(p->get(is[0]));
00017   vector length(p->getDimensions());
00018   
00019   /* calculate bounds */
00020   for (i = 1; i < is.size(); i++) {
00021     for (j = 0; j < p->getDimensions(); j++) {
00022       vector& x = p->get(is[i]);
00023       if (x(j) < lower(j)) {
00024         lower(j) = x(j);
00025       } else if (x(j) > upper(j)) {
00026         upper(j) = x(j);
00027       }
00028     }
00029   }
00030 
00031   /* select longest dimension */
00032   noalias(length) = upper - lower;
00033   this->index = index_norm_inf(length);   
00034 
00035   /* split on midpoint of selected dimension */
00036   this->value = (lower(index) + upper(index)) / 2.0;
00037   
00038   return length(this->index) > 0.0;
00039 }
00040 

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