Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

histogram.h

Go to the documentation of this file.
00001 
00002 #ifndef _HISTOGRAM_H_
00003 #define _HISTOGRAM_H_
00004 
00005 #include <assert.h>
00006 
00045 class histogram
00046 {
00047 private:
00048   // copy constructor
00049   histogram( const histogram &rhs );
00050 
00051   class bin_vec;
00052   void init_bins( bin_vec &bins,
00053                   const double min,
00054                   const double max );
00055 
00059   class value_pool
00060   {
00061   private:
00062     size_t ix_;
00063     const double *vec_;
00064     const size_t N_;
00065 
00066   public:
00067     value_pool( const double *vec, size_t N ) : vec_( vec ), N_( N )
00068     {
00069       ix_ = 0;
00070     }
00071 
00072     bool get_val( double &val )
00073     {
00074       bool rslt = false;
00075       val = 0.0;
00076       if (ix_ < N_) {
00077         rslt = true;
00078         val = vec_[ ix_ ];
00079         ix_++;
00080       }
00081       return rslt;
00082     } // get_val
00083 
00084   }; // value_pool
00085 
00086 public:
00096   class histo_bin
00097   {
00098   private:
00100     double frequency_;
00102     double start_;
00104     double end_;
00105 
00106   public:
00107     histo_bin() {}
00108     ~histo_bin() {}
00109 
00110     double frequency() { return frequency_; }
00111     void frequency( const double f ) { frequency_ = f; }
00112 
00113     double &freqPtr() { return frequency_; }
00114 
00115     double start() { return start_; }
00116     void start( const double s ) { start_ = s; }
00117 
00118     double end() { return end_; }
00119     void end( const double e ) { end_ = e; }
00120 
00121   }; // class histo_bin
00122 
00123 
00140   class bin_vec
00141   {
00142   private:
00143     bin_vec( const bin_vec &rhs );
00144     const size_t num_bins;
00145     histo_bin *bins;
00146 
00147   public:
00148     bin_vec( size_t N ) : num_bins( N )
00149     {
00150       bins = new histo_bin[ num_bins ];
00151     }
00152 
00153     ~bin_vec()
00154     {
00155       delete [] bins;
00156     }
00157 
00158     size_t length() { return num_bins; }
00159 
00160     double start( const size_t i ) 
00161     { 
00162       assert( i < num_bins );
00163       return bins[i].start(); 
00164     }
00165 
00166     void start( const size_t i, const double val )
00167     {
00168       assert( i < num_bins );
00169       bins[i].start( val );
00170     }
00171 
00172     double end( const size_t i ) 
00173     { 
00174       assert( i < num_bins );
00175       return bins[i].end(); 
00176     }
00177 
00178     void end( const size_t i, const double val )
00179     {
00180       assert( i < num_bins );
00181       bins[i].end( val );
00182     }
00183 
00185     double &operator[]( const size_t i )
00186     {
00187       assert( i < num_bins );
00188       
00189       return bins[i].freqPtr();
00190     }
00191 
00193     double operator[]( const size_t i ) const
00194     {
00195       assert( i < num_bins );
00196       return bins[i].frequency();
00197     }
00198 
00199   }; // class bin_vec
00200 
00201 public:
00202   histogram() {}
00203   ~histogram() {}
00204 
00205   void calculate( const double *raw_data,
00206                   const size_t N,
00207                   bin_vec &binz );
00208 }; // histogram
00209 
00210 
00211 #endif

Generated at Thu May 22 21:12:35 2003 for Hurst Exponent Calculation and Supporting Statistics by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001