annotate DEPENDENCIES/generic/include/boost/numeric/ublas/symmetric.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 //
Chris@16 2 // Copyright (c) 2000-2002
Chris@16 3 // Joerg Walter, Mathias Koch
Chris@16 4 //
Chris@16 5 // Distributed under the Boost Software License, Version 1.0. (See
Chris@16 6 // accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8 //
Chris@16 9 // The authors gratefully acknowledge the support of
Chris@16 10 // GeNeSys mbH & Co. KG in producing this work.
Chris@16 11 //
Chris@16 12
Chris@16 13 #ifndef _BOOST_UBLAS_SYMMETRIC_
Chris@16 14 #define _BOOST_UBLAS_SYMMETRIC_
Chris@16 15
Chris@16 16 #include <boost/numeric/ublas/matrix.hpp>
Chris@16 17 #include <boost/numeric/ublas/triangular.hpp>
Chris@16 18 #include <boost/numeric/ublas/detail/temporary.hpp>
Chris@16 19
Chris@16 20 // Iterators based on ideas of Jeremy Siek
Chris@16 21 // Symmetric matrices are square. Thanks to Peter Schmitteckert for spotting this.
Chris@16 22
Chris@16 23 namespace boost { namespace numeric { namespace ublas {
Chris@16 24
Chris@16 25 template<class M>
Chris@16 26 bool is_symmetric (const M &m) {
Chris@16 27 typedef typename M::size_type size_type;
Chris@16 28
Chris@16 29 if (m.size1 () != m.size2 ())
Chris@16 30 return false;
Chris@16 31 size_type size = BOOST_UBLAS_SAME (m.size1 (), m.size2 ());
Chris@16 32 for (size_type i = 0; i < size; ++ i) {
Chris@16 33 for (size_type j = i; j < size; ++ j) {
Chris@16 34 if (m (i, j) != m (j, i))
Chris@16 35 return false;
Chris@16 36 }
Chris@16 37 }
Chris@16 38 return true;
Chris@16 39 }
Chris@16 40
Chris@16 41 // Array based symmetric matrix class
Chris@16 42 template<class T, class TRI, class L, class A>
Chris@16 43 class symmetric_matrix:
Chris@16 44 public matrix_container<symmetric_matrix<T, TRI, L, A> > {
Chris@16 45
Chris@16 46 typedef T *pointer;
Chris@16 47 typedef TRI triangular_type;
Chris@16 48 typedef L layout_type;
Chris@16 49 typedef symmetric_matrix<T, TRI, L, A> self_type;
Chris@16 50 public:
Chris@16 51 #ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
Chris@16 52 using matrix_container<self_type>::operator ();
Chris@16 53 #endif
Chris@16 54 typedef typename A::size_type size_type;
Chris@16 55 typedef typename A::difference_type difference_type;
Chris@16 56 typedef T value_type;
Chris@16 57 typedef const T &const_reference;
Chris@16 58 typedef T &reference;
Chris@16 59 typedef A array_type;
Chris@16 60
Chris@16 61 typedef const matrix_reference<const self_type> const_closure_type;
Chris@16 62 typedef matrix_reference<self_type> closure_type;
Chris@16 63 typedef vector<T, A> vector_temporary_type;
Chris@16 64 typedef matrix<T, L, A> matrix_temporary_type; // general sub-matrix
Chris@16 65 typedef packed_tag storage_category;
Chris@16 66 typedef typename L::orientation_category orientation_category;
Chris@16 67
Chris@16 68 // Construction and destruction
Chris@16 69 BOOST_UBLAS_INLINE
Chris@16 70 symmetric_matrix ():
Chris@16 71 matrix_container<self_type> (),
Chris@16 72 size_ (0), data_ (0) {}
Chris@16 73 BOOST_UBLAS_INLINE
Chris@16 74 symmetric_matrix (size_type size):
Chris@16 75 matrix_container<self_type> (),
Chris@16 76 size_ (BOOST_UBLAS_SAME (size, size)), data_ (triangular_type::packed_size (layout_type (), size, size)) {
Chris@16 77 }
Chris@16 78 BOOST_UBLAS_INLINE
Chris@16 79 symmetric_matrix (size_type size1, size_type size2):
Chris@16 80 matrix_container<self_type> (),
Chris@16 81 size_ (BOOST_UBLAS_SAME (size1, size2)), data_ (triangular_type::packed_size (layout_type (), size1, size2)) {
Chris@16 82 }
Chris@16 83 BOOST_UBLAS_INLINE
Chris@16 84 symmetric_matrix (size_type size, const array_type &data):
Chris@16 85 matrix_container<self_type> (),
Chris@16 86 size_ (size), data_ (data) {}
Chris@16 87 BOOST_UBLAS_INLINE
Chris@16 88 symmetric_matrix (const symmetric_matrix &m):
Chris@16 89 matrix_container<self_type> (),
Chris@16 90 size_ (m.size_), data_ (m.data_) {}
Chris@16 91 template<class AE>
Chris@16 92 BOOST_UBLAS_INLINE
Chris@16 93 symmetric_matrix (const matrix_expression<AE> &ae):
Chris@16 94 matrix_container<self_type> (),
Chris@16 95 size_ (BOOST_UBLAS_SAME (ae ().size1 (), ae ().size2 ())),
Chris@16 96 data_ (triangular_type::packed_size (layout_type (), size_, size_)) {
Chris@16 97 matrix_assign<scalar_assign> (*this, ae);
Chris@16 98 }
Chris@16 99
Chris@16 100 // Accessors
Chris@16 101 BOOST_UBLAS_INLINE
Chris@16 102 size_type size1 () const {
Chris@16 103 return size_;
Chris@16 104 }
Chris@16 105 BOOST_UBLAS_INLINE
Chris@16 106 size_type size2 () const {
Chris@16 107 return size_;
Chris@16 108 }
Chris@16 109
Chris@16 110 // Storage accessors
Chris@16 111 BOOST_UBLAS_INLINE
Chris@16 112 const array_type &data () const {
Chris@16 113 return data_;
Chris@16 114 }
Chris@16 115 BOOST_UBLAS_INLINE
Chris@16 116 array_type &data () {
Chris@16 117 return data_;
Chris@16 118 }
Chris@16 119
Chris@16 120 // Resizing
Chris@16 121 BOOST_UBLAS_INLINE
Chris@16 122 void resize (size_type size, bool preserve = true) {
Chris@16 123 if (preserve) {
Chris@16 124 self_type temporary (size, size);
Chris@16 125 detail::matrix_resize_preserve<layout_type, triangular_type> (*this, temporary);
Chris@16 126 }
Chris@16 127 else {
Chris@16 128 data ().resize (triangular_type::packed_size (layout_type (), size, size));
Chris@16 129 size_ = size;
Chris@16 130 }
Chris@16 131 }
Chris@16 132 BOOST_UBLAS_INLINE
Chris@16 133 void resize (size_type size1, size_type size2, bool preserve = true) {
Chris@16 134 resize (BOOST_UBLAS_SAME (size1, size2), preserve);
Chris@16 135 }
Chris@16 136 BOOST_UBLAS_INLINE
Chris@16 137 void resize_packed_preserve (size_type size) {
Chris@16 138 size_ = BOOST_UBLAS_SAME (size, size);
Chris@16 139 data ().resize (triangular_type::packed_size (layout_type (), size_, size_), value_type ());
Chris@16 140 }
Chris@16 141
Chris@16 142 // Element access
Chris@16 143 BOOST_UBLAS_INLINE
Chris@16 144 const_reference operator () (size_type i, size_type j) const {
Chris@16 145 BOOST_UBLAS_CHECK (i < size_, bad_index ());
Chris@16 146 BOOST_UBLAS_CHECK (j < size_, bad_index ());
Chris@16 147 if (triangular_type::other (i, j))
Chris@16 148 return data () [triangular_type::element (layout_type (), i, size_, j, size_)];
Chris@16 149 else
Chris@16 150 return data () [triangular_type::element (layout_type (), j, size_, i, size_)];
Chris@16 151 }
Chris@16 152 BOOST_UBLAS_INLINE
Chris@16 153 reference at_element (size_type i, size_type j) {
Chris@16 154 BOOST_UBLAS_CHECK (i < size_, bad_index ());
Chris@16 155 BOOST_UBLAS_CHECK (j < size_, bad_index ());
Chris@16 156 return data () [triangular_type::element (layout_type (), i, size_, j, size_)];
Chris@16 157 }
Chris@16 158 BOOST_UBLAS_INLINE
Chris@16 159 reference operator () (size_type i, size_type j) {
Chris@16 160 BOOST_UBLAS_CHECK (i < size_, bad_index ());
Chris@16 161 BOOST_UBLAS_CHECK (j < size_, bad_index ());
Chris@16 162 if (triangular_type::other (i, j))
Chris@16 163 return data () [triangular_type::element (layout_type (), i, size_, j, size_)];
Chris@16 164 else
Chris@16 165 return data () [triangular_type::element (layout_type (), j, size_, i, size_)];
Chris@16 166 }
Chris@16 167
Chris@16 168 // Element assignment
Chris@16 169 BOOST_UBLAS_INLINE
Chris@16 170 reference insert_element (size_type i, size_type j, const_reference t) {
Chris@16 171 return (operator () (i, j) = t);
Chris@16 172 }
Chris@16 173 BOOST_UBLAS_INLINE
Chris@16 174 void erase_element (size_type i, size_type j) {
Chris@16 175 operator () (i, j) = value_type/*zero*/();
Chris@16 176 }
Chris@16 177
Chris@16 178 // Zeroing
Chris@16 179 BOOST_UBLAS_INLINE
Chris@16 180 void clear () {
Chris@16 181 // data ().clear ();
Chris@16 182 std::fill (data ().begin (), data ().end (), value_type/*zero*/());
Chris@16 183 }
Chris@16 184
Chris@16 185 // Assignment
Chris@16 186 BOOST_UBLAS_INLINE
Chris@16 187 symmetric_matrix &operator = (const symmetric_matrix &m) {
Chris@16 188 size_ = m.size_;
Chris@16 189 data () = m.data ();
Chris@16 190 return *this;
Chris@16 191 }
Chris@16 192 BOOST_UBLAS_INLINE
Chris@16 193 symmetric_matrix &assign_temporary (symmetric_matrix &m) {
Chris@16 194 swap (m);
Chris@16 195 return *this;
Chris@16 196 }
Chris@16 197 template<class AE>
Chris@16 198 BOOST_UBLAS_INLINE
Chris@16 199 symmetric_matrix &operator = (const matrix_expression<AE> &ae) {
Chris@16 200 self_type temporary (ae);
Chris@16 201 return assign_temporary (temporary);
Chris@16 202 }
Chris@16 203 template<class AE>
Chris@16 204 BOOST_UBLAS_INLINE
Chris@16 205 symmetric_matrix &assign (const matrix_expression<AE> &ae) {
Chris@16 206 matrix_assign<scalar_assign> (*this, ae);
Chris@16 207 return *this;
Chris@16 208 }
Chris@16 209 template<class AE>
Chris@16 210 BOOST_UBLAS_INLINE
Chris@16 211 symmetric_matrix& operator += (const matrix_expression<AE> &ae) {
Chris@16 212 self_type temporary (*this + ae);
Chris@16 213 return assign_temporary (temporary);
Chris@16 214 }
Chris@16 215 template<class AE>
Chris@16 216 BOOST_UBLAS_INLINE
Chris@16 217 symmetric_matrix &plus_assign (const matrix_expression<AE> &ae) {
Chris@16 218 matrix_assign<scalar_plus_assign> (*this, ae);
Chris@16 219 return *this;
Chris@16 220 }
Chris@16 221 template<class AE>
Chris@16 222 BOOST_UBLAS_INLINE
Chris@16 223 symmetric_matrix& operator -= (const matrix_expression<AE> &ae) {
Chris@16 224 self_type temporary (*this - ae);
Chris@16 225 return assign_temporary (temporary);
Chris@16 226 }
Chris@16 227 template<class AE>
Chris@16 228 BOOST_UBLAS_INLINE
Chris@16 229 symmetric_matrix &minus_assign (const matrix_expression<AE> &ae) {
Chris@16 230 matrix_assign<scalar_minus_assign> (*this, ae);
Chris@16 231 return *this;
Chris@16 232 }
Chris@16 233 template<class AT>
Chris@16 234 BOOST_UBLAS_INLINE
Chris@16 235 symmetric_matrix& operator *= (const AT &at) {
Chris@16 236 matrix_assign_scalar<scalar_multiplies_assign> (*this, at);
Chris@16 237 return *this;
Chris@16 238 }
Chris@16 239 template<class AT>
Chris@16 240 BOOST_UBLAS_INLINE
Chris@16 241 symmetric_matrix& operator /= (const AT &at) {
Chris@16 242 matrix_assign_scalar<scalar_divides_assign> (*this, at);
Chris@16 243 return *this;
Chris@16 244 }
Chris@16 245
Chris@16 246 // Swapping
Chris@16 247 BOOST_UBLAS_INLINE
Chris@16 248 void swap (symmetric_matrix &m) {
Chris@16 249 if (this != &m) {
Chris@16 250 std::swap (size_, m.size_);
Chris@16 251 data ().swap (m.data ());
Chris@16 252 }
Chris@16 253 }
Chris@16 254 BOOST_UBLAS_INLINE
Chris@16 255 friend void swap (symmetric_matrix &m1, symmetric_matrix &m2) {
Chris@16 256 m1.swap (m2);
Chris@16 257 }
Chris@16 258
Chris@16 259 // Iterator types
Chris@16 260 #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
Chris@16 261 typedef indexed_iterator1<self_type, packed_random_access_iterator_tag> iterator1;
Chris@16 262 typedef indexed_iterator2<self_type, packed_random_access_iterator_tag> iterator2;
Chris@16 263 typedef indexed_const_iterator1<self_type, dense_random_access_iterator_tag> const_iterator1;
Chris@16 264 typedef indexed_const_iterator2<self_type, dense_random_access_iterator_tag> const_iterator2;
Chris@16 265 #else
Chris@16 266 class const_iterator1;
Chris@16 267 class iterator1;
Chris@16 268 class const_iterator2;
Chris@16 269 class iterator2;
Chris@16 270 #endif
Chris@16 271 typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
Chris@16 272 typedef reverse_iterator_base1<iterator1> reverse_iterator1;
Chris@16 273 typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
Chris@16 274 typedef reverse_iterator_base2<iterator2> reverse_iterator2;
Chris@16 275
Chris@16 276 // Element lookup
Chris@16 277 BOOST_UBLAS_INLINE
Chris@16 278 const_iterator1 find1 (int /* rank */, size_type i, size_type j) const {
Chris@16 279 return const_iterator1 (*this, i, j);
Chris@16 280 }
Chris@16 281 BOOST_UBLAS_INLINE
Chris@16 282 iterator1 find1 (int rank, size_type i, size_type j) {
Chris@16 283 if (rank == 1)
Chris@16 284 i = triangular_type::mutable_restrict1 (i, j, size1(), size2());
Chris@16 285 if (rank == 0)
Chris@16 286 i = triangular_type::global_mutable_restrict1 (i, size1(), j, size2());
Chris@16 287 return iterator1 (*this, i, j);
Chris@16 288 }
Chris@16 289 BOOST_UBLAS_INLINE
Chris@16 290 const_iterator2 find2 (int /* rank */, size_type i, size_type j) const {
Chris@16 291 return const_iterator2 (*this, i, j);
Chris@16 292 }
Chris@16 293 BOOST_UBLAS_INLINE
Chris@16 294 iterator2 find2 (int rank, size_type i, size_type j) {
Chris@16 295 if (rank == 1)
Chris@16 296 j = triangular_type::mutable_restrict2 (i, j, size1(), size2());
Chris@16 297 if (rank == 0)
Chris@16 298 j = triangular_type::global_mutable_restrict2 (i, size1(), j, size2());
Chris@16 299 return iterator2 (*this, i, j);
Chris@16 300 }
Chris@16 301
Chris@16 302 // Iterators simply are indices.
Chris@16 303
Chris@16 304 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
Chris@16 305 class const_iterator1:
Chris@16 306 public container_const_reference<symmetric_matrix>,
Chris@16 307 public random_access_iterator_base<dense_random_access_iterator_tag,
Chris@16 308 const_iterator1, value_type> {
Chris@16 309 public:
Chris@16 310 typedef typename symmetric_matrix::value_type value_type;
Chris@16 311 typedef typename symmetric_matrix::difference_type difference_type;
Chris@16 312 typedef typename symmetric_matrix::const_reference reference;
Chris@16 313 typedef const typename symmetric_matrix::pointer pointer;
Chris@16 314
Chris@16 315 typedef const_iterator2 dual_iterator_type;
Chris@16 316 typedef const_reverse_iterator2 dual_reverse_iterator_type;
Chris@16 317
Chris@16 318 // Construction and destruction
Chris@16 319 BOOST_UBLAS_INLINE
Chris@16 320 const_iterator1 ():
Chris@16 321 container_const_reference<self_type> (), it1_ (), it2_ () {}
Chris@16 322 BOOST_UBLAS_INLINE
Chris@16 323 const_iterator1 (const self_type &m, size_type it1, size_type it2):
Chris@16 324 container_const_reference<self_type> (m), it1_ (it1), it2_ (it2) {}
Chris@16 325 BOOST_UBLAS_INLINE
Chris@16 326 const_iterator1 (const iterator1 &it):
Chris@16 327 container_const_reference<self_type> (it ()), it1_ (it.it1_), it2_ (it.it2_) {}
Chris@16 328
Chris@16 329 // Arithmetic
Chris@16 330 BOOST_UBLAS_INLINE
Chris@16 331 const_iterator1 &operator ++ () {
Chris@16 332 ++ it1_;
Chris@16 333 return *this;
Chris@16 334 }
Chris@16 335 BOOST_UBLAS_INLINE
Chris@16 336 const_iterator1 &operator -- () {
Chris@16 337 -- it1_;
Chris@16 338 return *this;
Chris@16 339 }
Chris@16 340 BOOST_UBLAS_INLINE
Chris@16 341 const_iterator1 &operator += (difference_type n) {
Chris@16 342 it1_ += n;
Chris@16 343 return *this;
Chris@16 344 }
Chris@16 345 BOOST_UBLAS_INLINE
Chris@16 346 const_iterator1 &operator -= (difference_type n) {
Chris@16 347 it1_ -= n;
Chris@16 348 return *this;
Chris@16 349 }
Chris@16 350 BOOST_UBLAS_INLINE
Chris@16 351 difference_type operator - (const const_iterator1 &it) const {
Chris@16 352 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 353 BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ());
Chris@16 354 return it1_ - it.it1_;
Chris@16 355 }
Chris@16 356
Chris@16 357 // Dereference
Chris@16 358 BOOST_UBLAS_INLINE
Chris@16 359 const_reference operator * () const {
Chris@16 360 return (*this) () (it1_, it2_);
Chris@16 361 }
Chris@16 362 BOOST_UBLAS_INLINE
Chris@16 363 const_reference operator [] (difference_type n) const {
Chris@16 364 return *(*this + n);
Chris@16 365 }
Chris@16 366
Chris@16 367 #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
Chris@16 368 BOOST_UBLAS_INLINE
Chris@16 369 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 370 typename self_type::
Chris@16 371 #endif
Chris@16 372 const_iterator2 begin () const {
Chris@16 373 return (*this) ().find2 (1, it1_, 0);
Chris@16 374 }
Chris@16 375 BOOST_UBLAS_INLINE
Chris@16 376 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 377 typename self_type::
Chris@16 378 #endif
Chris@101 379 const_iterator2 cbegin () const {
Chris@101 380 return begin ();
Chris@101 381 }
Chris@101 382 BOOST_UBLAS_INLINE
Chris@101 383 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 384 typename self_type::
Chris@101 385 #endif
Chris@16 386 const_iterator2 end () const {
Chris@16 387 return (*this) ().find2 (1, it1_, (*this) ().size2 ());
Chris@16 388 }
Chris@16 389 BOOST_UBLAS_INLINE
Chris@16 390 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 391 typename self_type::
Chris@16 392 #endif
Chris@101 393 const_iterator2 cend () const {
Chris@101 394 return end ();
Chris@101 395 }
Chris@101 396 BOOST_UBLAS_INLINE
Chris@101 397 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 398 typename self_type::
Chris@101 399 #endif
Chris@16 400 const_reverse_iterator2 rbegin () const {
Chris@16 401 return const_reverse_iterator2 (end ());
Chris@16 402 }
Chris@16 403 BOOST_UBLAS_INLINE
Chris@16 404 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 405 typename self_type::
Chris@16 406 #endif
Chris@101 407 const_reverse_iterator2 crbegin () const {
Chris@101 408 return rbegin ();
Chris@101 409 }
Chris@101 410 BOOST_UBLAS_INLINE
Chris@101 411 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 412 typename self_type::
Chris@101 413 #endif
Chris@16 414 const_reverse_iterator2 rend () const {
Chris@16 415 return const_reverse_iterator2 (begin ());
Chris@16 416 }
Chris@101 417 BOOST_UBLAS_INLINE
Chris@101 418 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 419 typename self_type::
Chris@101 420 #endif
Chris@101 421 const_reverse_iterator2 crend () const {
Chris@101 422 return rend ();
Chris@101 423 }
Chris@16 424 #endif
Chris@16 425
Chris@16 426 // Indices
Chris@16 427 BOOST_UBLAS_INLINE
Chris@16 428 size_type index1 () const {
Chris@16 429 return it1_;
Chris@16 430 }
Chris@16 431 BOOST_UBLAS_INLINE
Chris@16 432 size_type index2 () const {
Chris@16 433 return it2_;
Chris@16 434 }
Chris@16 435
Chris@16 436 // Assignment
Chris@16 437 BOOST_UBLAS_INLINE
Chris@16 438 const_iterator1 &operator = (const const_iterator1 &it) {
Chris@16 439 container_const_reference<self_type>::assign (&it ());
Chris@16 440 it1_ = it.it1_;
Chris@16 441 it2_ = it.it2_;
Chris@16 442 return *this;
Chris@16 443 }
Chris@16 444
Chris@16 445 // Comparison
Chris@16 446 BOOST_UBLAS_INLINE
Chris@16 447 bool operator == (const const_iterator1 &it) const {
Chris@16 448 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 449 BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ());
Chris@16 450 return it1_ == it.it1_;
Chris@16 451 }
Chris@16 452 BOOST_UBLAS_INLINE
Chris@16 453 bool operator < (const const_iterator1 &it) const {
Chris@16 454 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 455 BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ());
Chris@16 456 return it1_ < it.it1_;
Chris@16 457 }
Chris@16 458
Chris@16 459 private:
Chris@16 460 size_type it1_;
Chris@16 461 size_type it2_;
Chris@16 462 };
Chris@16 463 #endif
Chris@16 464
Chris@16 465 BOOST_UBLAS_INLINE
Chris@16 466 const_iterator1 begin1 () const {
Chris@16 467 return find1 (0, 0, 0);
Chris@16 468 }
Chris@16 469 BOOST_UBLAS_INLINE
Chris@101 470 const_iterator1 cbegin1 () const {
Chris@101 471 return begin1 ();
Chris@101 472 }
Chris@101 473 BOOST_UBLAS_INLINE
Chris@16 474 const_iterator1 end1 () const {
Chris@16 475 return find1 (0, size_, 0);
Chris@16 476 }
Chris@101 477 BOOST_UBLAS_INLINE
Chris@101 478 const_iterator1 cend1 () const {
Chris@101 479 return end1 ();
Chris@101 480 }
Chris@16 481
Chris@16 482 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
Chris@16 483 class iterator1:
Chris@16 484 public container_reference<symmetric_matrix>,
Chris@16 485 public random_access_iterator_base<packed_random_access_iterator_tag,
Chris@16 486 iterator1, value_type> {
Chris@16 487 public:
Chris@16 488 typedef typename symmetric_matrix::value_type value_type;
Chris@16 489 typedef typename symmetric_matrix::difference_type difference_type;
Chris@16 490 typedef typename symmetric_matrix::reference reference;
Chris@16 491 typedef typename symmetric_matrix::pointer pointer;
Chris@16 492 typedef iterator2 dual_iterator_type;
Chris@16 493 typedef reverse_iterator2 dual_reverse_iterator_type;
Chris@16 494
Chris@16 495 // Construction and destruction
Chris@16 496 BOOST_UBLAS_INLINE
Chris@16 497 iterator1 ():
Chris@16 498 container_reference<self_type> (), it1_ (), it2_ () {}
Chris@16 499 BOOST_UBLAS_INLINE
Chris@16 500 iterator1 (self_type &m, size_type it1, size_type it2):
Chris@16 501 container_reference<self_type> (m), it1_ (it1), it2_ (it2) {}
Chris@16 502
Chris@16 503 // Arithmetic
Chris@16 504 BOOST_UBLAS_INLINE
Chris@16 505 iterator1 &operator ++ () {
Chris@16 506 ++ it1_;
Chris@16 507 return *this;
Chris@16 508 }
Chris@16 509 BOOST_UBLAS_INLINE
Chris@16 510 iterator1 &operator -- () {
Chris@16 511 -- it1_;
Chris@16 512 return *this;
Chris@16 513 }
Chris@16 514 BOOST_UBLAS_INLINE
Chris@16 515 iterator1 &operator += (difference_type n) {
Chris@16 516 it1_ += n;
Chris@16 517 return *this;
Chris@16 518 }
Chris@16 519 BOOST_UBLAS_INLINE
Chris@16 520 iterator1 &operator -= (difference_type n) {
Chris@16 521 it1_ -= n;
Chris@16 522 return *this;
Chris@16 523 }
Chris@16 524 BOOST_UBLAS_INLINE
Chris@16 525 difference_type operator - (const iterator1 &it) const {
Chris@16 526 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 527 BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ());
Chris@16 528 return it1_ - it.it1_;
Chris@16 529 }
Chris@16 530
Chris@16 531 // Dereference
Chris@16 532 BOOST_UBLAS_INLINE
Chris@16 533 reference operator * () const {
Chris@16 534 return (*this) () (it1_, it2_);
Chris@16 535 }
Chris@16 536 BOOST_UBLAS_INLINE
Chris@16 537 reference operator [] (difference_type n) const {
Chris@16 538 return *(*this + n);
Chris@16 539 }
Chris@16 540
Chris@16 541 #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
Chris@16 542 BOOST_UBLAS_INLINE
Chris@16 543 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 544 typename self_type::
Chris@16 545 #endif
Chris@16 546 iterator2 begin () const {
Chris@16 547 return (*this) ().find2 (1, it1_, 0);
Chris@16 548 }
Chris@16 549 BOOST_UBLAS_INLINE
Chris@16 550 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 551 typename self_type::
Chris@16 552 #endif
Chris@16 553 iterator2 end () const {
Chris@16 554 return (*this) ().find2 (1, it1_, (*this) ().size2 ());
Chris@16 555 }
Chris@16 556 BOOST_UBLAS_INLINE
Chris@16 557 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 558 typename self_type::
Chris@16 559 #endif
Chris@16 560 reverse_iterator2 rbegin () const {
Chris@16 561 return reverse_iterator2 (end ());
Chris@16 562 }
Chris@16 563 BOOST_UBLAS_INLINE
Chris@16 564 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 565 typename self_type::
Chris@16 566 #endif
Chris@16 567 reverse_iterator2 rend () const {
Chris@16 568 return reverse_iterator2 (begin ());
Chris@16 569 }
Chris@16 570 #endif
Chris@16 571
Chris@16 572 // Indices
Chris@16 573 BOOST_UBLAS_INLINE
Chris@16 574 size_type index1 () const {
Chris@16 575 return it1_;
Chris@16 576 }
Chris@16 577 BOOST_UBLAS_INLINE
Chris@16 578 size_type index2 () const {
Chris@16 579 return it2_;
Chris@16 580 }
Chris@16 581
Chris@16 582 // Assignment
Chris@16 583 BOOST_UBLAS_INLINE
Chris@16 584 iterator1 &operator = (const iterator1 &it) {
Chris@16 585 container_reference<self_type>::assign (&it ());
Chris@16 586 it1_ = it.it1_;
Chris@16 587 it2_ = it.it2_;
Chris@16 588 return *this;
Chris@16 589 }
Chris@16 590
Chris@16 591 // Comparison
Chris@16 592 BOOST_UBLAS_INLINE
Chris@16 593 bool operator == (const iterator1 &it) const {
Chris@16 594 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 595 BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ());
Chris@16 596 return it1_ == it.it1_;
Chris@16 597 }
Chris@16 598 BOOST_UBLAS_INLINE
Chris@16 599 bool operator < (const iterator1 &it) const {
Chris@16 600 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 601 BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ());
Chris@16 602 return it1_ < it.it1_;
Chris@16 603 }
Chris@16 604
Chris@16 605 private:
Chris@16 606 size_type it1_;
Chris@16 607 size_type it2_;
Chris@16 608
Chris@16 609 friend class const_iterator1;
Chris@16 610 };
Chris@16 611 #endif
Chris@16 612
Chris@16 613 BOOST_UBLAS_INLINE
Chris@16 614 iterator1 begin1 () {
Chris@16 615 return find1 (0, 0, 0);
Chris@16 616 }
Chris@16 617 BOOST_UBLAS_INLINE
Chris@16 618 iterator1 end1 () {
Chris@16 619 return find1 (0, size_, 0);
Chris@16 620 }
Chris@16 621
Chris@16 622 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
Chris@16 623 class const_iterator2:
Chris@16 624 public container_const_reference<symmetric_matrix>,
Chris@16 625 public random_access_iterator_base<dense_random_access_iterator_tag,
Chris@16 626 const_iterator2, value_type> {
Chris@16 627 public:
Chris@16 628 typedef typename symmetric_matrix::value_type value_type;
Chris@16 629 typedef typename symmetric_matrix::difference_type difference_type;
Chris@16 630 typedef typename symmetric_matrix::const_reference reference;
Chris@16 631 typedef const typename symmetric_matrix::pointer pointer;
Chris@16 632
Chris@16 633 typedef const_iterator1 dual_iterator_type;
Chris@16 634 typedef const_reverse_iterator1 dual_reverse_iterator_type;
Chris@16 635
Chris@16 636 // Construction and destruction
Chris@16 637 BOOST_UBLAS_INLINE
Chris@16 638 const_iterator2 ():
Chris@16 639 container_const_reference<self_type> (), it1_ (), it2_ () {}
Chris@16 640 BOOST_UBLAS_INLINE
Chris@16 641 const_iterator2 (const self_type &m, size_type it1, size_type it2):
Chris@16 642 container_const_reference<self_type> (m), it1_ (it1), it2_ (it2) {}
Chris@16 643 BOOST_UBLAS_INLINE
Chris@16 644 const_iterator2 (const iterator2 &it):
Chris@16 645 container_const_reference<self_type> (it ()), it1_ (it.it1_), it2_ (it.it2_) {}
Chris@16 646
Chris@16 647 // Arithmetic
Chris@16 648 BOOST_UBLAS_INLINE
Chris@16 649 const_iterator2 &operator ++ () {
Chris@16 650 ++ it2_;
Chris@16 651 return *this;
Chris@16 652 }
Chris@16 653 BOOST_UBLAS_INLINE
Chris@16 654 const_iterator2 &operator -- () {
Chris@16 655 -- it2_;
Chris@16 656 return *this;
Chris@16 657 }
Chris@16 658 BOOST_UBLAS_INLINE
Chris@16 659 const_iterator2 &operator += (difference_type n) {
Chris@16 660 it2_ += n;
Chris@16 661 return *this;
Chris@16 662 }
Chris@16 663 BOOST_UBLAS_INLINE
Chris@16 664 const_iterator2 &operator -= (difference_type n) {
Chris@16 665 it2_ -= n;
Chris@16 666 return *this;
Chris@16 667 }
Chris@16 668 BOOST_UBLAS_INLINE
Chris@16 669 difference_type operator - (const const_iterator2 &it) const {
Chris@16 670 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 671 BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ());
Chris@16 672 return it2_ - it.it2_;
Chris@16 673 }
Chris@16 674
Chris@16 675 // Dereference
Chris@16 676 BOOST_UBLAS_INLINE
Chris@16 677 const_reference operator * () const {
Chris@16 678 return (*this) () (it1_, it2_);
Chris@16 679 }
Chris@16 680 BOOST_UBLAS_INLINE
Chris@16 681 const_reference operator [] (difference_type n) const {
Chris@16 682 return *(*this + n);
Chris@16 683 }
Chris@16 684
Chris@16 685 #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
Chris@16 686 BOOST_UBLAS_INLINE
Chris@16 687 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 688 typename self_type::
Chris@16 689 #endif
Chris@16 690 const_iterator1 begin () const {
Chris@16 691 return (*this) ().find1 (1, 0, it2_);
Chris@16 692 }
Chris@16 693 BOOST_UBLAS_INLINE
Chris@16 694 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 695 typename self_type::
Chris@16 696 #endif
Chris@101 697 const_iterator1 cbegin () const {
Chris@101 698 return begin ();
Chris@101 699 }
Chris@101 700 BOOST_UBLAS_INLINE
Chris@101 701 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 702 typename self_type::
Chris@101 703 #endif
Chris@16 704 const_iterator1 end () const {
Chris@16 705 return (*this) ().find1 (1, (*this) ().size1 (), it2_);
Chris@16 706 }
Chris@16 707 BOOST_UBLAS_INLINE
Chris@16 708 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 709 typename self_type::
Chris@16 710 #endif
Chris@101 711 const_iterator1 cend () const {
Chris@101 712 return end ();
Chris@101 713 }
Chris@101 714 BOOST_UBLAS_INLINE
Chris@101 715 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 716 typename self_type::
Chris@101 717 #endif
Chris@16 718 const_reverse_iterator1 rbegin () const {
Chris@16 719 return const_reverse_iterator1 (end ());
Chris@16 720 }
Chris@16 721 BOOST_UBLAS_INLINE
Chris@16 722 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 723 typename self_type::
Chris@16 724 #endif
Chris@101 725 const_reverse_iterator1 crbegin () const {
Chris@101 726 return rbegin ();
Chris@101 727 }
Chris@101 728 BOOST_UBLAS_INLINE
Chris@101 729 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 730 typename self_type::
Chris@101 731 #endif
Chris@16 732 const_reverse_iterator1 rend () const {
Chris@16 733 return const_reverse_iterator1 (begin ());
Chris@16 734 }
Chris@101 735 BOOST_UBLAS_INLINE
Chris@101 736 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 737 typename self_type::
Chris@101 738 #endif
Chris@101 739 const_reverse_iterator1 crend () const {
Chris@101 740 return rend ();
Chris@101 741 }
Chris@16 742 #endif
Chris@16 743
Chris@16 744 // Indices
Chris@16 745 BOOST_UBLAS_INLINE
Chris@16 746 size_type index1 () const {
Chris@16 747 return it1_;
Chris@16 748 }
Chris@16 749 BOOST_UBLAS_INLINE
Chris@16 750 size_type index2 () const {
Chris@16 751 return it2_;
Chris@16 752 }
Chris@16 753
Chris@16 754 // Assignment
Chris@16 755 BOOST_UBLAS_INLINE
Chris@16 756 const_iterator2 &operator = (const const_iterator2 &it) {
Chris@16 757 container_const_reference<self_type>::assign (&it ());
Chris@16 758 it1_ = it.it1_;
Chris@16 759 it2_ = it.it2_;
Chris@16 760 return *this;
Chris@16 761 }
Chris@16 762
Chris@16 763 // Comparison
Chris@16 764 BOOST_UBLAS_INLINE
Chris@16 765 bool operator == (const const_iterator2 &it) const {
Chris@16 766 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 767 BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ());
Chris@16 768 return it2_ == it.it2_;
Chris@16 769 }
Chris@16 770 BOOST_UBLAS_INLINE
Chris@16 771 bool operator < (const const_iterator2 &it) const {
Chris@16 772 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 773 BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ());
Chris@16 774 return it2_ < it.it2_;
Chris@16 775 }
Chris@16 776
Chris@16 777 private:
Chris@16 778 size_type it1_;
Chris@16 779 size_type it2_;
Chris@16 780 };
Chris@16 781 #endif
Chris@16 782
Chris@16 783 BOOST_UBLAS_INLINE
Chris@16 784 const_iterator2 begin2 () const {
Chris@16 785 return find2 (0, 0, 0);
Chris@16 786 }
Chris@16 787 BOOST_UBLAS_INLINE
Chris@101 788 const_iterator2 cbegin2 () const {
Chris@101 789 return begin2 ();
Chris@101 790 }
Chris@101 791 BOOST_UBLAS_INLINE
Chris@16 792 const_iterator2 end2 () const {
Chris@16 793 return find2 (0, 0, size_);
Chris@16 794 }
Chris@101 795 BOOST_UBLAS_INLINE
Chris@101 796 const_iterator2 cend2 () const {
Chris@101 797 return end2 ();
Chris@101 798 }
Chris@16 799
Chris@16 800 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
Chris@16 801 class iterator2:
Chris@16 802 public container_reference<symmetric_matrix>,
Chris@16 803 public random_access_iterator_base<packed_random_access_iterator_tag,
Chris@16 804 iterator2, value_type> {
Chris@16 805 public:
Chris@16 806 typedef typename symmetric_matrix::value_type value_type;
Chris@16 807 typedef typename symmetric_matrix::difference_type difference_type;
Chris@16 808 typedef typename symmetric_matrix::reference reference;
Chris@16 809 typedef typename symmetric_matrix::pointer pointer;
Chris@16 810
Chris@16 811 typedef iterator1 dual_iterator_type;
Chris@16 812 typedef reverse_iterator1 dual_reverse_iterator_type;
Chris@16 813
Chris@16 814 // Construction and destruction
Chris@16 815 BOOST_UBLAS_INLINE
Chris@16 816 iterator2 ():
Chris@16 817 container_reference<self_type> (), it1_ (), it2_ () {}
Chris@16 818 BOOST_UBLAS_INLINE
Chris@16 819 iterator2 (self_type &m, size_type it1, size_type it2):
Chris@16 820 container_reference<self_type> (m), it1_ (it1), it2_ (it2) {}
Chris@16 821
Chris@16 822 // Arithmetic
Chris@16 823 BOOST_UBLAS_INLINE
Chris@16 824 iterator2 &operator ++ () {
Chris@16 825 ++ it2_;
Chris@16 826 return *this;
Chris@16 827 }
Chris@16 828 BOOST_UBLAS_INLINE
Chris@16 829 iterator2 &operator -- () {
Chris@16 830 -- it2_;
Chris@16 831 return *this;
Chris@16 832 }
Chris@16 833 BOOST_UBLAS_INLINE
Chris@16 834 iterator2 &operator += (difference_type n) {
Chris@16 835 it2_ += n;
Chris@16 836 return *this;
Chris@16 837 }
Chris@16 838 BOOST_UBLAS_INLINE
Chris@16 839 iterator2 &operator -= (difference_type n) {
Chris@16 840 it2_ -= n;
Chris@16 841 return *this;
Chris@16 842 }
Chris@16 843 BOOST_UBLAS_INLINE
Chris@16 844 difference_type operator - (const iterator2 &it) const {
Chris@16 845 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 846 BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ());
Chris@16 847 return it2_ - it.it2_;
Chris@16 848 }
Chris@16 849
Chris@16 850 // Dereference
Chris@16 851 BOOST_UBLAS_INLINE
Chris@16 852 reference operator * () const {
Chris@16 853 return (*this) () (it1_, it2_);
Chris@16 854 }
Chris@16 855 BOOST_UBLAS_INLINE
Chris@16 856 reference operator [] (difference_type n) const {
Chris@16 857 return *(*this + n);
Chris@16 858 }
Chris@16 859
Chris@16 860 #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
Chris@16 861 BOOST_UBLAS_INLINE
Chris@16 862 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 863 typename self_type::
Chris@16 864 #endif
Chris@16 865 iterator1 begin () const {
Chris@16 866 return (*this) ().find1 (1, 0, it2_);
Chris@16 867 }
Chris@16 868 BOOST_UBLAS_INLINE
Chris@16 869 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 870 typename self_type::
Chris@16 871 #endif
Chris@16 872 iterator1 end () const {
Chris@16 873 return (*this) ().find1 (1, (*this) ().size1 (), it2_);
Chris@16 874 }
Chris@16 875 BOOST_UBLAS_INLINE
Chris@16 876 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 877 typename self_type::
Chris@16 878 #endif
Chris@16 879 reverse_iterator1 rbegin () const {
Chris@16 880 return reverse_iterator1 (end ());
Chris@16 881 }
Chris@16 882 BOOST_UBLAS_INLINE
Chris@16 883 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 884 typename self_type::
Chris@16 885 #endif
Chris@16 886 reverse_iterator1 rend () const {
Chris@16 887 return reverse_iterator1 (begin ());
Chris@16 888 }
Chris@16 889 #endif
Chris@16 890
Chris@16 891 // Indices
Chris@16 892 BOOST_UBLAS_INLINE
Chris@16 893 size_type index1 () const {
Chris@16 894 return it1_;
Chris@16 895 }
Chris@16 896 BOOST_UBLAS_INLINE
Chris@16 897 size_type index2 () const {
Chris@16 898 return it2_;
Chris@16 899 }
Chris@16 900
Chris@16 901 // Assignment
Chris@16 902 BOOST_UBLAS_INLINE
Chris@16 903 iterator2 &operator = (const iterator2 &it) {
Chris@16 904 container_reference<self_type>::assign (&it ());
Chris@16 905 it1_ = it.it1_;
Chris@16 906 it2_ = it.it2_;
Chris@16 907 return *this;
Chris@16 908 }
Chris@16 909
Chris@16 910 // Comparison
Chris@16 911 BOOST_UBLAS_INLINE
Chris@16 912 bool operator == (const iterator2 &it) const {
Chris@16 913 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 914 BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ());
Chris@16 915 return it2_ == it.it2_;
Chris@16 916 }
Chris@16 917 BOOST_UBLAS_INLINE
Chris@16 918 bool operator < (const iterator2 &it) const {
Chris@16 919 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 920 BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ());
Chris@16 921 return it2_ < it.it2_;
Chris@16 922 }
Chris@16 923
Chris@16 924 private:
Chris@16 925 size_type it1_;
Chris@16 926 size_type it2_;
Chris@16 927
Chris@16 928 friend class const_iterator2;
Chris@16 929 };
Chris@16 930 #endif
Chris@16 931
Chris@16 932 BOOST_UBLAS_INLINE
Chris@16 933 iterator2 begin2 () {
Chris@16 934 return find2 (0, 0, 0);
Chris@16 935 }
Chris@16 936 BOOST_UBLAS_INLINE
Chris@16 937 iterator2 end2 () {
Chris@16 938 return find2 (0, 0, size_);
Chris@16 939 }
Chris@16 940
Chris@16 941 // Reverse iterators
Chris@16 942
Chris@16 943 BOOST_UBLAS_INLINE
Chris@16 944 const_reverse_iterator1 rbegin1 () const {
Chris@16 945 return const_reverse_iterator1 (end1 ());
Chris@16 946 }
Chris@16 947 BOOST_UBLAS_INLINE
Chris@101 948 const_reverse_iterator1 crbegin1 () const {
Chris@101 949 return rbegin1 ();
Chris@101 950 }
Chris@101 951 BOOST_UBLAS_INLINE
Chris@16 952 const_reverse_iterator1 rend1 () const {
Chris@16 953 return const_reverse_iterator1 (begin1 ());
Chris@16 954 }
Chris@101 955 BOOST_UBLAS_INLINE
Chris@101 956 const_reverse_iterator1 crend1 () const {
Chris@101 957 return rend1 ();
Chris@101 958 }
Chris@16 959
Chris@16 960 BOOST_UBLAS_INLINE
Chris@16 961 reverse_iterator1 rbegin1 () {
Chris@16 962 return reverse_iterator1 (end1 ());
Chris@16 963 }
Chris@16 964 BOOST_UBLAS_INLINE
Chris@16 965 reverse_iterator1 rend1 () {
Chris@16 966 return reverse_iterator1 (begin1 ());
Chris@16 967 }
Chris@16 968
Chris@16 969 BOOST_UBLAS_INLINE
Chris@16 970 const_reverse_iterator2 rbegin2 () const {
Chris@16 971 return const_reverse_iterator2 (end2 ());
Chris@16 972 }
Chris@16 973 BOOST_UBLAS_INLINE
Chris@101 974 const_reverse_iterator2 crbegin2 () const {
Chris@101 975 return rbegin2 ();
Chris@101 976 }
Chris@101 977 BOOST_UBLAS_INLINE
Chris@16 978 const_reverse_iterator2 rend2 () const {
Chris@16 979 return const_reverse_iterator2 (begin2 ());
Chris@16 980 }
Chris@101 981 BOOST_UBLAS_INLINE
Chris@101 982 const_reverse_iterator2 crend2 () const {
Chris@101 983 return rend2 ();
Chris@101 984 }
Chris@16 985 BOOST_UBLAS_INLINE
Chris@16 986 reverse_iterator2 rbegin2 () {
Chris@16 987 return reverse_iterator2 (end2 ());
Chris@16 988 }
Chris@16 989 BOOST_UBLAS_INLINE
Chris@16 990 reverse_iterator2 rend2 () {
Chris@16 991 return reverse_iterator2 (begin2 ());
Chris@16 992 }
Chris@16 993
Chris@16 994 private:
Chris@16 995 size_type size_;
Chris@16 996 array_type data_;
Chris@16 997 };
Chris@16 998
Chris@16 999
Chris@16 1000 // Symmetric matrix adaptor class
Chris@16 1001 template<class M, class TRI>
Chris@16 1002 class symmetric_adaptor:
Chris@16 1003 public matrix_expression<symmetric_adaptor<M, TRI> > {
Chris@16 1004
Chris@16 1005 typedef symmetric_adaptor<M, TRI> self_type;
Chris@16 1006 public:
Chris@16 1007 #ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
Chris@16 1008 using matrix_expression<self_type>::operator ();
Chris@16 1009 #endif
Chris@16 1010 typedef const M const_matrix_type;
Chris@16 1011 typedef M matrix_type;
Chris@16 1012 typedef TRI triangular_type;
Chris@16 1013 typedef typename M::size_type size_type;
Chris@16 1014 typedef typename M::difference_type difference_type;
Chris@16 1015 typedef typename M::value_type value_type;
Chris@16 1016 typedef typename M::const_reference const_reference;
Chris@16 1017 typedef typename boost::mpl::if_<boost::is_const<M>,
Chris@16 1018 typename M::const_reference,
Chris@16 1019 typename M::reference>::type reference;
Chris@16 1020 typedef typename boost::mpl::if_<boost::is_const<M>,
Chris@16 1021 typename M::const_closure_type,
Chris@16 1022 typename M::closure_type>::type matrix_closure_type;
Chris@16 1023 typedef const self_type const_closure_type;
Chris@16 1024 typedef self_type closure_type;
Chris@16 1025 // Replaced by _temporary_traits to avoid type requirements on M
Chris@16 1026 //typedef typename M::vector_temporary_type vector_temporary_type;
Chris@16 1027 //typedef typename M::matrix_temporary_type matrix_temporary_type;
Chris@16 1028 typedef typename storage_restrict_traits<typename M::storage_category,
Chris@16 1029 packed_proxy_tag>::storage_category storage_category;
Chris@16 1030 typedef typename M::orientation_category orientation_category;
Chris@16 1031
Chris@16 1032 // Construction and destruction
Chris@16 1033 BOOST_UBLAS_INLINE
Chris@16 1034 symmetric_adaptor (matrix_type &data):
Chris@16 1035 matrix_expression<self_type> (),
Chris@16 1036 data_ (data) {
Chris@16 1037 BOOST_UBLAS_CHECK (data_.size1 () == data_.size2 (), bad_size ());
Chris@16 1038 }
Chris@16 1039 BOOST_UBLAS_INLINE
Chris@16 1040 symmetric_adaptor (const symmetric_adaptor &m):
Chris@16 1041 matrix_expression<self_type> (),
Chris@16 1042 data_ (m.data_) {
Chris@16 1043 BOOST_UBLAS_CHECK (data_.size1 () == data_.size2 (), bad_size ());
Chris@16 1044 }
Chris@16 1045
Chris@16 1046 // Accessors
Chris@16 1047 BOOST_UBLAS_INLINE
Chris@16 1048 size_type size1 () const {
Chris@16 1049 return data_.size1 ();
Chris@16 1050 }
Chris@16 1051 BOOST_UBLAS_INLINE
Chris@16 1052 size_type size2 () const {
Chris@16 1053 return data_.size2 ();
Chris@16 1054 }
Chris@16 1055
Chris@16 1056 // Storage accessors
Chris@16 1057 BOOST_UBLAS_INLINE
Chris@16 1058 const matrix_closure_type &data () const {
Chris@16 1059 return data_;
Chris@16 1060 }
Chris@16 1061 BOOST_UBLAS_INLINE
Chris@16 1062 matrix_closure_type &data () {
Chris@16 1063 return data_;
Chris@16 1064 }
Chris@16 1065
Chris@16 1066 // Element access
Chris@16 1067 #ifndef BOOST_UBLAS_PROXY_CONST_MEMBER
Chris@16 1068 BOOST_UBLAS_INLINE
Chris@16 1069 const_reference operator () (size_type i, size_type j) const {
Chris@16 1070 BOOST_UBLAS_CHECK (i < size1 (), bad_index ());
Chris@16 1071 BOOST_UBLAS_CHECK (j < size2 (), bad_index ());
Chris@16 1072 if (triangular_type::other (i, j))
Chris@16 1073 return data () (i, j);
Chris@16 1074 else
Chris@16 1075 return data () (j, i);
Chris@16 1076 }
Chris@16 1077 BOOST_UBLAS_INLINE
Chris@16 1078 reference operator () (size_type i, size_type j) {
Chris@16 1079 BOOST_UBLAS_CHECK (i < size1 (), bad_index ());
Chris@16 1080 BOOST_UBLAS_CHECK (j < size2 (), bad_index ());
Chris@16 1081 if (triangular_type::other (i, j))
Chris@16 1082 return data () (i, j);
Chris@16 1083 else
Chris@16 1084 return data () (j, i);
Chris@16 1085 }
Chris@16 1086 #else
Chris@16 1087 BOOST_UBLAS_INLINE
Chris@16 1088 reference operator () (size_type i, size_type j) const {
Chris@16 1089 BOOST_UBLAS_CHECK (i < size1 (), bad_index ());
Chris@16 1090 BOOST_UBLAS_CHECK (j < size2 (), bad_index ());
Chris@16 1091 if (triangular_type::other (i, j))
Chris@16 1092 return data () (i, j);
Chris@16 1093 else
Chris@16 1094 return data () (j, i);
Chris@16 1095 }
Chris@16 1096 #endif
Chris@16 1097
Chris@16 1098 // Assignment
Chris@16 1099 BOOST_UBLAS_INLINE
Chris@16 1100 symmetric_adaptor &operator = (const symmetric_adaptor &m) {
Chris@16 1101 matrix_assign<scalar_assign, triangular_type> (*this, m);
Chris@16 1102 return *this;
Chris@16 1103 }
Chris@16 1104 BOOST_UBLAS_INLINE
Chris@16 1105 symmetric_adaptor &assign_temporary (symmetric_adaptor &m) {
Chris@16 1106 *this = m;
Chris@16 1107 return *this;
Chris@16 1108 }
Chris@16 1109 template<class AE>
Chris@16 1110 BOOST_UBLAS_INLINE
Chris@16 1111 symmetric_adaptor &operator = (const matrix_expression<AE> &ae) {
Chris@16 1112 matrix_assign<scalar_assign, triangular_type> (*this, matrix<value_type> (ae));
Chris@16 1113 return *this;
Chris@16 1114 }
Chris@16 1115 template<class AE>
Chris@16 1116 BOOST_UBLAS_INLINE
Chris@16 1117 symmetric_adaptor &assign (const matrix_expression<AE> &ae) {
Chris@16 1118 matrix_assign<scalar_assign, triangular_type> (*this, ae);
Chris@16 1119 return *this;
Chris@16 1120 }
Chris@16 1121 template<class AE>
Chris@16 1122 BOOST_UBLAS_INLINE
Chris@16 1123 symmetric_adaptor& operator += (const matrix_expression<AE> &ae) {
Chris@16 1124 matrix_assign<scalar_assign, triangular_type> (*this, matrix<value_type> (*this + ae));
Chris@16 1125 return *this;
Chris@16 1126 }
Chris@16 1127 template<class AE>
Chris@16 1128 BOOST_UBLAS_INLINE
Chris@16 1129 symmetric_adaptor &plus_assign (const matrix_expression<AE> &ae) {
Chris@16 1130 matrix_assign<scalar_plus_assign, triangular_type> (*this, ae);
Chris@16 1131 return *this;
Chris@16 1132 }
Chris@16 1133 template<class AE>
Chris@16 1134 BOOST_UBLAS_INLINE
Chris@16 1135 symmetric_adaptor& operator -= (const matrix_expression<AE> &ae) {
Chris@16 1136 matrix_assign<scalar_assign, triangular_type> (*this, matrix<value_type> (*this - ae));
Chris@16 1137 return *this;
Chris@16 1138 }
Chris@16 1139 template<class AE>
Chris@16 1140 BOOST_UBLAS_INLINE
Chris@16 1141 symmetric_adaptor &minus_assign (const matrix_expression<AE> &ae) {
Chris@16 1142 matrix_assign<scalar_minus_assign, triangular_type> (*this, ae);
Chris@16 1143 return *this;
Chris@16 1144 }
Chris@16 1145 template<class AT>
Chris@16 1146 BOOST_UBLAS_INLINE
Chris@16 1147 symmetric_adaptor& operator *= (const AT &at) {
Chris@16 1148 matrix_assign_scalar<scalar_multiplies_assign> (*this, at);
Chris@16 1149 return *this;
Chris@16 1150 }
Chris@16 1151 template<class AT>
Chris@16 1152 BOOST_UBLAS_INLINE
Chris@16 1153 symmetric_adaptor& operator /= (const AT &at) {
Chris@16 1154 matrix_assign_scalar<scalar_divides_assign> (*this, at);
Chris@16 1155 return *this;
Chris@16 1156 }
Chris@16 1157
Chris@16 1158 // Closure comparison
Chris@16 1159 BOOST_UBLAS_INLINE
Chris@16 1160 bool same_closure (const symmetric_adaptor &sa) const {
Chris@16 1161 return (*this).data ().same_closure (sa.data ());
Chris@16 1162 }
Chris@16 1163
Chris@16 1164 // Swapping
Chris@16 1165 BOOST_UBLAS_INLINE
Chris@16 1166 void swap (symmetric_adaptor &m) {
Chris@16 1167 if (this != &m)
Chris@16 1168 matrix_swap<scalar_swap, triangular_type> (*this, m);
Chris@16 1169 }
Chris@16 1170 BOOST_UBLAS_INLINE
Chris@16 1171 friend void swap (symmetric_adaptor &m1, symmetric_adaptor &m2) {
Chris@16 1172 m1.swap (m2);
Chris@16 1173 }
Chris@16 1174
Chris@16 1175 // Iterator types
Chris@16 1176 private:
Chris@16 1177 // Use matrix iterator
Chris@16 1178 typedef typename M::const_iterator1 const_subiterator1_type;
Chris@16 1179 typedef typename boost::mpl::if_<boost::is_const<M>,
Chris@16 1180 typename M::const_iterator1,
Chris@16 1181 typename M::iterator1>::type subiterator1_type;
Chris@16 1182 typedef typename M::const_iterator2 const_subiterator2_type;
Chris@16 1183 typedef typename boost::mpl::if_<boost::is_const<M>,
Chris@16 1184 typename M::const_iterator2,
Chris@16 1185 typename M::iterator2>::type subiterator2_type;
Chris@16 1186
Chris@16 1187 public:
Chris@16 1188 #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
Chris@16 1189 typedef indexed_iterator1<self_type, packed_random_access_iterator_tag> iterator1;
Chris@16 1190 typedef indexed_iterator2<self_type, packed_random_access_iterator_tag> iterator2;
Chris@16 1191 typedef indexed_const_iterator1<self_type, dense_random_access_iterator_tag> const_iterator1;
Chris@16 1192 typedef indexed_const_iterator2<self_type, dense_random_access_iterator_tag> const_iterator2;
Chris@16 1193 #else
Chris@16 1194 class const_iterator1;
Chris@16 1195 class iterator1;
Chris@16 1196 class const_iterator2;
Chris@16 1197 class iterator2;
Chris@16 1198 #endif
Chris@16 1199 typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
Chris@16 1200 typedef reverse_iterator_base1<iterator1> reverse_iterator1;
Chris@16 1201 typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
Chris@16 1202 typedef reverse_iterator_base2<iterator2> reverse_iterator2;
Chris@16 1203
Chris@16 1204 // Element lookup
Chris@16 1205 BOOST_UBLAS_INLINE
Chris@16 1206 const_iterator1 find1 (int rank, size_type i, size_type j) const {
Chris@16 1207 if (triangular_type::other (i, j)) {
Chris@16 1208 if (triangular_type::other (size1 (), j)) {
Chris@16 1209 return const_iterator1 (*this, 0, 0,
Chris@16 1210 data ().find1 (rank, i, j), data ().find1 (rank, size1 (), j),
Chris@16 1211 data ().find2 (rank, size2 (), size1 ()), data ().find2 (rank, size2 (), size1 ()));
Chris@16 1212 } else {
Chris@16 1213 return const_iterator1 (*this, 0, 1,
Chris@16 1214 data ().find1 (rank, i, j), data ().find1 (rank, j, j),
Chris@16 1215 data ().find2 (rank, j, j), data ().find2 (rank, j, size1 ()));
Chris@16 1216 }
Chris@16 1217 } else {
Chris@16 1218 if (triangular_type::other (size1 (), j)) {
Chris@16 1219 return const_iterator1 (*this, 1, 0,
Chris@16 1220 data ().find1 (rank, j, j), data ().find1 (rank, size1 (), j),
Chris@16 1221 data ().find2 (rank, j, i), data ().find2 (rank, j, j));
Chris@16 1222 } else {
Chris@16 1223 return const_iterator1 (*this, 1, 1,
Chris@16 1224 data ().find1 (rank, size1 (), size2 ()), data ().find1 (rank, size1 (), size2 ()),
Chris@16 1225 data ().find2 (rank, j, i), data ().find2 (rank, j, size1 ()));
Chris@16 1226 }
Chris@16 1227 }
Chris@16 1228 }
Chris@16 1229 BOOST_UBLAS_INLINE
Chris@16 1230 iterator1 find1 (int rank, size_type i, size_type j) {
Chris@16 1231 if (rank == 1)
Chris@16 1232 i = triangular_type::mutable_restrict1 (i, j, size1(), size2());
Chris@16 1233 return iterator1 (*this, data ().find1 (rank, i, j));
Chris@16 1234 }
Chris@16 1235 BOOST_UBLAS_INLINE
Chris@16 1236 const_iterator2 find2 (int rank, size_type i, size_type j) const {
Chris@16 1237 if (triangular_type::other (i, j)) {
Chris@16 1238 if (triangular_type::other (i, size2 ())) {
Chris@16 1239 return const_iterator2 (*this, 1, 1,
Chris@16 1240 data ().find1 (rank, size2 (), size1 ()), data ().find1 (rank, size2 (), size1 ()),
Chris@16 1241 data ().find2 (rank, i, j), data ().find2 (rank, i, size2 ()));
Chris@16 1242 } else {
Chris@16 1243 return const_iterator2 (*this, 1, 0,
Chris@16 1244 data ().find1 (rank, i, i), data ().find1 (rank, size2 (), i),
Chris@16 1245 data ().find2 (rank, i, j), data ().find2 (rank, i, i));
Chris@16 1246 }
Chris@16 1247 } else {
Chris@16 1248 if (triangular_type::other (i, size2 ())) {
Chris@16 1249 return const_iterator2 (*this, 0, 1,
Chris@16 1250 data ().find1 (rank, j, i), data ().find1 (rank, i, i),
Chris@16 1251 data ().find2 (rank, i, i), data ().find2 (rank, i, size2 ()));
Chris@16 1252 } else {
Chris@16 1253 return const_iterator2 (*this, 0, 0,
Chris@16 1254 data ().find1 (rank, j, i), data ().find1 (rank, size2 (), i),
Chris@16 1255 data ().find2 (rank, size1 (), size2 ()), data ().find2 (rank, size2 (), size2 ()));
Chris@16 1256 }
Chris@16 1257 }
Chris@16 1258 }
Chris@16 1259 BOOST_UBLAS_INLINE
Chris@16 1260 iterator2 find2 (int rank, size_type i, size_type j) {
Chris@16 1261 if (rank == 1)
Chris@16 1262 j = triangular_type::mutable_restrict2 (i, j, size1(), size2());
Chris@16 1263 return iterator2 (*this, data ().find2 (rank, i, j));
Chris@16 1264 }
Chris@16 1265
Chris@16 1266 // Iterators simply are indices.
Chris@16 1267
Chris@16 1268 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
Chris@16 1269 class const_iterator1:
Chris@16 1270 public container_const_reference<symmetric_adaptor>,
Chris@16 1271 public random_access_iterator_base<typename iterator_restrict_traits<
Chris@16 1272 typename const_subiterator1_type::iterator_category, dense_random_access_iterator_tag>::iterator_category,
Chris@16 1273 const_iterator1, value_type> {
Chris@16 1274 public:
Chris@16 1275 typedef typename const_subiterator1_type::value_type value_type;
Chris@16 1276 typedef typename const_subiterator1_type::difference_type difference_type;
Chris@16 1277 typedef typename const_subiterator1_type::reference reference;
Chris@16 1278 typedef typename const_subiterator1_type::pointer pointer;
Chris@16 1279
Chris@16 1280 typedef const_iterator2 dual_iterator_type;
Chris@16 1281 typedef const_reverse_iterator2 dual_reverse_iterator_type;
Chris@16 1282
Chris@16 1283 // Construction and destruction
Chris@16 1284 BOOST_UBLAS_INLINE
Chris@16 1285 const_iterator1 ():
Chris@16 1286 container_const_reference<self_type> (),
Chris@16 1287 begin_ (-1), end_ (-1), current_ (-1),
Chris@16 1288 it1_begin_ (), it1_end_ (), it1_ (),
Chris@16 1289 it2_begin_ (), it2_end_ (), it2_ () {}
Chris@16 1290 BOOST_UBLAS_INLINE
Chris@16 1291 const_iterator1 (const self_type &m, int begin, int end,
Chris@16 1292 const const_subiterator1_type &it1_begin, const const_subiterator1_type &it1_end,
Chris@16 1293 const const_subiterator2_type &it2_begin, const const_subiterator2_type &it2_end):
Chris@16 1294 container_const_reference<self_type> (m),
Chris@16 1295 begin_ (begin), end_ (end), current_ (begin),
Chris@16 1296 it1_begin_ (it1_begin), it1_end_ (it1_end), it1_ (it1_begin_),
Chris@16 1297 it2_begin_ (it2_begin), it2_end_ (it2_end), it2_ (it2_begin_) {
Chris@16 1298 if (current_ == 0 && it1_ == it1_end_)
Chris@16 1299 current_ = 1;
Chris@16 1300 if (current_ == 1 && it2_ == it2_end_)
Chris@16 1301 current_ = 0;
Chris@16 1302 if ((current_ == 0 && it1_ == it1_end_) ||
Chris@16 1303 (current_ == 1 && it2_ == it2_end_))
Chris@16 1304 current_ = end_;
Chris@16 1305 BOOST_UBLAS_CHECK (current_ == end_ ||
Chris@16 1306 (current_ == 0 && it1_ != it1_end_) ||
Chris@16 1307 (current_ == 1 && it2_ != it2_end_), internal_logic ());
Chris@16 1308 }
Chris@16 1309 // FIXME cannot compile
Chris@16 1310 // iterator1 does not have these members!
Chris@16 1311 BOOST_UBLAS_INLINE
Chris@16 1312 const_iterator1 (const iterator1 &it):
Chris@16 1313 container_const_reference<self_type> (it ()),
Chris@16 1314 begin_ (it.begin_), end_ (it.end_), current_ (it.current_),
Chris@16 1315 it1_begin_ (it.it1_begin_), it1_end_ (it.it1_end_), it1_ (it.it1_),
Chris@16 1316 it2_begin_ (it.it2_begin_), it2_end_ (it.it2_end_), it2_ (it.it2_) {
Chris@16 1317 BOOST_UBLAS_CHECK (current_ == end_ ||
Chris@16 1318 (current_ == 0 && it1_ != it1_end_) ||
Chris@16 1319 (current_ == 1 && it2_ != it2_end_), internal_logic ());
Chris@16 1320 }
Chris@16 1321
Chris@16 1322 // Arithmetic
Chris@16 1323 BOOST_UBLAS_INLINE
Chris@16 1324 const_iterator1 &operator ++ () {
Chris@16 1325 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 1326 if (current_ == 0) {
Chris@16 1327 BOOST_UBLAS_CHECK (it1_ != it1_end_, internal_logic ());
Chris@16 1328 ++ it1_;
Chris@16 1329 if (it1_ == it1_end_ && end_ == 1) {
Chris@16 1330 it2_ = it2_begin_;
Chris@16 1331 current_ = 1;
Chris@16 1332 }
Chris@16 1333 } else /* if (current_ == 1) */ {
Chris@16 1334 BOOST_UBLAS_CHECK (it2_ != it2_end_, internal_logic ());
Chris@16 1335 ++ it2_;
Chris@16 1336 if (it2_ == it2_end_ && end_ == 0) {
Chris@16 1337 it1_ = it1_begin_;
Chris@16 1338 current_ = 0;
Chris@16 1339 }
Chris@16 1340 }
Chris@16 1341 return *this;
Chris@16 1342 }
Chris@16 1343 BOOST_UBLAS_INLINE
Chris@16 1344 const_iterator1 &operator -- () {
Chris@16 1345 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 1346 if (current_ == 0) {
Chris@16 1347 if (it1_ == it1_begin_ && begin_ == 1) {
Chris@16 1348 it2_ = it2_end_;
Chris@16 1349 BOOST_UBLAS_CHECK (it2_ != it2_begin_, internal_logic ());
Chris@16 1350 -- it2_;
Chris@16 1351 current_ = 1;
Chris@16 1352 } else {
Chris@16 1353 -- it1_;
Chris@16 1354 }
Chris@16 1355 } else /* if (current_ == 1) */ {
Chris@16 1356 if (it2_ == it2_begin_ && begin_ == 0) {
Chris@16 1357 it1_ = it1_end_;
Chris@16 1358 BOOST_UBLAS_CHECK (it1_ != it1_begin_, internal_logic ());
Chris@16 1359 -- it1_;
Chris@16 1360 current_ = 0;
Chris@16 1361 } else {
Chris@16 1362 -- it2_;
Chris@16 1363 }
Chris@16 1364 }
Chris@16 1365 return *this;
Chris@16 1366 }
Chris@16 1367 BOOST_UBLAS_INLINE
Chris@16 1368 const_iterator1 &operator += (difference_type n) {
Chris@16 1369 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 1370 if (current_ == 0) {
Chris@16 1371 size_type d = (std::min) (n, it1_end_ - it1_);
Chris@16 1372 it1_ += d;
Chris@16 1373 n -= d;
Chris@16 1374 if (n > 0 || (end_ == 1 && it1_ == it1_end_)) {
Chris@16 1375 BOOST_UBLAS_CHECK (end_ == 1, external_logic ());
Chris@16 1376 d = (std::min) (n, it2_end_ - it2_begin_);
Chris@16 1377 it2_ = it2_begin_ + d;
Chris@16 1378 n -= d;
Chris@16 1379 current_ = 1;
Chris@16 1380 }
Chris@16 1381 } else /* if (current_ == 1) */ {
Chris@16 1382 size_type d = (std::min) (n, it2_end_ - it2_);
Chris@16 1383 it2_ += d;
Chris@16 1384 n -= d;
Chris@16 1385 if (n > 0 || (end_ == 0 && it2_ == it2_end_)) {
Chris@16 1386 BOOST_UBLAS_CHECK (end_ == 0, external_logic ());
Chris@16 1387 d = (std::min) (n, it1_end_ - it1_begin_);
Chris@16 1388 it1_ = it1_begin_ + d;
Chris@16 1389 n -= d;
Chris@16 1390 current_ = 0;
Chris@16 1391 }
Chris@16 1392 }
Chris@16 1393 BOOST_UBLAS_CHECK (n == 0, external_logic ());
Chris@16 1394 return *this;
Chris@16 1395 }
Chris@16 1396 BOOST_UBLAS_INLINE
Chris@16 1397 const_iterator1 &operator -= (difference_type n) {
Chris@16 1398 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 1399 if (current_ == 0) {
Chris@16 1400 size_type d = (std::min) (n, it1_ - it1_begin_);
Chris@16 1401 it1_ -= d;
Chris@16 1402 n -= d;
Chris@16 1403 if (n > 0) {
Chris@16 1404 BOOST_UBLAS_CHECK (end_ == 1, external_logic ());
Chris@16 1405 d = (std::min) (n, it2_end_ - it2_begin_);
Chris@16 1406 it2_ = it2_end_ - d;
Chris@16 1407 n -= d;
Chris@16 1408 current_ = 1;
Chris@16 1409 }
Chris@16 1410 } else /* if (current_ == 1) */ {
Chris@16 1411 size_type d = (std::min) (n, it2_ - it2_begin_);
Chris@16 1412 it2_ -= d;
Chris@16 1413 n -= d;
Chris@16 1414 if (n > 0) {
Chris@16 1415 BOOST_UBLAS_CHECK (end_ == 0, external_logic ());
Chris@16 1416 d = (std::min) (n, it1_end_ - it1_begin_);
Chris@16 1417 it1_ = it1_end_ - d;
Chris@16 1418 n -= d;
Chris@16 1419 current_ = 0;
Chris@16 1420 }
Chris@16 1421 }
Chris@16 1422 BOOST_UBLAS_CHECK (n == 0, external_logic ());
Chris@16 1423 return *this;
Chris@16 1424 }
Chris@16 1425 BOOST_UBLAS_INLINE
Chris@16 1426 difference_type operator - (const const_iterator1 &it) const {
Chris@16 1427 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 1428 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 1429 BOOST_UBLAS_CHECK (it.current_ == 0 || it.current_ == 1, internal_logic ());
Chris@16 1430 BOOST_UBLAS_CHECK (/* begin_ == it.begin_ && */ end_ == it.end_, internal_logic ());
Chris@16 1431 if (current_ == 0 && it.current_ == 0) {
Chris@16 1432 return it1_ - it.it1_;
Chris@16 1433 } else if (current_ == 0 && it.current_ == 1) {
Chris@16 1434 if (end_ == 1 && it.end_ == 1) {
Chris@16 1435 return (it1_ - it.it1_end_) + (it.it2_begin_ - it.it2_);
Chris@16 1436 } else /* if (end_ == 0 && it.end_ == 0) */ {
Chris@16 1437 return (it1_ - it.it1_begin_) + (it.it2_end_ - it.it2_);
Chris@16 1438 }
Chris@16 1439
Chris@16 1440 } else if (current_ == 1 && it.current_ == 0) {
Chris@16 1441 if (end_ == 1 && it.end_ == 1) {
Chris@16 1442 return (it2_ - it.it2_begin_) + (it.it1_end_ - it.it1_);
Chris@16 1443 } else /* if (end_ == 0 && it.end_ == 0) */ {
Chris@16 1444 return (it2_ - it.it2_end_) + (it.it1_begin_ - it.it1_);
Chris@16 1445 }
Chris@16 1446 }
Chris@16 1447 /* current_ == 1 && it.current_ == 1 */ {
Chris@16 1448 return it2_ - it.it2_;
Chris@16 1449 }
Chris@16 1450 }
Chris@16 1451
Chris@16 1452 // Dereference
Chris@16 1453 BOOST_UBLAS_INLINE
Chris@16 1454 const_reference operator * () const {
Chris@16 1455 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 1456 if (current_ == 0) {
Chris@16 1457 BOOST_UBLAS_CHECK (it1_ != it1_end_, internal_logic ());
Chris@16 1458 return *it1_;
Chris@16 1459 } else /* if (current_ == 1) */ {
Chris@16 1460 BOOST_UBLAS_CHECK (it2_ != it2_end_, internal_logic ());
Chris@16 1461 return *it2_;
Chris@16 1462 }
Chris@16 1463 }
Chris@16 1464 BOOST_UBLAS_INLINE
Chris@16 1465 const_reference operator [] (difference_type n) const {
Chris@16 1466 return *(*this + n);
Chris@16 1467 }
Chris@16 1468
Chris@16 1469 #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
Chris@16 1470 BOOST_UBLAS_INLINE
Chris@16 1471 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 1472 typename self_type::
Chris@16 1473 #endif
Chris@16 1474 const_iterator2 begin () const {
Chris@16 1475 return (*this) ().find2 (1, index1 (), 0);
Chris@16 1476 }
Chris@16 1477 BOOST_UBLAS_INLINE
Chris@16 1478 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 1479 typename self_type::
Chris@16 1480 #endif
Chris@101 1481 const_iterator2 cbegin () const {
Chris@101 1482 return begin ();
Chris@101 1483 }
Chris@101 1484 BOOST_UBLAS_INLINE
Chris@101 1485 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 1486 typename self_type::
Chris@101 1487 #endif
Chris@16 1488 const_iterator2 end () const {
Chris@16 1489 return (*this) ().find2 (1, index1 (), (*this) ().size2 ());
Chris@16 1490 }
Chris@16 1491 BOOST_UBLAS_INLINE
Chris@16 1492 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 1493 typename self_type::
Chris@16 1494 #endif
Chris@101 1495 const_iterator2 cend () const {
Chris@101 1496 return end ();
Chris@101 1497 }
Chris@101 1498 BOOST_UBLAS_INLINE
Chris@101 1499 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 1500 typename self_type::
Chris@101 1501 #endif
Chris@16 1502 const_reverse_iterator2 rbegin () const {
Chris@16 1503 return const_reverse_iterator2 (end ());
Chris@16 1504 }
Chris@16 1505 BOOST_UBLAS_INLINE
Chris@16 1506 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 1507 typename self_type::
Chris@16 1508 #endif
Chris@101 1509 const_reverse_iterator2 crbegin () const {
Chris@101 1510 return rbegin ();
Chris@101 1511 }
Chris@101 1512 BOOST_UBLAS_INLINE
Chris@101 1513 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 1514 typename self_type::
Chris@101 1515 #endif
Chris@16 1516 const_reverse_iterator2 rend () const {
Chris@16 1517 return const_reverse_iterator2 (begin ());
Chris@16 1518 }
Chris@101 1519 BOOST_UBLAS_INLINE
Chris@101 1520 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 1521 typename self_type::
Chris@101 1522 #endif
Chris@101 1523 const_reverse_iterator2 crend () const {
Chris@101 1524 return rend ();
Chris@101 1525 }
Chris@16 1526 #endif
Chris@16 1527
Chris@16 1528 // Indices
Chris@16 1529 BOOST_UBLAS_INLINE
Chris@16 1530 size_type index1 () const {
Chris@16 1531 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 1532 if (current_ == 0) {
Chris@16 1533 BOOST_UBLAS_CHECK (it1_ != it1_end_, internal_logic ());
Chris@16 1534 return it1_.index1 ();
Chris@16 1535 } else /* if (current_ == 1) */ {
Chris@16 1536 BOOST_UBLAS_CHECK (it2_ != it2_end_, internal_logic ());
Chris@16 1537 return it2_.index2 ();
Chris@16 1538 }
Chris@16 1539 }
Chris@16 1540 BOOST_UBLAS_INLINE
Chris@16 1541 size_type index2 () const {
Chris@16 1542 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 1543 if (current_ == 0) {
Chris@16 1544 BOOST_UBLAS_CHECK (it1_ != it1_end_, internal_logic ());
Chris@16 1545 return it1_.index2 ();
Chris@16 1546 } else /* if (current_ == 1) */ {
Chris@16 1547 BOOST_UBLAS_CHECK (it2_ != it2_end_, internal_logic ());
Chris@16 1548 return it2_.index1 ();
Chris@16 1549 }
Chris@16 1550 }
Chris@16 1551
Chris@16 1552 // Assignment
Chris@16 1553 BOOST_UBLAS_INLINE
Chris@16 1554 const_iterator1 &operator = (const const_iterator1 &it) {
Chris@16 1555 container_const_reference<self_type>::assign (&it ());
Chris@16 1556 begin_ = it.begin_;
Chris@16 1557 end_ = it.end_;
Chris@16 1558 current_ = it.current_;
Chris@16 1559 it1_begin_ = it.it1_begin_;
Chris@16 1560 it1_end_ = it.it1_end_;
Chris@16 1561 it1_ = it.it1_;
Chris@16 1562 it2_begin_ = it.it2_begin_;
Chris@16 1563 it2_end_ = it.it2_end_;
Chris@16 1564 it2_ = it.it2_;
Chris@16 1565 return *this;
Chris@16 1566 }
Chris@16 1567
Chris@16 1568 // Comparison
Chris@16 1569 BOOST_UBLAS_INLINE
Chris@16 1570 bool operator == (const const_iterator1 &it) const {
Chris@16 1571 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 1572 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 1573 BOOST_UBLAS_CHECK (it.current_ == 0 || it.current_ == 1, internal_logic ());
Chris@16 1574 BOOST_UBLAS_CHECK (/* begin_ == it.begin_ && */ end_ == it.end_, internal_logic ());
Chris@16 1575 return (current_ == 0 && it.current_ == 0 && it1_ == it.it1_) ||
Chris@16 1576 (current_ == 1 && it.current_ == 1 && it2_ == it.it2_);
Chris@16 1577 }
Chris@16 1578 BOOST_UBLAS_INLINE
Chris@16 1579 bool operator < (const const_iterator1 &it) const {
Chris@16 1580 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 1581 return it - *this > 0;
Chris@16 1582 }
Chris@16 1583
Chris@16 1584 private:
Chris@16 1585 int begin_;
Chris@16 1586 int end_;
Chris@16 1587 int current_;
Chris@16 1588 const_subiterator1_type it1_begin_;
Chris@16 1589 const_subiterator1_type it1_end_;
Chris@16 1590 const_subiterator1_type it1_;
Chris@16 1591 const_subiterator2_type it2_begin_;
Chris@16 1592 const_subiterator2_type it2_end_;
Chris@16 1593 const_subiterator2_type it2_;
Chris@16 1594 };
Chris@16 1595 #endif
Chris@16 1596
Chris@16 1597 BOOST_UBLAS_INLINE
Chris@16 1598 const_iterator1 begin1 () const {
Chris@16 1599 return find1 (0, 0, 0);
Chris@16 1600 }
Chris@16 1601 BOOST_UBLAS_INLINE
Chris@101 1602 const_iterator1 cbegin1 () const {
Chris@101 1603 return begin1 ();
Chris@101 1604 }
Chris@101 1605 BOOST_UBLAS_INLINE
Chris@16 1606 const_iterator1 end1 () const {
Chris@16 1607 return find1 (0, size1 (), 0);
Chris@16 1608 }
Chris@101 1609 BOOST_UBLAS_INLINE
Chris@101 1610 const_iterator1 cend1 () const {
Chris@101 1611 return end1 ();
Chris@101 1612 }
Chris@16 1613
Chris@16 1614 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
Chris@16 1615 class iterator1:
Chris@16 1616 public container_reference<symmetric_adaptor>,
Chris@16 1617 public random_access_iterator_base<typename iterator_restrict_traits<
Chris@16 1618 typename subiterator1_type::iterator_category, packed_random_access_iterator_tag>::iterator_category,
Chris@16 1619 iterator1, value_type> {
Chris@16 1620 public:
Chris@16 1621 typedef typename subiterator1_type::value_type value_type;
Chris@16 1622 typedef typename subiterator1_type::difference_type difference_type;
Chris@16 1623 typedef typename subiterator1_type::reference reference;
Chris@16 1624 typedef typename subiterator1_type::pointer pointer;
Chris@16 1625
Chris@16 1626 typedef iterator2 dual_iterator_type;
Chris@16 1627 typedef reverse_iterator2 dual_reverse_iterator_type;
Chris@16 1628
Chris@16 1629 // Construction and destruction
Chris@16 1630 BOOST_UBLAS_INLINE
Chris@16 1631 iterator1 ():
Chris@16 1632 container_reference<self_type> (), it1_ () {}
Chris@16 1633 BOOST_UBLAS_INLINE
Chris@16 1634 iterator1 (self_type &m, const subiterator1_type &it1):
Chris@16 1635 container_reference<self_type> (m), it1_ (it1) {}
Chris@16 1636
Chris@16 1637 // Arithmetic
Chris@16 1638 BOOST_UBLAS_INLINE
Chris@16 1639 iterator1 &operator ++ () {
Chris@16 1640 ++ it1_;
Chris@16 1641 return *this;
Chris@16 1642 }
Chris@16 1643 BOOST_UBLAS_INLINE
Chris@16 1644 iterator1 &operator -- () {
Chris@16 1645 -- it1_;
Chris@16 1646 return *this;
Chris@16 1647 }
Chris@16 1648 BOOST_UBLAS_INLINE
Chris@16 1649 iterator1 &operator += (difference_type n) {
Chris@16 1650 it1_ += n;
Chris@16 1651 return *this;
Chris@16 1652 }
Chris@16 1653 BOOST_UBLAS_INLINE
Chris@16 1654 iterator1 &operator -= (difference_type n) {
Chris@16 1655 it1_ -= n;
Chris@16 1656 return *this;
Chris@16 1657 }
Chris@16 1658 BOOST_UBLAS_INLINE
Chris@16 1659 difference_type operator - (const iterator1 &it) const {
Chris@16 1660 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 1661 return it1_ - it.it1_;
Chris@16 1662 }
Chris@16 1663
Chris@16 1664 // Dereference
Chris@16 1665 BOOST_UBLAS_INLINE
Chris@16 1666 reference operator * () const {
Chris@16 1667 return *it1_;
Chris@16 1668 }
Chris@16 1669 BOOST_UBLAS_INLINE
Chris@16 1670 reference operator [] (difference_type n) const {
Chris@16 1671 return *(*this + n);
Chris@16 1672 }
Chris@16 1673
Chris@16 1674 #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
Chris@16 1675 BOOST_UBLAS_INLINE
Chris@16 1676 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 1677 typename self_type::
Chris@16 1678 #endif
Chris@16 1679 iterator2 begin () const {
Chris@16 1680 return (*this) ().find2 (1, index1 (), 0);
Chris@16 1681 }
Chris@16 1682 BOOST_UBLAS_INLINE
Chris@16 1683 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 1684 typename self_type::
Chris@16 1685 #endif
Chris@16 1686 iterator2 end () const {
Chris@16 1687 return (*this) ().find2 (1, index1 (), (*this) ().size2 ());
Chris@16 1688 }
Chris@16 1689 BOOST_UBLAS_INLINE
Chris@16 1690 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 1691 typename self_type::
Chris@16 1692 #endif
Chris@16 1693 reverse_iterator2 rbegin () const {
Chris@16 1694 return reverse_iterator2 (end ());
Chris@16 1695 }
Chris@16 1696 BOOST_UBLAS_INLINE
Chris@16 1697 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 1698 typename self_type::
Chris@16 1699 #endif
Chris@16 1700 reverse_iterator2 rend () const {
Chris@16 1701 return reverse_iterator2 (begin ());
Chris@16 1702 }
Chris@16 1703 #endif
Chris@16 1704
Chris@16 1705 // Indices
Chris@16 1706 BOOST_UBLAS_INLINE
Chris@16 1707 size_type index1 () const {
Chris@16 1708 return it1_.index1 ();
Chris@16 1709 }
Chris@16 1710 BOOST_UBLAS_INLINE
Chris@16 1711 size_type index2 () const {
Chris@16 1712 return it1_.index2 ();
Chris@16 1713 }
Chris@16 1714
Chris@16 1715 // Assignment
Chris@16 1716 BOOST_UBLAS_INLINE
Chris@16 1717 iterator1 &operator = (const iterator1 &it) {
Chris@16 1718 container_reference<self_type>::assign (&it ());
Chris@16 1719 it1_ = it.it1_;
Chris@16 1720 return *this;
Chris@16 1721 }
Chris@16 1722
Chris@16 1723 // Comparison
Chris@16 1724 BOOST_UBLAS_INLINE
Chris@16 1725 bool operator == (const iterator1 &it) const {
Chris@16 1726 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 1727 return it1_ == it.it1_;
Chris@16 1728 }
Chris@16 1729 BOOST_UBLAS_INLINE
Chris@16 1730 bool operator < (const iterator1 &it) const {
Chris@16 1731 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 1732 return it1_ < it.it1_;
Chris@16 1733 }
Chris@16 1734
Chris@16 1735 private:
Chris@16 1736 subiterator1_type it1_;
Chris@16 1737
Chris@16 1738 friend class const_iterator1;
Chris@16 1739 };
Chris@16 1740 #endif
Chris@16 1741
Chris@16 1742 BOOST_UBLAS_INLINE
Chris@16 1743 iterator1 begin1 () {
Chris@16 1744 return find1 (0, 0, 0);
Chris@16 1745 }
Chris@16 1746 BOOST_UBLAS_INLINE
Chris@16 1747 iterator1 end1 () {
Chris@16 1748 return find1 (0, size1 (), 0);
Chris@16 1749 }
Chris@16 1750
Chris@16 1751 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
Chris@16 1752 class const_iterator2:
Chris@16 1753 public container_const_reference<symmetric_adaptor>,
Chris@16 1754 public random_access_iterator_base<typename iterator_restrict_traits<
Chris@16 1755 typename const_subiterator2_type::iterator_category, dense_random_access_iterator_tag>::iterator_category,
Chris@16 1756 const_iterator2, value_type> {
Chris@16 1757 public:
Chris@16 1758 typedef typename const_subiterator2_type::value_type value_type;
Chris@16 1759 typedef typename const_subiterator2_type::difference_type difference_type;
Chris@16 1760 typedef typename const_subiterator2_type::reference reference;
Chris@16 1761 typedef typename const_subiterator2_type::pointer pointer;
Chris@16 1762
Chris@16 1763 typedef const_iterator1 dual_iterator_type;
Chris@16 1764 typedef const_reverse_iterator1 dual_reverse_iterator_type;
Chris@16 1765
Chris@16 1766 // Construction and destruction
Chris@16 1767 BOOST_UBLAS_INLINE
Chris@16 1768 const_iterator2 ():
Chris@16 1769 container_const_reference<self_type> (),
Chris@16 1770 begin_ (-1), end_ (-1), current_ (-1),
Chris@16 1771 it1_begin_ (), it1_end_ (), it1_ (),
Chris@16 1772 it2_begin_ (), it2_end_ (), it2_ () {}
Chris@16 1773 BOOST_UBLAS_INLINE
Chris@16 1774 const_iterator2 (const self_type &m, int begin, int end,
Chris@16 1775 const const_subiterator1_type &it1_begin, const const_subiterator1_type &it1_end,
Chris@16 1776 const const_subiterator2_type &it2_begin, const const_subiterator2_type &it2_end):
Chris@16 1777 container_const_reference<self_type> (m),
Chris@16 1778 begin_ (begin), end_ (end), current_ (begin),
Chris@16 1779 it1_begin_ (it1_begin), it1_end_ (it1_end), it1_ (it1_begin_),
Chris@16 1780 it2_begin_ (it2_begin), it2_end_ (it2_end), it2_ (it2_begin_) {
Chris@16 1781 if (current_ == 0 && it1_ == it1_end_)
Chris@16 1782 current_ = 1;
Chris@16 1783 if (current_ == 1 && it2_ == it2_end_)
Chris@16 1784 current_ = 0;
Chris@16 1785 if ((current_ == 0 && it1_ == it1_end_) ||
Chris@16 1786 (current_ == 1 && it2_ == it2_end_))
Chris@16 1787 current_ = end_;
Chris@16 1788 BOOST_UBLAS_CHECK (current_ == end_ ||
Chris@16 1789 (current_ == 0 && it1_ != it1_end_) ||
Chris@16 1790 (current_ == 1 && it2_ != it2_end_), internal_logic ());
Chris@16 1791 }
Chris@16 1792 // FIXME cannot compiler
Chris@16 1793 // iterator2 does not have these members!
Chris@16 1794 BOOST_UBLAS_INLINE
Chris@16 1795 const_iterator2 (const iterator2 &it):
Chris@16 1796 container_const_reference<self_type> (it ()),
Chris@16 1797 begin_ (it.begin_), end_ (it.end_), current_ (it.current_),
Chris@16 1798 it1_begin_ (it.it1_begin_), it1_end_ (it.it1_end_), it1_ (it.it1_),
Chris@16 1799 it2_begin_ (it.it2_begin_), it2_end_ (it.it2_end_), it2_ (it.it2_) {
Chris@16 1800 BOOST_UBLAS_CHECK (current_ == end_ ||
Chris@16 1801 (current_ == 0 && it1_ != it1_end_) ||
Chris@16 1802 (current_ == 1 && it2_ != it2_end_), internal_logic ());
Chris@16 1803 }
Chris@16 1804
Chris@16 1805 // Arithmetic
Chris@16 1806 BOOST_UBLAS_INLINE
Chris@16 1807 const_iterator2 &operator ++ () {
Chris@16 1808 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 1809 if (current_ == 0) {
Chris@16 1810 BOOST_UBLAS_CHECK (it1_ != it1_end_, internal_logic ());
Chris@16 1811 ++ it1_;
Chris@16 1812 if (it1_ == it1_end_ && end_ == 1) {
Chris@16 1813 it2_ = it2_begin_;
Chris@16 1814 current_ = 1;
Chris@16 1815 }
Chris@16 1816 } else /* if (current_ == 1) */ {
Chris@16 1817 BOOST_UBLAS_CHECK (it2_ != it2_end_, internal_logic ());
Chris@16 1818 ++ it2_;
Chris@16 1819 if (it2_ == it2_end_ && end_ == 0) {
Chris@16 1820 it1_ = it1_begin_;
Chris@16 1821 current_ = 0;
Chris@16 1822 }
Chris@16 1823 }
Chris@16 1824 return *this;
Chris@16 1825 }
Chris@16 1826 BOOST_UBLAS_INLINE
Chris@16 1827 const_iterator2 &operator -- () {
Chris@16 1828 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 1829 if (current_ == 0) {
Chris@16 1830 if (it1_ == it1_begin_ && begin_ == 1) {
Chris@16 1831 it2_ = it2_end_;
Chris@16 1832 BOOST_UBLAS_CHECK (it2_ != it2_begin_, internal_logic ());
Chris@16 1833 -- it2_;
Chris@16 1834 current_ = 1;
Chris@16 1835 } else {
Chris@16 1836 -- it1_;
Chris@16 1837 }
Chris@16 1838 } else /* if (current_ == 1) */ {
Chris@16 1839 if (it2_ == it2_begin_ && begin_ == 0) {
Chris@16 1840 it1_ = it1_end_;
Chris@16 1841 BOOST_UBLAS_CHECK (it1_ != it1_begin_, internal_logic ());
Chris@16 1842 -- it1_;
Chris@16 1843 current_ = 0;
Chris@16 1844 } else {
Chris@16 1845 -- it2_;
Chris@16 1846 }
Chris@16 1847 }
Chris@16 1848 return *this;
Chris@16 1849 }
Chris@16 1850 BOOST_UBLAS_INLINE
Chris@16 1851 const_iterator2 &operator += (difference_type n) {
Chris@16 1852 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 1853 if (current_ == 0) {
Chris@16 1854 size_type d = (std::min) (n, it1_end_ - it1_);
Chris@16 1855 it1_ += d;
Chris@16 1856 n -= d;
Chris@16 1857 if (n > 0 || (end_ == 1 && it1_ == it1_end_)) {
Chris@16 1858 BOOST_UBLAS_CHECK (end_ == 1, external_logic ());
Chris@16 1859 d = (std::min) (n, it2_end_ - it2_begin_);
Chris@16 1860 it2_ = it2_begin_ + d;
Chris@16 1861 n -= d;
Chris@16 1862 current_ = 1;
Chris@16 1863 }
Chris@16 1864 } else /* if (current_ == 1) */ {
Chris@16 1865 size_type d = (std::min) (n, it2_end_ - it2_);
Chris@16 1866 it2_ += d;
Chris@16 1867 n -= d;
Chris@16 1868 if (n > 0 || (end_ == 0 && it2_ == it2_end_)) {
Chris@16 1869 BOOST_UBLAS_CHECK (end_ == 0, external_logic ());
Chris@16 1870 d = (std::min) (n, it1_end_ - it1_begin_);
Chris@16 1871 it1_ = it1_begin_ + d;
Chris@16 1872 n -= d;
Chris@16 1873 current_ = 0;
Chris@16 1874 }
Chris@16 1875 }
Chris@16 1876 BOOST_UBLAS_CHECK (n == 0, external_logic ());
Chris@16 1877 return *this;
Chris@16 1878 }
Chris@16 1879 BOOST_UBLAS_INLINE
Chris@16 1880 const_iterator2 &operator -= (difference_type n) {
Chris@16 1881 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 1882 if (current_ == 0) {
Chris@16 1883 size_type d = (std::min) (n, it1_ - it1_begin_);
Chris@16 1884 it1_ -= d;
Chris@16 1885 n -= d;
Chris@16 1886 if (n > 0) {
Chris@16 1887 BOOST_UBLAS_CHECK (end_ == 1, external_logic ());
Chris@16 1888 d = (std::min) (n, it2_end_ - it2_begin_);
Chris@16 1889 it2_ = it2_end_ - d;
Chris@16 1890 n -= d;
Chris@16 1891 current_ = 1;
Chris@16 1892 }
Chris@16 1893 } else /* if (current_ == 1) */ {
Chris@16 1894 size_type d = (std::min) (n, it2_ - it2_begin_);
Chris@16 1895 it2_ -= d;
Chris@16 1896 n -= d;
Chris@16 1897 if (n > 0) {
Chris@16 1898 BOOST_UBLAS_CHECK (end_ == 0, external_logic ());
Chris@16 1899 d = (std::min) (n, it1_end_ - it1_begin_);
Chris@16 1900 it1_ = it1_end_ - d;
Chris@16 1901 n -= d;
Chris@16 1902 current_ = 0;
Chris@16 1903 }
Chris@16 1904 }
Chris@16 1905 BOOST_UBLAS_CHECK (n == 0, external_logic ());
Chris@16 1906 return *this;
Chris@16 1907 }
Chris@16 1908 BOOST_UBLAS_INLINE
Chris@16 1909 difference_type operator - (const const_iterator2 &it) const {
Chris@16 1910 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 1911 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 1912 BOOST_UBLAS_CHECK (it.current_ == 0 || it.current_ == 1, internal_logic ());
Chris@16 1913 BOOST_UBLAS_CHECK (/* begin_ == it.begin_ && */ end_ == it.end_, internal_logic ());
Chris@16 1914 if (current_ == 0 && it.current_ == 0) {
Chris@16 1915 return it1_ - it.it1_;
Chris@16 1916 } else if (current_ == 0 && it.current_ == 1) {
Chris@16 1917 if (end_ == 1 && it.end_ == 1) {
Chris@16 1918 return (it1_ - it.it1_end_) + (it.it2_begin_ - it.it2_);
Chris@16 1919 } else /* if (end_ == 0 && it.end_ == 0) */ {
Chris@16 1920 return (it1_ - it.it1_begin_) + (it.it2_end_ - it.it2_);
Chris@16 1921 }
Chris@16 1922
Chris@16 1923 } else if (current_ == 1 && it.current_ == 0) {
Chris@16 1924 if (end_ == 1 && it.end_ == 1) {
Chris@16 1925 return (it2_ - it.it2_begin_) + (it.it1_end_ - it.it1_);
Chris@16 1926 } else /* if (end_ == 0 && it.end_ == 0) */ {
Chris@16 1927 return (it2_ - it.it2_end_) + (it.it1_begin_ - it.it1_);
Chris@16 1928 }
Chris@16 1929 }
Chris@16 1930 /* current_ == 1 && it.current_ == 1 */ {
Chris@16 1931 return it2_ - it.it2_;
Chris@16 1932 }
Chris@16 1933 }
Chris@16 1934
Chris@16 1935 // Dereference
Chris@16 1936 BOOST_UBLAS_INLINE
Chris@16 1937 const_reference operator * () const {
Chris@16 1938 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 1939 if (current_ == 0) {
Chris@16 1940 BOOST_UBLAS_CHECK (it1_ != it1_end_, internal_logic ());
Chris@16 1941 return *it1_;
Chris@16 1942 } else /* if (current_ == 1) */ {
Chris@16 1943 BOOST_UBLAS_CHECK (it2_ != it2_end_, internal_logic ());
Chris@16 1944 return *it2_;
Chris@16 1945 }
Chris@16 1946 }
Chris@16 1947 BOOST_UBLAS_INLINE
Chris@16 1948 const_reference operator [] (difference_type n) const {
Chris@16 1949 return *(*this + n);
Chris@16 1950 }
Chris@16 1951
Chris@16 1952 #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
Chris@16 1953 BOOST_UBLAS_INLINE
Chris@16 1954 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 1955 typename self_type::
Chris@16 1956 #endif
Chris@16 1957 const_iterator1 begin () const {
Chris@16 1958 return (*this) ().find1 (1, 0, index2 ());
Chris@16 1959 }
Chris@16 1960 BOOST_UBLAS_INLINE
Chris@16 1961 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 1962 typename self_type::
Chris@16 1963 #endif
Chris@101 1964 const_iterator1 cbegin () const {
Chris@101 1965 return begin ();
Chris@101 1966 }
Chris@101 1967 BOOST_UBLAS_INLINE
Chris@101 1968 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 1969 typename self_type::
Chris@101 1970 #endif
Chris@16 1971 const_iterator1 end () const {
Chris@16 1972 return (*this) ().find1 (1, (*this) ().size1 (), index2 ());
Chris@16 1973 }
Chris@16 1974 BOOST_UBLAS_INLINE
Chris@16 1975 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 1976 typename self_type::
Chris@16 1977 #endif
Chris@101 1978 const_iterator1 cend () const {
Chris@101 1979 return end ();
Chris@101 1980 }
Chris@101 1981 BOOST_UBLAS_INLINE
Chris@101 1982 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 1983 typename self_type::
Chris@101 1984 #endif
Chris@16 1985 const_reverse_iterator1 rbegin () const {
Chris@16 1986 return const_reverse_iterator1 (end ());
Chris@16 1987 }
Chris@16 1988 BOOST_UBLAS_INLINE
Chris@16 1989 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 1990 typename self_type::
Chris@16 1991 #endif
Chris@101 1992 const_reverse_iterator1 crbegin () const {
Chris@101 1993 return rbegin ();
Chris@101 1994 }
Chris@101 1995 BOOST_UBLAS_INLINE
Chris@101 1996 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 1997 typename self_type::
Chris@101 1998 #endif
Chris@16 1999 const_reverse_iterator1 rend () const {
Chris@16 2000 return const_reverse_iterator1 (begin ());
Chris@16 2001 }
Chris@101 2002 BOOST_UBLAS_INLINE
Chris@101 2003 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@101 2004 typename self_type::
Chris@101 2005 #endif
Chris@101 2006 const_reverse_iterator1 crend () const {
Chris@101 2007 return rend ();
Chris@101 2008 }
Chris@16 2009 #endif
Chris@16 2010
Chris@16 2011 // Indices
Chris@16 2012 BOOST_UBLAS_INLINE
Chris@16 2013 size_type index1 () const {
Chris@16 2014 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 2015 if (current_ == 0) {
Chris@16 2016 BOOST_UBLAS_CHECK (it1_ != it1_end_, internal_logic ());
Chris@16 2017 return it1_.index2 ();
Chris@16 2018 } else /* if (current_ == 1) */ {
Chris@16 2019 BOOST_UBLAS_CHECK (it2_ != it2_end_, internal_logic ());
Chris@16 2020 return it2_.index1 ();
Chris@16 2021 }
Chris@16 2022 }
Chris@16 2023 BOOST_UBLAS_INLINE
Chris@16 2024 size_type index2 () const {
Chris@16 2025 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 2026 if (current_ == 0) {
Chris@16 2027 BOOST_UBLAS_CHECK (it1_ != it1_end_, internal_logic ());
Chris@16 2028 return it1_.index1 ();
Chris@16 2029 } else /* if (current_ == 1) */ {
Chris@16 2030 BOOST_UBLAS_CHECK (it2_ != it2_end_, internal_logic ());
Chris@16 2031 return it2_.index2 ();
Chris@16 2032 }
Chris@16 2033 }
Chris@16 2034
Chris@16 2035 // Assignment
Chris@16 2036 BOOST_UBLAS_INLINE
Chris@16 2037 const_iterator2 &operator = (const const_iterator2 &it) {
Chris@16 2038 container_const_reference<self_type>::assign (&it ());
Chris@16 2039 begin_ = it.begin_;
Chris@16 2040 end_ = it.end_;
Chris@16 2041 current_ = it.current_;
Chris@16 2042 it1_begin_ = it.it1_begin_;
Chris@16 2043 it1_end_ = it.it1_end_;
Chris@16 2044 it1_ = it.it1_;
Chris@16 2045 it2_begin_ = it.it2_begin_;
Chris@16 2046 it2_end_ = it.it2_end_;
Chris@16 2047 it2_ = it.it2_;
Chris@16 2048 return *this;
Chris@16 2049 }
Chris@16 2050
Chris@16 2051 // Comparison
Chris@16 2052 BOOST_UBLAS_INLINE
Chris@16 2053 bool operator == (const const_iterator2 &it) const {
Chris@16 2054 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 2055 BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ());
Chris@16 2056 BOOST_UBLAS_CHECK (it.current_ == 0 || it.current_ == 1, internal_logic ());
Chris@16 2057 BOOST_UBLAS_CHECK (/* begin_ == it.begin_ && */ end_ == it.end_, internal_logic ());
Chris@16 2058 return (current_ == 0 && it.current_ == 0 && it1_ == it.it1_) ||
Chris@16 2059 (current_ == 1 && it.current_ == 1 && it2_ == it.it2_);
Chris@16 2060 }
Chris@16 2061 BOOST_UBLAS_INLINE
Chris@16 2062 bool operator < (const const_iterator2 &it) const {
Chris@16 2063 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 2064 return it - *this > 0;
Chris@16 2065 }
Chris@16 2066
Chris@16 2067 private:
Chris@16 2068 int begin_;
Chris@16 2069 int end_;
Chris@16 2070 int current_;
Chris@16 2071 const_subiterator1_type it1_begin_;
Chris@16 2072 const_subiterator1_type it1_end_;
Chris@16 2073 const_subiterator1_type it1_;
Chris@16 2074 const_subiterator2_type it2_begin_;
Chris@16 2075 const_subiterator2_type it2_end_;
Chris@16 2076 const_subiterator2_type it2_;
Chris@16 2077 };
Chris@16 2078 #endif
Chris@16 2079
Chris@16 2080 BOOST_UBLAS_INLINE
Chris@16 2081 const_iterator2 begin2 () const {
Chris@16 2082 return find2 (0, 0, 0);
Chris@16 2083 }
Chris@16 2084 BOOST_UBLAS_INLINE
Chris@101 2085 const_iterator2 cbegin2 () const {
Chris@101 2086 return begin2 ();
Chris@101 2087 }
Chris@101 2088 BOOST_UBLAS_INLINE
Chris@16 2089 const_iterator2 end2 () const {
Chris@16 2090 return find2 (0, 0, size2 ());
Chris@16 2091 }
Chris@101 2092 BOOST_UBLAS_INLINE
Chris@101 2093 const_iterator2 cend2 () const {
Chris@101 2094 return end2 ();
Chris@101 2095 }
Chris@16 2096
Chris@16 2097 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
Chris@16 2098 class iterator2:
Chris@16 2099 public container_reference<symmetric_adaptor>,
Chris@16 2100 public random_access_iterator_base<typename iterator_restrict_traits<
Chris@16 2101 typename subiterator2_type::iterator_category, packed_random_access_iterator_tag>::iterator_category,
Chris@16 2102 iterator2, value_type> {
Chris@16 2103 public:
Chris@16 2104 typedef typename subiterator2_type::value_type value_type;
Chris@16 2105 typedef typename subiterator2_type::difference_type difference_type;
Chris@16 2106 typedef typename subiterator2_type::reference reference;
Chris@16 2107 typedef typename subiterator2_type::pointer pointer;
Chris@16 2108
Chris@16 2109 typedef iterator1 dual_iterator_type;
Chris@16 2110 typedef reverse_iterator1 dual_reverse_iterator_type;
Chris@16 2111
Chris@16 2112 // Construction and destruction
Chris@16 2113 BOOST_UBLAS_INLINE
Chris@16 2114 iterator2 ():
Chris@16 2115 container_reference<self_type> (), it2_ () {}
Chris@16 2116 BOOST_UBLAS_INLINE
Chris@16 2117 iterator2 (self_type &m, const subiterator2_type &it2):
Chris@16 2118 container_reference<self_type> (m), it2_ (it2) {}
Chris@16 2119
Chris@16 2120 // Arithmetic
Chris@16 2121 BOOST_UBLAS_INLINE
Chris@16 2122 iterator2 &operator ++ () {
Chris@16 2123 ++ it2_;
Chris@16 2124 return *this;
Chris@16 2125 }
Chris@16 2126 BOOST_UBLAS_INLINE
Chris@16 2127 iterator2 &operator -- () {
Chris@16 2128 -- it2_;
Chris@16 2129 return *this;
Chris@16 2130 }
Chris@16 2131 BOOST_UBLAS_INLINE
Chris@16 2132 iterator2 &operator += (difference_type n) {
Chris@16 2133 it2_ += n;
Chris@16 2134 return *this;
Chris@16 2135 }
Chris@16 2136 BOOST_UBLAS_INLINE
Chris@16 2137 iterator2 &operator -= (difference_type n) {
Chris@16 2138 it2_ -= n;
Chris@16 2139 return *this;
Chris@16 2140 }
Chris@16 2141 BOOST_UBLAS_INLINE
Chris@16 2142 difference_type operator - (const iterator2 &it) const {
Chris@16 2143 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 2144 return it2_ - it.it2_;
Chris@16 2145 }
Chris@16 2146
Chris@16 2147 // Dereference
Chris@16 2148 BOOST_UBLAS_INLINE
Chris@16 2149 reference operator * () const {
Chris@16 2150 return *it2_;
Chris@16 2151 }
Chris@16 2152 BOOST_UBLAS_INLINE
Chris@16 2153 reference operator [] (difference_type n) const {
Chris@16 2154 return *(*this + n);
Chris@16 2155 }
Chris@16 2156
Chris@16 2157 #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
Chris@16 2158 BOOST_UBLAS_INLINE
Chris@16 2159 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 2160 typename self_type::
Chris@16 2161 #endif
Chris@16 2162 iterator1 begin () const {
Chris@16 2163 return (*this) ().find1 (1, 0, index2 ());
Chris@16 2164 }
Chris@16 2165 BOOST_UBLAS_INLINE
Chris@16 2166 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 2167 typename self_type::
Chris@16 2168 #endif
Chris@16 2169 iterator1 end () const {
Chris@16 2170 return (*this) ().find1 (1, (*this) ().size1 (), index2 ());
Chris@16 2171 }
Chris@16 2172 BOOST_UBLAS_INLINE
Chris@16 2173 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 2174 typename self_type::
Chris@16 2175 #endif
Chris@16 2176 reverse_iterator1 rbegin () const {
Chris@16 2177 return reverse_iterator1 (end ());
Chris@16 2178 }
Chris@16 2179 BOOST_UBLAS_INLINE
Chris@16 2180 #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
Chris@16 2181 typename self_type::
Chris@16 2182 #endif
Chris@16 2183 reverse_iterator1 rend () const {
Chris@16 2184 return reverse_iterator1 (begin ());
Chris@16 2185 }
Chris@16 2186 #endif
Chris@16 2187
Chris@16 2188 // Indices
Chris@16 2189 BOOST_UBLAS_INLINE
Chris@16 2190 size_type index1 () const {
Chris@16 2191 return it2_.index1 ();
Chris@16 2192 }
Chris@16 2193 BOOST_UBLAS_INLINE
Chris@16 2194 size_type index2 () const {
Chris@16 2195 return it2_.index2 ();
Chris@16 2196 }
Chris@16 2197
Chris@16 2198 // Assignment
Chris@16 2199 BOOST_UBLAS_INLINE
Chris@16 2200 iterator2 &operator = (const iterator2 &it) {
Chris@16 2201 container_reference<self_type>::assign (&it ());
Chris@16 2202 it2_ = it.it2_;
Chris@16 2203 return *this;
Chris@16 2204 }
Chris@16 2205
Chris@16 2206 // Comparison
Chris@16 2207 BOOST_UBLAS_INLINE
Chris@16 2208 bool operator == (const iterator2 &it) const {
Chris@16 2209 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 2210 return it2_ == it.it2_;
Chris@16 2211 }
Chris@16 2212 BOOST_UBLAS_INLINE
Chris@16 2213 bool operator < (const iterator2 &it) const {
Chris@16 2214 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
Chris@16 2215 return it2_ < it.it2_;
Chris@16 2216 }
Chris@16 2217
Chris@16 2218 private:
Chris@16 2219 subiterator2_type it2_;
Chris@16 2220
Chris@16 2221 friend class const_iterator2;
Chris@16 2222 };
Chris@16 2223 #endif
Chris@16 2224
Chris@16 2225 BOOST_UBLAS_INLINE
Chris@16 2226 iterator2 begin2 () {
Chris@16 2227 return find2 (0, 0, 0);
Chris@16 2228 }
Chris@16 2229 BOOST_UBLAS_INLINE
Chris@16 2230 iterator2 end2 () {
Chris@16 2231 return find2 (0, 0, size2 ());
Chris@16 2232 }
Chris@16 2233
Chris@16 2234 // Reverse iterators
Chris@16 2235
Chris@16 2236 BOOST_UBLAS_INLINE
Chris@16 2237 const_reverse_iterator1 rbegin1 () const {
Chris@16 2238 return const_reverse_iterator1 (end1 ());
Chris@16 2239 }
Chris@16 2240 BOOST_UBLAS_INLINE
Chris@101 2241 const_reverse_iterator1 crbegin1 () const {
Chris@101 2242 return rbegin1 ();
Chris@101 2243 }
Chris@101 2244 BOOST_UBLAS_INLINE
Chris@16 2245 const_reverse_iterator1 rend1 () const {
Chris@16 2246 return const_reverse_iterator1 (begin1 ());
Chris@16 2247 }
Chris@101 2248 BOOST_UBLAS_INLINE
Chris@101 2249 const_reverse_iterator1 crend1 () const {
Chris@101 2250 return rend1 ();
Chris@101 2251 }
Chris@16 2252
Chris@16 2253 BOOST_UBLAS_INLINE
Chris@16 2254 reverse_iterator1 rbegin1 () {
Chris@16 2255 return reverse_iterator1 (end1 ());
Chris@16 2256 }
Chris@16 2257 BOOST_UBLAS_INLINE
Chris@16 2258 reverse_iterator1 rend1 () {
Chris@16 2259 return reverse_iterator1 (begin1 ());
Chris@16 2260 }
Chris@16 2261
Chris@16 2262 BOOST_UBLAS_INLINE
Chris@16 2263 const_reverse_iterator2 rbegin2 () const {
Chris@16 2264 return const_reverse_iterator2 (end2 ());
Chris@16 2265 }
Chris@16 2266 BOOST_UBLAS_INLINE
Chris@101 2267 const_reverse_iterator2 crbegin2 () const {
Chris@101 2268 return rbegin2 ();
Chris@101 2269 }
Chris@101 2270 BOOST_UBLAS_INLINE
Chris@16 2271 const_reverse_iterator2 rend2 () const {
Chris@16 2272 return const_reverse_iterator2 (begin2 ());
Chris@16 2273 }
Chris@101 2274 BOOST_UBLAS_INLINE
Chris@101 2275 const_reverse_iterator2 crend2 () const {
Chris@101 2276 return rend2 ();
Chris@101 2277 }
Chris@16 2278
Chris@16 2279 BOOST_UBLAS_INLINE
Chris@16 2280 reverse_iterator2 rbegin2 () {
Chris@16 2281 return reverse_iterator2 (end2 ());
Chris@16 2282 }
Chris@16 2283 BOOST_UBLAS_INLINE
Chris@16 2284 reverse_iterator2 rend2 () {
Chris@16 2285 return reverse_iterator2 (begin2 ());
Chris@16 2286 }
Chris@16 2287
Chris@16 2288 private:
Chris@16 2289 matrix_closure_type data_;
Chris@16 2290 };
Chris@16 2291
Chris@16 2292 // Specialization for temporary_traits
Chris@16 2293 template <class M, class TRI>
Chris@16 2294 struct vector_temporary_traits< symmetric_adaptor<M, TRI> >
Chris@16 2295 : vector_temporary_traits< M > {} ;
Chris@16 2296 template <class M, class TRI>
Chris@16 2297 struct vector_temporary_traits< const symmetric_adaptor<M, TRI> >
Chris@16 2298 : vector_temporary_traits< M > {} ;
Chris@16 2299
Chris@16 2300 template <class M, class TRI>
Chris@16 2301 struct matrix_temporary_traits< symmetric_adaptor<M, TRI> >
Chris@16 2302 : matrix_temporary_traits< M > {} ;
Chris@16 2303 template <class M, class TRI>
Chris@16 2304 struct matrix_temporary_traits< const symmetric_adaptor<M, TRI> >
Chris@16 2305 : matrix_temporary_traits< M > {} ;
Chris@16 2306
Chris@16 2307 }}}
Chris@16 2308
Chris@16 2309 #endif