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

packcontainer.h

Go to the documentation of this file.
00001 
00002 #ifndef _PACKCONTAINER_H_
00003 #define _PACKCONTAINER_H_
00004 
00005 #include "packnode.h"
00006 
00038 
00039 
00052 class packcontainer {
00053 private:
00055   size_t N;
00057   double* lhs;
00059   double* rhs;
00060 
00061 private:
00063   packcontainer( const packcontainer &rhs ) {};
00065   packcontainer() {};
00066 
00067 public:
00068 
00088   packcontainer( packnode<double>* node )
00089   {
00090     assert( node != 0 );
00091     N = node->length();
00092     assert( N > 1 );
00093 
00094     size_t half = N >> 1;
00095     block_pool mem_pool;
00096     size_t num_bytes = half * sizeof(double);
00097 
00098     lhs = (double *)mem_pool.pool_alloc( num_bytes );
00099     rhs = (double *)mem_pool.pool_alloc( num_bytes );
00100 
00101     for (size_t i = 0; i < N; i++) {
00102       (*this)[i] = (*node)[i];
00103     }
00104   } // packcontainer
00105 
00106 
00117   packcontainer( size_t n )
00118   {
00119     N = n;
00120     lhs = 0;
00121     rhs = 0;
00122   }
00123 
00130   void *operator new( unsigned int num_bytes )
00131   {
00132     block_pool mem_pool;
00133 
00134     void *mem_addr = mem_pool.pool_alloc( num_bytes );
00135     return mem_addr;
00136   } // new
00137 
00138 
00140   double &operator[]( const size_t i )
00141   {
00142     assert( i < N );
00143     size_t half = N >> 1;
00144 
00145     if (i < half)
00146       return lhs[i];
00147     else {
00148       return rhs[i-half];
00149     }
00150   }
00151 
00153   double operator[]( const size_t i ) const
00154   {
00155     assert( i < N );
00156     size_t half = N >> 1;
00157 
00158     if (i < half)
00159       return lhs[i];
00160     else {
00161       return rhs[i-half];
00162     }
00163   }
00164 
00166   double* lhsData() { return lhs; }
00168   double* rhsData() { return rhs; }
00169 
00171   void lhsData(double* l) { lhs = l; }
00173   void rhsData(double* r) { rhs = r; }
00174 
00180   size_t length() { return N; }
00181 
00182 }; // packcontainer
00183 
00184 #endif

Generated at Tue May 27 21:56:16 2003 for Wavelet compression, determinism and time series forecasting by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001