Anaphe Home Page Reference Documentation

Main Page     Namespaces     Classes     Source Code    

Even_Partition.h

Go to the documentation of this file.
00001 #ifndef _EVEN_PARTITION_H_
00002 #define _EVEN_PARTITION_H_ 1
00003 
00004 #include "HTL/HTL_std.h"
00005 #include "HTL/I_Partition.h"
00006 #include "HTL/Extra_Bin_Indexes.h"
00007 #include "HTL/HTLExceptions.h"
00008 
00009 #undef T_Point
00010 #define T_Point double
00011 
00016 class Even_Partition: public I_Partition
00017 {
00018 public:
00020   H_IID_IMPLEMENT( Even_Partition );
00021 public: 
00022   typedef T_Point Mapped_Point;
00023   typedef Even_Partition Like_Current;
00024   typedef Even_Partition T__Partition;
00025 public:
00027   virtual ~Even_Partition() {}
00029   Even_Partition() {}
00033   Even_Partition( Size a_bin_count, 
00034                   T_Point a_leftmost_point, T_Point a_rightmost_point, 
00035                   End_Point_Convention a_convention = RIGHT_OPEN )
00036 #ifdef HTL_USE_EXCEPTIONS
00037     throw (HTLExceptions::WrongLimits,HTLExceptions::WrongBins)
00038 #endif //HTL_USE_EXCEPTIONS
00039 ;
00040 
00045   Even_Partition( I_Partition &another ) 
00046 #ifdef HTL_USE_EXCEPTIONS
00047    throw (HTLExceptions::IncompatiblePartition);
00048 #endif //HTL_USE_EXCEPTIONS
00049 ;
00050 public: 
00052   virtual double i_bin_width( Index i ) const { return double(bin_width(i)); }
00053 
00055         virtual Size bin_count() const { return Size(count_); }
00056 
00058         virtual double i_lower_point() const { return double(lower_point()); }
00059   
00061         virtual double i_upper_point() const { return double(upper_point()); }
00062 
00064   virtual double i_lower_point(Index i) const {return double(lower_point(i)); }
00065 
00067   virtual double i_upper_point(Index i) const{ return double(upper_point(i)); }
00068 
00070   virtual void map_point( double a_point, Index &an_index, 
00071                                 Extra_Index &an_extra_index )
00072     {map_index (a_point,an_index,an_extra_index);}
00073 
00074 public:
00086   void map_index( T_Point a_point, Index &an_index, 
00087                         Extra_Index &an_extra_index ) {
00088     if((end_point_convention_ == RIGHT_OPEN)&&(a_point>=lower_point_)
00089        && (a_point < upper_point_)) {
00090       an_index = Index( (a_point - lower_point_) / bin_width_ );
00091       an_extra_index = H_IN_RANGE;
00092       return;
00093     } else {
00094       map_index1( a_point, an_index, an_extra_index );
00095     }
00096   }
00097 
00106   void map_index1( T_Point a_point, Index &an_index, 
00107                    Extra_Index &an_extra_index );
00108 public:
00110         T_Point bin_width( Index ) const { return bin_width_; }
00111 
00114   T_Point lower_point() const { return lower_point_; }
00115 
00118   T_Point upper_point() const { return upper_point_; }
00119 
00121   T_Point lower_point( Index i ) const
00122     {
00123       T_Point retval = 0;
00124       if ((i >= 0) && (i < count_)) {
00125         retval = lower_point() + i*bin_width(i) ;
00126       } else {
00127         HTL_ERR("Index out of range in Even_Partition::lower_point. lower point is zero");
00128       }
00129       return retval;
00130     }
00131 
00133    T_Point upper_point( Index i ) const
00134     {
00135       T_Point retval = 0;
00136       if ((i >= 0) && (i < count_)) {
00137         retval = lower_point() + (i+1)*bin_width(i) ;
00138       } else {
00139         HTL_ERR("Index out of range in Even_Partition::upper_point. upper point is zero");
00140       }
00141       return retval;
00142     }
00143 
00144 public:
00146   virtual End_Point_Convention end_point_convention() const
00147     { return end_point_convention_; }
00148 protected:
00149   Size  count_;
00150   T_Point lower_point_;
00151   T_Point upper_point_;
00152   T_Point       bin_width_;
00153   End_Point_Convention end_point_convention_;
00154 };
00155 
00156 #undef T_Point
00157 
00158 #endif
00159 


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