Anaphe Home Page Reference Documentation

Main Page     Namespaces     Classes     Source Code    

P_Uneven_Partition.h

Go to the documentation of this file.
00001 #ifndef H_P__UNEVEN_PARTITION_H_
00002 #define H_P__UNEVEN_PARTITION_H_
00003 
00004 #include "HTL/HTL_std.h"
00005 #include "HTL/I_Partition.h"
00006 #include "HTL/Extra_Bin_Indexes.h"
00007 #include <oo.h>
00008 
00009 #include "HTL/T_Uneven_Partition.h"
00010 
00011 #undef T_Point
00012 #define T_Point double
00013 
00018 class P_Uneven_Partition: public I_Partition {
00019 public:
00021   H_IID_IMPLEMENT( P_Uneven_Partition )
00022 public:
00023   typedef T_Point                       Mapped_Point;
00024   typedef P_Uneven_Partition            Like_Current;
00025   typedef ooVArrayT<T_Point>            Points_Set;
00026   typedef T_Uneven_Partition            T__Partition;
00027 public: 
00029   virtual ~P_Uneven_Partition() {}
00031   P_Uneven_Partition() {}
00032 
00038   P_Uneven_Partition( HTL_STD::vector<float> &some_points,
00039                 End_Point_Convention a_convention = RIGHT_OPEN )
00040 #ifdef HTL_USE_EXCEPTIONS
00041     throw (HTLExceptions::NotEnoughPoints);
00042 #endif //HTL_USE_EXCEPTIONS
00043 ;
00044   P_Uneven_Partition( HTL_STD::vector<double> &some_points,
00050                 End_Point_Convention a_convention = RIGHT_OPEN )
00051 #ifdef HTL_USE_EXCEPTIONS
00052     throw (HTLExceptions::NotEnoughPoints);
00053 #endif //HTL_USE_EXCEPTIONS
00054 ;
00055 
00060   P_Uneven_Partition( I_Partition &another )
00061 #ifdef HTL_USE_EXCEPTIONS
00062     throw (HTLExceptions::NotEnoughPoints);
00063 #endif //HTL_USE_EXCEPTIONS
00064 ;
00065 
00066 public: 
00067 
00069   virtual double i_bin_width( Index i ) const{ return double(bin_width(i)); }
00070 
00072   virtual Size bin_count() const { return Size(count_); }
00073 
00075   virtual double i_lower_point() const { return double(lower_point()); }
00076 
00078   virtual double i_upper_point() const { return double(upper_point()); }
00079 
00081   virtual double i_lower_point( Index i ) const 
00082     { return double(lower_point(i)); }
00083 
00085   virtual double i_upper_point( Index i ) const
00086     { return double(upper_point(i)); }
00087 
00089   virtual void map_point( double a_point, Index &an_index, 
00090                           Extra_Index &an_extra_index )
00091     {map_index (a_point,an_index,an_extra_index);}
00092 
00093 public:
00104   void map_index( T_Point a_point, Index &an_index, 
00105                        Extra_Index &an_extra_index ) {
00106     if((end_point_convention_ == RIGHT_OPEN)&&(a_point>=lower_point_)
00107        && (a_point < upper_point_)) {
00108       an_index = 0;
00109       while( an_index < bin_count() ) {
00110         if( a_point < upper_point( an_index ) ) break;
00111         an_index ++;
00112       }
00113       an_extra_index = H_IN_RANGE;
00114       return;
00115     } else {
00116       map_index1( a_point, an_index, an_extra_index );
00117     }
00118   }
00119 
00128   void map_index1( T_Point a_point, Index &an_index, 
00129                    Extra_Index &an_extra_index );
00130 public:
00132   T_Point bin_width( Index i ) const
00133     {
00134       T_Point retval = 0;
00135       if ( i>= 0 && i<bin_count() )
00136         retval = points_[i+1] - points_[i] ;
00137       else
00138         HTL_ERR("Index out of range in P_Uneven_Partition::bin_width");
00139       return retval;
00140     }
00141 
00144   T_Point lower_point() const { return lower_point_; }
00145 
00148   T_Point upper_point() const { return upper_point_; }
00149 
00151   T_Point lower_point( Index i ) const
00152     {
00153       T_Point retval = 0;
00154       if ( (i >= 0) && (i < count_) )
00155         retval = points_[i] ;
00156       else
00157         HTL_ERR("Index out of range in P_Uneven_Partition::bin_width");
00158       return retval;
00159     }
00160 
00162   T_Point upper_point( Index i ) const
00163     {
00164       T_Point retval = 0;
00165       if ( (i >= 0) && (i < count_) )
00166         retval = points_[i+1] ;
00167       else
00168         HTL_ERR("Index out of range in P_Uneven_Partition::bin_width");
00169       return retval;
00170     }
00171 
00172 public:
00174   virtual End_Point_Convention end_point_convention() const
00175     { return end_point_convention_; }
00176 
00177 protected:
00178   void initializePartition();
00179 
00180 protected:
00181   T_Point lower_point_;
00182   T_Point upper_point_;
00183   Size  count_;
00184 
00185   End_Point_Convention end_point_convention_;
00186   Points_Set points_;
00187 };
00188 
00189 #undef T_Point
00190 #endif
00191 


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