本文整理汇总了C++中typenamestd::vector::at方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::at方法的具体用法?C++ vector::at怎么用?C++ vector::at使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typenamestd::vector
的用法示例。
在下文中一共展示了vector::at方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pow
void CPDRigid<T, D>::correspondences()
{
_corres.setZero(_M, _N);
for (size_t n = 0; n < _N; n ++)
{
typename std::vector<T> t_exp;
T sum_exp = 0;
T c = pow((2*M_PI*_paras._sigma2), 0.5*D) * (_w/(1-_w)) * (T(_M)/_N);
for (size_t m = 0; m < _M; m ++)
{
T m_exp = computeGaussianExp(m, n);
t_exp.push_back(m_exp);
sum_exp += m_exp;
}
for (size_t m = 0; m < _M; m ++)
{
_corres(m, n) = t_exp.at(m) / (sum_exp + c);
}
}
}
示例2: pow
void CPDNRigid<Scalar, Dim>::correspondences()
{
this->corres_.setZero(this->M_, this->N_);
for (size_t n = 0; n < this->N_; n ++)
{
typename std::vector<Scalar> t_exp;
Scalar sum_exp = 0;
Scalar c = pow((2*M_PI*paras_.sigma2_), 0.5*Dim) * (this->w_/(1-this->w_)) * (Scalar(this->M_)/this->N_);
for (size_t m = 0; m < this->M_; m ++)
{
Scalar m_exp = computeGaussianExp(m, n);
t_exp.push_back(m_exp);
sum_exp += m_exp;
}
for (size_t m = 0; m < this->M_; m ++)
{
this->corres_(m, n) = t_exp.at(m) / (sum_exp + c);
}
}
}
示例3: OrderDownwindForDofDist
void OrderDownwindForDofDist(SmartPtr<DoFDistribution> dd, ConstSmartPtr<TDomain> domain,
SmartPtr<UserData<MathVector<TDomain::dim>, TDomain::dim> > spVelocity,
number time, int si, number threshold)
{
static const int dim = TDomain::dim;
const size_t num_ind = dd->num_indices();
typedef typename std::pair<MathVector<dim>, size_t> pos_type;
typedef typename std::vector<std::vector<size_t> > adjacency_type;
// get positions of indices
typename std::vector<pos_type> vPositions;
ExtractPositions(domain, dd, vPositions);
// get adjacency vector of vectors
adjacency_type vvConnections;
dd->get_connections(vvConnections);
// Check vector sizes match
if (vvConnections.size() != num_ind)
UG_THROW("OrderDownstreamForDofDist: "
"Adjacency list of dimension " << num_ind << " expected, got "<< vvConnections.size());
if (vPositions.size() != num_ind)
UG_THROW("OrderDownstreamForDofDist: "
"Position list of dimension " << num_ind << " expected, got "<< vPositions.size());
// init helper structures
std::vector<size_t> vNewIndex(num_ind, 0);
std::vector<size_t> vAncestorsCount(num_ind, 0);
std::vector<bool> vVisited(num_ind, false);
// remove connections that are not in stream direction
adjacency_type::iterator VertexIter;
std::vector<size_t>::iterator AdjIter;
std::vector<size_t> vAdjacency;
// count how many vertex were kept / removed per adjacency vector
size_t initialcount, kept, removed = 0;
MathVector<TDomain::dim> vVel1, vPos1, vPos2, vDir1_2;
size_t i;
for (VertexIter = vvConnections.begin(), i=0; VertexIter != vvConnections.end(); VertexIter++, i++)
{
UG_DLOG(LIB_DISC_ORDER, 2, "Filtering vertex " << i << " adjacency vector." <<std::endl);
initialcount = VertexIter->size();
kept = 0;
removed = 0;
// get position and velocity of first trait
vPos1 = vPositions.at(i).first;
(*spVelocity)(vVel1, vPos1, time, si);
if (VecLengthSq(vVel1) == 0 )
{
// if the velocity is zero at this trait it does not interfere with others
// NOTE: otherwise this trait would be downwind-connected to all of it's neighbors
// NOTE: VertexIter-> will access inner vector functions (*VertexIter) is the inner vector.
removed = VertexIter->size();
VertexIter->clear();
}
else {
AdjIter = VertexIter->begin();
while (AdjIter != VertexIter->end())
{
// get position of second trait
vPos2 = vPositions.at(*AdjIter).first;
// get difference vector as direction vector
VecSubtract(vDir1_2, vPos2, vPos1);
// compute angle between velocity and direction vector
number anglex1_2 = VecAngle(vDir1_2, vVel1);
// if angle is smaller then threshold continue else remove connection
if (anglex1_2 <= threshold && i != *AdjIter)
{
vAncestorsCount.at(*AdjIter) += 1;
++AdjIter;
kept++;
} else {
AdjIter = VertexIter->erase(AdjIter);
removed++;
}
}
}
UG_DLOG(LIB_DISC_ORDER, 2, "Kept: " << kept << ", removed: " << removed << " of " << initialcount
<< " entries in adjacency matrix." << std::endl << std::endl);
}
// calculate downwindorder
// Find vertexes without any ancestors and start NumeriereKnoten on them.
size_t v,N;
for (v=0, N=0; v < vvConnections.size(); v++)
{
if (vAncestorsCount[v] == 0 && !vVisited[v])
{
NumeriereKnoten(vvConnections, vVisited, vAncestorsCount, vNewIndex, N, v);
}
}
// sanity check
if (N < vvConnections.size()){
size_t fails = 0;
//.........这里部分代码省略.........
示例4: get
T get(int v) const
{
return m_int2name.at(v);
}