/** Element access. Use this whenever possible to avoid the virtual function overhead of get(). */ T const & operator()(long row, long col) const { ConstIterator existing = m.find(IndexPair(row, col)); if (existing == m.end()) return ZERO; else return existing->second; }
int FF_Restraint_NativeContact::createContacts() { printf("Searching for native contacts\n"); // Proxies WorkSpace& wspace = RestraintForcefieldBase::getWSpace(); int i, j = 0; double dist; // delete all previous forces contact.clear(); for(i = 0; i < wspace.atom.size(); i++) { // Does this atom need to be part of the restraint set ? if(!m_Picker->matches(wspace.atom[i])) continue; for(j = i + 1; j < wspace.atom.size(); j++) { // Does this atom need to be part of the restraint set ? if(!m_Picker->matches(wspace.atom[j])) continue; // get the distance between atoms i and j - this will be assumed to be their "native" distance. dist = wspace.calcAtomDistance(i, j); if(dist > (NativeDist - (log(1.0/0.1 - 1)/Steepness)) ) continue; // only accept contacts that are will at least score 0.9 out of 1.0 on // the sigmoidal function //printf("Native Contact: %d %d %d \n",contact.size(), i ,j ); contact.push_back(IndexPair(i, j)); } } if(contact.size() == 0){ throw(ProcedureException("No native contacts found! Are you sure there isnt an error somewhere ?")); } return 0; }
/** Constructor. */ ConstIterator(AddressableMatrix const & m_, long r = 0, long c = 0) : m(m_), nrows(m_.numRows()), ncols(m_.numColumns()), entry(IndexPair(r, c), 0) {}
/** Unset an element by removing it from the underlying map. Its value is now identically zero. */ void unset(long row, long col) { m.erase(IndexPair(row, col)); }
void set(long row, long col, T const & value) { m[IndexPair(row, col)] = value; }
/** * {@inheritDoc} * * For mapped matrices, this function will always add the (row, col) element to the matrix if it doesn't yet exist, setting * it to an initial value of zero. This may destroy the sparsity of the matrix. */ T & getMutable(long row, long col) { // See documentation of std::map::insert() return m.insert(typename Map::value_type(IndexPair(row, col), static_cast<T>(0))).first->second; }
/** Check if an element has an explicitly set value. */ bool isSet(long row, long col) const { return m.find(IndexPair(row, col)) != m.end(); }
IndexPair DirichletProblem::getLastPoint(Index nx, Index ny) const { return IndexPair(nx-1,ny-1); }
IndexPair DirichletProblem::getFirstPoint(Index, Index) const { return IndexPair(1,1); }