示例#1
0
//! Set all the weights
void Weight::set_weights(algebra::VectorKD w) {
  IMP_USAGE_CHECK(static_cast<int>(w.get_dimension()) == get_number_of_states(),
                  "Out of range");
  for (int i = 0; i < get_number_of_states(); ++i) {
    get_particle()->set_value(get_weight_key(i), w[i]);
  }
}
示例#2
0
文件: knn.cpp 项目: drussel/imp
 double min_distance_to_rectangle(const algebra::VectorKD& p,
                 const CGAL::Kd_tree_rectangle<TreeTraits>& b) const {
   double distance(0.0);
   for (unsigned int i=0; i< p.get_dimension(); ++i) {
     double h = p[i];
     if (h < b.min_coord(i)) distance += base::square(b.min_coord(i)-h);
     if (h > b.max_coord(i)) distance += base::square(h-b.max_coord(i));
   }
   return distance;
 }
示例#3
0
文件: knn.cpp 项目: drussel/imp
 double max_distance_to_rectangle(const algebra::VectorKD& p,
                   const CGAL::Kd_tree_rectangle<TreeTraits>& b) const {
   double d=0.0;
   for (unsigned int i=0; i< p.get_dimension(); ++i) {
     double h = p[i];
     double di = (h >= (b.min_coord(i)+b.max_coord(i))/2.0) ?
       base::square(h-b.min_coord(i)) : base::square(b.max_coord(i)-h);
     d+=di;
   }
   return d;
 }
示例#4
0
Assignment
get_nearest_assignment(const Subset &s,
                       const algebra::VectorKD &embedding,
                       ParticleStatesTable *pst) {

  Ints ret(s.size());
  unsigned int cur=0;
  // kind of a hack to get size
  for (unsigned int i=0; i< s.size(); ++i) {
    unsigned int sz
        = pst->get_particle_states(s[i])->get_embedding(0).get_dimension();
    algebra::VectorKD cpt(embedding.coordinates_begin()+cur,
                          embedding.coordinates_begin()+cur+sz);
    cur+=sz;
    ret[i]= pst->get_particle_states(s[i])->get_nearest_state(cpt);
  }
  return Assignment(ret);
}