本文整理汇总了C++中PointSet::end方法的典型用法代码示例。如果您正苦于以下问题:C++ PointSet::end方法的具体用法?C++ PointSet::end怎么用?C++ PointSet::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointSet
的用法示例。
在下文中一共展示了PointSet::end方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testScalability
// Create a randomly generated point
// scatter time execution
void testScalability(unsigned numpts)
{
using namespace boost;
using namespace std;
typedef adjacency_matrix<undirectedS, no_property,
property <edge_weight_t, double,
property<edge_index_t, int> > > Graph;
typedef graph_traits<Graph>::vertex_descriptor Vertex;
typedef property_map<Graph, edge_weight_t>::type WeightMap;
typedef set<simple_point<double>, cmpPnt<double> > PointSet;
typedef vector< Vertex > Container;
boost::mt19937 rng(time(0));
uniform_real<> range(0.01, (numpts * 2));
variate_generator<boost::mt19937&, uniform_real<> >
pnt_gen(rng, range);
PointSet points;
simple_point<double> pnt;
while (points.size() < numpts)
{
pnt.x = pnt_gen();
pnt.y = pnt_gen();
points.insert(pnt);
}
Graph g(numpts);
WeightMap weight_map(get(edge_weight, g));
vector<simple_point<double> > point_vec(points.begin(), points.end());
connectAllEuclidean(g, point_vec, weight_map, get(vertex_index, g), numpts);
Container c;
timer t;
double len = 0.0;
// Run the TSP approx, creating the visitor on the fly.
metric_tsp_approx(g, make_tsp_tour_len_visitor(g, back_inserter(c), len, weight_map));
cout << "Number of points: " << num_vertices(g) << endl;
cout << "Number of edges: " << num_edges(g) << endl;
cout << "Length of tour: " << len << endl;
cout << "Elapsed: " << t.elapsed() << endl;
}
示例2: VectorCoordinateProduct
void
computeCovarianceMatrixFromPointSet( const PointSet &aPoints, Vector3f &aCenter, Eigen::Matrix3f &aCovarianceMatrix )
{
float scale = 1.0f/aPoints.size();
aCenter = scale * std::accumulate( aPoints.begin(), aPoints.end(), Vector3f() );
/* //compute variances
Vector3f variances;
for ( size_t k = 0; k < aPoints.size(); ++k ) {
variances += VectorCoordinateProduct( aPoints[k]-aCenter, aPoints[k]-aCenter );
}
variances *= scale;*/
for ( size_t i = 0; i < 3; ++i ) {
for ( size_t j = 0; j < 3; ++j ) {
float covariance = 0.0f;
for ( size_t k = 0; k < aPoints.size(); ++k ) {
covariance += (aPoints[k][i]-aCenter[i]) * (aPoints[k][j]-aCenter[j]);
}
aCovarianceMatrix(i,j) = scale * covariance;
}
}
}
示例3:
PointSet::PointSet(const PointSet &ps) : PointSet{ps.begin(), ps.end()} {}
示例4: updateProbabilitiesBeforeAction
void SoftmaxPolicyPlayout::updateProbabilitiesBeforeAction(const Go::Board *board, Color player) {
// check the last move
size_t historySize = board->getHistoryCount();
const Board::MoveChangeEntry *lastMove = board->getHistory(historySize-1); // enemy's move
const Board::MoveChangeEntry *secondLastMove = board->getHistory(historySize-2); // last my move
const Board::MoveChangeEntry *thirdLastMove = board->getHistory(historySize-3);
double *table = NULL;
SparseVector *featureTable = NULL;
if (player == BLACK) {
table = m_probTableBlack;
featureTable = m_featureTableBlack;
} else {
table = m_probTableWhite;
featureTable = m_featureTableWhite;
}
if (lastMove && lastMove->m_putPos != PASS) table[lastMove->m_putPos] = 0;
if (secondLastMove && secondLastMove->m_putPos != PASS) table[secondLastMove->m_putPos] = 0;
PointSet updatedMoves;
// reset static features which are set in the last time of player
PointSet &previousSetMoves = player == BLACK ? m_toResetStaticFeaturesMovesBlack : m_toResetStaticFeaturesMovesWhite;
for (size_t i=0; i<previousSetMoves.size(); i++) {
//cerr << previousSetMoves[i] << ":" << featureTable[previousSetMoves[i]].toString() << endl;
Point p = previousSetMoves[i];
StandardFeatureExtractor::clearStaticFeatures(featureTable[p]);
if (board->isColor(p, FREE) &&
(board->getNeighborEmptyCount(p) >= 1 || board->checkLegalHand(p, player, Board::flipColor(player)) == Board::PUT_LEGAL)) {
updatedMoves.insert(p,p);
}
}
previousSetMoves.clear();
// enumerate pattern update moves
PointSet patternUpdateMoves;
enumerateMovesOfPatternChanged(patternUpdateMoves, board, player, lastMove, secondLastMove, false);
// enumerate moves that their status will change
PointSet toBeLegal, toBeIllegal;
PointSet legalMovesSet;
toBeLegal.clear(); toBeIllegal.clear();
enumerateToBeLegalAndIllegalMoves(board, table, player, toBeLegal, toBeIllegal, legalMovesSet, false);
PointSet &staticFeatureUpdateMoves = previousSetMoves;
if (lastMove == NULL) return; // no further old moves
// update static features
m_featureExtractor.updateStaticFeaturesForAllMovesWithoutClearOldFeatures(board, player, legalMovesSet, featureTable, staticFeatureUpdateMoves);
// update patterns
PointSet::ListConstIterator it, end = patternUpdateMoves.end();
for (it = patternUpdateMoves.begin(); it!=end; it++) {
SparseVector &targetFeatures = featureTable[*it];
assert (board->isColor(*it, FREE));
m_featureExtractor.updatePatternFeature(targetFeatures, board, *it, player);
//if (board->checkLegalHand(*it, player, Board::flipColor(player)) == Board::PUT_LEGAL) {
if ((!toBeIllegal.contains(*it) && table[*it] != 0) || toBeLegal.contains(*it)) {
updatedMoves.insert(*it,*it);
}
}
end = toBeLegal.end();
for (it = toBeLegal.begin(); it!=end; it++) {
updatedMoves.insert(*it,*it);
// check capturing, atari features
}
end = staticFeatureUpdateMoves.end();
for (it=staticFeatureUpdateMoves.begin(); it!=end; it++) {
//table[*it] = m_expFeatureWeights.multiplyAll(featureTable[*it]);
updatedMoves.insert(*it,*it);
}
end = updatedMoves.end();
for (it=updatedMoves.begin(); it!=end; it++) {
//table[*it] = m_expFeatureWeights.multiplyAll(featureTable[*it]);
table[*it] = fmath::expd(m_featureWeights.dot(featureTable[*it]));
//table[*it] = exp(m_featureWeights.dot(featureTable[*it]));
}
end = toBeIllegal.end();
for (it = toBeIllegal.begin(); it!=end; it++) {
table[*it] = 0;
StandardFeatureExtractor::clearStaticFeatures(featureTable[*it]);
}
#ifdef STRICT_CHECK
for (int y=0; y<board->getSize(); y++) {
for (int x=0; x<board->getSize(); x++) {
Point p = board->xyToPoint(x,y);
Board::PutType err = board->checkLegalHand(p, player, Board::flipColor(player));
assert (!(err == Board::PUT_LEGAL && table[p] == 0) &&
!(err != Board::PUT_LEGAL && table[p] != 0));
if (err == Board::PUT_LEGAL) {
double v = m_expFeatureWeights.multiplyAll(featureTable[p]);
if (fabs(v-table[p]) >= 0.001) {
cerr << "v = " << v << endl;
//.........这里部分代码省略.........