NAMD
Public Member Functions | Public Attributes | List of all members
ExclusionSignature Struct Reference

#include <structures.h>

Public Member Functions

 ExclusionSignature ()
 
 ExclusionSignature (const ExclusionSignature &sig)
 
 ~ExclusionSignature ()
 
ExclusionSignatureoperator= (const ExclusionSignature &sig)
 
int operator== (const ExclusionSignature &sig) const
 
void setOffsets (std::vector< int > &fullVec, std::vector< int > &modVec)
 
void buildTuples ()
 
int hash () const
 
void removeEmptyOffset ()
 
int findOffset (int offset, int *fullOrMod)
 
void pack (MOStream *msg)
 
void unpack (MIStream *msg)
 

Public Attributes

int fullExclCnt
 
int * fullOffset
 
int modExclCnt
 
int * modOffset
 
int allExclCnt
 
TupleSignatureallTuples
 

Detailed Description

Definition at line 515 of file structures.h.

Constructor & Destructor Documentation

ExclusionSignature::ExclusionSignature ( )
inline

Definition at line 525 of file structures.h.

References allExclCnt, allTuples, fullExclCnt, fullOffset, modExclCnt, and modOffset.

525  {
526  fullExclCnt = modExclCnt = 0;
527  fullOffset = modOffset = NULL;
528 #ifdef NAMD_CUDA
529  allExclCnt = 0;
530  allTuples = NULL;
531 #endif
532  }
TupleSignature * allTuples
Definition: structures.h:522
ExclusionSignature::ExclusionSignature ( const ExclusionSignature sig)
inline

Definition at line 533 of file structures.h.

References allExclCnt, allTuples, fullExclCnt, fullOffset, modExclCnt, and modOffset.

533  {
534  fullOffset = modOffset = NULL;
535  fullExclCnt = sig.fullExclCnt;
536  if(fullExclCnt>0){
537  fullOffset = new int[fullExclCnt];
538  for(int i=0; i<fullExclCnt; i++)
539  fullOffset[i] = sig.fullOffset[i];
540  }
541 
542  modExclCnt = sig.modExclCnt;
543  if(modExclCnt>0){
544  modOffset = new int[modExclCnt];
545  for(int i=0; i<modExclCnt; i++)
546  modOffset[i] = sig.modOffset[i];
547  }
548 #ifdef NAMD_CUDA
549  allTuples = NULL;
550  allExclCnt = sig.allExclCnt;
551  if(allExclCnt>0){
553  for(int i=0; i<allExclCnt; i++)
554  allTuples[i] = sig.allTuples[i];
555  }
556 #endif
557  }
TupleSignature * allTuples
Definition: structures.h:522
ExclusionSignature::~ExclusionSignature ( )
inline

Definition at line 558 of file structures.h.

References allTuples, fullOffset, and modOffset.

558  {
559  if(fullOffset) delete [] fullOffset;
560  if(modOffset) delete [] modOffset;
561 #ifdef NAMD_CUDA
562  if(allTuples) delete [] allTuples;
563 #endif
564  }
TupleSignature * allTuples
Definition: structures.h:522

Member Function Documentation

void ExclusionSignature::buildTuples ( )
inline

Definition at line 627 of file structures.h.

References allExclCnt, allTuples, EXCLUSION, fullExclCnt, fullOffset, modExclCnt, modOffset, and TupleSignature::offset.

Referenced by setOffsets().

627  {
628  delete [] allTuples;
629  allTuples = NULL;
630  allExclCnt = 0;
631  for(int i=0; i<fullExclCnt; i++)
632  if ( fullOffset[i] > 0 ) ++allExclCnt;
633  for(int i=0; i<modExclCnt; i++)
634  if ( modOffset[i] > 0 ) ++allExclCnt;
635  if(allExclCnt>0){
637  int j = 0;
638  for(int i=0; i<fullExclCnt; i++){
639  if ( fullOffset[i] <= 0 ) continue;
640  TupleSignature oneSig(1,EXCLUSION,0);
641  oneSig.offset[0] = fullOffset[i];
642  allTuples[j++] = oneSig;
643  }
644  for(int i=0; i<modExclCnt; i++){
645  if ( modOffset[i] <= 0 ) continue;
646  TupleSignature oneSig(1,EXCLUSION,1);
647  oneSig.offset[0] = modOffset[i];
648  allTuples[j++] = oneSig;
649  }
650  }
651 #endif
652  }
TupleSignature * allTuples
Definition: structures.h:522
int ExclusionSignature::findOffset ( int  offset,
int *  fullOrMod 
)
int ExclusionSignature::hash ( void  ) const
inline

Definition at line 654 of file structures.h.

References circShift(), fullExclCnt, fullOffset, modExclCnt, and modOffset.

654  {
655  unsigned int numOffset = fullExclCnt + modExclCnt;
656  unsigned int code = 0x12345678;
657  unsigned int codesz = 8 * sizeof(int);
658  unsigned int shift = codesz / numOffset;
659 
660  if (shift == 0) shift=1;
661  unsigned int i;
662  for(i=0; i < fullExclCnt; i++) {
663  code = circShift(code,shift);
664  code ^= fullOffset[i];
665  }
666  for(i=0; i < modExclCnt; i++) {
667  code = circShift(code,shift);
668  code ^= modOffset[i];
669  }
670  return code;
671  }
unsigned int circShift(unsigned int h, unsigned int by)
Definition: structures.h:186
ExclusionSignature& ExclusionSignature::operator= ( const ExclusionSignature sig)
inline

Definition at line 566 of file structures.h.

References allExclCnt, allTuples, fullExclCnt, fullOffset, modExclCnt, and modOffset.

566  {
567  fullExclCnt = sig.fullExclCnt;
568  if(fullOffset) delete [] fullOffset;
569  if(fullExclCnt>0){
570  fullOffset = new int[fullExclCnt];
571  for(int i=0; i<fullExclCnt; i++)
572  fullOffset[i] = sig.fullOffset[i];
573  }else
574  fullOffset = NULL;
575 
576  modExclCnt = sig.modExclCnt;
577  if(modOffset) delete [] modOffset;
578  if(modExclCnt>0){
579  modOffset = new int[modExclCnt];
580  for(int i=0; i<modExclCnt; i++)
581  modOffset[i] = sig.modOffset[i];
582  }else
583  modOffset = NULL;
584 #ifdef NAMD_CUDA
585  allExclCnt = sig.allExclCnt;
586  if(allTuples) delete [] allTuples;
587  if(allExclCnt>0){
589  for(int i=0; i<allExclCnt; i++)
590  allTuples[i] = sig.allTuples[i];
591  }else
592  allTuples = NULL;
593 #endif
594 
595  return *this;
596  }
TupleSignature * allTuples
Definition: structures.h:522
int ExclusionSignature::operator== ( const ExclusionSignature sig) const
inline

Definition at line 597 of file structures.h.

References fullExclCnt, fullOffset, modExclCnt, and modOffset.

597  {
598  if(fullExclCnt!=sig.fullExclCnt) return 0;
599  if(modExclCnt!=sig.modExclCnt) return 0;
600 
601  for(int i=0; i<fullExclCnt; i++){
602  if(fullOffset[i]!=sig.fullOffset[i]) return 0;
603  }
604  for(int i=0; i<modExclCnt; i++){
605  if(modOffset[i]!=sig.modOffset[i]) return 0;
606  }
607  return 1;
608  }
void ExclusionSignature::pack ( MOStream msg)
void ExclusionSignature::removeEmptyOffset ( )
void ExclusionSignature::setOffsets ( std::vector< int > &  fullVec,
std::vector< int > &  modVec 
)
inline

Definition at line 610 of file structures.h.

References buildTuples(), fullExclCnt, fullOffset, modExclCnt, and modOffset.

610  {
611  fullExclCnt = fullVec.size();
612  modExclCnt = modVec.size();
613  if(fullExclCnt>0) {
614  fullOffset = new int[fullExclCnt];
615  for(int i=0; i<fullExclCnt; i++)
616  fullOffset[i] = fullVec[i];
617  }
618 
619  if(modExclCnt>0) {
620  modOffset = new int[modExclCnt];
621  for(int i=0; i<modExclCnt; i++)
622  modOffset[i] = modVec[i];
623  }
624 #ifdef NAMD_CUDA
625  buildTuples();
626  }
void ExclusionSignature::unpack ( MIStream msg)

Member Data Documentation

int ExclusionSignature::allExclCnt

Definition at line 521 of file structures.h.

Referenced by buildTuples(), ExclusionSignature(), ExclElem::getTupleInfo(), and operator=().

TupleSignature* ExclusionSignature::allTuples
int ExclusionSignature::fullExclCnt
int* ExclusionSignature::fullOffset
int ExclusionSignature::modExclCnt
int* ExclusionSignature::modOffset

The documentation for this struct was generated from the following file: