Ejemplo n.º 1
0
typename MAT::value_type 
test_iterator3( const MAT & A ) {

#ifndef NOMESSAGES
    std::cout << "=>";
#endif
  typename MAT::value_type result = 0;

  // check mutable iterators
  typename MAT::const_iterator1 it1 = A.begin1();
  typename MAT::const_iterator1 it1_end = A.end1();
  
  for ( ; it1 != it1_end; ++it1 ) {
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
    typename MAT::const_iterator2 it2 = it1.begin();
    typename MAT::const_iterator2 it2_end = it1.end();
#else
    typename MAT::const_iterator2 it2 = begin(it1, iterator1_tag());
    typename MAT::const_iterator2 it2_end = end(it1, iterator1_tag());
#endif
    for ( ; it2 != it2_end ; ++ it2 ) {
#ifndef NOMESSAGES
      std::cout << "( " << it2.index1() << ", " << it2.index2() << ") " << std::flush;
#endif
      result += * it2;
    }
#ifndef NOMESSAGES
    std::cout << std::endl;
#endif
  }
  return result;

}
Ejemplo n.º 2
0
void test_iterator( MAT & A ) {

#ifndef NOMESSAGES
    std::cout << "=>";
#endif
  // check mutable iterators
  typename MAT::iterator1 it1 = A.begin1();
  typename MAT::iterator1 it1_end = A.end1();
  
  for ( ; it1 != it1_end; ++it1 ) {
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
    typename MAT::iterator2 it2 = it1.begin();
    typename MAT::iterator2 it2_end = it1.end();
#else
    typename MAT::iterator2 it2 = begin(it1, iterator1_tag());
    typename MAT::iterator2 it2_end = end(it1, iterator1_tag());
#endif
    for ( ; it2 != it2_end ; ++ it2 ) {
#ifndef NOMESSAGES
      std::cout << "( " << it2.index1() << ", " << it2.index2() << ") " << std::flush;
#endif
      * it2 = ( 10 * it2.index1() + it2.index2() );
    }
#ifndef NOMESSAGES
    std::cout << std::endl;
#endif
  }

}