本文整理汇总了C++中Floats::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Floats::begin方法的具体用法?C++ Floats::begin怎么用?C++ Floats::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Floats
的用法示例。
在下文中一共展示了Floats::begin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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());
}
}
示例2: 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();
}
示例3: do_propose
core::MonteCarloMoverResult WeightMover::do_propose() {
IMP_OBJECT_LOG;
// store the old weights in case of reject
oldweights_ = w_.get_weights();
// Draw weights from a uniform distribution of variables that sum to one
// taken from http://stats.stackexchange.com/questions/14059/
// generate-uniformly-distributed-weights-that-sum-to-unity
// get the old x
Floats x;
x.push_back(oldweights_[0]);
for (unsigned i = 1; i < oldweights_.get_dimension() - 1; ++i) {
x.push_back(oldweights_[i] + x[i - 1]);
}
// zero vector in D dimension
algebra::VectorKD zero = algebra::get_zero_vector_kd(x.size());
// generate random perturbation of old components
algebra::VectorKD dX =
algebra::get_random_vector_in(algebra::SphereKD(zero, radius_));
// add perturbation to x and apply reflective boundaries
for (unsigned i = 0; i < x.size(); ++i) {
if (x[i] + dX[i] > 1.0)
x[i] = 2.0 - x[i] - dX[i];
else if (x[i] + dX[i] < 0.0)
x[i] = -x[i] - dX[i];
else
x[i] += dX[i];
}
// sort the new x here
std::sort(x.begin(), x.end(), std::less<double>());
// get the new weights
algebra::VectorKD newweights =
algebra::get_zero_vector_kd(oldweights_.get_dimension());
newweights[0] = x[0];
for (unsigned i = 1; i < newweights.get_dimension() - 1; ++i) {
newweights[i] = x[i] - x[i - 1];
}
newweights[newweights.get_dimension() - 1] = 1.0 - x[x.size() - 1];
// set the new weights
w_.set_weights(newweights);
return core::MonteCarloMoverResult(
ParticleIndexes(1, w_.get_particle()->get_index()), 1.0);
}