Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

TupleSignature Class Reference

#include <structures.h>

List of all members.

Public Member Functions

 TupleSignature ()
 TupleSignature (int n, TupleSigType t, Index paramType, char ir=1)
 TupleSignature (const TupleSignature &oneSig)
TupleSignatureoperator= (const TupleSignature &oneSig)
int operator== (const TupleSignature &sig) const
 ~TupleSignature ()
void setOffsets (int *offs)
void setEmpty ()
int isEmpty ()
void output (FILE *ofp)
int hash () const
void pack (MOStream *msg)
void unpack (MIStream *msg)

Public Attributes

TupleSigType tupleType
int numOffset
int * offset
Index tupleParamType
char isReal


Constructor & Destructor Documentation

TupleSignature::TupleSignature  )  [inline]
 

Definition at line 182 of file structures.h.

00182                     {        
00183         offset = NULL;
00184         isReal = 1;
00185     }

TupleSignature::TupleSignature int  n,
TupleSigType  t,
Index  paramType,
char  ir = 1
[inline]
 

Definition at line 187 of file structures.h.

00187                                                                      {
00188         tupleType = t;
00189         numOffset = n;
00190         offset = new int[n];        
00191         tupleParamType = paramType;
00192         isReal = ir;
00193     }

TupleSignature::TupleSignature const TupleSignature oneSig  )  [inline]
 

Definition at line 194 of file structures.h.

References isReal, numOffset, offset, tupleParamType, and tupleType.

00194                                                 {
00195         tupleType = oneSig.tupleType;
00196         numOffset = oneSig.numOffset;
00197         offset = new int[numOffset];
00198         setOffsets(oneSig.offset);        
00199         tupleParamType = oneSig.tupleParamType;
00200         isReal = oneSig.isReal;
00201     }

TupleSignature::~TupleSignature  )  [inline]
 

Definition at line 231 of file structures.h.

00231                      {
00232         if(offset) delete[] offset;
00233     }


Member Function Documentation

int TupleSignature::hash void   )  const [inline]
 

Definition at line 277 of file structures.h.

References circShift().

00277                      {
00278       unsigned int code = tupleType;
00279       unsigned int codesz = 8 * sizeof(int);
00280       unsigned int shift = codesz / numOffset;
00281       
00282       if (shift == 0) shift=1;
00283       unsigned int i;
00284       for(i=0; i < numOffset; i++) {
00285         code = circShift(code,shift);
00286         code ^= offset[i];
00287       }
00288       return code;
00289     }

int TupleSignature::isEmpty  )  [inline]
 

Definition at line 268 of file structures.h.

00268                  {
00269         return offset==NULL;
00270     }

TupleSignature& TupleSignature::operator= const TupleSignature oneSig  )  [inline]
 

Definition at line 202 of file structures.h.

References isReal, numOffset, offset, tupleParamType, and tupleType.

00202                                                            {
00203         tupleType = oneSig.tupleType;
00204         numOffset = oneSig.numOffset;
00205         if(offset) delete [] offset;
00206         offset = new int[numOffset];
00207         setOffsets(oneSig.offset);        
00208         tupleParamType = oneSig.tupleParamType;
00209         isReal = oneSig.isReal;
00210         return *this;
00211     }

int TupleSignature::operator== const TupleSignature sig  )  const [inline]
 

Definition at line 212 of file structures.h.

References isReal, numOffset, offset, tupleParamType, and tupleType.

00212                                                    {
00213             if(tupleType!=sig.tupleType)
00214                 return 0;
00215 
00216             if(tupleParamType != sig.tupleParamType)
00217                 return 0;
00218 
00219         if(isReal != sig.isReal)
00220             return 0;
00221 
00222                 if(numOffset != sig.numOffset) return 0;
00223                 
00224             int equalCnt=0;
00225                     
00226             for(int i=0; i<numOffset; i++){
00227                 equalCnt += (offset[i]==sig.offset[i]);      
00228             }
00229             return equalCnt==numOffset;
00230         }

void TupleSignature::output FILE *  ofp  )  [inline]
 

Definition at line 271 of file structures.h.

Referenced by outputCompressedFile(), and outputPsfFile().

00271                           {
00272         for(int i=0; i<numOffset; i++)
00273             fprintf(ofp, "%d ", offset[i]);
00274         fprintf(ofp, "| %d | %d\n", tupleParamType, isReal);         
00275     }

void TupleSignature::pack MOStream msg  ) 
 

void TupleSignature::setEmpty  )  [inline]
 

Definition at line 264 of file structures.h.

00264                    {
00265         delete [] offset;
00266         offset = NULL;
00267     }

void TupleSignature::setOffsets int *  offs  )  [inline]
 

Definition at line 234 of file structures.h.

00234                               {
00235         for(int i=0; i<numOffset; i++)
00236             offset[i] = offs[i];
00237         //sort the offset in increasing order
00238         //based on the input files, this offset is almost sorted increasingly
00239         //Therefore using insertion sort
00240         /*switch(numOffset){
00241             case 1:
00242                 break;
00243             case 2:
00244                 if(offset[0]>offset[1]){
00245                     int tmp = offset[0];
00246                     offset[0] = offset[1];
00247                     offset[1] = tmp;
00248                 }
00249                 break;
00250             default: //insertion sort
00251                 for(int ii=1; ii<numOffset; ii++){
00252                     int val = offset[ii];
00253                     for(int jj=ii-1; jj>=0; jj--){
00254                         if(offset[jj]<val){
00255                             offset[jj+1] = offset[jj];
00256                             offset[jj] = val;
00257                         }else
00258                             break;
00259                     }
00260                 }
00261         }*/
00262 
00263     }

void TupleSignature::unpack MIStream msg  ) 
 


Member Data Documentation

char TupleSignature::isReal
 

Definition at line 179 of file structures.h.

Referenced by buildExclusions(), operator=(), operator==(), and TupleSignature().

int TupleSignature::numOffset
 

Definition at line 168 of file structures.h.

Referenced by operator=(), operator==(), and TupleSignature().

int* TupleSignature::offset
 

Definition at line 170 of file structures.h.

Referenced by AngleElem::AngleElem(), BondElem::BondElem(), buildBondData(), buildExclusions(), CrosstermElem::CrosstermElem(), DihedralElem::DihedralElem(), ExclElem::ExclElem(), getBondData(), ImproperElem::ImproperElem(), operator=(), operator==(), Molecule::print_bonds(), and TupleSignature().

Index TupleSignature::tupleParamType
 

Definition at line 174 of file structures.h.

Referenced by AngleElem::AngleElem(), BondElem::BondElem(), CrosstermElem::CrosstermElem(), DihedralElem::DihedralElem(), dumpbench(), ExclElem::ExclElem(), ImproperElem::ImproperElem(), operator=(), operator==(), Molecule::print_bonds(), and TupleSignature().

TupleSigType TupleSignature::tupleType
 

Definition at line 167 of file structures.h.

Referenced by operator=(), operator==(), and TupleSignature().


The documentation for this class was generated from the following file:
Generated on Mon Nov 23 05:00:12 2009 for NAMD by  doxygen 1.3.9.1