本文整理汇总了C++中vector_expression::end方法的典型用法代码示例。如果您正苦于以下问题:C++ vector_expression::end方法的具体用法?C++ vector_expression::end怎么用?C++ vector_expression::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector_expression
的用法示例。
在下文中一共展示了vector_expression::end方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vector_assign
void vector_assign(
vector_expression<V, cpu_tag>& v, vector_expression<E, cpu_tag> const& e,
packed_tag, packed_tag
) {
typedef typename E::const_iterator EIterator;
EIterator eiter = e.begin();
EIterator eend = e.end();
//special case:
//right hand side is completely 0
if(eiter == eend){
v().clear();
return;
}
EIterator viter = v.begin();
EIterator vend = v.end();
//check for compatible layout
REMORA_SIZE_CHECK(vend-viter);//empty ranges can't be compatible
//check whether the right hand side range is included in the left hand side range
REMORA_SIZE_CHECK(viter.index() <= eiter.index());
REMORA_SIZE_CHECK(viter.index()+(vend-viter) >= eiter.index()+(eend-eiter));
//copy contents of right-hand side
viter += eiter.index()-viter.index();
for(;eiter != eend; ++eiter,++viter){
*viter= *eiter;
}
}
示例2: assign
void assign(
vector_expression<V>& v, vector_expression<E> const& e,
dense_random_access_iterator_tag, packed_random_access_iterator_tag
) {
SIZE_CHECK(v().size() == e().size());
typedef typename E::const_iterator EIterator;
typedef typename V::scalar_type scalar_type;
EIterator eiter = e.begin();
EIterator eend = e.end();
//special case:
//right hand side is completely 0
if(eiter == eend) {
v().clear();
return;
}
EIterator viter = v.begin();
EIterator vend = v.end();
//set the first elements to zero
for(; viter.index() != eiter.index(); ++viter) {
*viter= scalar_type/*zero*/();
}
//copy contents of right-hand side
for(; eiter != eend; ++eiter,++viter) {
*viter= *eiter;
}
for(; viter!= vend; ++viter) {
*viter= scalar_type/*zero*/();
}
}
示例3: assign
void assign(
vector_expression<V>& v,
vector_expression<E> const& e,
F f,
dense_random_access_iterator_tag, packed_random_access_iterator_tag
) {
SIZE_CHECK(v().size() == e().size());
typedef typename E::const_iterator EIterator;
typedef typename V::scalar_type scalar_type;
EIterator eiter = e.begin();
EIterator eend = e.end();
EIterator viter = v.begin();
EIterator vend = v.end();
//right hand side hasnonzero elements
if(eiter != eend){
//apply f to the first elements for which the right hand side is 0, unless f is the identity
for(;viter.index() != eiter.index() &&!F::right_zero_identity; ++viter){
f(*viter,scalar_type/*zero*/());
}
//copy contents of right-hand side
for(;eiter != eend; ++eiter,++viter){
f(*viter,*eiter);
}
}
//apply f to the last elements for which the right hand side is 0, unless f is the identity
for(;viter!= vend &&!F::right_zero_identity; ++viter){
*viter= scalar_type/*zero*/();
}
}