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


Detailed Description

Definition at line 182 of file structures.h.


Constructor & Destructor Documentation

TupleSignature::TupleSignature (  )  [inline]

Definition at line 200 of file structures.h.

References isReal, and offset.

00200                     {        
00201         offset = NULL;
00202         isReal = 1;
00203     }

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

Definition at line 205 of file structures.h.

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

00205                                                                      {
00206         tupleType = t;
00207         numOffset = n;
00208         offset = new int[n];        
00209         tupleParamType = paramType;
00210         isReal = ir;
00211     }

TupleSignature::TupleSignature ( const TupleSignature oneSig  )  [inline]

Definition at line 212 of file structures.h.

References isReal, numOffset, offset, setOffsets(), tupleParamType, and tupleType.

00212                                                 {
00213         tupleType = oneSig.tupleType;
00214         numOffset = oneSig.numOffset;
00215         offset = new int[numOffset];
00216         setOffsets(oneSig.offset);        
00217         tupleParamType = oneSig.tupleParamType;
00218         isReal = oneSig.isReal;
00219     }

TupleSignature::~TupleSignature (  )  [inline]

Definition at line 249 of file structures.h.

References offset.

00249                      {
00250         if(offset) delete[] offset;
00251     }


Member Function Documentation

int TupleSignature::hash ( void   )  const [inline]

Definition at line 294 of file structures.h.

References circShift(), numOffset, offset, and tupleType.

00294                      {
00295       unsigned int code = tupleType;
00296       unsigned int codesz = 8 * sizeof(int);
00297       unsigned int shift = codesz / numOffset;
00298       
00299       if (shift == 0) shift=1;
00300       unsigned int i;
00301       for(i=0; i < numOffset; i++) {
00302         code = circShift(code,shift);
00303         code ^= offset[i];
00304       }
00305       return code;
00306     }

int TupleSignature::isEmpty (  )  [inline]

Definition at line 285 of file structures.h.

References offset.

00285                  {
00286         return offset==NULL;
00287     }

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

Definition at line 220 of file structures.h.

References isReal, numOffset, offset, setOffsets(), tupleParamType, and tupleType.

00220                                                            {
00221         tupleType = oneSig.tupleType;
00222         numOffset = oneSig.numOffset;
00223         if(offset) delete [] offset;
00224         offset = new int[numOffset];
00225         setOffsets(oneSig.offset);        
00226         tupleParamType = oneSig.tupleParamType;
00227         isReal = oneSig.isReal;
00228         return *this;
00229     }

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

Definition at line 230 of file structures.h.

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

00230                                                    {
00231             if(tupleType!=sig.tupleType)
00232                 return 0;
00233 
00234             if(tupleParamType != sig.tupleParamType)
00235                 return 0;
00236 
00237         if(isReal != sig.isReal)
00238             return 0;
00239 
00240                 if(numOffset != sig.numOffset) return 0;
00241                 
00242             int equalCnt=0;
00243                     
00244             for(int i=0; i<numOffset; i++){
00245                 equalCnt += (offset[i]==sig.offset[i]);      
00246             }
00247             return equalCnt==numOffset;
00248         }

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

Definition at line 288 of file structures.h.

References isReal, numOffset, offset, and tupleParamType.

00288                           {
00289         for(int i=0; i<numOffset; i++)
00290             fprintf(ofp, "%d ", offset[i]);
00291         fprintf(ofp, "| %d | %d\n", tupleParamType, isReal);         
00292     }

void TupleSignature::pack ( MOStream msg  ) 

void TupleSignature::setEmpty (  )  [inline]

Definition at line 281 of file structures.h.

References offset.

00281                    {
00282         delete [] offset;
00283         offset = NULL;
00284     }

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

Definition at line 252 of file structures.h.

References numOffset, and offset.

Referenced by buildAngleData(), buildCrosstermData(), buildDihedralData(), buildImproperData(), operator=(), and TupleSignature().

00252                               {
00253         for(int i=0; i<numOffset; i++)
00254             offset[i] = offs[i];
00255         //sort the offset in increasing order
00256         //based on the input files, this offset is almost sorted increasingly
00257         //Therefore using insertion sort
00258         /*switch(numOffset){
00259             case 1:
00260                 break;
00261             case 2:
00262                 if(offset[0]>offset[1]){
00263                     int tmp = offset[0];
00264                     offset[0] = offset[1];
00265                     offset[1] = tmp;
00266                 }
00267                 break;
00268             default: //insertion sort
00269                 for(int ii=1; ii<numOffset; ii++){
00270                     int val = offset[ii];
00271                     for(int jj=ii-1; jj>=0; jj--){
00272                         if(offset[jj]<val){
00273                             offset[jj+1] = offset[jj];
00274                             offset[jj] = val;
00275                         }else
00276                             break;
00277                     }
00278                 }
00279         }*/
00280     }

void TupleSignature::unpack ( MIStream msg  ) 


Member Data Documentation

char TupleSignature::isReal

Definition at line 197 of file structures.h.

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

int TupleSignature::numOffset

Definition at line 186 of file structures.h.

Referenced by hash(), operator=(), operator==(), output(), setOffsets(), and TupleSignature().

int* TupleSignature::offset

Definition at line 188 of file structures.h.

Referenced by AngleElem::AngleElem(), BondElem::BondElem(), buildBondData(), ExclusionSignature::buildTuples(), CrosstermElem::CrosstermElem(), DihedralElem::DihedralElem(), ExclElem::ExclElem(), GromacsPairElem::GromacsPairElem(), hash(), ImproperElem::ImproperElem(), isEmpty(), operator=(), operator==(), output(), setEmpty(), setOffsets(), TupleSignature(), and ~TupleSignature().

Index TupleSignature::tupleParamType

Definition at line 192 of file structures.h.

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

TupleSigType TupleSignature::tupleType

Definition at line 185 of file structures.h.

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


The documentation for this class was generated from the following file:
Generated on Wed Sep 20 01:17:20 2017 for NAMD by  doxygen 1.4.7