fl rmsd_upper_bound(const vecv& a, const vecv& b) { VINA_CHECK(a.size() == b.size()); fl acc = 0; VINA_FOR_IN(i, a) acc += vec_distance_sqr(a[i], b[i]); return (a.size() > 0) ? std::sqrt(acc / a.size()) : 0; }
T checked_convert_substring(const std::string& str, sz i, sz j, const std::string& dest_nature) { VINA_CHECK(i >= 1); VINA_CHECK(i <= j+1); if(j > str.size()) throw atom_syntax_error("The line is too short"); // omit leading whitespace while(i <= j && std::isspace(str[i-1])) ++i; const std::string substr = str.substr(i-1, j-i+1); try { return boost::lexical_cast<T>(substr); } catch(...) { throw atom_syntax_error(std::string("\"") + substr + "\" is not a valid " + dest_nature); } }
std::string omit_whitespace(const std::string& str, sz i, sz j) { if(i < 1) i = 1; if(j < i-1) j = i-1; // i >= 1 if(j < str.size()) j = str.size(); // omit leading whitespace while(i <= j && std::isspace(str[i-1])) ++i; // omit trailing whitespace while(i <= j && std::isspace(str[j-1])) --j; VINA_CHECK(i-1 < str.size()); VINA_CHECK(j-i+1 < str.size()); return str.substr(i-1, j-i+1); }
output_type monte_carlo::operator()(model& m, const precalculate& p, const igrid& ig, const vec& corner1, const vec& corner2, incrementable* increment_me, rng& generator, grid& user_grid) const { output_container tmp; this->operator()(m, tmp, p, ig, corner1, corner2, increment_me, generator, user_grid); // call the version that produces the whole container VINA_CHECK(!tmp.empty()); return tmp.front(); }