2
0
mirror of https://github.com/boostorg/ublas.git synced 2026-02-27 17:32:09 +00:00

FIX packed and sparse overloads for increment and decrement

svn path=/trunk/boost/boost/numeric/ublas/; revision=30310
This commit is contained in:
Michael Stevens
2005-07-29 12:18:39 +00:00
parent f742950411
commit 7a12106f01
2 changed files with 182 additions and 12 deletions

View File

@@ -1814,14 +1814,23 @@ namespace boost { namespace numeric { namespace ublas {
const const_iterator21_type &it2, const const_iterator21_type &it2_end):
container_const_reference<self_type> (mb), i_ (i), j_ (j), it1_ (it1), it1_end_ (it1_end), it2_ (it2), it2_end_ (it2_end) {}
private:
// Dense specializations
BOOST_UBLAS_INLINE
void increment (dense_random_access_iterator_tag) {
++ i_, ++ it1_, ++ it2_;
++ i_; ++ it1_; ++ it2_;
}
BOOST_UBLAS_INLINE
void decrement (dense_random_access_iterator_tag) {
-- i_, -- it1_, -- it2_;
-- i_; -- it1_; -- it2_;
}
BOOST_UBLAS_INLINE
void increment (dense_random_access_iterator_tag, difference_type n) {
i_ += n; it1_ += n; it2_ += n;
}
BOOST_UBLAS_INLINE
void decrement (dense_random_access_iterator_tag, difference_type n) {
i_ -= n; it1_ -= n; it2_ -= n;
}
BOOST_UBLAS_INLINE
value_type dereference (dense_random_access_iterator_tag) const {
@@ -1850,6 +1859,28 @@ namespace boost { namespace numeric { namespace ublas {
-- i_;
}
BOOST_UBLAS_INLINE
void increment (packed_random_access_iterator_tag, difference_type n) {
while (n > 0) {
increment (packed_random_access_iterator_tag ());
--n;
}
while (n < 0) {
decrement (packed_random_access_iterator_tag ());
++n;
}
}
BOOST_UBLAS_INLINE
void decrement (packed_random_access_iterator_tag, difference_type n) {
while (n > 0) {
decrement (packed_random_access_iterator_tag ());
--n;
}
while (n < 0) {
increment (packed_random_access_iterator_tag ());
++n;
}
}
BOOST_UBLAS_INLINE
value_type dereference (packed_random_access_iterator_tag) const {
value_type t1 = value_type/*zero*/();
if (it1_ != it1_end_) {
@@ -1904,6 +1935,28 @@ namespace boost { namespace numeric { namespace ublas {
i_ = (std::max) (index1, index2);
}
BOOST_UBLAS_INLINE
void increment (sparse_bidirectional_iterator_tag, difference_type n) {
while (n > 0) {
increment (sparse_bidirectional_iterator_tag ());
--n;
}
while (n < 0) {
decrement (sparse_bidirectional_iterator_tag ());
++n;
}
}
BOOST_UBLAS_INLINE
void decrement (sparse_bidirectional_iterator_tag, difference_type n) {
while (n > 0) {
decrement (sparse_bidirectional_iterator_tag ());
--n;
}
while (n < 0) {
increment (sparse_bidirectional_iterator_tag ());
++n;
}
}
BOOST_UBLAS_INLINE
value_type dereference (sparse_bidirectional_iterator_tag) const {
value_type t1 = value_type/*zero*/();
if (it1_ != it1_end_) {
@@ -1920,6 +1973,7 @@ namespace boost { namespace numeric { namespace ublas {
return functor_type::apply (t1, t2);
}
public:
// Arithmetic
BOOST_UBLAS_INLINE
const_iterator1 &operator ++ () {
@@ -1933,12 +1987,12 @@ namespace boost { namespace numeric { namespace ublas {
}
BOOST_UBLAS_INLINE
const_iterator1 &operator += (difference_type n) {
i_ += n, it1_ += n, it2_ += n;
increment (iterator_category (), n);
return *this;
}
BOOST_UBLAS_INLINE
const_iterator1 &operator -= (difference_type n) {
i_ -= n, it1_ -= n, it2_ -= n;
decrement (iterator_category (), n);
return *this;
}
BOOST_UBLAS_INLINE
@@ -2071,14 +2125,23 @@ namespace boost { namespace numeric { namespace ublas {
const const_iterator22_type &it2, const const_iterator22_type &it2_end):
container_const_reference<self_type> (mb), i_ (i), j_ (j), it1_ (it1), it1_end_ (it1_end), it2_ (it2), it2_end_ (it2_end) {}
private:
// Dense access specializations
BOOST_UBLAS_INLINE
void increment (dense_random_access_iterator_tag) {
++ j_, ++ it1_, ++ it2_;
++ j_; ++ it1_; ++ it2_;
}
BOOST_UBLAS_INLINE
void decrement (dense_random_access_iterator_tag) {
-- j_, -- it1_, -- it2_;
-- j_; -- it1_; -- it2_;
}
BOOST_UBLAS_INLINE
void increment (dense_random_access_iterator_tag, difference_type n) {
j_ += n; it1_ += n; it2_ += n;
}
BOOST_UBLAS_INLINE
void decrement (dense_random_access_iterator_tag, difference_type n) {
j_ -= n; it1_ -= n; it2_ -= n;
}
BOOST_UBLAS_INLINE
value_type dereference (dense_random_access_iterator_tag) const {
@@ -2107,6 +2170,28 @@ namespace boost { namespace numeric { namespace ublas {
-- j_;
}
BOOST_UBLAS_INLINE
void increment (packed_random_access_iterator_tag, difference_type n) {
while (n > 0) {
increment (packed_random_access_iterator_tag ());
--n;
}
while (n < 0) {
decrement (packed_random_access_iterator_tag ());
++n;
}
}
BOOST_UBLAS_INLINE
void decrement (packed_random_access_iterator_tag, difference_type n) {
while (n > 0) {
decrement (packed_random_access_iterator_tag ());
--n;
}
while (n < 0) {
increment (packed_random_access_iterator_tag ());
++n;
}
}
BOOST_UBLAS_INLINE
value_type dereference (packed_random_access_iterator_tag) const {
value_type t1 = value_type/*zero*/();
if (it1_ != it1_end_) {
@@ -2161,6 +2246,28 @@ namespace boost { namespace numeric { namespace ublas {
j_ = (std::max) (index1, index2);
}
BOOST_UBLAS_INLINE
void increment (sparse_bidirectional_iterator_tag, difference_type n) {
while (n > 0) {
increment (sparse_bidirectional_iterator_tag ());
--n;
}
while (n < 0) {
decrement (sparse_bidirectional_iterator_tag ());
++n;
}
}
BOOST_UBLAS_INLINE
void decrement (sparse_bidirectional_iterator_tag, difference_type n) {
while (n > 0) {
decrement (sparse_bidirectional_iterator_tag ());
--n;
}
while (n < 0) {
increment (sparse_bidirectional_iterator_tag ());
++n;
}
}
BOOST_UBLAS_INLINE
value_type dereference (sparse_bidirectional_iterator_tag) const {
value_type t1 = value_type/*zero*/();
if (it1_ != it1_end_) {
@@ -2177,6 +2284,7 @@ namespace boost { namespace numeric { namespace ublas {
return functor_type::apply (t1, t2);
}
public:
// Arithmetic
BOOST_UBLAS_INLINE
const_iterator2 &operator ++ () {
@@ -2190,12 +2298,12 @@ namespace boost { namespace numeric { namespace ublas {
}
BOOST_UBLAS_INLINE
const_iterator2 &operator += (difference_type n) {
j_ += n, it1_ += n, it2_ += n;
increment (iterator_category (), n);
return *this;
}
BOOST_UBLAS_INLINE
const_iterator2 &operator -= (difference_type n) {
j_ -= n, it1_ -= n, it2_ -= n;
decrement (iterator_category (), n);
return *this;
}
BOOST_UBLAS_INLINE
@@ -3363,6 +3471,7 @@ namespace boost { namespace numeric { namespace ublas {
container_const_reference<self_type> (mvb), it1_ (it1) {}
#endif
private:
// Dense random access specialization
BOOST_UBLAS_INLINE
value_type dereference (dense_random_access_iterator_tag) const {
@@ -3425,6 +3534,7 @@ namespace boost { namespace numeric { namespace ublas {
#endif
}
public:
// Arithmetic
BOOST_UBLAS_INLINE
const_iterator &operator ++ () {
@@ -3747,6 +3857,7 @@ namespace boost { namespace numeric { namespace ublas {
container_const_reference<self_type> (mvb), it2_ (it2) {}
#endif
private:
// Dense random access specialization
BOOST_UBLAS_INLINE
value_type dereference (dense_random_access_iterator_tag) const {
@@ -3809,6 +3920,7 @@ namespace boost { namespace numeric { namespace ublas {
#endif
}
public:
// Arithmetic
BOOST_UBLAS_INLINE
const_iterator &operator ++ () {
@@ -4170,6 +4282,7 @@ namespace boost { namespace numeric { namespace ublas {
container_const_reference<self_type> (mmb), it1_ (it1), it2_ (it2) {}
#endif
private:
// Random access specialization
BOOST_UBLAS_INLINE
value_type dereference (dense_random_access_iterator_tag) const {
@@ -4234,6 +4347,7 @@ namespace boost { namespace numeric { namespace ublas {
#endif
}
public:
// Arithmetic
BOOST_UBLAS_INLINE
const_iterator1 &operator ++ () {
@@ -4390,6 +4504,7 @@ namespace boost { namespace numeric { namespace ublas {
container_const_reference<self_type> (mmb), it1_ (it1), it2_ (it2) {}
#endif
private:
// Random access specialization
BOOST_UBLAS_INLINE
value_type dereference (dense_random_access_iterator_tag) const {
@@ -4454,6 +4569,7 @@ namespace boost { namespace numeric { namespace ublas {
#endif
}
public:
// Arithmetic
BOOST_UBLAS_INLINE
const_iterator2 &operator ++ () {

View File

@@ -638,14 +638,23 @@ namespace boost { namespace numeric { namespace ublas {
const const_subiterator2_type &it2, const const_subiterator2_type &it2_end):
container_const_reference<self_type> (vb), i_ (i), it1_ (it1), it1_end_ (it1_end), it2_ (it2), it2_end_ (it2_end) {}
private:
// Dense specializations
BOOST_UBLAS_INLINE
void increment (dense_random_access_iterator_tag) {
++ i_, ++ it1_, ++ it2_;
++ i_; ++ it1_; ++ it2_;
}
BOOST_UBLAS_INLINE
void decrement (dense_random_access_iterator_tag) {
-- i_, -- it1_, -- it2_;
-- i_; -- it1_; -- it2_;
}
BOOST_UBLAS_INLINE
void increment (dense_random_access_iterator_tag, difference_type n) {
i_ += n; it1_ += n; it2_ += n;
}
BOOST_UBLAS_INLINE
void decrement (dense_random_access_iterator_tag, difference_type n) {
i_ -= n; it1_ -= n; it2_ -= n;
}
BOOST_UBLAS_INLINE
value_type dereference (dense_random_access_iterator_tag) const {
@@ -674,6 +683,28 @@ namespace boost { namespace numeric { namespace ublas {
-- i_;
}
BOOST_UBLAS_INLINE
void increment (packed_random_access_iterator_tag, difference_type n) {
while (n > 0) {
increment (packed_random_access_iterator_tag ());
--n;
}
while (n < 0) {
decrement (packed_random_access_iterator_tag ());
++n;
}
}
BOOST_UBLAS_INLINE
void decrement (packed_random_access_iterator_tag, difference_type n) {
while (n > 0) {
decrement (packed_random_access_iterator_tag ());
--n;
}
while (n < 0) {
increment (packed_random_access_iterator_tag ());
++n;
}
}
BOOST_UBLAS_INLINE
value_type dereference (packed_random_access_iterator_tag) const {
value_type t1 = value_type/*zero*/();
if (it1_ != it1_end_)
@@ -724,6 +755,28 @@ namespace boost { namespace numeric { namespace ublas {
i_ = (std::max) (index1, index2);
}
BOOST_UBLAS_INLINE
void increment (sparse_bidirectional_iterator_tag, difference_type n) {
while (n > 0) {
increment (sparse_bidirectional_iterator_tag ());
--n;
}
while (n < 0) {
decrement (sparse_bidirectional_iterator_tag ());
++n;
}
}
BOOST_UBLAS_INLINE
void decrement (sparse_bidirectional_iterator_tag, difference_type n) {
while (n > 0) {
decrement (sparse_bidirectional_iterator_tag ());
--n;
}
while (n < 0) {
increment (sparse_bidirectional_iterator_tag ());
++n;
}
}
BOOST_UBLAS_INLINE
value_type dereference (sparse_bidirectional_iterator_tag) const {
value_type t1 = value_type/*zero*/();
if (it1_ != it1_end_)
@@ -736,6 +789,7 @@ namespace boost { namespace numeric { namespace ublas {
return functor_type::apply (t1, t2);
}
public:
// Arithmetic
BOOST_UBLAS_INLINE
const_iterator &operator ++ () {
@@ -749,12 +803,12 @@ namespace boost { namespace numeric { namespace ublas {
}
BOOST_UBLAS_INLINE
const_iterator &operator += (difference_type n) {
i_ += n, it1_ += n, it2_ += n;
increment (iterator_category (), n);
return *this;
}
BOOST_UBLAS_INLINE
const_iterator &operator -= (difference_type n) {
i_ -= n, it1_ -= n, it2_ -= n;
decrement (iterator_category (), n);
return *this;
}
BOOST_UBLAS_INLINE