Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ComPackFlatFloat Class Reference

#include <ComPackFlatFloat.h>

Inheritance diagram for ComPackFlatFloat:

ComPackBase< double > ComPackBase< double > ComPackBaseBase ComPackBaseBase ComPackBaseBase ComPackBaseBase List of all members.

Public Types

enum  StatusCode {
  TAG_OK, TAG_BAD, TAG_RANGE_ERROR, TAG_VAL_ROUND_DOWN,
  TAG_VAL_ROUND_UP
}
enum  StatusCode {
  TAG_OK, TAG_BAD, TAG_RANGE_ERROR, TAG_VAL_ROUND_DOWN,
  TAG_VAL_ROUND_UP
}

Public Member Functions

d_ULong bitMask () const
d_ULong bitMask () const
d_ULong bitRange () const
d_ULong bitRange () const
 ComPackFlatFloat (const double, const double, size_t)
 ComPackFlatFloat (const double, const double, size_t)
virtual const double & getMaxVal () const
virtual const double & getMaxVal () const
virtual const double & getMinVal () const
virtual const double & getMinVal () const
virtual const double & getRange () const
virtual const double & getRange () const
StatusCode pack (const double, d_ULong &) const
StatusCode pack (const double, d_ULong &) const
void testMe (size_t, double &)
void testMe (size_t, double &)
StatusCode unpack (const d_ULong, double &) const
StatusCode unpack (const d_ULong, double &) const
virtual ~ComPackFlatFloat ()
virtual ~ComPackFlatFloat ()

Protected Attributes

d_ULong _bitMask
d_ULong _bitRange
double _maxVal
double _minVal
double _valRange

Private Attributes

double _pacfac
double _upacfac

Member Enumeration Documentation

enum ComPackBaseBase::StatusCode [inherited]
 

Enumeration values:
TAG_OK 
TAG_BAD 
TAG_RANGE_ERROR 
TAG_VAL_ROUND_DOWN 
TAG_VAL_ROUND_UP 
00035                   {
00036     TAG_OK, TAG_BAD, TAG_RANGE_ERROR, TAG_VAL_ROUND_DOWN, TAG_VAL_ROUND_UP 
00037   };

enum ComPackBaseBase::StatusCode [inherited]
 

Enumeration values:
TAG_OK 
TAG_BAD 
TAG_RANGE_ERROR 
TAG_VAL_ROUND_DOWN 
TAG_VAL_ROUND_UP 
00035                   {
00036     TAG_OK, TAG_BAD, TAG_RANGE_ERROR, TAG_VAL_ROUND_DOWN, TAG_VAL_ROUND_UP 
00037   };


Constructor & Destructor Documentation

ComPackFlatFloat::ComPackFlatFloat const   double,
const   double,
size_t 
 

00060 {
00061   if (val_one>val_two) {
00062     _minVal=val_two; 
00063     _maxVal=val_one;
00064   } else {
00065     _minVal=val_one; 
00066     _maxVal=val_two;
00067   }
00068 
00069 // this is a stupid test.  I wanted to packa a number in nano-seconds,
00070 // and it refused.  I've removed the test dnb 11/17/00
00071 //  const double epsilon = 0.0001;
00072   const double epsilon = 0.0;
00073   if (( _maxVal - _minVal )<=epsilon) {
00074     cout <<" ErrMsg(fatal) "  << "Error : Range is zero!" << endl;
00075     abort();
00076   }
00077   _valRange = _maxVal - _minVal;
00078 
00079   if (bits > _maxlongbits ) {
00080     bits = _maxlongbits;
00081     cout << " ErrMsg(fatal) "<< "Warning : Number of bits truncated! "
00082     << "Reason  : Number of bits too large for " << _maxlongbits << " bit packing operations! "
00083     << "This is probably caused by a serious typo somewhere!" << endl;
00084     abort();
00085   }
00086   _bitRange = bits;
00087   _bitMask = (1<<_bitRange) - 1;
00088   if ( 0 == _bitMask) { // check for wrap around
00089     _bitMask--;
00090   }
00091 // preset packing.
00092   _pacfac = (1<<_bitRange)/_valRange;
00093   _upacfac = 1.0/_pacfac;
00094 }

ComPackFlatFloat::~ComPackFlatFloat  )  [virtual]
 

00096 {}

ComPackFlatFloat::ComPackFlatFloat const   double,
const   double,
size_t 
 

virtual ComPackFlatFloat::~ComPackFlatFloat  )  [virtual]
 


Member Function Documentation

d_ULong ComPackBase< double >::bitMask  )  const [inline, inherited]
 

00075 { return _bitMask; }

d_ULong ComPackBase< double >::bitMask  )  const [inline, inherited]
 

00075 { return _bitMask; }

d_ULong ComPackBase< double >::bitRange  )  const [inline, inherited]
 

00074 { return _bitRange; }

d_ULong ComPackBase< double >::bitRange  )  const [inline, inherited]
 

00074 { return _bitRange; }

virtual const double & ComPackBase< double >::getMaxVal  )  const [inline, virtual, inherited]
 

00071 { return _maxVal;};

virtual const double & ComPackBase< double >::getMaxVal  )  const [inline, virtual, inherited]
 

00071 { return _maxVal;};

virtual const double & ComPackBase< double >::getMinVal  )  const [inline, virtual, inherited]
 

00070 { return _minVal;};

virtual const double & ComPackBase< double >::getMinVal  )  const [inline, virtual, inherited]
 

00070 { return _minVal;};

virtual const double & ComPackBase< double >::getRange  )  const [inline, virtual, inherited]
 

00072 { return _valRange;};

virtual const double & ComPackBase< double >::getRange  )  const [inline, virtual, inherited]
 

00072 { return _valRange;};

StatusCode ComPackFlatFloat::pack const   double,
d_ULong
const [virtual]
 

Implements ComPackBase< double >.

ComPackBase< double >::StatusCode ComPackFlatFloat::pack const   double,
d_ULong
const [virtual]
 

Implements ComPackBase< double >.

00100 {
00101   StatusCode retval(TAG_OK);
00102   double dpack = (theval-_minVal)*_pacfac;
00103   packedval = (d_ULong)dpack;
00104   if (dpack>_bitMask) { 
00105     packedval = _bitMask;
00106     retval = TAG_VAL_ROUND_DOWN;
00107   } else if (dpack<0) {
00108     packedval = 0; // clamp
00109     retval = TAG_VAL_ROUND_UP;
00110   }
00111   return retval;
00112 }

void ComPackFlatFloat::testMe size_t  ,
double & 
 

void ComPackFlatFloat::testMe size_t  ,
double & 
 

00123 {
00124   if ( 0 == numsteps) return;
00125   toterror = 0.;
00126   const double incstep = double (_valRange) / double (numsteps);
00127   for ( double i = _minVal; i<= _maxVal; i+=incstep)
00128     {
00129       d_ULong tagVal;
00130       pack ( i, tagVal );
00131       double unTagVal;
00132       unpack ( tagVal, unTagVal );
00133       cout << i << " is converted to :" << tagVal << ". Upon unpacking :" << unTagVal << endl;
00134       toterror += fabs ( i-unTagVal );
00135     }
00136 }

StatusCode ComPackFlatFloat::unpack const   d_ULong,
double & 
const [virtual]
 

Implements ComPackBase< double >.

ComPackBase< double >::StatusCode ComPackFlatFloat::unpack const   d_ULong,
double & 
const [virtual]
 

Implements ComPackBase< double >.

00116 {
00117   unpackedval = ((val&_bitMask)+0.5)*_upacfac + _minVal;
00118   return TAG_OK;
00119 }


Member Data Documentation

d_ULong ComPackBase< double >::_bitMask [protected, inherited]
 

d_ULong ComPackBase< double >::_bitRange [protected, inherited]
 

double ComPackBase< double >::_maxVal [protected, inherited]
 

double ComPackBase< double >::_minVal [protected, inherited]
 

double ComPackFlatFloat::_pacfac [private]
 

double ComPackFlatFloat::_upacfac [private]
 

double ComPackBase< double >::_valRange [protected, inherited]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 15:56:29 2011 for BOSS6.5.5 by  doxygen 1.3.9.1