Anaphe Home Page Reference Documentation

Main Page     Namespaces     Classes     Source Code    

T_Uneven_Partition.h

Go to the documentation of this file.
00001 #ifndef _H_T__UNEVEN_PARTITION_H_
00002 #define _H_T__UNEVEN_PARTITION_H_ 1
00003 
00004 #include "HTL/I_Partition.h"
00005 #include "HTL/Extra_Bin_Indexes.h"
00006 #include "HTL/HTL_std.h"
00007 #include "HTL/HTL_std.h"
00008 #include "HTL/HTLExceptions.h"
00009 
00010 # include <vector>
00011 
00012 #undef T_Point
00013 #define T_Point double
00014 
00018 class T_Uneven_Partition: public I_Partition {
00019 public:
00021   H_IID_IMPLEMENT( T_Uneven_Partition );
00022 public:
00023   typedef T_Point                       Mapped_Point;
00024   typedef T_Uneven_Partition            Like_Current;
00025   typedef HTL_STD::vector<T_Point>      Points_Set;
00026   typedef T_Uneven_Partition            T__Partition;
00027 public: 
00029   virtual ~T_Uneven_Partition() {}
00031   T_Uneven_Partition() {}
00032 
00039   T_Uneven_Partition( HTL_STD::vector<float> &some_points,
00040                       End_Point_Convention a_convention = RIGHT_OPEN )
00041 #ifdef HTL_USE_EXCEPTIONS
00042     throw (HTLExceptions::NotEnoughPoints);
00043 #endif //HTL_USE_EXCEPTIONS
00044 ;
00045 
00051   T_Uneven_Partition( HTL_STD::vector<double> &some_points,
00052                       End_Point_Convention a_convention = RIGHT_OPEN )
00053 #ifdef HTL_USE_EXCEPTIONS
00054     throw (HTLExceptions::NotEnoughPoints);
00055 #endif //HTL_USE_EXCEPTIONS
00056 ;
00057   
00059   T_Uneven_Partition( I_Partition &another )
00060 #ifdef HTL_USE_EXCEPTIONS
00061     throw (HTLExceptions::NotEnoughPoints);
00062 #endif //HTL_USE_EXCEPTIONS
00063 ;
00064 
00065 public: 
00066 
00068   virtual double i_bin_width( Index i ) const {return double(bin_width(i)); }
00069 
00071   virtual Size bin_count() const { return Size(count_); }
00072 
00074   virtual double i_lower_point() const { return double(lower_point()); }
00075 
00077   virtual double i_upper_point() const { return double(upper_point()); }
00078 
00080   virtual double i_lower_point(Index i) const {return double(lower_point(i));}
00081 
00083   virtual double i_upper_point( Index i ) const{return double(upper_point(i));}
00084 
00086   virtual void map_point(double a_point, Index &_index, Extra_Index &_exindex )
00087     { map_index (a_point, _index, _exindex);}
00088 
00089 public:
00100   void map_index( T_Point a_point, Index &an_index, 
00101                        Extra_Index &an_extra_index ) {
00102     if((end_point_convention_ == RIGHT_OPEN)&&(a_point>=lower_point_)
00103        && (a_point < upper_point_)) {
00104       an_index = 0;
00105       while( an_index < bin_count() ) {
00106         if( a_point < upper_point( an_index ) ) break;
00107         an_index ++;
00108       }
00109       an_extra_index = H_IN_RANGE;
00110       return;
00111     } else {
00112       map_index1( a_point, an_index, an_extra_index );
00113     }
00114   }
00115 
00124   void map_index1(T_Point a_point, Index &_index, Extra_Index &_extra_index);
00125 
00126 public:
00128   T_Point bin_width( Index i ) const {
00129     T_Point retval = 0;
00130     if ( i>= 0 && i<bin_count() )
00131       retval = points_[i+1] - points_[i] ;
00132     else
00133       HTL_ERR("Index out of range in T_Uneven_Partition::bin_width");
00134     return retval;
00135   }
00136 
00140   T_Point lower_point() const { return lower_point_; }
00141 
00145   T_Point upper_point() const { return upper_point_; }
00146 
00148   T_Point lower_point( Index i ) const {
00149     T_Point retval = 0;
00150     if ( (i >= 0) && (i < count_) )
00151       retval = points_[i] ;
00152     else
00153       HTL_ERR("Index out of range in T_Uneven_Partition::bin_width");
00154     return retval;
00155   }
00156 
00158   T_Point upper_point( Index i ) const {
00159     T_Point retval = 0;
00160     if ( (i >= 0) && (i < count_) )
00161       retval = points_[i+1] ;
00162     else
00163       HTL_ERR("Index out of range in T_Uneven_Partition::bin_width");
00164     return retval;
00165   }
00166 
00167 public:
00169   virtual End_Point_Convention end_point_convention() const 
00170     { return end_point_convention_; }
00171 
00172 protected:
00173   void initializePartition();
00174 
00175 protected:
00176   T_Point lower_point_;
00177   T_Point upper_point_;
00178   Size  count_;
00179   End_Point_Convention end_point_convention_;
00180   Points_Set points_;
00181 };
00182 
00183 #undef T_Point
00184 
00185 #endif
00186 


Anaphe documentation generated by Doxygen (www.doxygen.org)