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 192 of file structures.h.


Constructor & Destructor Documentation

TupleSignature::TupleSignature (  )  [inline]

Definition at line 210 of file structures.h.

References isReal, and offset.

00210                     {        
00211         offset = NULL;
00212         isReal = 1;
00213     }

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

Definition at line 215 of file structures.h.

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

00215                                                                      {
00216         tupleType = t;
00217         numOffset = n;
00218         offset = new int[n];        
00219         tupleParamType = paramType;
00220         isReal = ir;
00221     }

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

Definition at line 222 of file structures.h.

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

00222                                                 {
00223         tupleType = oneSig.tupleType;
00224         numOffset = oneSig.numOffset;
00225         offset = new int[numOffset];
00226         setOffsets(oneSig.offset);        
00227         tupleParamType = oneSig.tupleParamType;
00228         isReal = oneSig.isReal;
00229     }

TupleSignature::~TupleSignature (  )  [inline]

Definition at line 259 of file structures.h.

References offset.

00259                      {
00260         if(offset) delete[] offset;
00261     }


Member Function Documentation

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

Definition at line 304 of file structures.h.

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

00304                      {
00305       unsigned int code = tupleType;
00306       unsigned int codesz = 8 * sizeof(int);
00307       unsigned int shift = codesz / numOffset;
00308       
00309       if (shift == 0) shift=1;
00310       unsigned int i;
00311       for(i=0; i < numOffset; i++) {
00312         code = circShift(code,shift);
00313         code ^= offset[i];
00314       }
00315       return code;
00316     }

int TupleSignature::isEmpty (  )  [inline]

Definition at line 295 of file structures.h.

References offset.

00295                  {
00296         return offset==NULL;
00297     }

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

Definition at line 230 of file structures.h.

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

00230                                                            {
00231         tupleType = oneSig.tupleType;
00232         numOffset = oneSig.numOffset;
00233         if(offset) delete [] offset;
00234         offset = new int[numOffset];
00235         setOffsets(oneSig.offset);        
00236         tupleParamType = oneSig.tupleParamType;
00237         isReal = oneSig.isReal;
00238         return *this;
00239     }

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

Definition at line 240 of file structures.h.

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

00240                                                    {
00241             if(tupleType!=sig.tupleType)
00242                 return 0;
00243 
00244             if(tupleParamType != sig.tupleParamType)
00245                 return 0;
00246 
00247         if(isReal != sig.isReal)
00248             return 0;
00249 
00250                 if(numOffset != sig.numOffset) return 0;
00251                 
00252             int equalCnt=0;
00253                     
00254             for(int i=0; i<numOffset; i++){
00255                 equalCnt += (offset[i]==sig.offset[i]);      
00256             }
00257             return equalCnt==numOffset;
00258         }

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

Definition at line 298 of file structures.h.

References isReal, numOffset, offset, and tupleParamType.

00298                           {
00299         for(int i=0; i<numOffset; i++)
00300             fprintf(ofp, "%d ", offset[i]);
00301         fprintf(ofp, "| %d | %d\n", tupleParamType, isReal);         
00302     }

void TupleSignature::pack ( MOStream msg  ) 

void TupleSignature::setEmpty (  )  [inline]

Definition at line 291 of file structures.h.

References offset.

00291                    {
00292         delete [] offset;
00293         offset = NULL;
00294     }

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

Definition at line 262 of file structures.h.

References numOffset, and offset.

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

00262                               {
00263         for(int i=0; i<numOffset; i++)
00264             offset[i] = offs[i];
00265         //sort the offset in increasing order
00266         //based on the input files, this offset is almost sorted increasingly
00267         //Therefore using insertion sort
00268         /*switch(numOffset){
00269             case 1:
00270                 break;
00271             case 2:
00272                 if(offset[0]>offset[1]){
00273                     int tmp = offset[0];
00274                     offset[0] = offset[1];
00275                     offset[1] = tmp;
00276                 }
00277                 break;
00278             default: //insertion sort
00279                 for(int ii=1; ii<numOffset; ii++){
00280                     int val = offset[ii];
00281                     for(int jj=ii-1; jj>=0; jj--){
00282                         if(offset[jj]<val){
00283                             offset[jj+1] = offset[jj];
00284                             offset[jj] = val;
00285                         }else
00286                             break;
00287                     }
00288                 }
00289         }*/
00290     }

void TupleSignature::unpack ( MIStream msg  ) 


Member Data Documentation

char TupleSignature::isReal

Definition at line 207 of file structures.h.

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

int TupleSignature::numOffset

Definition at line 196 of file structures.h.

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

int* TupleSignature::offset

Definition at line 198 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 202 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 195 of file structures.h.

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


The documentation for this class was generated from the following file:
Generated on Tue Oct 23 01:17:23 2018 for NAMD by  doxygen 1.4.7