Index: matrix_sparse.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/numeric/ublas/matrix_sparse.hpp,v retrieving revision 1.82 diff -u -p -r1.82 matrix_sparse.hpp --- matrix_sparse.hpp 18 May 2006 16:44:57 -0000 1.82 +++ matrix_sparse.hpp 7 Nov 2006 14:10:43 -0000 @@ -1632,8 +1632,18 @@ namespace boost { namespace numeric { na const_subiterator_type it ((*itv).second.lower_bound (layout_type::index_m (i, j))); const_subiterator_type it_end ((*itv).second.end ()); - if (rank == 0) - return const_iterator1 (*this, rank, i, j, itv, it); + if (rank == 0) { + // advance to the first available major index + size_type M = itv->first; + size_type m; + if (it != it_end) { + m = it->first; + } else { + m = layout_type::size_m(size1_, size2_); + } + size_type first_i = layout_type::index_M(M,m); + return const_iterator1 (*this, rank, first_i, j, itv, it); + } if (it != it_end && (*it).first == layout_type::index_m (i, j)) return const_iterator1 (*this, rank, i, j, itv, it); if (direction > 0) { @@ -1671,8 +1681,18 @@ namespace boost { namespace numeric { na subiterator_type it ((*itv).second.lower_bound (layout_type::index_m (i, j))); subiterator_type it_end ((*itv).second.end ()); - if (rank == 0) - return iterator1 (*this, rank, i, j, itv, it); + if (rank == 0) { + // advance to the first available major index + size_type M = itv->first; + size_type m; + if (it != it_end) { + m = it->first; + } else { + m = layout_type::size_m(size1_, size2_); + } + size_type first_i = layout_type::index_M(M,m); + return iterator1 (*this, rank, first_i, j, itv, it); + } if (it != it_end && (*it).first == layout_type::index_m (i, j)) return iterator1 (*this, rank, i, j, itv, it); if (direction > 0) { @@ -1710,8 +1730,18 @@ namespace boost { namespace numeric { na const_subiterator_type it ((*itv).second.lower_bound (layout_type::index_m (i, j))); const_subiterator_type it_end ((*itv).second.end ()); - if (rank == 0) - return const_iterator2 (*this, rank, i, j, itv, it); + if (rank == 0) { + // advance to the first available major index + size_type M = itv->first; + size_type m; + if (it != it_end) { + m = it->first; + } else { + m = layout_type::size_m(size1_, size2_); + } + size_type first_j = layout_type::index_m(M,m); + return const_iterator2 (*this, rank, i, first_j, itv, it); + } if (it != it_end && (*it).first == layout_type::index_m (i, j)) return const_iterator2 (*this, rank, i, j, itv, it); if (direction > 0) { @@ -1749,8 +1779,18 @@ namespace boost { namespace numeric { na subiterator_type it ((*itv).second.lower_bound (layout_type::index_m (i, j))); subiterator_type it_end ((*itv).second.end ()); - if (rank == 0) - return iterator2 (*this, rank, i, j, itv, it); + if (rank == 0) { + // advance to the first available major index + size_type M = itv->first; + size_type m; + if (it != it_end) { + m = it->first; + } else { + m = layout_type::size_m(size1_, size2_); + } + size_type first_j = layout_type::index_m(M,m); + return iterator2 (*this, rank, i, first_j, itv, it); + } if (it != it_end && (*it).first == layout_type::index_m (i, j)) return iterator2 (*this, rank, i, j, itv, it); if (direction > 0) { @@ -1809,7 +1849,12 @@ namespace boost { namespace numeric { na ++ it_; else { const self_type &m = (*this) (); - i_ = index1 () + 1; + if (rank_ == 0) { + ++ itv_; + i_ = itv_->first; + } else { + i_ = index1 () + 1; + } if (rank_ == 1 && ++ itv_ == m.end1 ().itv_) *this = m.find1 (rank_, i_, j_, 1); else if (rank_ == 1) { @@ -1826,7 +1871,13 @@ namespace boost { namespace numeric { na -- it_; else { const self_type &m = (*this) (); - i_ = index1 () - 1; + if (rank_ == 0) { + -- itv_; + i_ = itv_->first; + } else { + i_ = index1 () - 1; + } + // FIXME: this expression should never become true! if (rank_ == 1 && -- itv_ == m.end1 ().itv_) *this = m.find1 (rank_, i_, j_, -1); else if (rank_ == 1) { @@ -1973,7 +2024,12 @@ namespace boost { namespace numeric { na ++ it_; else { self_type &m = (*this) (); - i_ = index1 () + 1; + if (rank_ == 0) { + ++ itv_; + i_ = itv_->first; + } else { + i_ = index1 () + 1; + } if (rank_ == 1 && ++ itv_ == m.end1 ().itv_) *this = m.find1 (rank_, i_, j_, 1); else if (rank_ == 1) { @@ -1990,7 +2046,13 @@ namespace boost { namespace numeric { na -- it_; else { self_type &m = (*this) (); - i_ = index1 () - 1; + if (rank_ == 0) { + -- itv_; + i_ = itv_->first; + } else { + i_ = index1 () - 1; + } + // FIXME: this expression should never become true! if (rank_ == 1 && -- itv_ == m.end1 ().itv_) *this = m.find1 (rank_, i_, j_, -1); else if (rank_ == 1) { @@ -2142,7 +2204,12 @@ namespace boost { namespace numeric { na ++ it_; else { const self_type &m = (*this) (); - j_ = index2 () + 1; + if (rank_ == 0) { + ++ itv_; + j_ = itv_->first; + } else { + j_ = index2 () + 1; + } if (rank_ == 1 && ++ itv_ == m.end2 ().itv_) *this = m.find2 (rank_, i_, j_, 1); else if (rank_ == 1) { @@ -2159,7 +2226,13 @@ namespace boost { namespace numeric { na -- it_; else { const self_type &m = (*this) (); - j_ = index2 () - 1; + if (rank_ == 0) { + -- itv_; + j_ = itv_->first; + } else { + j_ = index2 () - 1; + } + // FIXME: this expression should never become true! if (rank_ == 1 && -- itv_ == m.end2 ().itv_) *this = m.find2 (rank_, i_, j_, -1); else if (rank_ == 1) { @@ -2306,7 +2379,12 @@ namespace boost { namespace numeric { na ++ it_; else { self_type &m = (*this) (); - j_ = index2 () + 1; + if (rank_ == 0) { + ++ itv_; + j_ = itv_->first; + } else { + j_ = index2 () + 1; + } if (rank_ == 1 && ++ itv_ == m.end2 ().itv_) *this = m.find2 (rank_, i_, j_, 1); else if (rank_ == 1) { @@ -2323,7 +2401,13 @@ namespace boost { namespace numeric { na -- it_; else { self_type &m = (*this) (); - j_ = index2 () - 1; + if (rank_ == 0) { + -- itv_; + j_ = itv_->first; + } else { + j_ = index2 () - 1; + } + // FIXME: this expression should never become true! if (rank_ == 1 && -- itv_ == m.end2 ().itv_) *this = m.find2 (rank_, i_, j_, -1); else if (rank_ == 1) {