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


C++ Floats类代码示例

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


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

示例1: setup_coarse_secondary_structure_residue

SecondaryStructureResidue setup_coarse_secondary_structure_residue(
    const Particles &ssr_ps, Model *mdl,
    bool winner_takes_all_per_res) {
  Floats scores;
  scores.push_back(0.0);
  scores.push_back(0.0);
  scores.push_back(0.0);
  int count = 0;
  for (Particles::const_iterator p = ssr_ps.begin(); p != ssr_ps.end();
       ++p) {
    IMP_USAGE_CHECK(SecondaryStructureResidue::get_is_setup(*p),
                    "all particles must be SecondaryStructureResidues");
    SecondaryStructureResidue ssr(*p);
    Floats tmp_scores;
    tmp_scores.push_back(ssr.get_prob_helix());
    tmp_scores.push_back(ssr.get_prob_strand());
    tmp_scores.push_back(ssr.get_prob_coil());
    int max_i = 0;
    Float max = 0.0;
    for (int i = 0; i < 3; i++) {
      if (tmp_scores[i] > max) {
        max = tmp_scores[i];
        max_i = i;
      }
      if (!winner_takes_all_per_res) scores[i] += tmp_scores[i];
    }
    if (winner_takes_all_per_res) scores[max_i] += 1.0;
    count++;
  }
  IMP_NEW(Particle, coarse_p, (mdl));
  SecondaryStructureResidue ssres = SecondaryStructureResidue::setup_particle(
      coarse_p, scores[0] / count, scores[1] / count, scores[2] / count);
  return ssres;
}
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:34,代码来源:SecondaryStructureResidue.cpp

示例2: memcpy

/// A thread-safe version of CalcSummary.  BlockFile::CalcSummary
/// uses a static summary array across the class, which we can't use.
/// Get a buffer containing a summary block describing this sample
/// data.  This must be called by derived classes when they
/// are constructed, to allow them to construct their summary data,
/// after which they should write that data to their disk file.
///
/// This method also has the side effect of setting the mMin, mMax,
/// and mRMS members of this class.
///
/// Unlike BlockFile's implementation You SHOULD DELETE the returned buffer.
/// this is protected so it shouldn't be hard to deal with - just override
/// all BlockFile methods that use this method.
///
/// @param buffer A buffer containing the sample data to be analyzed
/// @param len    The length of the sample data
/// @param format The format of the sample data.
void *ODDecodeBlockFile::CalcSummary(samplePtr buffer, size_t len,
                             sampleFormat format, ArrayOf<char> &cleanup)
{
   cleanup.reinit(mSummaryInfo.totalSummaryBytes);
   char* localFullSummary = cleanup.get();

   memcpy(localFullSummary, bheaderTag, bheaderTagLen);

   float *summary64K = (float *)(localFullSummary + mSummaryInfo.offset64K);
   float *summary256 = (float *)(localFullSummary + mSummaryInfo.offset256);

   Floats floats;
   float *fbuffer;

   //mchinen: think we can hack this - don't allocate and copy if we don't need to.,
   if(format==floatSample)
   {
      fbuffer = (float*)buffer;
   }
   else
   {
      floats.reinit(len);
      fbuffer = floats.get();
      CopySamples(buffer, format,
               (samplePtr)fbuffer, floatSample, len);
   }

   BlockFile::CalcSummaryFromBuffer(fbuffer, len, summary256, summary64K);

   return localFullSummary;
}
开发者ID:MindFy,项目名称:audacity,代码行数:48,代码来源:ODDecodeBlockFile.cpp

示例3: TEST

TEST(Neighbors,CoverTreeDistanceNeighbors)
{
	typedef std::vector<float> Floats;
	const int N = 100;
	const int k = 10;

	Floats floats;
	for (int i=0;i<N;i++) 
		floats.push_back(float(i));

	float_distance_callback fdc;
	tapkee::tapkee_internal::Neighbors neighbors = 
		tapkee::tapkee_internal::find_neighbors(tapkee::CoverTree, floats.begin(), floats.end(),
				tapkee::tapkee_internal::PlainDistance<Floats::iterator,float_distance_callback>(fdc), k, true);

	for (int i=0;i<N;i++)
	{
		// total number of found neighbors is k
		ASSERT_EQ(neighbors[i].size(),k);
		std::set<float> neighbors_set;
		for (int j=0;j<k;j++) 
			neighbors_set.insert(neighbors[i][j]);
		// there are no repeated values
		ASSERT_EQ(neighbors_set.size(),k);
		// the vector is not a neighbor of itself
		ASSERT_EQ(neighbors_set.find(floats[i]),neighbors_set.end());
		// check neighbors
		int k_left = std::min(i,k/2);
		int k_right = std::min(N-i-1,k/2);
		for (int j=0; j<k_left; j++) 
			ASSERT_NE(neighbors_set.find(floats[i-j-1]),neighbors_set.end());
		for (int j=0; j<k_right; j++) 
			ASSERT_NE(neighbors_set.find(floats[i+j+1]),neighbors_set.end());
	}
}
开发者ID:genba,项目名称:tapkee,代码行数:35,代码来源:neighbors.cpp

示例4: get_omegas

Floats CysteineCrossLinkData::get_omegas(Floats fmods, double omega0) const {
  Floats omegas;
  for (unsigned n = 0; n < fmods.size(); ++n) {

    double cumul = 0;
    double cumul2 = 0;

    for (unsigned j = 1; j < omega_grid_.size(); ++j) {
      double omj = omega_grid_[j];
      double omjm1 = omega_grid_[j - 1];
      double dom = omj - omjm1;

      double priorj = get_omega_prior(omj, omega0);
      double priorjm1 = get_omega_prior(omjm1, omega0);

      double pj = get_element(fexp_, fmods[n], omj) * priorj;
      double pjm1 = get_element(fexp_, fmods[n], omjm1) * priorjm1;

      double pj2 = get_element(fexp_, fmods[n], omj) * priorj * omj;
      double pjm12 = get_element(fexp_, fmods[n], omjm1) * priorjm1 * omjm1;

      cumul += (pj + pjm1) / 2.0 * dom;
      cumul2 += (pj2 + pjm12) / 2.0 * dom;
    }

    omegas.push_back(cumul2 / cumul);
  }
  return omegas;
}
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:29,代码来源:CysteineCrossLinkData.cpp

示例5: mat

Floats GaussianProcessInterpolation::get_posterior_covariance_derivative(
    Floats x, bool) const {
  IMP_Eigen::VectorXd mat(get_posterior_covariance_derivative(x));
  Floats tmp;
  for (unsigned j = 0; j < mat.rows(); j++) tmp.push_back(mat(j));
  return tmp;
}
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:7,代码来源:GaussianProcessInterpolation.cpp

示例6: evaluate_derivative_FX

Floats FStudentT::evaluate_derivative_FX(const Floats FXs) const {
  Floats dervs;
  double c = (N_ + nu_) / IMP::square(sigma_) / (nu_ + t2_);
  for (unsigned int i = 0; i < FXs.size(); i++) {
    dervs.push_back(c * (FXs[i] - FM_));
  }
  return dervs;
}
开发者ID:salilab,项目名称:imp,代码行数:8,代码来源:FStudentT.cpp

示例7: create_temperatures

Floats ReplicaExchange::create_temperatures(double tmin,double tmax,int nrep)
{
 Floats temp;
 double tfact=exp(log(tmax/tmin)/double(nrep-1));
 for(int i=0;i<nrep;++i) {
  temp.push_back(tmin*pow(tfact,i));
 }
 return temp;
}
开发者ID:apolitis,项目名称:imp,代码行数:9,代码来源:ReplicaExchange.cpp

示例8: get_marginal_elements

Floats CrossLinkData::get_marginal_elements(double sigma, Floats dists) const {
  Floats probs;
  unsigned is = get_closest(sigma_grid_, sigma);
  for (unsigned n = 0; n < dists.size(); n++) {

    unsigned id = get_closest(dist_grid_, dists[n]);
    probs.push_back(grid_[is][id]);
  }
  return probs;
}
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:10,代码来源:CrossLinkData.cpp

示例9: get_nonmarginal_elements

Floats CysteineCrossLinkData::get_nonmarginal_elements(double fexp,
                                                       Floats fmods,
                                                       double omega) const {
  Floats probs;

  for (unsigned n = 0; n < fmods.size(); n++) {
    probs.push_back(get_element(fexp, fmods[n], omega));
  }
  return probs;
}
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:10,代码来源:CysteineCrossLinkData.cpp

示例10: write_cmm

void write_cmm(const std::string &cmm_filename,
               const std::string &marker_set_name, const AnchorsData &ad) {
  Floats radii;
  // algebra::get_enclosing_sphere(dpa.get_cluster_vectors(i));
  radii.insert(radii.begin(), ad.get_number_of_points(), 5.);
  std::ofstream out;
  out.open(cmm_filename.c_str(), std::ios::out);
  write_cmm_helper(out, marker_set_name, ad.points_, ad.edges_, radii);
  out.close();
}
开发者ID:AljGaber,项目名称:imp,代码行数:10,代码来源:anchors_reader.cpp

示例11: tmp

FloatsList GaussianProcessInterpolationRestraint::get_hessian(bool) const {
  IMP_Eigen::MatrixXd tmp(get_hessian());
  FloatsList ret;
  for (unsigned i = 0; i < tmp.rows(); ++i) {
    Floats buf;
    for (unsigned j = 0; j < tmp.cols(); ++j) buf.push_back(tmp(i, j));
    ret.push_back(buf);
  }
  return ret;
}
开发者ID:newtonjoo,项目名称:imp,代码行数:10,代码来源:GaussianProcessInterpolationRestraint.cpp

示例12: S

FloatsList GaussianProcessInterpolation::get_data_variance() const {
  FloatsList ret;
  IMP_Eigen::MatrixXd S(get_S());
  for (unsigned i = 0; i < M_; i++) {
    Floats val;
    for (unsigned j = 0; j < M_; j++) val.push_back(S(i, j));
    ret.push_back(val);
  }
  return ret;
}
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:10,代码来源:GaussianProcessInterpolation.cpp

示例13: Object

IMPISD_BEGIN_NAMESPACE

CysteineCrossLinkData::CysteineCrossLinkData(double fexp, Floats fmod_grid,
                                             Floats omega_grid,
                                             Floats omega0_grid, int prior_type)
    : Object("Data Structure for CysteineCrossLinkRestraint %1%") {
  prior_type_ = prior_type;
  // fexp is the experimental frequency
  // fmod is the model frequency
  // omega0 is the typical value for omega, i.e., the experimental uncertainty

  // this constructor calculates the marginal likelihood using a
  // truncated gaussian function
  // to account for outliers

  // Store omega0 grid
  omega0_grid_ = omega0_grid;

  // Store the fmod grid
  fmod_grid_ = fmod_grid;

  // Store omega grid
  omega_grid_ = omega_grid;

  fexp_ = fexp;

  for (unsigned k = 0; k < omega0_grid_.size(); ++k) {

    double omega0 = omega0_grid_[k];

    Floats grid;

    for (unsigned i = 0; i < fmod_grid_.size(); ++i) {

      double fmod = fmod_grid_[i];

      double cumul = 0;
      for (unsigned j = 1; j < omega_grid_.size(); ++j) {

        double omj = omega_grid_[j];
        double omjm1 = omega_grid_[j - 1];
        double dom = omj - omjm1;

        double priorj = get_omega_prior(omj, omega0);
        double priorjm1 = get_omega_prior(omjm1, omega0);

        double pj = get_element(fexp_, fmod, omj) * priorj;
        double pjm1 = get_element(fexp_, fmod, omjm1) * priorjm1;
        cumul += (pj + pjm1) / 2.0 * dom;
      }
      grid.push_back(cumul);
    }
    grid_.push_back(grid);
  }
}
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:55,代码来源:CysteineCrossLinkData.cpp

示例14: get_particle_probabilities

algebra::Vector3Ds ProbabilisticAnchorGraph::get_particle_anchors(
    Particle *p, float min_prob) const {
  Floats probs = get_particle_probabilities(p);
  algebra::Vector3Ds anchors;
  for (unsigned int i = 0; i < probs.size(); i++) {
    if (probs[i] >= min_prob) {
      anchors.push_back(positions_[i]);
    }
  }
  return anchors;
}
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:11,代码来源:anchor_graph.cpp

示例15: get_marginal_elements

Floats CysteineCrossLinkData::get_marginal_elements(Floats fmods,
                                                    double omega0) const {
  Floats probs;
  unsigned is = get_closest(omega0_grid_, omega0);
  for (unsigned n = 0; n < fmods.size(); n++) {

    unsigned id = get_closest(fmod_grid_, fmods[n]);
    probs.push_back(grid_[is][id]);
  }
  return probs;
}
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:11,代码来源:CysteineCrossLinkData.cpp


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