Example #1
0
u_int8_t
maxblock(u_int32_t addr, u_int8_t bits)
{
	u_int32_t m;

	while (bits > 0) {
		m = imask(bits - 1);

		if ((addr & m) != addr)
			return (bits);
		bits--;
	}
	return (bits);
}
Example #2
0
u_int8_t
maxdiff(u_int32_t a, u_int32_t b)
{
	u_int8_t bits = 0;
	u_int32_t m;

	b++;
	while (bits < 32) {
		m = imask(bits);

		if ((a & m) != (b & m))
			return (bits);
		bits++;
	}
	return (bits);
}
Example #3
0
/** An atom pair list consists of 2 values for each entry, a beginning
  * index and ending index. For molecules and residues this is the first
  * and just beyond the last atom; for atoms it is just the atom itself
  * twice.
  */
Image::PairType Image::CreatePairList(Topology const& Parm, Mode modeIn,
                                       std::string const& maskExpression)
{
  PairType atomPairs;
  // Set up mask based on desired imaging mode.
  if ( modeIn == BYMOL || modeIn == BYRES ) {
    CharMask cmask( maskExpression );
    if ( Parm.SetupCharMask( cmask ) ) return atomPairs;
    cmask.MaskInfo();
    if (cmask.None()) return atomPairs;
    // Set up atom range for each entity to be imaged.
    if (modeIn == BYMOL) {
      atomPairs.reserve( Parm.Nmol()*2 );
      for (Topology::mol_iterator mol = Parm.MolStart();
                                  mol != Parm.MolEnd(); ++mol)
        CheckRange( atomPairs, cmask, mol->BeginAtom(), mol->EndAtom());
    } else { // BYRES
      atomPairs.reserve( Parm.Nres()*2 );
      for (Topology::res_iterator residue = Parm.ResStart();
                                  residue != Parm.ResEnd(); ++residue)
        CheckRange( atomPairs, cmask, residue->FirstAtom(), residue->LastAtom() );
    }
  } else { // BYATOM
    AtomMask imask( maskExpression );
    if ( Parm.SetupIntegerMask( imask ) ) return atomPairs;
    imask.MaskInfo();
    if (imask.None()) return atomPairs;
    atomPairs.reserve( Parm.Natom()*2 );
    for (AtomMask::const_iterator atom = imask.begin(); atom != imask.end(); ++atom) {
      atomPairs.push_back(  *atom    );
      atomPairs.push_back( (*atom)+1 );
    }
  }
//  mprintf("\tNumber of %ss to be imaged is %zu based on mask '%s'\n",
//           ModeString[modeIn], atomPairs.size()/2, maskIn.MaskString());
  return atomPairs;
}