当前位置: 首页>>代码示例>>C++>>正文


C++ ParticlesTemp::size方法代码示例

本文整理汇总了C++中ParticlesTemp::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticlesTemp::size方法的具体用法?C++ ParticlesTemp::size怎么用?C++ ParticlesTemp::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParticlesTemp的用法示例。


在下文中一共展示了ParticlesTemp::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assign_blame

void assign_blame(const RestraintsTemp &rs,
                  const ParticlesTemp &ps, FloatKey attribute) {
  IMP_FUNCTION_LOG;
  for (unsigned int i = 0; i < ps.size(); ++i) {
    if (ps[i]->has_attribute(attribute)) {
      ps[i]->set_value(attribute, 0);
    } else {
      ps[i]->add_attribute(attribute, 0, false);
    }
  }
  Restraints drs;
  for (unsigned int i = 0; i < rs.size(); ++i) {
    Pointer<Restraint> rd = rs[i]->create_decomposition();
    if (rd) {
      drs.push_back(rd);
    }
  }
  IMP_NEW(RestraintsScoringFunction, rsf, (drs));
  rsf->evaluate(false);
  DependencyGraph dg = get_dependency_graph(IMP::internal::get_model(rs));
  // attempt to get around boost/gcc bug and the most vexing parse
  DependencyGraphVertexIndex dgi((IMP::get_vertex_index(dg)));
  ControlledBy controlled_by;
  for (unsigned int i = 0; i < ps.size(); ++i) {
    ParticlesTemp cps = get_dependent_particles(ps[i], ps, dg, dgi);
    IMP_INTERNAL_CHECK(cps.size() > 0, "No dependent particles for " << ps[i]);
    for (unsigned int j = 0; j < cps.size(); ++j) {
      controlled_by[cps[j]] = ps[i];
    }
  }
  for (unsigned int i = 0; i < drs.size(); ++i) {
    distribute_blame(drs[i], controlled_by, attribute, 1.0);
  }
}
开发者ID:AljGaber,项目名称:imp,代码行数:34,代码来源:blame.cpp

示例2: do_reject

void MolecularDynamicsMover::do_reject() {
  IMP_OBJECT_LOG;
  ParticlesTemp ps = md_->get_simulation_particles();
  unsigned nparts = ps.size();
  IMP_USAGE_CHECK(coordinates_.size() == ps.size(),
                  "The list of particles that move has been changed!");
  IMP_USAGE_CHECK(velocities_.size() == ps.size(),
                  "The list of particles that move has been changed!");
  for (unsigned i = 0; i < nparts; i++) {
    bool isnuisance = Nuisance::get_is_setup(ps[i]);
    bool isxyz = core::XYZ::get_is_setup(ps[i]);
    IMP_USAGE_CHECK(isnuisance || isxyz,
                    "Particle " << ps[i] << " is neither nuisance nor xyz!");
    if (isnuisance) {
      IMP_USAGE_CHECK(coordinates_[i].size() == 1,
                      "wrong size for coordinates_[" << i << "] !");
      IMP_USAGE_CHECK(velocities_[i].size() == 1, "wrong size for velocities_["
                                                      << i << "] !");
      Nuisance(ps[i]).set_nuisance(coordinates_[i][0]);
      ps[i]->set_value(FloatKey("vel"), velocities_[i][0]);
    }
    if (isxyz) {
      IMP_USAGE_CHECK(coordinates_[i].size() == 3,
                      "wrong size for coordinates_[" << i << "] !");
      IMP_USAGE_CHECK(velocities_[i].size() == 3, "wrong size for velocities_["
                                                      << i << "] !");
      core::XYZ(ps[i]).set_coordinate(0, coordinates_[i][0]);
      core::XYZ(ps[i]).set_coordinate(1, coordinates_[i][1]);
      core::XYZ(ps[i]).set_coordinate(2, coordinates_[i][2]);
      ps[i]->set_value(FloatKey("vx"), velocities_[i][0]);
      ps[i]->set_value(FloatKey("vy"), velocities_[i][1]);
      ps[i]->set_value(FloatKey("vz"), velocities_[i][2]);
    }
  }
}
开发者ID:AljGaber,项目名称:imp,代码行数:35,代码来源:MolecularDynamicsMover.cpp

示例3: create_blame_geometries

display::Geometries create_blame_geometries(const RestraintsTemp &rs,
                                            const ParticlesTemp &ps,
                                            double max, std::string name) {
  IMP_FUNCTION_LOG;
  FloatKey key("blame temporary key");
  assign_blame(rs, ps, key);
  if (max == NO_MAX) {
    max = -NO_MAX;
    for (unsigned int i = 0; i < ps.size(); ++i) {
      max = std::max(ps[i]->get_value(key), max);
    }
    IMP_LOG_TERSE("Maximum blame value is " << max << std::endl);
  }
  display::Geometries ret;
  for (unsigned int i = 0; i < ps.size(); ++i) {
    double colorv;
    if (max == 0) {
      colorv = 0;
    } else {
      colorv =
          display::get_linear_color_map_value(0, max, ps[i]->get_value(key));
    }
    display::Color c = display::get_hot_color(colorv);
    IMP_NEW(XYZRGeometry, g, (ps[i]));
    if (!name.empty()) {
      g->set_name(name);
    }
    g->set_color(c);
    ret.push_back(g);
  }
  return ret;
}
开发者ID:AljGaber,项目名称:imp,代码行数:32,代码来源:blame.cpp

示例4: destroy

void destroy(Hierarchy d) {
  ParticlesTemp all;
  //core::Hierarchy h=d;

  core::gather(d, True(), std::back_inserter(all));
  for (unsigned int i=0; i< all.size(); ++i) {
    if (Bonded::particle_is_instance(all[i])) {
     Bonded b(all[i]);
      while (b.get_number_of_bonds() > 0) {
        destroy_bond(b.get_bond(b.get_number_of_bonds()-1));
      }
    }
    Hierarchy hc(all[i]);
    while (hc.get_number_of_children() > 0) {
      hc.remove_child(hc.get_child(hc.get_number_of_children()-1));
    }
  }

  // If this Hierarchy has a parent, remove the relationship
  Hierarchy parent = d.get_parent();
  if (parent) {
    parent.remove_child(d);
  }

  for (unsigned int i=0; i< all.size(); ++i) {
    all[i]->get_model()->remove_particle(all[i]);
  }
}
开发者ID:andreyto,项目名称:imp-fork-proddl,代码行数:28,代码来源:Hierarchy.cpp

示例5: get_radius_of_gyration

double get_radius_of_gyration(const ParticlesTemp& ps) {
  IMP_USAGE_CHECK(ps.size() > 0, "No particles provided");
  bool mass = Mass::get_is_setup(ps[0]);
  bool radii = core::XYZR::get_is_setup(ps[0]);
  algebra::Vector3D cm(0, 0, 0);
  double total = 0;
  for (unsigned int i = 0; i < ps.size(); ++i) {
    double weight = get_weight(mass, radii, ps[i]);
    total += weight;
    cm += core::XYZ(ps[i]).get_coordinates() * weight;
  }
  cm /= total;
  double ret = 0;
  for (unsigned int i = 0; i < ps.size(); ++i) {
    double c;
    if (radii) {
      c = .6 * square(core::XYZR(ps[i]).get_radius());
    } else {
      c = 0;
    }
    double d = get_squared_distance(core::XYZ(ps[i]).get_coordinates(), cm);
    ret += get_weight(mass, radii, ps[i]) * (d + c);
  }
  return std::sqrt(ret / total);
}
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:25,代码来源:distance.cpp

示例6: get_actual_radius_of_gyration

float get_actual_radius_of_gyration(ParticlesTemp ps) {
  algebra::Vector3D cm(0,0,0);
  for (unsigned int i=0; i< ps.size(); ++i) {
    cm+= core::XYZ(ps[i]).get_coordinates();
  }
  cm/=ps.size();
  double ret=0;
  for (unsigned int i=0; i < ps.size(); ++i) {
    double d= get_distance(core::XYZ(ps[i]).get_coordinates(),cm);
    ret+= d;
  }
  return ret/ps.size();
}
开发者ID:andreyto,项目名称:imp-fork-proddl,代码行数:13,代码来源:RadiusOfGyrationRestraint.cpp

示例7: Restraint

IMPEM_BEGIN_NAMESPACE

FitRestraint::FitRestraint(
   ParticlesTemp ps,
   DensityMap *em_map,
   FloatPair norm_factors,
   FloatKey weight_key,
   float scale,
   bool use_rigid_bodies,
   KernelType kt
                           ): Restraint(IMP::internal::get_model(ps),
                                        "Fit restraint"),kt_(kt)
{
  use_rigid_bodies_=use_rigid_bodies;
  IMP_LOG(TERSE,"Load fit restraint with the following input:"<<
          "number of particles:"<<ps.size()<<" scale:"<<scale<<
           "\n");
  // special_treatment_of_particles_outside_of_density_=
  //   special_treatment_of_particles_outside_of_density;
  target_dens_map_ = em_map;
  weight_key_=weight_key;
  norm_factors_=norm_factors;
  IMP_IF_CHECK(USAGE) {
    for (unsigned int i=0; i< ps.size(); ++i) {
      IMP_USAGE_CHECK(core::XYZR::particle_is_instance(ps[i]),
                      "Particle " << ps[i]->get_name()
                      << " is not XYZR"
                      << std::endl);
      IMP_USAGE_CHECK(ps[i]->has_attribute(weight_key),
                "Particle " << ps[i]->get_name()
                << " is missing the mass "<< weight_key
                << std::endl);
    }
  }
  scalefac_ = scale;
  store_particles(ps);
  IMP_LOG(TERSE,"after adding "<< all_ps_.size()<<" particles"<<std::endl);
  model_dens_map_ = new SampledDensityMap(*em_map->get_header(),kt_);
  model_dens_map_->set_particles(get_as<ParticlesTemp>(all_ps_),weight_key);
  kernel_params_=model_dens_map_->get_kernel_params();
  dist_mask_=new DistanceMask(model_dens_map_->get_header());
  IMP_LOG(TERSE,"going to initialize_model_density_map"<<std::endl);
  initialize_model_density_map(weight_key);
  IMP_LOG(TERSE,"going to initialize derivatives"<<std::endl);
   // initialize the derivatives
  dv_.insert(dv_.end(),all_ps_.size(),algebra::Vector3D(0.,0.,0.));

  // normalize the target density data
  //target_dens_map->std_normalize();
  IMP_LOG(TERSE, "Finish initialization" << std::endl);
}
开发者ID:andreyto,项目名称:imp-fork-proddl,代码行数:51,代码来源:FitRestraint.cpp

示例8: Refiner

IMPCORE_BEGIN_NAMESPACE

FixedRefiner::FixedRefiner(const ParticlesTemp &ps)
  : Refiner("FixedRefiner%d", true) {
  IMP_USAGE_CHECK(ps.size()>0, "cannot refine with empty particle list");
  IMP_LOG_VERBOSE("Created fixed particle refiner with "
                  << ps.size() << " particles" << std::endl);
  m_ = ps[0]->get_model();
  for(unsigned int i = 0; i < ps.size(); i++){
    IMP_USAGE_CHECK(m_ == ps[i]->get_model(),
                    "refiner assumes all particles are from the same model");
    pis_.push_back(ps[i]->get_index());
  }
}
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:14,代码来源:FixedRefiner.cpp

示例9: set_model_particles

void CollisionCrossSection::set_model_particles(
    const ParticlesTemp &ps) {

  IMP_LOG_TERSE("CollisionCrossSection: Model particles set"
                << std::endl);

  for (unsigned int i = 0; i < ps.size(); ++i) {
    IMP_USAGE_CHECK(
        (core::XYZR::get_is_setup(ps[i]) && atom::Mass::get_is_setup(ps[i])),
        "Particle " << i << " does not have the required attributes"
                    << std::endl);
  }
  masks_manager_->create_masks(ps);
  // Compute projections
  collision_cross_section_ = 0.0;
  for (unsigned int i = 0; i < n_projections_; ++i) {
    ProjectingOptions options(pixel_size_, resolution_);
    do_project_particles(ps, average_projection_, regs_[i].get_rotation(),
                         pixel_size_ * regs_[i].get_shift_3d(), options,
                         masks_manager_);
    collision_cross_section_ += get_projected_area(average_projection_);
  }
  collision_cross_section_ /= static_cast<double>(n_projections_);
  particles_set_ = true;
}
开发者ID:salilab,项目名称:imp,代码行数:25,代码来源:CollisionCrossSection.cpp

示例10: Refiner

IMPCORE_BEGIN_NAMESPACE

FixedRefiner::FixedRefiner(const ParticlesTemp &ps):
  Refiner("FixedRefiner%d"), ps_(ps){
  IMP_LOG(VERBOSE, "Created fixed particle refiner with " << ps.size()
          << " particles" << std::endl);
}
开发者ID:andreyto,项目名称:imp-fork-proddl,代码行数:7,代码来源:FixedRefiner.cpp

示例11: save_coordinates

void MolecularDynamicsMover::save_coordinates() {
  IMP_OBJECT_LOG;
  ParticlesTemp ps = md_->get_simulation_particles();
  unsigned nparts = ps.size();
  coordinates_.clear();
  coordinates_.reserve(nparts);
  velocities_.clear();
  velocities_.reserve(nparts);
  for (unsigned i = 0; i < nparts; i++) {
    bool isnuisance = Nuisance::get_is_setup(ps[i]);
    bool isxyz = core::XYZ::get_is_setup(ps[i]);
    IMP_USAGE_CHECK(isnuisance || isxyz,
                    "Particle " << ps[i] << " is neither nuisance nor xyz!");
    if (isnuisance) {
      std::vector<double> x(1, Nuisance(ps[i]).get_nuisance());
      coordinates_.push_back(x);
      std::vector<double> v(1, ps[i]->get_value(FloatKey("vel")));
      velocities_.push_back(v);
    }
    if (isxyz) {
      std::vector<double> coords;
      core::XYZ d(ps[i]);
      coords.push_back(d.get_coordinate(0));
      coords.push_back(d.get_coordinate(1));
      coords.push_back(d.get_coordinate(2));
      coordinates_.push_back(coords);
      std::vector<double> v;
      v.push_back(ps[i]->get_value(FloatKey("vx")));
      v.push_back(ps[i]->get_value(FloatKey("vy")));
      v.push_back(ps[i]->get_value(FloatKey("vz")));
      velocities_.push_back(v);
    }
  }
}
开发者ID:AljGaber,项目名称:imp,代码行数:34,代码来源:MolecularDynamicsMover.cpp

示例12:

unsigned int MSConnectivityRestraint::ParticleMatrix::add_type(
    const ParticlesTemp &ps) {
  protein_by_class_.push_back(Ints());
  for (unsigned int i = 0; i < ps.size(); ++i) {
    unsigned int n = particles_.size();
    particles_.push_back(ParticleData(ps[i], current_id_));
    protein_by_class_.back().push_back(n);
  }
  return current_id_++;
}
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:10,代码来源:MSConnectivityRestraint.cpp

示例13: ret

base::Vector<char>
write_particles_to_buffer(const ParticlesTemp &particles,
                          const FloatKeys &keys) {
  if (particles.empty() || keys.empty()) {
    return base::Vector<char>();
  }
  unsigned int size= particles.size()*keys.size()*sizeof(double);
  base::Vector<char> ret(size);
  write_particles_to_buffer(particles, keys, &ret.front(), size);
  return ret;
}
开发者ID:drussel,项目名称:imp,代码行数:11,代码来源:io.cpp

示例14: populate_data_points

void ParticlesDataPoints::populate_data_points(ParticlesTemp ps) {
  ps_ = get_as<Particles>(ps);
  int dim = atts_.size();
  for(unsigned int i=0;i<ps.size();i++) {
    data_.push_back(Array1DD(dim));
    for(int d=0;d<dim;d++) {
      data_[i][d] = double(ps[i]->get_value(atts_[d]));
    }
    vecs_.push_back(core::XYZ(ps[i]).get_coordinates());
  }
}
开发者ID:andreyto,项目名称:imp-fork-proddl,代码行数:11,代码来源:DataPoints.cpp

示例15:

void DerivativesToRefined
::apply(Particle *p,
        DerivativeAccumulator &da) const
{
  ParticlesTemp ps = refiner_->get_refined(p);

  for (unsigned int i=0; i< ps.size(); ++i) {
    for (unsigned int j=0; j< ks_.size(); ++j) {
      Float f= p->get_derivative(ks_[j]);
      ps[i]->add_to_derivative(ks_[j], f, da);
    }
  }
}
开发者ID:andreyto,项目名称:imp-fork-proddl,代码行数:13,代码来源:DerivativesToRefined.cpp


注:本文中的ParticlesTemp::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。