本文整理汇总了C++中Iter::index方法的典型用法代码示例。如果您正苦于以下问题:C++ Iter::index方法的具体用法?C++ Iter::index怎么用?C++ Iter::index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Iter
的用法示例。
在下文中一共展示了Iter::index方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkDenseMatrixEqual
void checkDenseMatrixEqual(M1 const& m1, M2 const& m2){
BOOST_REQUIRE_EQUAL(m1.size1(),m2.size1());
BOOST_REQUIRE_EQUAL(m1.size2(),m2.size2());
//indexed access
for(std::size_t i = 0; i != m2.size1(); ++i){
for(std::size_t j = 0; j != m2.size2(); ++j){
BOOST_CHECK_EQUAL(m1(i,j),m2(i,j));
}
}
//iterator access rows
for(std::size_t i = 0; i != m2.size1(); ++i){
typedef typename M1::const_row_iterator Iter;
BOOST_REQUIRE_EQUAL(m1.row_end(i)-m1.row_begin(i), m1.size2());
std::size_t k = 0;
for(Iter it = m1.row_begin(i); it != m1.row_end(i); ++it,++k){
BOOST_CHECK_EQUAL(k,it.index());
BOOST_CHECK_EQUAL(*it,m2(i,k));
}
//test that the actual iterated length equals the number of elements
BOOST_CHECK_EQUAL(k, m1.size2());
}
//iterator access columns
for(std::size_t i = 0; i != m2.size2(); ++i){
typedef typename M1::const_column_iterator Iter;
BOOST_REQUIRE_EQUAL(m1.column_end(i)-m1.column_begin(i), m1.size1());
std::size_t k = 0;
for(Iter it = m1.column_begin(i); it != m1.column_end(i); ++it,++k){
BOOST_CHECK_EQUAL(k,it.index());
BOOST_CHECK_EQUAL(*it,m2(k,i));
}
//test that the actual iterated length equals the number of elements
BOOST_CHECK_EQUAL(k, m1.size1());
}
}
示例2: checkDenseVectorAssignment
void checkDenseVectorAssignment(V1& v1, V2 const& v2){
BOOST_REQUIRE_EQUAL(v1.size(),v2.size());
//indexed access
for(std::size_t i = 0; i != v2.size(); ++i){
v1(i) = 0;
BOOST_CHECK_EQUAL(v1(i),0);
v1(i) = v2(i);
BOOST_CHECK_EQUAL(v1(i),v2(i));
v1(i) = 0;
BOOST_CHECK_EQUAL(v1(i),0);
}
//iterator access rows
typedef typename V1::iterator Iter;
BOOST_REQUIRE_EQUAL(v1.end()-v1.begin(), v1.size());
std::size_t k = 0;
for(Iter it = v1.begin(); it != v1.end(); ++it,++k){
BOOST_CHECK_EQUAL(k,it.index());
*it = 0;
BOOST_CHECK_EQUAL(v1(k),0);
*it = v2(k);
BOOST_CHECK_EQUAL(v1(k),v2(k));
*it = 0;
BOOST_CHECK_EQUAL(v1(k),0);
}
//test that the actual iterated length equals the number of elements
BOOST_CHECK_EQUAL(k, v2.size());
}
示例3: log_probability
double log_probability(Iter const & iter, int target) const {
double log_prob = _func->log_probability(iter, target);
if (std::isnan(log_prob))
throw QHMMException("NaN detected", "log_probability", true, _stateID, -1, iter.index(), -1);
return log_prob;
}
示例4:
Iter
PhoneBook::searchIndex(const long index, Iter i)
{
for ( ; i != _records.end(); i++)
if (i->index()==index)
return i;
return i;
}