os/ossrv/ossrv_pub/boost_apis/boost/numeric/ublas/matrix.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/numeric/ublas/matrix.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,4045 @@
     1.4 +//
     1.5 +//  Copyright (c) 2000-2002
     1.6 +//  Joerg Walter, Mathias Koch
     1.7 +//
     1.8 +//  Permission to use, copy, modify, distribute and sell this software
     1.9 +//  and its documentation for any purpose is hereby granted without fee,
    1.10 +//  provided that the above copyright notice appear in all copies and
    1.11 +//  that both that copyright notice and this permission notice appear
    1.12 +//  in supporting documentation.  The authors make no representations
    1.13 +//  about the suitability of this software for any purpose.
    1.14 +//  It is provided "as is" without express or implied warranty.
    1.15 +//
    1.16 +//  The authors gratefully acknowledge the support of
    1.17 +//  GeNeSys mbH & Co. KG in producing this work.
    1.18 +//
    1.19 +
    1.20 +#ifndef _BOOST_UBLAS_MATRIX_
    1.21 +#define _BOOST_UBLAS_MATRIX_
    1.22 +
    1.23 +#include <boost/numeric/ublas/vector.hpp>
    1.24 +#include <boost/numeric/ublas/matrix_expression.hpp>
    1.25 +#include <boost/numeric/ublas/detail/matrix_assign.hpp>
    1.26 +
    1.27 +// Iterators based on ideas of Jeremy Siek
    1.28 +
    1.29 +namespace boost { namespace numeric { namespace ublas {
    1.30 +
    1.31 +    namespace detail {
    1.32 +        using namespace boost::numeric::ublas;
    1.33 +
    1.34 +        // Matrix resizing algorithm
    1.35 +        template <class L, class M>
    1.36 +        BOOST_UBLAS_INLINE
    1.37 +        void matrix_resize_preserve (M& m, M& temporary) {
    1.38 +            typedef L layout_type;
    1.39 +            typedef typename M::size_type size_type;
    1.40 +            const size_type msize1 (m.size1 ());        // original size
    1.41 +            const size_type msize2 (m.size2 ());
    1.42 +            const size_type size1 (temporary.size1 ());    // new size is specified by temporary
    1.43 +            const size_type size2 (temporary.size2 ());
    1.44 +            // Common elements to preserve
    1.45 +            const size_type size1_min = (std::min) (size1, msize1);
    1.46 +            const size_type size2_min = (std::min) (size2, msize2);
    1.47 +            // Order loop for i-major and j-minor sizes
    1.48 +            const size_type i_size = layout_type::size1 (size1_min, size2_min);
    1.49 +            const size_type j_size = layout_type::size2 (size1_min, size2_min);
    1.50 +            for (size_type i = 0; i != i_size; ++i) {    // indexing copy over major
    1.51 +                for (size_type j = 0; j != j_size; ++j) {
    1.52 +                    const size_type element1 = layout_type::element1(i,i_size, j,j_size);
    1.53 +                    const size_type element2 = layout_type::element2(i,i_size, j,j_size);
    1.54 +                    temporary.data () [layout_type::element (element1, size1, element2, size2)] =
    1.55 +                            m.data() [layout_type::element (element1, msize1, element2, msize2)];
    1.56 +                }
    1.57 +            }
    1.58 +            m.assign_temporary (temporary);
    1.59 +        }
    1.60 +    }
    1.61 +
    1.62 +
    1.63 +    // Array based matrix class
    1.64 +    template<class T, class L, class A>
    1.65 +    class matrix:
    1.66 +        public matrix_container<matrix<T, L, A> > {
    1.67 +
    1.68 +        typedef T *pointer;
    1.69 +        typedef L layout_type;
    1.70 +        typedef matrix<T, L, A> self_type;
    1.71 +    public:
    1.72 +#ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
    1.73 +        using matrix_container<self_type>::operator ();
    1.74 +#endif
    1.75 +        typedef typename A::size_type size_type;
    1.76 +        typedef typename A::difference_type difference_type;
    1.77 +        typedef T value_type;
    1.78 +        typedef const T &const_reference;
    1.79 +        typedef T &reference;
    1.80 +        typedef A array_type;
    1.81 +        typedef const matrix_reference<const self_type> const_closure_type;
    1.82 +        typedef matrix_reference<self_type> closure_type;
    1.83 +        typedef vector<T, A> vector_temporary_type;
    1.84 +        typedef self_type matrix_temporary_type;
    1.85 +        typedef dense_tag storage_category;
    1.86 +        // This could be better for performance,
    1.87 +        // typedef typename unknown_orientation_tag orientation_category;
    1.88 +        // but others depend on the orientation information...
    1.89 +        typedef typename L::orientation_category orientation_category;
    1.90 +
    1.91 +        // Construction and destruction
    1.92 +        BOOST_UBLAS_INLINE
    1.93 +        matrix ():
    1.94 +            matrix_container<self_type> (),
    1.95 +            size1_ (0), size2_ (0), data_ () {}
    1.96 +        BOOST_UBLAS_INLINE
    1.97 +        matrix (size_type size1, size_type size2):
    1.98 +            matrix_container<self_type> (),
    1.99 +            size1_ (size1), size2_ (size2), data_ (layout_type::storage_size (size1, size2)) {
   1.100 +        }
   1.101 +        BOOST_UBLAS_INLINE
   1.102 +        matrix (size_type size1, size_type size2, const array_type &data):
   1.103 +            matrix_container<self_type> (),
   1.104 +            size1_ (size1), size2_ (size2), data_ (data) {}
   1.105 +        BOOST_UBLAS_INLINE
   1.106 +        matrix (const matrix &m):
   1.107 +            matrix_container<self_type> (),
   1.108 +            size1_ (m.size1_), size2_ (m.size2_), data_ (m.data_) {}
   1.109 +        template<class AE>
   1.110 +        BOOST_UBLAS_INLINE
   1.111 +        matrix (const matrix_expression<AE> &ae):
   1.112 +            matrix_container<self_type> (),
   1.113 +            size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ (layout_type::storage_size (size1_, size2_)) {
   1.114 +            matrix_assign<scalar_assign> (*this, ae);
   1.115 +        }
   1.116 +
   1.117 +        // Accessors
   1.118 +        BOOST_UBLAS_INLINE
   1.119 +        size_type size1 () const {
   1.120 +            return size1_;
   1.121 +        }
   1.122 +        BOOST_UBLAS_INLINE
   1.123 +        size_type size2 () const {
   1.124 +            return size2_;
   1.125 +        }
   1.126 +
   1.127 +        // Storage accessors
   1.128 +        BOOST_UBLAS_INLINE
   1.129 +        const array_type &data () const {
   1.130 +            return data_;
   1.131 +        }
   1.132 +        BOOST_UBLAS_INLINE
   1.133 +        array_type &data () {
   1.134 +            return data_;
   1.135 +        }
   1.136 +
   1.137 +        // Resizing
   1.138 +        BOOST_UBLAS_INLINE
   1.139 +        void resize (size_type size1, size_type size2, bool preserve = true) {
   1.140 +            if (preserve) {
   1.141 +                self_type temporary (size1, size2);
   1.142 +                detail::matrix_resize_preserve<layout_type> (*this, temporary);
   1.143 +            }
   1.144 +            else {
   1.145 +                data ().resize (layout_type::storage_size (size1, size2));
   1.146 +                size1_ = size1;
   1.147 +                size2_ = size2;
   1.148 +            }
   1.149 +        }
   1.150 +
   1.151 +        // Element access
   1.152 +        BOOST_UBLAS_INLINE
   1.153 +        const_reference operator () (size_type i, size_type j) const {
   1.154 +            return data () [layout_type::element (i, size1_, j, size2_)];
   1.155 +        }
   1.156 +        BOOST_UBLAS_INLINE
   1.157 +        reference at_element (size_type i, size_type j) {
   1.158 +            return data () [layout_type::element (i, size1_, j, size2_)];
   1.159 +        }
   1.160 +        BOOST_UBLAS_INLINE
   1.161 +        reference operator () (size_type i, size_type j) {
   1.162 +            return at_element (i, j);
   1.163 +        }
   1.164 +
   1.165 +        // Element assignment
   1.166 +        BOOST_UBLAS_INLINE
   1.167 +        reference insert_element (size_type i, size_type j, const_reference t) {
   1.168 +            return (at_element (i, j) = t);
   1.169 +        }
   1.170 +        void erase_element (size_type i, size_type j) {
   1.171 +            at_element (i, j) = value_type/*zero*/();
   1.172 +        }
   1.173 +
   1.174 +        // Zeroing
   1.175 +        BOOST_UBLAS_INLINE
   1.176 +        void clear () {
   1.177 +            std::fill (data ().begin (), data ().end (), value_type/*zero*/());
   1.178 +        }
   1.179 +
   1.180 +        // Assignment
   1.181 +        BOOST_UBLAS_INLINE
   1.182 +        matrix &operator = (const matrix &m) {
   1.183 +            size1_ = m.size1_;
   1.184 +            size2_ = m.size2_;
   1.185 +            data () = m.data ();
   1.186 +            return *this;
   1.187 +        }
   1.188 +        template<class C>          // Container assignment without temporary
   1.189 +        BOOST_UBLAS_INLINE
   1.190 +        matrix &operator = (const matrix_container<C> &m) {
   1.191 +            resize (m ().size1 (), m ().size2 (), false);
   1.192 +            assign (m);
   1.193 +            return *this;
   1.194 +        }
   1.195 +        BOOST_UBLAS_INLINE
   1.196 +        matrix &assign_temporary (matrix &m) {
   1.197 +            swap (m);
   1.198 +            return *this;
   1.199 +        }
   1.200 +        template<class AE>
   1.201 +        BOOST_UBLAS_INLINE
   1.202 +        matrix &operator = (const matrix_expression<AE> &ae) {
   1.203 +            self_type temporary (ae);
   1.204 +            return assign_temporary (temporary);
   1.205 +        }
   1.206 +        template<class AE>
   1.207 +        BOOST_UBLAS_INLINE
   1.208 +        matrix &assign (const matrix_expression<AE> &ae) {
   1.209 +            matrix_assign<scalar_assign> (*this, ae);
   1.210 +            return *this;
   1.211 +        }
   1.212 +        template<class AE>
   1.213 +        BOOST_UBLAS_INLINE
   1.214 +        matrix& operator += (const matrix_expression<AE> &ae) {
   1.215 +            self_type temporary (*this + ae);
   1.216 +            return assign_temporary (temporary);
   1.217 +        }
   1.218 +        template<class C>          // Container assignment without temporary
   1.219 +        BOOST_UBLAS_INLINE
   1.220 +        matrix &operator += (const matrix_container<C> &m) {
   1.221 +            plus_assign (m);
   1.222 +            return *this;
   1.223 +        }
   1.224 +        template<class AE>
   1.225 +        BOOST_UBLAS_INLINE
   1.226 +        matrix &plus_assign (const matrix_expression<AE> &ae) {
   1.227 +            matrix_assign<scalar_plus_assign> (*this, ae);
   1.228 +            return *this;
   1.229 +        }
   1.230 +        template<class AE>
   1.231 +        BOOST_UBLAS_INLINE
   1.232 +        matrix& operator -= (const matrix_expression<AE> &ae) {
   1.233 +            self_type temporary (*this - ae);
   1.234 +            return assign_temporary (temporary);
   1.235 +        }
   1.236 +        template<class C>          // Container assignment without temporary
   1.237 +        BOOST_UBLAS_INLINE
   1.238 +        matrix &operator -= (const matrix_container<C> &m) {
   1.239 +            minus_assign (m);
   1.240 +            return *this;
   1.241 +        }
   1.242 +        template<class AE>
   1.243 +        BOOST_UBLAS_INLINE
   1.244 +        matrix &minus_assign (const matrix_expression<AE> &ae) {
   1.245 +            matrix_assign<scalar_minus_assign> (*this, ae);
   1.246 +            return *this;
   1.247 +        }
   1.248 +        template<class AT>
   1.249 +        BOOST_UBLAS_INLINE
   1.250 +        matrix& operator *= (const AT &at) {
   1.251 +            matrix_assign_scalar<scalar_multiplies_assign> (*this, at);
   1.252 +            return *this;
   1.253 +        }
   1.254 +        template<class AT>
   1.255 +        BOOST_UBLAS_INLINE
   1.256 +        matrix& operator /= (const AT &at) {
   1.257 +            matrix_assign_scalar<scalar_divides_assign> (*this, at);
   1.258 +            return *this;
   1.259 +        }
   1.260 +
   1.261 +        // Swapping
   1.262 +        BOOST_UBLAS_INLINE
   1.263 +        void swap (matrix &m) {
   1.264 +            if (this != &m) {
   1.265 +                std::swap (size1_, m.size1_);
   1.266 +                std::swap (size2_, m.size2_);
   1.267 +                data ().swap (m.data ());
   1.268 +            }
   1.269 +        }
   1.270 +        BOOST_UBLAS_INLINE
   1.271 +        friend void swap (matrix &m1, matrix &m2) {
   1.272 +            m1.swap (m2);
   1.273 +        }
   1.274 +
   1.275 +        // Iterator types
   1.276 +    private:
   1.277 +        // Use the storage array iterator
   1.278 +        typedef typename A::const_iterator const_subiterator_type;
   1.279 +        typedef typename A::iterator subiterator_type;
   1.280 +
   1.281 +    public:
   1.282 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
   1.283 +        typedef indexed_iterator1<self_type, dense_random_access_iterator_tag> iterator1;
   1.284 +        typedef indexed_iterator2<self_type, dense_random_access_iterator_tag> iterator2;
   1.285 +        typedef indexed_const_iterator1<self_type, dense_random_access_iterator_tag> const_iterator1;
   1.286 +        typedef indexed_const_iterator2<self_type, dense_random_access_iterator_tag> const_iterator2;
   1.287 +#else
   1.288 +        class const_iterator1;
   1.289 +        class iterator1;
   1.290 +        class const_iterator2;
   1.291 +        class iterator2;
   1.292 +#endif
   1.293 +        typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
   1.294 +        typedef reverse_iterator_base1<iterator1> reverse_iterator1;
   1.295 +        typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
   1.296 +        typedef reverse_iterator_base2<iterator2> reverse_iterator2;
   1.297 +
   1.298 +        // Element lookup
   1.299 +        BOOST_UBLAS_INLINE
   1.300 +        const_iterator1 find1 (int /* rank */, size_type i, size_type j) const {
   1.301 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
   1.302 +            return const_iterator1 (*this, i, j);
   1.303 +#else
   1.304 +            return const_iterator1 (*this, data ().begin () + layout_type::address (i, size1_, j, size2_));
   1.305 +#endif
   1.306 +        }
   1.307 +        BOOST_UBLAS_INLINE
   1.308 +        iterator1 find1 (int /* rank */, size_type i, size_type j) {
   1.309 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
   1.310 +            return iterator1 (*this, i, j);
   1.311 +#else
   1.312 +            return iterator1 (*this, data ().begin () + layout_type::address (i, size1_, j, size2_));
   1.313 +#endif
   1.314 +        }
   1.315 +        BOOST_UBLAS_INLINE
   1.316 +        const_iterator2 find2 (int /* rank */, size_type i, size_type j) const {
   1.317 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
   1.318 +            return const_iterator2 (*this, i, j);
   1.319 +#else
   1.320 +            return const_iterator2 (*this, data ().begin () + layout_type::address (i, size1_, j, size2_));
   1.321 +#endif
   1.322 +        }
   1.323 +        BOOST_UBLAS_INLINE
   1.324 +        iterator2 find2 (int /* rank */, size_type i, size_type j) {
   1.325 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
   1.326 +            return iterator2 (*this, i, j);
   1.327 +#else
   1.328 +            return iterator2 (*this, data ().begin () + layout_type::address (i, size1_, j, size2_));
   1.329 +#endif
   1.330 +        }
   1.331 +
   1.332 +
   1.333 +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
   1.334 +        class const_iterator1:
   1.335 +            public container_const_reference<matrix>,
   1.336 +            public random_access_iterator_base<dense_random_access_iterator_tag,
   1.337 +                                               const_iterator1, value_type> {
   1.338 +        public:
   1.339 +            typedef typename matrix::value_type value_type;
   1.340 +            typedef typename matrix::difference_type difference_type;
   1.341 +            typedef typename matrix::const_reference reference;
   1.342 +            typedef const typename matrix::pointer pointer;
   1.343 +
   1.344 +            typedef const_iterator2 dual_iterator_type;
   1.345 +            typedef const_reverse_iterator2 dual_reverse_iterator_type;
   1.346 +
   1.347 +            // Construction and destruction
   1.348 +            BOOST_UBLAS_INLINE
   1.349 +            const_iterator1 ():
   1.350 +                container_const_reference<self_type> (), it_ () {}
   1.351 +            BOOST_UBLAS_INLINE
   1.352 +            const_iterator1 (const self_type &m, const const_subiterator_type &it):
   1.353 +                container_const_reference<self_type> (m), it_ (it) {}
   1.354 +            BOOST_UBLAS_INLINE
   1.355 +            const_iterator1 (const iterator1 &it):
   1.356 +                container_const_reference<self_type> (it ()), it_ (it.it_) {}
   1.357 +
   1.358 +            // Arithmetic
   1.359 +            BOOST_UBLAS_INLINE
   1.360 +            const_iterator1 &operator ++ () {
   1.361 +                layout_type::increment1 (it_, (*this) ().size1 (), (*this) ().size2 ());
   1.362 +                return *this;
   1.363 +            }
   1.364 +            BOOST_UBLAS_INLINE
   1.365 +            const_iterator1 &operator -- () {
   1.366 +                layout_type::decrement1 (it_, (*this) ().size1 (), (*this) ().size2 ());
   1.367 +                return *this;
   1.368 +            }
   1.369 +            BOOST_UBLAS_INLINE
   1.370 +            const_iterator1 &operator += (difference_type n) {
   1.371 +                it_ += n * layout_type::one1 ((*this) ().size1 (), (*this) ().size2 ());
   1.372 +                return *this;
   1.373 +            }
   1.374 +            BOOST_UBLAS_INLINE
   1.375 +            const_iterator1 &operator -= (difference_type n) {
   1.376 +                it_ -= n * layout_type::one1 ((*this) ().size1 (), (*this) ().size2 ());
   1.377 +                return *this;
   1.378 +            }
   1.379 +            BOOST_UBLAS_INLINE
   1.380 +            difference_type operator - (const const_iterator1 &it) const {
   1.381 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
   1.382 +                return layout_type::distance1 (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ());
   1.383 +            }
   1.384 +
   1.385 +            // Dereference
   1.386 +            BOOST_UBLAS_INLINE
   1.387 +            const_reference operator * () const {
   1.388 +                BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());
   1.389 +                BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ());
   1.390 +                return *it_;
   1.391 +            }
   1.392 +            BOOST_UBLAS_INLINE
   1.393 +            const_reference operator [] (difference_type n) const {
   1.394 +                return *(*this + n);
   1.395 +            }
   1.396 +
   1.397 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
   1.398 +            BOOST_UBLAS_INLINE
   1.399 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.400 +            typename self_type::
   1.401 +#endif
   1.402 +            const_iterator2 begin () const {
   1.403 +                const self_type &m = (*this) ();
   1.404 +                return m.find2 (1, index1 (), 0);
   1.405 +            }
   1.406 +            BOOST_UBLAS_INLINE
   1.407 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.408 +            typename self_type::
   1.409 +#endif
   1.410 +            const_iterator2 end () const {
   1.411 +                const self_type &m = (*this) ();
   1.412 +                return m.find2 (1, index1 (), m.size2 ());
   1.413 +            }
   1.414 +            BOOST_UBLAS_INLINE
   1.415 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.416 +            typename self_type::
   1.417 +#endif
   1.418 +            const_reverse_iterator2 rbegin () const {
   1.419 +                return const_reverse_iterator2 (end ());
   1.420 +            }
   1.421 +            BOOST_UBLAS_INLINE
   1.422 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.423 +            typename self_type::
   1.424 +#endif
   1.425 +            const_reverse_iterator2 rend () const {
   1.426 +                return const_reverse_iterator2 (begin ());
   1.427 +            }
   1.428 +#endif
   1.429 +
   1.430 +            // Indices
   1.431 +            BOOST_UBLAS_INLINE
   1.432 +            size_type index1 () const {
   1.433 +                const self_type &m = (*this) ();
   1.434 +                return layout_type::index1 (it_ - m.begin1 ().it_, m.size1 (), m.size2 ());
   1.435 +            }
   1.436 +            BOOST_UBLAS_INLINE
   1.437 +            size_type index2 () const {
   1.438 +                const self_type &m = (*this) ();
   1.439 +                return layout_type::index2 (it_ - m.begin1 ().it_, m.size1 (), m.size2 ());
   1.440 +            }
   1.441 +
   1.442 +            // Assignment
   1.443 +            BOOST_UBLAS_INLINE
   1.444 +            const_iterator1 &operator = (const const_iterator1 &it) {
   1.445 +                container_const_reference<self_type>::assign (&it ());
   1.446 +                it_ = it.it_;
   1.447 +                return *this;
   1.448 +            }
   1.449 +
   1.450 +            // Comparison
   1.451 +            BOOST_UBLAS_INLINE
   1.452 +            bool operator == (const const_iterator1 &it) const {
   1.453 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
   1.454 +                return it_ == it.it_;
   1.455 +            }
   1.456 +            BOOST_UBLAS_INLINE
   1.457 +            bool operator < (const const_iterator1 &it) const {
   1.458 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
   1.459 +                return it_ < it.it_;
   1.460 +            }
   1.461 +
   1.462 +        private:
   1.463 +            const_subiterator_type it_;
   1.464 +
   1.465 +            friend class iterator1;
   1.466 +        };
   1.467 +#endif
   1.468 +
   1.469 +        BOOST_UBLAS_INLINE
   1.470 +        const_iterator1 begin1 () const {
   1.471 +            return find1 (0, 0, 0);
   1.472 +        }
   1.473 +        BOOST_UBLAS_INLINE
   1.474 +        const_iterator1 end1 () const {
   1.475 +            return find1 (0, size1_, 0);
   1.476 +        }
   1.477 +
   1.478 +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
   1.479 +        class iterator1:
   1.480 +            public container_reference<matrix>,
   1.481 +            public random_access_iterator_base<dense_random_access_iterator_tag,
   1.482 +                                               iterator1, value_type> {
   1.483 +        public:
   1.484 +            typedef typename matrix::value_type value_type;
   1.485 +            typedef typename matrix::difference_type difference_type;
   1.486 +            typedef typename matrix::reference reference;
   1.487 +            typedef typename matrix::pointer pointer;
   1.488 +
   1.489 +            typedef iterator2 dual_iterator_type;
   1.490 +            typedef reverse_iterator2 dual_reverse_iterator_type;
   1.491 +
   1.492 +            // Construction and destruction
   1.493 +            BOOST_UBLAS_INLINE
   1.494 +            iterator1 ():
   1.495 +                container_reference<self_type> (), it_ () {}
   1.496 +            BOOST_UBLAS_INLINE
   1.497 +            iterator1 (self_type &m, const subiterator_type &it):
   1.498 +                container_reference<self_type> (m), it_ (it) {}
   1.499 +
   1.500 +            // Arithmetic
   1.501 +            BOOST_UBLAS_INLINE
   1.502 +            iterator1 &operator ++ () {
   1.503 +                layout_type::increment1 (it_, (*this) ().size1 (), (*this) ().size2 ());
   1.504 +                return *this;
   1.505 +            }
   1.506 +            BOOST_UBLAS_INLINE
   1.507 +            iterator1 &operator -- () {
   1.508 +                layout_type::decrement1 (it_, (*this) ().size1 (), (*this) ().size2 ());
   1.509 +                return *this;
   1.510 +            }
   1.511 +            BOOST_UBLAS_INLINE
   1.512 +            iterator1 &operator += (difference_type n) {
   1.513 +                it_ += n * layout_type::one1 ((*this) ().size1 (), (*this) ().size2 ());
   1.514 +                return *this;
   1.515 +            }
   1.516 +            BOOST_UBLAS_INLINE
   1.517 +            iterator1 &operator -= (difference_type n) {
   1.518 +                it_ -= n * layout_type::one1 ((*this) ().size1 (), (*this) ().size2 ());
   1.519 +                return *this;
   1.520 +            }
   1.521 +            BOOST_UBLAS_INLINE
   1.522 +            difference_type operator - (const iterator1 &it) const {
   1.523 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
   1.524 +                return layout_type::distance1 (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ());
   1.525 +            }
   1.526 +
   1.527 +            // Dereference
   1.528 +            BOOST_UBLAS_INLINE
   1.529 +            reference operator * () const {
   1.530 +                BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());
   1.531 +                BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ());
   1.532 +                return *it_;
   1.533 +            }
   1.534 +            BOOST_UBLAS_INLINE
   1.535 +            reference operator [] (difference_type n) const {
   1.536 +                return *(*this + n);
   1.537 +            }
   1.538 +
   1.539 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
   1.540 +            BOOST_UBLAS_INLINE
   1.541 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.542 +            typename self_type::
   1.543 +#endif
   1.544 +            iterator2 begin () const {
   1.545 +                self_type &m = (*this) ();
   1.546 +                return m.find2 (1, index1 (), 0);
   1.547 +            }
   1.548 +            BOOST_UBLAS_INLINE
   1.549 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.550 +            typename self_type::
   1.551 +#endif
   1.552 +            iterator2 end () const {
   1.553 +                self_type &m = (*this) ();
   1.554 +                return m.find2 (1, index1 (), m.size2 ());
   1.555 +            }
   1.556 +            BOOST_UBLAS_INLINE
   1.557 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.558 +            typename self_type::
   1.559 +#endif
   1.560 +            reverse_iterator2 rbegin () const {
   1.561 +                return reverse_iterator2 (end ());
   1.562 +            }
   1.563 +            BOOST_UBLAS_INLINE
   1.564 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.565 +            typename self_type::
   1.566 +#endif
   1.567 +            reverse_iterator2 rend () const {
   1.568 +                return reverse_iterator2 (begin ());
   1.569 +            }
   1.570 +#endif
   1.571 +
   1.572 +            // Indices
   1.573 +            BOOST_UBLAS_INLINE
   1.574 +            size_type index1 () const {
   1.575 +                self_type &m = (*this) ();
   1.576 +                return layout_type::index1 (it_ - m.begin1 ().it_, m.size1 (), m.size2 ());
   1.577 +            }
   1.578 +            BOOST_UBLAS_INLINE
   1.579 +            size_type index2 () const {
   1.580 +                self_type &m = (*this) ();
   1.581 +                return layout_type::index2 (it_ - m.begin1 ().it_, m.size1 (), m.size2 ());
   1.582 +            }
   1.583 +
   1.584 +            // Assignment
   1.585 +            BOOST_UBLAS_INLINE
   1.586 +            iterator1 &operator = (const iterator1 &it) {
   1.587 +                container_reference<self_type>::assign (&it ());
   1.588 +                it_ = it.it_;
   1.589 +                return *this;
   1.590 +            }
   1.591 +
   1.592 +            // Comparison
   1.593 +            BOOST_UBLAS_INLINE
   1.594 +            bool operator == (const iterator1 &it) const {
   1.595 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
   1.596 +                return it_ == it.it_;
   1.597 +            }
   1.598 +            BOOST_UBLAS_INLINE
   1.599 +            bool operator < (const iterator1 &it) const {
   1.600 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
   1.601 +                return it_ < it.it_;
   1.602 +            }
   1.603 +
   1.604 +        private:
   1.605 +            subiterator_type it_;
   1.606 +
   1.607 +            friend class const_iterator1;
   1.608 +        };
   1.609 +#endif
   1.610 +
   1.611 +        BOOST_UBLAS_INLINE
   1.612 +        iterator1 begin1 () {
   1.613 +            return find1 (0, 0, 0);
   1.614 +        }
   1.615 +        BOOST_UBLAS_INLINE
   1.616 +        iterator1 end1 () {
   1.617 +            return find1 (0, size1_, 0);
   1.618 +        }
   1.619 +
   1.620 +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
   1.621 +        class const_iterator2:
   1.622 +            public container_const_reference<matrix>,
   1.623 +            public random_access_iterator_base<dense_random_access_iterator_tag,
   1.624 +                                               const_iterator2, value_type> {
   1.625 +        public:
   1.626 +            typedef typename matrix::value_type value_type;
   1.627 +            typedef typename matrix::difference_type difference_type;
   1.628 +            typedef typename matrix::const_reference reference;
   1.629 +            typedef const typename matrix::pointer pointer;
   1.630 +
   1.631 +            typedef const_iterator1 dual_iterator_type;
   1.632 +            typedef const_reverse_iterator1 dual_reverse_iterator_type;
   1.633 +
   1.634 +            // Construction and destruction
   1.635 +            BOOST_UBLAS_INLINE
   1.636 +            const_iterator2 ():
   1.637 +                container_const_reference<self_type> (), it_ () {}
   1.638 +            BOOST_UBLAS_INLINE
   1.639 +            const_iterator2 (const self_type &m, const const_subiterator_type &it):
   1.640 +                container_const_reference<self_type> (m), it_ (it) {}
   1.641 +            BOOST_UBLAS_INLINE
   1.642 +            const_iterator2 (const iterator2 &it):
   1.643 +                container_const_reference<self_type> (it ()), it_ (it.it_) {}
   1.644 +
   1.645 +            // Arithmetic
   1.646 +            BOOST_UBLAS_INLINE
   1.647 +            const_iterator2 &operator ++ () {
   1.648 +                layout_type::increment2 (it_, (*this) ().size1 (), (*this) ().size2 ());
   1.649 +                return *this;
   1.650 +            }
   1.651 +            BOOST_UBLAS_INLINE
   1.652 +            const_iterator2 &operator -- () {
   1.653 +                layout_type::decrement2 (it_, (*this) ().size1 (), (*this) ().size2 ());
   1.654 +                return *this;
   1.655 +            }
   1.656 +            BOOST_UBLAS_INLINE
   1.657 +            const_iterator2 &operator += (difference_type n) {
   1.658 +                it_ += n * layout_type::one2 ((*this) ().size1 (), (*this) ().size2 ());
   1.659 +                return *this;
   1.660 +            }
   1.661 +            BOOST_UBLAS_INLINE
   1.662 +            const_iterator2 &operator -= (difference_type n) {
   1.663 +                it_ -= n * layout_type::one2 ((*this) ().size1 (), (*this) ().size2 ());
   1.664 +                return *this;
   1.665 +            }
   1.666 +            BOOST_UBLAS_INLINE
   1.667 +            difference_type operator - (const const_iterator2 &it) const {
   1.668 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
   1.669 +                return layout_type::distance2 (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ());
   1.670 +            }
   1.671 +
   1.672 +            // Dereference
   1.673 +            BOOST_UBLAS_INLINE
   1.674 +            const_reference operator * () const {
   1.675 +                BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());
   1.676 +                BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ());
   1.677 +                return *it_;
   1.678 +            }
   1.679 +            BOOST_UBLAS_INLINE
   1.680 +            const_reference operator [] (difference_type n) const {
   1.681 +                return *(*this + n);
   1.682 +            }
   1.683 +
   1.684 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
   1.685 +            BOOST_UBLAS_INLINE
   1.686 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.687 +            typename self_type::
   1.688 +#endif
   1.689 +            const_iterator1 begin () const {
   1.690 +                const self_type &m = (*this) ();
   1.691 +                return m.find1 (1, 0, index2 ());
   1.692 +            }
   1.693 +            BOOST_UBLAS_INLINE
   1.694 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.695 +            typename self_type::
   1.696 +#endif
   1.697 +            const_iterator1 end () const {
   1.698 +                const self_type &m = (*this) ();
   1.699 +                return m.find1 (1, m.size1 (), index2 ());
   1.700 +            }
   1.701 +            BOOST_UBLAS_INLINE
   1.702 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.703 +            typename self_type::
   1.704 +#endif
   1.705 +            const_reverse_iterator1 rbegin () const {
   1.706 +                return const_reverse_iterator1 (end ());
   1.707 +            }
   1.708 +            BOOST_UBLAS_INLINE
   1.709 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.710 +            typename self_type::
   1.711 +#endif
   1.712 +            const_reverse_iterator1 rend () const {
   1.713 +                return const_reverse_iterator1 (begin ());
   1.714 +            }
   1.715 +#endif
   1.716 +
   1.717 +            // Indices
   1.718 +            BOOST_UBLAS_INLINE
   1.719 +            size_type index1 () const {
   1.720 +                const self_type &m = (*this) ();
   1.721 +                return layout_type::index1 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
   1.722 +            }
   1.723 +            BOOST_UBLAS_INLINE
   1.724 +            size_type index2 () const {
   1.725 +                const self_type &m = (*this) ();
   1.726 +                return layout_type::index2 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
   1.727 +            }
   1.728 +
   1.729 +            // Assignment
   1.730 +            BOOST_UBLAS_INLINE
   1.731 +            const_iterator2 &operator = (const const_iterator2 &it) {
   1.732 +                container_const_reference<self_type>::assign (&it ());
   1.733 +                it_ = it.it_;
   1.734 +                return *this;
   1.735 +            }
   1.736 +
   1.737 +            // Comparison
   1.738 +            BOOST_UBLAS_INLINE
   1.739 +            bool operator == (const const_iterator2 &it) const {
   1.740 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
   1.741 +                return it_ == it.it_;
   1.742 +            }
   1.743 +            BOOST_UBLAS_INLINE
   1.744 +            bool operator < (const const_iterator2 &it) const {
   1.745 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
   1.746 +                return it_ < it.it_;
   1.747 +            }
   1.748 +
   1.749 +        private:
   1.750 +            const_subiterator_type it_;
   1.751 +
   1.752 +            friend class iterator2;
   1.753 +        };
   1.754 +#endif
   1.755 +
   1.756 +        BOOST_UBLAS_INLINE
   1.757 +        const_iterator2 begin2 () const {
   1.758 +            return find2 (0, 0, 0);
   1.759 +        }
   1.760 +        BOOST_UBLAS_INLINE
   1.761 +        const_iterator2 end2 () const {
   1.762 +            return find2 (0, 0, size2_);
   1.763 +        }
   1.764 +
   1.765 +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
   1.766 +        class iterator2:
   1.767 +            public container_reference<matrix>,
   1.768 +            public random_access_iterator_base<dense_random_access_iterator_tag,
   1.769 +                                               iterator2, value_type> {
   1.770 +        public:
   1.771 +            typedef typename matrix::value_type value_type;
   1.772 +            typedef typename matrix::difference_type difference_type;
   1.773 +            typedef typename matrix::reference reference;
   1.774 +            typedef typename matrix::pointer pointer;
   1.775 +
   1.776 +            typedef iterator1 dual_iterator_type;
   1.777 +            typedef reverse_iterator1 dual_reverse_iterator_type;
   1.778 +
   1.779 +            // Construction and destruction
   1.780 +            BOOST_UBLAS_INLINE
   1.781 +            iterator2 ():
   1.782 +                container_reference<self_type> (), it_ () {}
   1.783 +            BOOST_UBLAS_INLINE
   1.784 +            iterator2 (self_type &m, const subiterator_type &it):
   1.785 +                container_reference<self_type> (m), it_ (it) {}
   1.786 +
   1.787 +            // Arithmetic
   1.788 +            BOOST_UBLAS_INLINE
   1.789 +            iterator2 &operator ++ () {
   1.790 +                layout_type::increment2 (it_, (*this) ().size1 (), (*this) ().size2 ());
   1.791 +                return *this;
   1.792 +            }
   1.793 +            BOOST_UBLAS_INLINE
   1.794 +            iterator2 &operator -- () {
   1.795 +                layout_type::decrement2 (it_, (*this) ().size1 (), (*this) ().size2 ());
   1.796 +                return *this;
   1.797 +            }
   1.798 +            BOOST_UBLAS_INLINE
   1.799 +            iterator2 &operator += (difference_type n) {
   1.800 +                it_ += n * layout_type::one2 ((*this) ().size1 (), (*this) ().size2 ());
   1.801 +                return *this;
   1.802 +            }
   1.803 +            BOOST_UBLAS_INLINE
   1.804 +            iterator2 &operator -= (difference_type n) {
   1.805 +                it_ -= n * layout_type::one2 ((*this) ().size1 (), (*this) ().size2 ());
   1.806 +                return *this;
   1.807 +            }
   1.808 +            BOOST_UBLAS_INLINE
   1.809 +            difference_type operator - (const iterator2 &it) const {
   1.810 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
   1.811 +                return layout_type::distance2 (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ());
   1.812 +            }
   1.813 +
   1.814 +            // Dereference
   1.815 +            BOOST_UBLAS_INLINE
   1.816 +            reference operator * () const {
   1.817 +                BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());
   1.818 +                BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ());
   1.819 +                return *it_;
   1.820 +            }
   1.821 +            BOOST_UBLAS_INLINE
   1.822 +            reference operator [] (difference_type n) const {
   1.823 +                return *(*this + n);
   1.824 +            }
   1.825 +
   1.826 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
   1.827 +            BOOST_UBLAS_INLINE
   1.828 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.829 +            typename self_type::
   1.830 +#endif
   1.831 +            iterator1 begin () const {
   1.832 +                self_type &m = (*this) ();
   1.833 +                return m.find1 (1, 0, index2 ());
   1.834 +            }
   1.835 +            BOOST_UBLAS_INLINE
   1.836 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.837 +            typename self_type::
   1.838 +#endif
   1.839 +            iterator1 end () const {
   1.840 +                self_type &m = (*this) ();
   1.841 +                return m.find1 (1, m.size1 (), index2 ());
   1.842 +            }
   1.843 +            BOOST_UBLAS_INLINE
   1.844 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.845 +            typename self_type::
   1.846 +#endif
   1.847 +            reverse_iterator1 rbegin () const {
   1.848 +                return reverse_iterator1 (end ());
   1.849 +            }
   1.850 +            BOOST_UBLAS_INLINE
   1.851 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
   1.852 +            typename self_type::
   1.853 +#endif
   1.854 +            reverse_iterator1 rend () const {
   1.855 +                return reverse_iterator1 (begin ());
   1.856 +            }
   1.857 +#endif
   1.858 +
   1.859 +            // Indices
   1.860 +            BOOST_UBLAS_INLINE
   1.861 +            size_type index1 () const {
   1.862 +                self_type &m = (*this) ();
   1.863 +                return layout_type::index1 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
   1.864 +            }
   1.865 +            BOOST_UBLAS_INLINE
   1.866 +            size_type index2 () const {
   1.867 +                self_type &m = (*this) ();
   1.868 +                return layout_type::index2 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
   1.869 +            }
   1.870 +
   1.871 +            // Assignment
   1.872 +            BOOST_UBLAS_INLINE
   1.873 +            iterator2 &operator = (const iterator2 &it) {
   1.874 +                container_reference<self_type>::assign (&it ());
   1.875 +                it_ = it.it_;
   1.876 +                return *this;
   1.877 +            }
   1.878 +
   1.879 +            // Comparison
   1.880 +            BOOST_UBLAS_INLINE
   1.881 +            bool operator == (const iterator2 &it) const {
   1.882 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
   1.883 +                return it_ == it.it_;
   1.884 +            }
   1.885 +            BOOST_UBLAS_INLINE
   1.886 +            bool operator < (const iterator2 &it) const {
   1.887 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
   1.888 +                return it_ < it.it_;
   1.889 +            }
   1.890 +
   1.891 +        private:
   1.892 +            subiterator_type it_;
   1.893 +
   1.894 +            friend class const_iterator2;
   1.895 +        };
   1.896 +#endif
   1.897 +
   1.898 +        BOOST_UBLAS_INLINE
   1.899 +        iterator2 begin2 () {
   1.900 +            return find2 (0, 0, 0);
   1.901 +        }
   1.902 +        BOOST_UBLAS_INLINE
   1.903 +        iterator2 end2 () {
   1.904 +            return find2 (0, 0, size2_);
   1.905 +        }
   1.906 +
   1.907 +        // Reverse iterators
   1.908 +
   1.909 +        BOOST_UBLAS_INLINE
   1.910 +        const_reverse_iterator1 rbegin1 () const {
   1.911 +            return const_reverse_iterator1 (end1 ());
   1.912 +        }
   1.913 +        BOOST_UBLAS_INLINE
   1.914 +        const_reverse_iterator1 rend1 () const {
   1.915 +            return const_reverse_iterator1 (begin1 ());
   1.916 +        }
   1.917 +
   1.918 +        BOOST_UBLAS_INLINE
   1.919 +        reverse_iterator1 rbegin1 () {
   1.920 +            return reverse_iterator1 (end1 ());
   1.921 +        }
   1.922 +        BOOST_UBLAS_INLINE
   1.923 +        reverse_iterator1 rend1 () {
   1.924 +            return reverse_iterator1 (begin1 ());
   1.925 +        }
   1.926 +
   1.927 +        BOOST_UBLAS_INLINE
   1.928 +        const_reverse_iterator2 rbegin2 () const {
   1.929 +            return const_reverse_iterator2 (end2 ());
   1.930 +        }
   1.931 +        BOOST_UBLAS_INLINE
   1.932 +        const_reverse_iterator2 rend2 () const {
   1.933 +            return const_reverse_iterator2 (begin2 ());
   1.934 +        }
   1.935 +
   1.936 +        BOOST_UBLAS_INLINE
   1.937 +        reverse_iterator2 rbegin2 () {
   1.938 +            return reverse_iterator2 (end2 ());
   1.939 +        }
   1.940 +        BOOST_UBLAS_INLINE
   1.941 +        reverse_iterator2 rend2 () {
   1.942 +            return reverse_iterator2 (begin2 ());
   1.943 +        }
   1.944 +
   1.945 +    private:
   1.946 +        size_type size1_;
   1.947 +        size_type size2_;
   1.948 +        array_type data_;
   1.949 +    };
   1.950 +
   1.951 +
   1.952 +    // Bounded matrix class
   1.953 +    template<class T, std::size_t M, std::size_t N, class L>
   1.954 +    class bounded_matrix:
   1.955 +        public matrix<T, L, bounded_array<T, M * N> > {
   1.956 +
   1.957 +        typedef matrix<T, L, bounded_array<T, M * N> > matrix_type;
   1.958 +    public:
   1.959 +        typedef typename matrix_type::size_type size_type;
   1.960 +        static const size_type max_size1 = M;
   1.961 +        static const size_type max_size2 = N;
   1.962 +
   1.963 +        // Construction and destruction
   1.964 +        BOOST_UBLAS_INLINE
   1.965 +        bounded_matrix ():
   1.966 +            matrix_type (M, N) {}
   1.967 +        BOOST_UBLAS_INLINE
   1.968 +        bounded_matrix (size_type size1, size_type size2):
   1.969 +            matrix_type (size1, size2) {}
   1.970 +        BOOST_UBLAS_INLINE
   1.971 +        bounded_matrix (const bounded_matrix &m):
   1.972 +            matrix_type (m) {}
   1.973 +        template<class A2>              // Allow matrix<T, L, bounded_array<M,N> > construction
   1.974 +        BOOST_UBLAS_INLINE
   1.975 +        bounded_matrix (const matrix<T, L, A2> &m):
   1.976 +            matrix_type (m) {}
   1.977 +        template<class AE>
   1.978 +        BOOST_UBLAS_INLINE
   1.979 +        bounded_matrix (const matrix_expression<AE> &ae):
   1.980 +            matrix_type (ae) {}
   1.981 +        BOOST_UBLAS_INLINE
   1.982 +        ~bounded_matrix () {}
   1.983 +
   1.984 +        // Assignment
   1.985 +        BOOST_UBLAS_INLINE
   1.986 +        bounded_matrix &operator = (const bounded_matrix &m) {
   1.987 +            matrix_type::operator = (m);
   1.988 +            return *this;
   1.989 +        }
   1.990 +        template<class L2, class A2>        // Generic matrix assignment
   1.991 +        BOOST_UBLAS_INLINE
   1.992 +        bounded_matrix &operator = (const matrix<T, L2, A2> &m) {
   1.993 +            matrix_type::operator = (m);
   1.994 +            return *this;
   1.995 +        }
   1.996 +        template<class C>          // Container assignment without temporary
   1.997 +        BOOST_UBLAS_INLINE
   1.998 +        bounded_matrix &operator = (const matrix_container<C> &m) {
   1.999 +            matrix_type::operator = (m);
  1.1000 +            return *this;
  1.1001 +        }
  1.1002 +        template<class AE>
  1.1003 +        BOOST_UBLAS_INLINE
  1.1004 +        bounded_matrix &operator = (const matrix_expression<AE> &ae) {
  1.1005 +            matrix_type::operator = (ae);
  1.1006 +            return *this;
  1.1007 +        }
  1.1008 +    };
  1.1009 +
  1.1010 +
  1.1011 +    // Array based matrix class
  1.1012 +    template<class T, class L, class A>
  1.1013 +    class vector_of_vector:
  1.1014 +        public matrix_container<vector_of_vector<T, L, A> > {
  1.1015 +
  1.1016 +        typedef T *pointer;
  1.1017 +        typedef L layout_type;
  1.1018 +        typedef vector_of_vector<T, L, A> self_type;
  1.1019 +    public:
  1.1020 +#ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
  1.1021 +        using matrix_container<self_type>::operator ();
  1.1022 +#endif
  1.1023 +        typedef typename A::size_type size_type;
  1.1024 +        typedef typename A::difference_type difference_type;
  1.1025 +        typedef T value_type;
  1.1026 +        typedef const T &const_reference;
  1.1027 +        typedef T &reference;
  1.1028 +        typedef A array_type;
  1.1029 +        typedef const matrix_reference<const self_type> const_closure_type;
  1.1030 +        typedef matrix_reference<self_type> closure_type;
  1.1031 +        typedef vector<T, typename A::value_type> vector_temporary_type;
  1.1032 +        typedef self_type matrix_temporary_type;
  1.1033 +        typedef dense_tag storage_category;
  1.1034 +        // This could be better for performance,
  1.1035 +        // typedef typename unknown_orientation_tag orientation_category;
  1.1036 +        // but others depend on the orientation information...
  1.1037 +        typedef typename L::orientation_category orientation_category;
  1.1038 +
  1.1039 +        // Construction and destruction
  1.1040 +        BOOST_UBLAS_INLINE
  1.1041 +        vector_of_vector ():
  1.1042 +            matrix_container<self_type> (),
  1.1043 +            size1_ (0), size2_ (0), data_ (1) {}
  1.1044 +        BOOST_UBLAS_INLINE
  1.1045 +        vector_of_vector (size_type size1, size_type size2):
  1.1046 +            matrix_container<self_type> (),
  1.1047 +            size1_ (size1), size2_ (size2), data_ (1) {
  1.1048 +            resize (size1, size2, true);
  1.1049 +        }
  1.1050 +        BOOST_UBLAS_INLINE
  1.1051 +        vector_of_vector (const vector_of_vector &m):
  1.1052 +            matrix_container<self_type> (),
  1.1053 +            size1_ (m.size1_), size2_ (m.size2_), data_ (m.data_) {}
  1.1054 +        template<class AE>
  1.1055 +        BOOST_UBLAS_INLINE
  1.1056 +        vector_of_vector (const matrix_expression<AE> &ae):
  1.1057 +            matrix_container<self_type> (),
  1.1058 +            size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ (layout_type::size1 (size1_, size2_) + 1) {
  1.1059 +            for (size_type k = 0; k < layout_type::size1 (size1_, size2_); ++ k)
  1.1060 +                data ()[k].resize (layout_type::size2 (size1_, size2_));
  1.1061 +            matrix_assign<scalar_assign> (*this, ae);
  1.1062 +        }
  1.1063 +
  1.1064 +        // Accessors
  1.1065 +        BOOST_UBLAS_INLINE
  1.1066 +        size_type size1 () const {
  1.1067 +            return size1_;
  1.1068 +        }
  1.1069 +        BOOST_UBLAS_INLINE
  1.1070 +        size_type size2 () const { 
  1.1071 +            return size2_;
  1.1072 +        }
  1.1073 +
  1.1074 +        // Storage accessors
  1.1075 +        BOOST_UBLAS_INLINE
  1.1076 +        const array_type &data () const {
  1.1077 +            return data_;
  1.1078 +        }
  1.1079 +        BOOST_UBLAS_INLINE
  1.1080 +        array_type &data () {
  1.1081 +            return data_;
  1.1082 +        }
  1.1083 +
  1.1084 +        // Resizing
  1.1085 +        BOOST_UBLAS_INLINE
  1.1086 +        void resize (size_type size1, size_type size2, bool preserve = true) {
  1.1087 +            size1_ = size1;
  1.1088 +            size2_ = size2;
  1.1089 +            if (preserve)
  1.1090 +                data ().resize (layout_type::size1 (size1, size2) + 1, typename array_type::value_type ());
  1.1091 +            else
  1.1092 +                data ().resize (layout_type::size1 (size1, size2) + 1);
  1.1093 +            for (size_type k = 0; k < layout_type::size1 (size1, size2); ++ k) {
  1.1094 +                if (preserve)
  1.1095 +                    data () [k].resize (layout_type::size2 (size1, size2), value_type ());
  1.1096 +                else
  1.1097 +                    data () [k].resize (layout_type::size2 (size1, size2));
  1.1098 +            }
  1.1099 +        }
  1.1100 +
  1.1101 +        // Element access
  1.1102 +        BOOST_UBLAS_INLINE
  1.1103 +        const_reference operator () (size_type i, size_type j) const {
  1.1104 +            return data () [layout_type::element1 (i, size1_, j, size2_)] [layout_type::element2 (i, size1_, j, size2_)]; 
  1.1105 +        }
  1.1106 +        BOOST_UBLAS_INLINE
  1.1107 +        reference at_element (size_type i, size_type j) {
  1.1108 +            return data () [layout_type::element1 (i, size1_, j, size2_)] [layout_type::element2 (i, size1_, j, size2_)]; 
  1.1109 +        }
  1.1110 +        BOOST_UBLAS_INLINE
  1.1111 +        reference operator () (size_type i, size_type j) {
  1.1112 +            return at_element (i, j); 
  1.1113 +        }
  1.1114 +
  1.1115 +        // Element assignment
  1.1116 +        BOOST_UBLAS_INLINE
  1.1117 +        reference insert_element (size_type i, size_type j, const_reference t) {
  1.1118 +            return (at_element (i, j) = t); 
  1.1119 +        }
  1.1120 +        BOOST_UBLAS_INLINE
  1.1121 +        void erase_element (size_type i, size_type j) {
  1.1122 +            at_element (i, j) = value_type/*zero*/(); 
  1.1123 +        }
  1.1124 +        
  1.1125 +        // Zeroing
  1.1126 +        BOOST_UBLAS_INLINE
  1.1127 +        void clear () {
  1.1128 +            for (size_type k = 0; k < layout_type::size1 (size1_, size2_); ++ k)
  1.1129 +                std::fill (data () [k].begin (), data () [k].end (), value_type/*zero*/());
  1.1130 +        }
  1.1131 +
  1.1132 +        // Assignment
  1.1133 +        BOOST_UBLAS_INLINE
  1.1134 +        vector_of_vector &operator = (const vector_of_vector &m) {
  1.1135 +            size1_ = m.size1_;
  1.1136 +            size2_ = m.size2_;
  1.1137 +            data () = m.data ();
  1.1138 +            return *this;
  1.1139 +        }
  1.1140 +        BOOST_UBLAS_INLINE
  1.1141 +        vector_of_vector &assign_temporary (vector_of_vector &m) { 
  1.1142 +            swap (m);
  1.1143 +            return *this;
  1.1144 +        }
  1.1145 +        template<class AE>
  1.1146 +        BOOST_UBLAS_INLINE
  1.1147 +        vector_of_vector &operator = (const matrix_expression<AE> &ae) { 
  1.1148 +            self_type temporary (ae);
  1.1149 +            return assign_temporary (temporary);
  1.1150 +        }
  1.1151 +        template<class C>          // Container assignment without temporary
  1.1152 +        BOOST_UBLAS_INLINE
  1.1153 +        vector_of_vector &operator = (const matrix_container<C> &m) {
  1.1154 +            resize (m ().size1 (), m ().size2 (), false);
  1.1155 +            assign (m);
  1.1156 +            return *this;
  1.1157 +        }
  1.1158 +        template<class AE>
  1.1159 +        BOOST_UBLAS_INLINE
  1.1160 +        vector_of_vector &assign (const matrix_expression<AE> &ae) { 
  1.1161 +            matrix_assign<scalar_assign> (*this, ae); 
  1.1162 +            return *this;
  1.1163 +        }
  1.1164 +        template<class AE>
  1.1165 +        BOOST_UBLAS_INLINE
  1.1166 +        vector_of_vector& operator += (const matrix_expression<AE> &ae) {
  1.1167 +            self_type temporary (*this + ae);
  1.1168 +            return assign_temporary (temporary);
  1.1169 +        }
  1.1170 +        template<class C>          // Container assignment without temporary
  1.1171 +        BOOST_UBLAS_INLINE
  1.1172 +        vector_of_vector &operator += (const matrix_container<C> &m) {
  1.1173 +            plus_assign (m);
  1.1174 +            return *this;
  1.1175 +        }
  1.1176 +        template<class AE>
  1.1177 +        BOOST_UBLAS_INLINE
  1.1178 +        vector_of_vector &plus_assign (const matrix_expression<AE> &ae) { 
  1.1179 +            matrix_assign<scalar_plus_assign> (*this, ae); 
  1.1180 +            return *this;
  1.1181 +        }
  1.1182 +        template<class AE>
  1.1183 +        BOOST_UBLAS_INLINE
  1.1184 +        vector_of_vector& operator -= (const matrix_expression<AE> &ae) {
  1.1185 +            self_type temporary (*this - ae);
  1.1186 +            return assign_temporary (temporary);
  1.1187 +        }
  1.1188 +        template<class C>          // Container assignment without temporary
  1.1189 +        BOOST_UBLAS_INLINE
  1.1190 +        vector_of_vector &operator -= (const matrix_container<C> &m) {
  1.1191 +            minus_assign (m);
  1.1192 +            return *this;
  1.1193 +        }
  1.1194 +        template<class AE>
  1.1195 +        BOOST_UBLAS_INLINE
  1.1196 +        vector_of_vector &minus_assign (const matrix_expression<AE> &ae) {
  1.1197 +            matrix_assign<scalar_minus_assign> (*this, ae); 
  1.1198 +            return *this;
  1.1199 +        }
  1.1200 +        template<class AT>
  1.1201 +        BOOST_UBLAS_INLINE
  1.1202 +        vector_of_vector& operator *= (const AT &at) {
  1.1203 +            matrix_assign_scalar<scalar_multiplies_assign> (*this, at);
  1.1204 +            return *this;
  1.1205 +        }
  1.1206 +        template<class AT>
  1.1207 +        BOOST_UBLAS_INLINE
  1.1208 +        vector_of_vector& operator /= (const AT &at) {
  1.1209 +            matrix_assign_scalar<scalar_divides_assign> (*this, at);
  1.1210 +            return *this;
  1.1211 +        }
  1.1212 +
  1.1213 +        // Swapping
  1.1214 +        BOOST_UBLAS_INLINE
  1.1215 +        void swap (vector_of_vector &m) {
  1.1216 +            if (this != &m) {
  1.1217 +                std::swap (size1_, m.size1_);
  1.1218 +                std::swap (size2_, m.size2_);
  1.1219 +                data ().swap (m.data ());
  1.1220 +            }
  1.1221 +        }
  1.1222 +        BOOST_UBLAS_INLINE
  1.1223 +        friend void swap (vector_of_vector &m1, vector_of_vector &m2) {
  1.1224 +            m1.swap (m2);
  1.1225 +        }
  1.1226 +
  1.1227 +        // Iterator types
  1.1228 +    private:
  1.1229 +        // Use the vector iterator
  1.1230 +        typedef typename A::value_type::const_iterator const_subiterator_type;
  1.1231 +        typedef typename A::value_type::iterator subiterator_type;
  1.1232 +    public:
  1.1233 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.1234 +        typedef indexed_iterator1<self_type, dense_random_access_iterator_tag> iterator1;
  1.1235 +        typedef indexed_iterator2<self_type, dense_random_access_iterator_tag> iterator2;
  1.1236 +        typedef indexed_const_iterator1<self_type, dense_random_access_iterator_tag> const_iterator1;
  1.1237 +        typedef indexed_const_iterator2<self_type, dense_random_access_iterator_tag> const_iterator2;
  1.1238 +#else
  1.1239 +        class const_iterator1;
  1.1240 +        class iterator1;
  1.1241 +        class const_iterator2;
  1.1242 +        class iterator2;
  1.1243 +#endif
  1.1244 +        typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
  1.1245 +        typedef reverse_iterator_base1<iterator1> reverse_iterator1;
  1.1246 +        typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
  1.1247 +        typedef reverse_iterator_base2<iterator2> reverse_iterator2;
  1.1248 +
  1.1249 +        // Element lookup
  1.1250 +        BOOST_UBLAS_INLINE
  1.1251 +        const_iterator1 find1 (int /*rank*/, size_type i, size_type j) const {
  1.1252 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.1253 +            return const_iterator1 (*this, i, j);
  1.1254 +#else
  1.1255 +            return const_iterator1 (*this, i, j, data () [layout_type::address1 (i, size1_, j, size2_)].begin ()  + layout_type::address2 (i, size1_, j, size2_));
  1.1256 +#endif
  1.1257 +        }
  1.1258 +        BOOST_UBLAS_INLINE
  1.1259 +        iterator1 find1 (int /*rank*/, size_type i, size_type j) {
  1.1260 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.1261 +            return iterator1 (*this, i, j);
  1.1262 +#else
  1.1263 +            return iterator1 (*this, i, j, data () [layout_type::address1 (i, size1_, j, size2_)].begin ()  + layout_type::address2 (i, size1_, j, size2_));
  1.1264 +#endif
  1.1265 +        }
  1.1266 +        BOOST_UBLAS_INLINE
  1.1267 +        const_iterator2 find2 (int /*rank*/, size_type i, size_type j) const {
  1.1268 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.1269 +            return const_iterator2 (*this, i, j);
  1.1270 +#else
  1.1271 +            return const_iterator2 (*this, i, j, data () [layout_type::address1 (i, size1_, j, size2_)].begin ()  + layout_type::address2 (i, size1_, j, size2_));
  1.1272 +#endif
  1.1273 +        }
  1.1274 +        BOOST_UBLAS_INLINE
  1.1275 +        iterator2 find2 (int /*rank*/, size_type i, size_type j) {
  1.1276 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.1277 +            return iterator2 (*this, i, j);
  1.1278 +#else
  1.1279 +            return iterator2 (*this, i, j, data () [layout_type::address1 (i, size1_, j, size2_)].begin () + layout_type::address2 (i, size1_, j, size2_));
  1.1280 +#endif
  1.1281 +        }
  1.1282 +
  1.1283 +
  1.1284 +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.1285 +        class const_iterator1:
  1.1286 +            public container_const_reference<vector_of_vector>,
  1.1287 +            public random_access_iterator_base<dense_random_access_iterator_tag,
  1.1288 +                                               const_iterator1, value_type> {
  1.1289 +        public:
  1.1290 +            typedef typename vector_of_vector::value_type value_type;
  1.1291 +            typedef typename vector_of_vector::difference_type difference_type;
  1.1292 +            typedef typename vector_of_vector::const_reference reference;
  1.1293 +            typedef const typename vector_of_vector::pointer pointer;
  1.1294 +
  1.1295 +            typedef const_iterator2 dual_iterator_type;
  1.1296 +            typedef const_reverse_iterator2 dual_reverse_iterator_type;
  1.1297 +
  1.1298 +            // Construction and destruction
  1.1299 +            BOOST_UBLAS_INLINE
  1.1300 +            const_iterator1 ():
  1.1301 +                container_const_reference<self_type> (), i_ (), j_ (), it_ () {}
  1.1302 +            BOOST_UBLAS_INLINE
  1.1303 +            const_iterator1 (const self_type &m, size_type i, size_type j, const const_subiterator_type &it):
  1.1304 +                container_const_reference<self_type> (m), i_ (i), j_ (j), it_ (it) {}
  1.1305 +            BOOST_UBLAS_INLINE
  1.1306 +            const_iterator1 (const iterator1 &it):
  1.1307 +                container_const_reference<self_type> (it ()), i_ (it.i_), j_ (it.j_), it_ (it.it_) {}
  1.1308 +
  1.1309 +            // Arithmetic
  1.1310 +            BOOST_UBLAS_INLINE
  1.1311 +            const_iterator1 &operator ++ () {
  1.1312 +                ++ i_;
  1.1313 +                const self_type &m = (*this) ();
  1.1314 +                if (layout_type::fast1 ())
  1.1315 +                    ++ it_;
  1.1316 +                else 
  1.1317 +                    it_ = m.find1 (1, i_, j_).it_;
  1.1318 +                return *this;
  1.1319 +            }
  1.1320 +            BOOST_UBLAS_INLINE
  1.1321 +            const_iterator1 &operator -- () {
  1.1322 +                -- i_;
  1.1323 +                const self_type &m = (*this) ();
  1.1324 +                if (layout_type::fast1 ())
  1.1325 +                    -- it_;
  1.1326 +                else
  1.1327 +                    it_ = m.find1 (1, i_, j_).it_;
  1.1328 +                return *this;
  1.1329 +            }
  1.1330 +            BOOST_UBLAS_INLINE
  1.1331 +            const_iterator1 &operator += (difference_type n) {
  1.1332 +                i_ += n;
  1.1333 +                const self_type &m = (*this) ();
  1.1334 +                it_ = m.find1 (1, i_, j_).it_;
  1.1335 +                return *this;
  1.1336 +            }
  1.1337 +            BOOST_UBLAS_INLINE
  1.1338 +            const_iterator1 &operator -= (difference_type n) {
  1.1339 +                i_ -= n;
  1.1340 +                const self_type &m = (*this) ();
  1.1341 +                it_ = m.find1 (1, i_, j_).it_;
  1.1342 +                return *this;
  1.1343 +            }
  1.1344 +            BOOST_UBLAS_INLINE
  1.1345 +            difference_type operator - (const const_iterator1 &it) const {
  1.1346 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.1347 +                BOOST_UBLAS_CHECK (index2 () == it.index2 (), bad_index ());
  1.1348 +                return index1 () - it.index1 ();
  1.1349 +            }
  1.1350 +
  1.1351 +            // Dereference
  1.1352 +            BOOST_UBLAS_INLINE
  1.1353 +            const_reference operator * () const {
  1.1354 +                BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());
  1.1355 +                BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ());
  1.1356 +                return *it_;
  1.1357 +            }
  1.1358 +            BOOST_UBLAS_INLINE
  1.1359 +            const_reference operator [] (difference_type n) const {
  1.1360 +                return *(*this + n);
  1.1361 +            }
  1.1362 +
  1.1363 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
  1.1364 +            BOOST_UBLAS_INLINE
  1.1365 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1366 +            typename self_type::
  1.1367 +#endif
  1.1368 +            const_iterator2 begin () const {
  1.1369 +                const self_type &m = (*this) ();
  1.1370 +                return m.find2 (1, index1 (), 0);
  1.1371 +            }
  1.1372 +            BOOST_UBLAS_INLINE
  1.1373 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1374 +            typename self_type::
  1.1375 +#endif
  1.1376 +            const_iterator2 end () const {
  1.1377 +                const self_type &m = (*this) ();
  1.1378 +                return m.find2 (1, index1 (), m.size2 ());
  1.1379 +            }
  1.1380 +            BOOST_UBLAS_INLINE
  1.1381 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1382 +            typename self_type::
  1.1383 +#endif
  1.1384 +            const_reverse_iterator2 rbegin () const {
  1.1385 +                return const_reverse_iterator2 (end ());
  1.1386 +            }
  1.1387 +            BOOST_UBLAS_INLINE
  1.1388 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1389 +            typename self_type::
  1.1390 +#endif
  1.1391 +            const_reverse_iterator2 rend () const {
  1.1392 +                return const_reverse_iterator2 (begin ());
  1.1393 +            }
  1.1394 +#endif
  1.1395 +
  1.1396 +            // Indices
  1.1397 +            BOOST_UBLAS_INLINE
  1.1398 +            size_type index1 () const {
  1.1399 +                return i_;
  1.1400 +            }
  1.1401 +            BOOST_UBLAS_INLINE
  1.1402 +            size_type index2 () const {
  1.1403 +                return j_;
  1.1404 +            }
  1.1405 +
  1.1406 +            // Assignment
  1.1407 +            BOOST_UBLAS_INLINE
  1.1408 +            const_iterator1 &operator = (const const_iterator1 &it) {
  1.1409 +                container_const_reference<self_type>::assign (&it ());
  1.1410 +                it_ = it.it_;
  1.1411 +                return *this;
  1.1412 +            }
  1.1413 +
  1.1414 +            // Comparison
  1.1415 +            BOOST_UBLAS_INLINE
  1.1416 +            bool operator == (const const_iterator1 &it) const {
  1.1417 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.1418 +                BOOST_UBLAS_CHECK (index2 () == it.index2 (), bad_index ());
  1.1419 +                return it_ == it.it_;
  1.1420 +            }
  1.1421 +            BOOST_UBLAS_INLINE
  1.1422 +            bool operator < (const const_iterator1 &it) const {
  1.1423 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.1424 +                BOOST_UBLAS_CHECK (index2 () == it.index2 (), bad_index ());
  1.1425 +                return it_ < it.it_;
  1.1426 +            }
  1.1427 +
  1.1428 +        private:
  1.1429 +            size_type i_;
  1.1430 +            size_type j_;
  1.1431 +            const_subiterator_type it_;
  1.1432 +
  1.1433 +            friend class iterator1;
  1.1434 +        };
  1.1435 +#endif
  1.1436 +
  1.1437 +        BOOST_UBLAS_INLINE
  1.1438 +        const_iterator1 begin1 () const {
  1.1439 +            return find1 (0, 0, 0);
  1.1440 +        }
  1.1441 +        BOOST_UBLAS_INLINE
  1.1442 +        const_iterator1 end1 () const {
  1.1443 +            return find1 (0, size1_, 0);
  1.1444 +        }
  1.1445 +
  1.1446 +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.1447 +        class iterator1:
  1.1448 +            public container_reference<vector_of_vector>,
  1.1449 +            public random_access_iterator_base<dense_random_access_iterator_tag,
  1.1450 +                                               iterator1, value_type> {
  1.1451 +        public:
  1.1452 +            typedef typename vector_of_vector::value_type value_type;
  1.1453 +            typedef typename vector_of_vector::difference_type difference_type;
  1.1454 +            typedef typename vector_of_vector::reference reference;
  1.1455 +            typedef typename vector_of_vector::pointer pointer;
  1.1456 +
  1.1457 +            typedef iterator2 dual_iterator_type;
  1.1458 +            typedef reverse_iterator2 dual_reverse_iterator_type;
  1.1459 +
  1.1460 +            // Construction and destruction
  1.1461 +            BOOST_UBLAS_INLINE
  1.1462 +            iterator1 ():
  1.1463 +                container_reference<self_type> (), i_ (), j_ (), it_ () {}
  1.1464 +            BOOST_UBLAS_INLINE
  1.1465 +            iterator1 (self_type &m, size_type i, size_type j, const subiterator_type &it):
  1.1466 +                container_reference<self_type> (m), i_ (i), j_ (j), it_ (it) {}
  1.1467 +
  1.1468 +            // Arithmetic
  1.1469 +            BOOST_UBLAS_INLINE
  1.1470 +            iterator1 &operator ++ () {
  1.1471 +                ++ i_;
  1.1472 +                self_type &m = (*this) ();
  1.1473 +                if (layout_type::fast1 ())
  1.1474 +                    ++ it_;
  1.1475 +                else
  1.1476 +                    it_ = m.find1 (1, i_, j_).it_;
  1.1477 +                return *this;
  1.1478 +            }
  1.1479 +            BOOST_UBLAS_INLINE
  1.1480 +            iterator1 &operator -- () {
  1.1481 +                -- i_;
  1.1482 +                self_type &m = (*this) ();
  1.1483 +                if (layout_type::fast1 ())
  1.1484 +                    -- it_;
  1.1485 +                else
  1.1486 +                    it_ = m.find1 (1, i_, j_).it_;
  1.1487 +                return *this;
  1.1488 +            }
  1.1489 +            BOOST_UBLAS_INLINE
  1.1490 +            iterator1 &operator += (difference_type n) {
  1.1491 +                i_ += n;
  1.1492 +                self_type &m = (*this) ();
  1.1493 +                it_ = m.find1 (1, i_, j_).it_;
  1.1494 +                return *this;
  1.1495 +            }
  1.1496 +            BOOST_UBLAS_INLINE
  1.1497 +            iterator1 &operator -= (difference_type n) {
  1.1498 +                i_ -= n;
  1.1499 +                self_type &m = (*this) ();
  1.1500 +                it_ = m.find1 (1, i_, j_).it_;
  1.1501 +                return *this;
  1.1502 +            }
  1.1503 +            BOOST_UBLAS_INLINE
  1.1504 +            difference_type operator - (const iterator1 &it) const {
  1.1505 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.1506 +                BOOST_UBLAS_CHECK (index2 () == it.index2 (), bad_index ());
  1.1507 +                return index1 () - it.index1 ();
  1.1508 +            }
  1.1509 +
  1.1510 +            // Dereference
  1.1511 +            BOOST_UBLAS_INLINE
  1.1512 +            reference operator * () const {
  1.1513 +                BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());
  1.1514 +                BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ());
  1.1515 +                return *it_;
  1.1516 +            }
  1.1517 +            BOOST_UBLAS_INLINE
  1.1518 +            reference operator [] (difference_type n) const {
  1.1519 +                return *(*this + n);
  1.1520 +            }
  1.1521 +
  1.1522 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
  1.1523 +            BOOST_UBLAS_INLINE
  1.1524 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1525 +            typename self_type::
  1.1526 +#endif
  1.1527 +            iterator2 begin () const {
  1.1528 +                self_type &m = (*this) ();
  1.1529 +                return m.find2 (1, index1 (), 0);
  1.1530 +            }
  1.1531 +            BOOST_UBLAS_INLINE
  1.1532 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1533 +            typename self_type::
  1.1534 +#endif
  1.1535 +            iterator2 end () const {
  1.1536 +                self_type &m = (*this) ();
  1.1537 +                return m.find2 (1, index1 (), m.size2 ());
  1.1538 +            }
  1.1539 +            BOOST_UBLAS_INLINE
  1.1540 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1541 +            typename self_type::
  1.1542 +#endif
  1.1543 +            reverse_iterator2 rbegin () const {
  1.1544 +                return reverse_iterator2 (end ());
  1.1545 +            }
  1.1546 +            BOOST_UBLAS_INLINE
  1.1547 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1548 +            typename self_type::
  1.1549 +#endif
  1.1550 +            reverse_iterator2 rend () const {
  1.1551 +                return reverse_iterator2 (begin ());
  1.1552 +            }
  1.1553 +#endif
  1.1554 +
  1.1555 +            // Indices
  1.1556 +            BOOST_UBLAS_INLINE
  1.1557 +            size_type index1 () const {
  1.1558 +                return i_;
  1.1559 +            }
  1.1560 +            BOOST_UBLAS_INLINE
  1.1561 +            size_type index2 () const {
  1.1562 +                return j_;
  1.1563 +            }
  1.1564 +
  1.1565 +            // Assignment
  1.1566 +            BOOST_UBLAS_INLINE
  1.1567 +            iterator1 &operator = (const iterator1 &it) {
  1.1568 +                container_reference<self_type>::assign (&it ());
  1.1569 +                it_ = it.it_;
  1.1570 +                return *this;
  1.1571 +            }
  1.1572 +
  1.1573 +            // Comparison
  1.1574 +            BOOST_UBLAS_INLINE
  1.1575 +            bool operator == (const iterator1 &it) const {
  1.1576 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.1577 +                BOOST_UBLAS_CHECK (index2 () == it.index2 (), bad_index ());
  1.1578 +                return it_ == it.it_;
  1.1579 +            }
  1.1580 +            BOOST_UBLAS_INLINE
  1.1581 +            bool operator < (const iterator1 &it) const {
  1.1582 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.1583 +                BOOST_UBLAS_CHECK (index2 () == it.index2 (), bad_index ());
  1.1584 +                return it_ < it.it_;
  1.1585 +            }
  1.1586 +
  1.1587 +        private:
  1.1588 +            size_type i_;
  1.1589 +            size_type j_;
  1.1590 +            subiterator_type it_;
  1.1591 +
  1.1592 +            friend class const_iterator1;
  1.1593 +        };
  1.1594 +#endif
  1.1595 +
  1.1596 +        BOOST_UBLAS_INLINE
  1.1597 +        iterator1 begin1 () {
  1.1598 +            return find1 (0, 0, 0);
  1.1599 +        }
  1.1600 +        BOOST_UBLAS_INLINE
  1.1601 +        iterator1 end1 () {
  1.1602 +            return find1 (0, size1_, 0);
  1.1603 +        }
  1.1604 +
  1.1605 +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.1606 +        class const_iterator2:
  1.1607 +            public container_const_reference<vector_of_vector>,
  1.1608 +            public random_access_iterator_base<dense_random_access_iterator_tag,
  1.1609 +                                               const_iterator2, value_type> {
  1.1610 +        public:
  1.1611 +            typedef typename vector_of_vector::value_type value_type;
  1.1612 +            typedef typename vector_of_vector::difference_type difference_type;
  1.1613 +            typedef typename vector_of_vector::const_reference reference;
  1.1614 +            typedef const typename vector_of_vector::pointer pointer;
  1.1615 +
  1.1616 +            typedef const_iterator1 dual_iterator_type;
  1.1617 +            typedef const_reverse_iterator1 dual_reverse_iterator_type;
  1.1618 +
  1.1619 +            // Construction and destruction
  1.1620 +            BOOST_UBLAS_INLINE
  1.1621 +            const_iterator2 ():
  1.1622 +                container_const_reference<self_type> (), i_ (), j_ (), it_ () {}
  1.1623 +            BOOST_UBLAS_INLINE
  1.1624 +            const_iterator2 (const self_type &m, size_type i, size_type j, const const_subiterator_type &it):
  1.1625 +                container_const_reference<self_type> (m), i_ (i), j_ (j), it_ (it) {}
  1.1626 +            BOOST_UBLAS_INLINE
  1.1627 +            const_iterator2 (const iterator2 &it):
  1.1628 +                container_const_reference<self_type> (it ()), i_ (it.i_), j_ (it.j_), it_ (it.it_) {}
  1.1629 +
  1.1630 +            // Arithmetic
  1.1631 +            BOOST_UBLAS_INLINE
  1.1632 +            const_iterator2 &operator ++ () {
  1.1633 +                ++ j_;
  1.1634 +                const self_type &m = (*this) ();
  1.1635 +                if (layout_type::fast2 ())
  1.1636 +                    ++ it_;
  1.1637 +                else
  1.1638 +                    it_ = m.find2 (1, i_, j_).it_;
  1.1639 +                return *this;
  1.1640 +            }
  1.1641 +            BOOST_UBLAS_INLINE
  1.1642 +            const_iterator2 &operator -- () {
  1.1643 +                -- j_;
  1.1644 +                const self_type &m = (*this) ();
  1.1645 +                if (layout_type::fast2 ())
  1.1646 +                    -- it_;
  1.1647 +                else
  1.1648 +                    it_ = m.find2 (1, i_, j_).it_;
  1.1649 +                return *this;
  1.1650 +            }
  1.1651 +            BOOST_UBLAS_INLINE
  1.1652 +            const_iterator2 &operator += (difference_type n) {
  1.1653 +                j_ += n;
  1.1654 +                const self_type &m = (*this) ();
  1.1655 +                it_ = m.find2 (1, i_, j_).it_;
  1.1656 +                return *this;
  1.1657 +            }
  1.1658 +            BOOST_UBLAS_INLINE
  1.1659 +            const_iterator2 &operator -= (difference_type n) {
  1.1660 +                j_ -= n;
  1.1661 +                const self_type &m = (*this) ();
  1.1662 +                it_ = m.find2 (1, i_, j_).it_;
  1.1663 +                return *this;
  1.1664 +            }
  1.1665 +            BOOST_UBLAS_INLINE
  1.1666 +            difference_type operator - (const const_iterator2 &it) const {
  1.1667 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.1668 +                BOOST_UBLAS_CHECK (index1 () == it.index1 (), bad_index ());
  1.1669 +                return index2 () - it.index2 ();
  1.1670 +            }
  1.1671 +
  1.1672 +            // Dereference
  1.1673 +            BOOST_UBLAS_INLINE
  1.1674 +            const_reference operator * () const {
  1.1675 +                BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());
  1.1676 +                BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ());
  1.1677 +                return *it_;
  1.1678 +            }
  1.1679 +            BOOST_UBLAS_INLINE
  1.1680 +            const_reference operator [] (difference_type n) const {
  1.1681 +                return *(*this + n);
  1.1682 +            }
  1.1683 +
  1.1684 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
  1.1685 +            BOOST_UBLAS_INLINE
  1.1686 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1687 +            typename self_type::
  1.1688 +#endif
  1.1689 +            const_iterator1 begin () const {
  1.1690 +                const self_type &m = (*this) ();
  1.1691 +                return m.find1 (1, 0, index2 ());
  1.1692 +            }
  1.1693 +            BOOST_UBLAS_INLINE
  1.1694 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1695 +            typename self_type::
  1.1696 +#endif
  1.1697 +            const_iterator1 end () const {
  1.1698 +                const self_type &m = (*this) ();
  1.1699 +                return m.find1 (1, m.size1 (), index2 ());
  1.1700 +            }
  1.1701 +            BOOST_UBLAS_INLINE
  1.1702 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1703 +            typename self_type::
  1.1704 +#endif
  1.1705 +            const_reverse_iterator1 rbegin () const {
  1.1706 +                return const_reverse_iterator1 (end ());
  1.1707 +            }
  1.1708 +            BOOST_UBLAS_INLINE
  1.1709 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1710 +            typename self_type::
  1.1711 +#endif
  1.1712 +            const_reverse_iterator1 rend () const {
  1.1713 +                return const_reverse_iterator1 (begin ());
  1.1714 +            }
  1.1715 +#endif
  1.1716 +
  1.1717 +            // Indices
  1.1718 +            BOOST_UBLAS_INLINE
  1.1719 +            size_type index1 () const {
  1.1720 +                return i_;
  1.1721 +            }
  1.1722 +            BOOST_UBLAS_INLINE
  1.1723 +            size_type index2 () const {
  1.1724 +                return j_;
  1.1725 +            }
  1.1726 +
  1.1727 +            // Assignment
  1.1728 +            BOOST_UBLAS_INLINE
  1.1729 +            const_iterator2 &operator = (const const_iterator2 &it) {
  1.1730 +                container_const_reference<self_type>::assign (&it ());
  1.1731 +                it_ = it.it_;
  1.1732 +                return *this;
  1.1733 +            }
  1.1734 +
  1.1735 +            // Comparison
  1.1736 +            BOOST_UBLAS_INLINE
  1.1737 +            bool operator == (const const_iterator2 &it) const {
  1.1738 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.1739 +                BOOST_UBLAS_CHECK (index1 () == it.index1 (), bad_index ());
  1.1740 +                return it_ == it.it_;
  1.1741 +            }
  1.1742 +            BOOST_UBLAS_INLINE
  1.1743 +            bool operator < (const const_iterator2 &it) const {
  1.1744 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.1745 +                BOOST_UBLAS_CHECK (index1 () == it.index1 (), bad_index ());
  1.1746 +                return it_ < it.it_;
  1.1747 +            }
  1.1748 +
  1.1749 +        private:
  1.1750 +            size_type i_;
  1.1751 +            size_type j_;
  1.1752 +            const_subiterator_type it_;
  1.1753 +
  1.1754 +            friend class iterator2;
  1.1755 +        };
  1.1756 +#endif
  1.1757 +
  1.1758 +        BOOST_UBLAS_INLINE
  1.1759 +        const_iterator2 begin2 () const {
  1.1760 +            return find2 (0, 0, 0);
  1.1761 +        }
  1.1762 +        BOOST_UBLAS_INLINE
  1.1763 +        const_iterator2 end2 () const {
  1.1764 +            return find2 (0, 0, size2_);
  1.1765 +        }
  1.1766 +
  1.1767 +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.1768 +        class iterator2:
  1.1769 +            public container_reference<vector_of_vector>,
  1.1770 +            public random_access_iterator_base<dense_random_access_iterator_tag,
  1.1771 +                                               iterator2, value_type> {
  1.1772 +        public:
  1.1773 +            typedef typename vector_of_vector::value_type value_type;
  1.1774 +            typedef typename vector_of_vector::difference_type difference_type;
  1.1775 +            typedef typename vector_of_vector::reference reference;
  1.1776 +            typedef typename vector_of_vector::pointer pointer;
  1.1777 +
  1.1778 +            typedef iterator1 dual_iterator_type;
  1.1779 +            typedef reverse_iterator1 dual_reverse_iterator_type;
  1.1780 +
  1.1781 +            // Construction and destruction
  1.1782 +            BOOST_UBLAS_INLINE
  1.1783 +            iterator2 ():
  1.1784 +                container_reference<self_type> (), i_ (), j_ (), it_ () {}
  1.1785 +            BOOST_UBLAS_INLINE
  1.1786 +            iterator2 (self_type &m, size_type i, size_type j, const subiterator_type &it):
  1.1787 +                container_reference<self_type> (m), i_ (i), j_ (j), it_ (it) {}
  1.1788 +
  1.1789 +            // Arithmetic
  1.1790 +            BOOST_UBLAS_INLINE
  1.1791 +            iterator2 &operator ++ () {
  1.1792 +                ++ j_;
  1.1793 +                self_type &m = (*this) ();
  1.1794 +                if (layout_type::fast2 ())
  1.1795 +                    ++ it_;
  1.1796 +                else
  1.1797 +                    it_ = m.find2 (1, i_, j_).it_;
  1.1798 +                return *this;
  1.1799 +            }
  1.1800 +            BOOST_UBLAS_INLINE
  1.1801 +            iterator2 &operator -- () {
  1.1802 +                -- j_;
  1.1803 +                self_type &m = (*this) ();
  1.1804 +                if (layout_type::fast2 ())
  1.1805 +                    -- it_;
  1.1806 +                else
  1.1807 +                    it_ = m.find2 (1, i_, j_).it_;
  1.1808 +                return *this;
  1.1809 +            }
  1.1810 +            BOOST_UBLAS_INLINE
  1.1811 +            iterator2 &operator += (difference_type n) {
  1.1812 +                j_ += n;
  1.1813 +                self_type &m = (*this) ();
  1.1814 +                it_ = m.find2 (1, i_, j_).it_;
  1.1815 +                return *this;
  1.1816 +            }
  1.1817 +            BOOST_UBLAS_INLINE
  1.1818 +            iterator2 &operator -= (difference_type n) {
  1.1819 +                j_ -= n;
  1.1820 +                self_type &m = (*this) ();
  1.1821 +                it_ = m.find2 (1, i_, j_).it_;
  1.1822 +                return *this;
  1.1823 +            }
  1.1824 +            BOOST_UBLAS_INLINE
  1.1825 +            difference_type operator - (const iterator2 &it) const {
  1.1826 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.1827 +                BOOST_UBLAS_CHECK (index1 () == it.index1 (), bad_index ());
  1.1828 +                return index2 () - it.index2 ();
  1.1829 +            }
  1.1830 +
  1.1831 +            // Dereference
  1.1832 +            BOOST_UBLAS_INLINE
  1.1833 +            reference operator * () const {
  1.1834 +                BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());
  1.1835 +                BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ());
  1.1836 +                return *it_;
  1.1837 +            }
  1.1838 +            BOOST_UBLAS_INLINE
  1.1839 +            reference operator [] (difference_type n) const {
  1.1840 +                return *(*this + n);
  1.1841 +            }
  1.1842 +
  1.1843 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
  1.1844 +            BOOST_UBLAS_INLINE
  1.1845 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1846 +            typename self_type::
  1.1847 +#endif
  1.1848 +            iterator1 begin () const {
  1.1849 +                self_type &m = (*this) ();
  1.1850 +                return m.find1 (1, 0, index2 ());
  1.1851 +            }
  1.1852 +            BOOST_UBLAS_INLINE
  1.1853 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1854 +            typename self_type::
  1.1855 +#endif
  1.1856 +            iterator1 end () const {
  1.1857 +                self_type &m = (*this) ();
  1.1858 +                return m.find1 (1, m.size1 (), index2 ());
  1.1859 +            }
  1.1860 +            BOOST_UBLAS_INLINE
  1.1861 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1862 +            typename self_type::
  1.1863 +#endif
  1.1864 +            reverse_iterator1 rbegin () const {
  1.1865 +                return reverse_iterator1 (end ());
  1.1866 +            }
  1.1867 +            BOOST_UBLAS_INLINE
  1.1868 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.1869 +            typename self_type::
  1.1870 +#endif
  1.1871 +            reverse_iterator1 rend () const {
  1.1872 +                return reverse_iterator1 (begin ());
  1.1873 +            }
  1.1874 +#endif
  1.1875 +
  1.1876 +            // Indices
  1.1877 +            BOOST_UBLAS_INLINE
  1.1878 +            size_type index1 () const {
  1.1879 +                return i_;
  1.1880 +            }
  1.1881 +            BOOST_UBLAS_INLINE
  1.1882 +            size_type index2 () const {
  1.1883 +                return j_;
  1.1884 +            }
  1.1885 +
  1.1886 +            // Assignment
  1.1887 +            BOOST_UBLAS_INLINE
  1.1888 +            iterator2 &operator = (const iterator2 &it) {
  1.1889 +                container_reference<self_type>::assign (&it ());
  1.1890 +                it_ = it.it_;
  1.1891 +                return *this;
  1.1892 +            }
  1.1893 +
  1.1894 +            // Comparison
  1.1895 +            BOOST_UBLAS_INLINE
  1.1896 +            bool operator == (const iterator2 &it) const {
  1.1897 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.1898 +                BOOST_UBLAS_CHECK (index1 () == it.index1 (), bad_index ());
  1.1899 +                return it_ == it.it_;
  1.1900 +            }
  1.1901 +            BOOST_UBLAS_INLINE
  1.1902 +            bool operator < (const iterator2 &it) const {
  1.1903 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.1904 +                BOOST_UBLAS_CHECK (index1 () == it.index1 (), bad_index ());
  1.1905 +                return it_ < it.it_;
  1.1906 +            }
  1.1907 +
  1.1908 +        private:
  1.1909 +            size_type i_;
  1.1910 +            size_type j_;
  1.1911 +            subiterator_type it_;
  1.1912 +
  1.1913 +            friend class const_iterator2;
  1.1914 +        };
  1.1915 +#endif
  1.1916 +
  1.1917 +        BOOST_UBLAS_INLINE
  1.1918 +        iterator2 begin2 () {
  1.1919 +            return find2 (0, 0, 0);
  1.1920 +        }
  1.1921 +        BOOST_UBLAS_INLINE
  1.1922 +        iterator2 end2 () {
  1.1923 +            return find2 (0, 0, size2_);
  1.1924 +        }
  1.1925 +
  1.1926 +        // Reverse iterators
  1.1927 +
  1.1928 +        BOOST_UBLAS_INLINE
  1.1929 +        const_reverse_iterator1 rbegin1 () const {
  1.1930 +            return const_reverse_iterator1 (end1 ());
  1.1931 +        }
  1.1932 +        BOOST_UBLAS_INLINE
  1.1933 +        const_reverse_iterator1 rend1 () const {
  1.1934 +            return const_reverse_iterator1 (begin1 ());
  1.1935 +        }
  1.1936 +
  1.1937 +        BOOST_UBLAS_INLINE
  1.1938 +        reverse_iterator1 rbegin1 () {
  1.1939 +            return reverse_iterator1 (end1 ());
  1.1940 +        }
  1.1941 +        BOOST_UBLAS_INLINE
  1.1942 +        reverse_iterator1 rend1 () {
  1.1943 +            return reverse_iterator1 (begin1 ());
  1.1944 +        }
  1.1945 +
  1.1946 +        BOOST_UBLAS_INLINE
  1.1947 +        const_reverse_iterator2 rbegin2 () const {
  1.1948 +            return const_reverse_iterator2 (end2 ());
  1.1949 +        }
  1.1950 +        BOOST_UBLAS_INLINE
  1.1951 +        const_reverse_iterator2 rend2 () const {
  1.1952 +            return const_reverse_iterator2 (begin2 ());
  1.1953 +        }
  1.1954 +
  1.1955 +        BOOST_UBLAS_INLINE
  1.1956 +        reverse_iterator2 rbegin2 () {
  1.1957 +            return reverse_iterator2 (end2 ());
  1.1958 +        }
  1.1959 +        BOOST_UBLAS_INLINE
  1.1960 +        reverse_iterator2 rend2 () {
  1.1961 +            return reverse_iterator2 (begin2 ());
  1.1962 +        }
  1.1963 +
  1.1964 +    private:
  1.1965 +        size_type size1_;
  1.1966 +        size_type size2_;
  1.1967 +        array_type data_;
  1.1968 +    };
  1.1969 +
  1.1970 +
  1.1971 +    // Zero matrix class
  1.1972 +    template<class T>
  1.1973 +    class zero_matrix:
  1.1974 +        public matrix_container<zero_matrix<T> > {
  1.1975 +
  1.1976 +        typedef const T *const_pointer;
  1.1977 +        typedef zero_matrix<T> self_type;
  1.1978 +    public:
  1.1979 +#ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
  1.1980 +        using matrix_container<self_type>::operator ();
  1.1981 +#endif
  1.1982 +        typedef std::size_t size_type;
  1.1983 +        typedef std::ptrdiff_t difference_type;
  1.1984 +        typedef T value_type;
  1.1985 +        typedef const T &const_reference;
  1.1986 +        typedef T &reference;
  1.1987 +        typedef const matrix_reference<const self_type> const_closure_type;
  1.1988 +        typedef matrix_reference<self_type> closure_type;
  1.1989 +        typedef sparse_tag storage_category;
  1.1990 +        typedef unknown_orientation_tag orientation_category;
  1.1991 +
  1.1992 +        // Construction and destruction
  1.1993 +        BOOST_UBLAS_INLINE
  1.1994 +        zero_matrix ():
  1.1995 +            matrix_container<self_type> (),
  1.1996 +            size1_ (0), size2_ (0) {}
  1.1997 +        BOOST_UBLAS_INLINE
  1.1998 +        zero_matrix (size_type size):
  1.1999 +            matrix_container<self_type> (),
  1.2000 +            size1_ (size), size2_ (size) {}
  1.2001 +        BOOST_UBLAS_INLINE
  1.2002 +        zero_matrix (size_type size1, size_type size2):
  1.2003 +            matrix_container<self_type> (),
  1.2004 +            size1_ (size1), size2_ (size2) {}
  1.2005 +        BOOST_UBLAS_INLINE
  1.2006 +        zero_matrix (const zero_matrix &m):
  1.2007 +            matrix_container<self_type> (),
  1.2008 +            size1_ (m.size1_), size2_ (m.size2_) {}
  1.2009 +
  1.2010 +        // Accessors
  1.2011 +        BOOST_UBLAS_INLINE
  1.2012 +        size_type size1 () const {
  1.2013 +            return size1_;
  1.2014 +        }
  1.2015 +        BOOST_UBLAS_INLINE
  1.2016 +        size_type size2 () const {
  1.2017 +            return size2_;
  1.2018 +        }
  1.2019 +
  1.2020 +        // Resizing
  1.2021 +        BOOST_UBLAS_INLINE
  1.2022 +        void resize (size_type size, bool preserve = true) {
  1.2023 +            size1_ = size;
  1.2024 +            size2_ = size;
  1.2025 +        }
  1.2026 +        BOOST_UBLAS_INLINE
  1.2027 +        void resize (size_type size1, size_type size2, bool /*preserve*/ = true) {
  1.2028 +            size1_ = size1;
  1.2029 +            size2_ = size2;
  1.2030 +        }
  1.2031 +
  1.2032 +        // Element access
  1.2033 +        BOOST_UBLAS_INLINE
  1.2034 +        const_reference operator () (size_type /* i */, size_type /* j */) const {
  1.2035 +            return zero_;
  1.2036 +        }
  1.2037 +
  1.2038 +        // Assignment
  1.2039 +        BOOST_UBLAS_INLINE
  1.2040 +        zero_matrix &operator = (const zero_matrix &m) {
  1.2041 +            size1_ = m.size1_;
  1.2042 +            size2_ = m.size2_;
  1.2043 +            return *this;
  1.2044 +        }
  1.2045 +        BOOST_UBLAS_INLINE
  1.2046 +        zero_matrix &assign_temporary (zero_matrix &m) {
  1.2047 +            swap (m);
  1.2048 +            return *this;
  1.2049 +        }
  1.2050 +
  1.2051 +        // Swapping
  1.2052 +        BOOST_UBLAS_INLINE
  1.2053 +        void swap (zero_matrix &m) {
  1.2054 +            if (this != &m) {
  1.2055 +                std::swap (size1_, m.size1_);
  1.2056 +                std::swap (size2_, m.size2_);
  1.2057 +            }
  1.2058 +        }
  1.2059 +        BOOST_UBLAS_INLINE
  1.2060 +        friend void swap (zero_matrix &m1, zero_matrix &m2) {
  1.2061 +            m1.swap (m2);
  1.2062 +        }
  1.2063 +
  1.2064 +        // Iterator types
  1.2065 +    public:
  1.2066 +        class const_iterator1;
  1.2067 +        class const_iterator2;
  1.2068 +        typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
  1.2069 +        typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
  1.2070 +
  1.2071 +        // Element lookup
  1.2072 +        BOOST_UBLAS_INLINE
  1.2073 +        const_iterator1 find1 (int /*rank*/, size_type /*i*/, size_type /*j*/) const {
  1.2074 +            return const_iterator1 (*this);
  1.2075 +        }
  1.2076 +        BOOST_UBLAS_INLINE
  1.2077 +        const_iterator2 find2 (int /*rank*/, size_type /*i*/, size_type /*j*/) const {
  1.2078 +            return const_iterator2 (*this);
  1.2079 +        }
  1.2080 +
  1.2081 +        class const_iterator1:
  1.2082 +            public container_const_reference<zero_matrix>,
  1.2083 +            public bidirectional_iterator_base<sparse_bidirectional_iterator_tag,
  1.2084 +                                               const_iterator1, value_type> {
  1.2085 +        public:
  1.2086 +            typedef typename zero_matrix::value_type value_type;
  1.2087 +            typedef typename zero_matrix::difference_type difference_type;
  1.2088 +            typedef typename zero_matrix::const_reference reference;
  1.2089 +            typedef typename zero_matrix::const_pointer pointer;
  1.2090 +
  1.2091 +            typedef const_iterator2 dual_iterator_type;
  1.2092 +            typedef const_reverse_iterator2 dual_reverse_iterator_type;
  1.2093 +
  1.2094 +            // Construction and destruction
  1.2095 +            BOOST_UBLAS_INLINE
  1.2096 +            const_iterator1 ():
  1.2097 +                container_const_reference<self_type> () {}
  1.2098 +            BOOST_UBLAS_INLINE
  1.2099 +            const_iterator1 (const self_type &m):
  1.2100 +                container_const_reference<self_type> (m) {}
  1.2101 +
  1.2102 +            // Arithmetic
  1.2103 +            BOOST_UBLAS_INLINE
  1.2104 +            const_iterator1 &operator ++ () {
  1.2105 +                BOOST_UBLAS_CHECK_FALSE (bad_index ());
  1.2106 +                return *this;
  1.2107 +            }
  1.2108 +            BOOST_UBLAS_INLINE
  1.2109 +            const_iterator1 &operator -- () {
  1.2110 +                BOOST_UBLAS_CHECK_FALSE (bad_index ());
  1.2111 +                return *this;
  1.2112 +            }
  1.2113 +
  1.2114 +            // Dereference
  1.2115 +            BOOST_UBLAS_INLINE
  1.2116 +            const_reference operator * () const {
  1.2117 +                BOOST_UBLAS_CHECK_FALSE (bad_index ());
  1.2118 +                return zero_;   // arbitary return value
  1.2119 +            }
  1.2120 +
  1.2121 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
  1.2122 +            BOOST_UBLAS_INLINE
  1.2123 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2124 +            typename self_type::
  1.2125 +#endif
  1.2126 +            const_iterator2 begin () const {
  1.2127 +                return const_iterator2 ((*this) ());
  1.2128 +            }
  1.2129 +            BOOST_UBLAS_INLINE
  1.2130 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2131 +            typename self_type::
  1.2132 +#endif
  1.2133 +            const_iterator2 end () const {
  1.2134 +                return const_iterator2 ((*this) ());
  1.2135 +            }
  1.2136 +            BOOST_UBLAS_INLINE
  1.2137 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2138 +            typename self_type::
  1.2139 +#endif
  1.2140 +            const_reverse_iterator2 rbegin () const {
  1.2141 +                return const_reverse_iterator2 (end ());
  1.2142 +            }
  1.2143 +            BOOST_UBLAS_INLINE
  1.2144 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2145 +            typename self_type::
  1.2146 +#endif
  1.2147 +            const_reverse_iterator2 rend () const {
  1.2148 +                return const_reverse_iterator2 (begin ());
  1.2149 +            }
  1.2150 +#endif
  1.2151 +
  1.2152 +            // Indices
  1.2153 +            BOOST_UBLAS_INLINE
  1.2154 +            size_type index1 () const {
  1.2155 +                BOOST_UBLAS_CHECK_FALSE (bad_index ());
  1.2156 +                return 0;   // arbitary return value
  1.2157 +            }
  1.2158 +            BOOST_UBLAS_INLINE
  1.2159 +            size_type index2 () const {
  1.2160 +                BOOST_UBLAS_CHECK_FALSE (bad_index ());
  1.2161 +                return 0;   // arbitary return value
  1.2162 +            }
  1.2163 +
  1.2164 +            // Assignment
  1.2165 +            BOOST_UBLAS_INLINE
  1.2166 +            const_iterator1 &operator = (const const_iterator1 &it) {
  1.2167 +                container_const_reference<self_type>::assign (&it ());
  1.2168 +                return *this;
  1.2169 +            }
  1.2170 +
  1.2171 +            // Comparison
  1.2172 +            BOOST_UBLAS_INLINE
  1.2173 +            bool operator == (const const_iterator1 &it) const {
  1.2174 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.2175 +                return true;
  1.2176 +            }
  1.2177 +        };
  1.2178 +
  1.2179 +        typedef const_iterator1 iterator1;
  1.2180 +
  1.2181 +        BOOST_UBLAS_INLINE
  1.2182 +        const_iterator1 begin1 () const {
  1.2183 +            return const_iterator1 (*this);
  1.2184 +        }
  1.2185 +        BOOST_UBLAS_INLINE
  1.2186 +        const_iterator1 end1 () const {
  1.2187 +            return const_iterator1 (*this);
  1.2188 +        }
  1.2189 +
  1.2190 +        class const_iterator2:
  1.2191 +            public container_const_reference<zero_matrix>,
  1.2192 +            public bidirectional_iterator_base<sparse_bidirectional_iterator_tag,
  1.2193 +                                               const_iterator2, value_type> {
  1.2194 +        public:
  1.2195 +            typedef typename zero_matrix::value_type value_type;
  1.2196 +            typedef typename zero_matrix::difference_type difference_type;
  1.2197 +            typedef typename zero_matrix::const_reference reference;
  1.2198 +            typedef typename zero_matrix::const_pointer pointer;
  1.2199 +
  1.2200 +            typedef const_iterator1 dual_iterator_type;
  1.2201 +            typedef const_reverse_iterator1 dual_reverse_iterator_type;
  1.2202 +
  1.2203 +            // Construction and destruction
  1.2204 +            BOOST_UBLAS_INLINE
  1.2205 +            const_iterator2 ():
  1.2206 +                container_const_reference<self_type> () {}
  1.2207 +            BOOST_UBLAS_INLINE
  1.2208 +            const_iterator2 (const self_type &m):
  1.2209 +                container_const_reference<self_type> (m) {}
  1.2210 +
  1.2211 +            // Arithmetic
  1.2212 +            BOOST_UBLAS_INLINE
  1.2213 +            const_iterator2 &operator ++ () {
  1.2214 +                BOOST_UBLAS_CHECK_FALSE (bad_index ());
  1.2215 +                return *this;
  1.2216 +            }
  1.2217 +            BOOST_UBLAS_INLINE
  1.2218 +            const_iterator2 &operator -- () {
  1.2219 +                BOOST_UBLAS_CHECK_FALSE (bad_index ());
  1.2220 +                return *this;
  1.2221 +            }
  1.2222 +
  1.2223 +            // Dereference
  1.2224 +            BOOST_UBLAS_INLINE
  1.2225 +            const_reference operator * () const {
  1.2226 +                BOOST_UBLAS_CHECK_FALSE (bad_index ());
  1.2227 +                return zero_;   // arbitary return value
  1.2228 +            }
  1.2229 +
  1.2230 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
  1.2231 +            BOOST_UBLAS_INLINE
  1.2232 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2233 +            typename self_type::
  1.2234 +#endif
  1.2235 +            const_iterator1 begin () const {
  1.2236 +                return const_iterator1 ((*this) ());
  1.2237 +            }
  1.2238 +            BOOST_UBLAS_INLINE
  1.2239 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2240 +            typename self_type::
  1.2241 +#endif
  1.2242 +            const_iterator1 end () const {
  1.2243 +                return const_iterator1 ((*this) ());
  1.2244 +            }
  1.2245 +            BOOST_UBLAS_INLINE
  1.2246 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2247 +            typename self_type::
  1.2248 +#endif
  1.2249 +            const_reverse_iterator1 rbegin () const {
  1.2250 +                return const_reverse_iterator1 (end ());
  1.2251 +            }
  1.2252 +            BOOST_UBLAS_INLINE
  1.2253 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2254 +            typename self_type::
  1.2255 +#endif
  1.2256 +            const_reverse_iterator1 rend () const {
  1.2257 +                return const_reverse_iterator1 (begin ());
  1.2258 +            }
  1.2259 +#endif
  1.2260 +
  1.2261 +            // Indices
  1.2262 +            BOOST_UBLAS_INLINE
  1.2263 +            size_type index1 () const {
  1.2264 +                BOOST_UBLAS_CHECK_FALSE (bad_index ());
  1.2265 +                return 0;   // arbitary return value
  1.2266 +            }
  1.2267 +            BOOST_UBLAS_INLINE
  1.2268 +            size_type index2 () const {
  1.2269 +                BOOST_UBLAS_CHECK_FALSE (bad_index ());
  1.2270 +                return 0;   // arbitary return value
  1.2271 +            }
  1.2272 +
  1.2273 +            // Assignment
  1.2274 +            BOOST_UBLAS_INLINE
  1.2275 +            const_iterator2 &operator = (const const_iterator2 &it) {
  1.2276 +                container_const_reference<self_type>::assign (&it ());
  1.2277 +                return *this;
  1.2278 +            }
  1.2279 +
  1.2280 +            // Comparison
  1.2281 +            BOOST_UBLAS_INLINE
  1.2282 +            bool operator == (const const_iterator2 &it) const {
  1.2283 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.2284 +                return true;
  1.2285 +            }
  1.2286 +        };
  1.2287 +
  1.2288 +        typedef const_iterator2 iterator2;
  1.2289 +
  1.2290 +        BOOST_UBLAS_INLINE
  1.2291 +        const_iterator2 begin2 () const {
  1.2292 +            return find2 (0, 0, 0);
  1.2293 +        }
  1.2294 +        BOOST_UBLAS_INLINE
  1.2295 +        const_iterator2 end2 () const {
  1.2296 +            return find2 (0, 0, size2_);
  1.2297 +        }
  1.2298 +
  1.2299 +        // Reverse iterators
  1.2300 +
  1.2301 +        BOOST_UBLAS_INLINE
  1.2302 +        const_reverse_iterator1 rbegin1 () const {
  1.2303 +            return const_reverse_iterator1 (end1 ());
  1.2304 +        }
  1.2305 +        BOOST_UBLAS_INLINE
  1.2306 +        const_reverse_iterator1 rend1 () const {
  1.2307 +            return const_reverse_iterator1 (begin1 ());
  1.2308 +        }
  1.2309 +
  1.2310 +        BOOST_UBLAS_INLINE
  1.2311 +        const_reverse_iterator2 rbegin2 () const {
  1.2312 +            return const_reverse_iterator2 (end2 ());
  1.2313 +        }
  1.2314 +        BOOST_UBLAS_INLINE
  1.2315 +        const_reverse_iterator2 rend2 () const {
  1.2316 +            return const_reverse_iterator2 (begin2 ());
  1.2317 +        }
  1.2318 +
  1.2319 +    private:
  1.2320 +        size_type size1_;
  1.2321 +        size_type size2_;
  1.2322 +        static const value_type zero_;
  1.2323 +    };
  1.2324 +
  1.2325 +    template<class T>
  1.2326 +    const typename zero_matrix<T>::value_type zero_matrix<T>::zero_ (0);
  1.2327 +
  1.2328 +
  1.2329 +    // Identity matrix class
  1.2330 +    template<class T>
  1.2331 +    class identity_matrix:
  1.2332 +        public matrix_container<identity_matrix<T> > {
  1.2333 +
  1.2334 +        typedef const T *const_pointer;
  1.2335 +        typedef identity_matrix<T> self_type;
  1.2336 +    public:
  1.2337 +#ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
  1.2338 +        using matrix_container<self_type>::operator ();
  1.2339 +#endif
  1.2340 +        typedef std::size_t size_type;
  1.2341 +        typedef std::ptrdiff_t difference_type;
  1.2342 +        typedef T value_type;
  1.2343 +        typedef const T &const_reference;
  1.2344 +        typedef T &reference;
  1.2345 +        typedef const matrix_reference<const self_type> const_closure_type;
  1.2346 +        typedef matrix_reference<self_type> closure_type;
  1.2347 +        typedef sparse_tag storage_category;
  1.2348 +        typedef unknown_orientation_tag orientation_category;
  1.2349 +
  1.2350 +        // Construction and destruction
  1.2351 +        BOOST_UBLAS_INLINE
  1.2352 +        identity_matrix ():
  1.2353 +            matrix_container<self_type> (),
  1.2354 +            size1_ (0), size2_ (0), size_common_ (0) {}
  1.2355 +        BOOST_UBLAS_INLINE
  1.2356 +        identity_matrix (size_type size):
  1.2357 +            matrix_container<self_type> (),
  1.2358 +            size1_ (size), size2_ (size), size_common_ ((std::min) (size1_, size2_)) {}
  1.2359 +        BOOST_UBLAS_INLINE
  1.2360 +        identity_matrix (size_type size1, size_type size2):
  1.2361 +            matrix_container<self_type> (),
  1.2362 +            size1_ (size1), size2_ (size2), size_common_ ((std::min) (size1_, size2_)) {}
  1.2363 +        BOOST_UBLAS_INLINE
  1.2364 +        identity_matrix (const identity_matrix &m):
  1.2365 +            matrix_container<self_type> (),
  1.2366 +            size1_ (m.size1_), size2_ (m.size2_), size_common_ ((std::min) (size1_, size2_)) {}
  1.2367 +
  1.2368 +        // Accessors
  1.2369 +        BOOST_UBLAS_INLINE
  1.2370 +        size_type size1 () const {
  1.2371 +            return size1_;
  1.2372 +        }
  1.2373 +        BOOST_UBLAS_INLINE
  1.2374 +        size_type size2 () const {
  1.2375 +            return size2_;
  1.2376 +        }
  1.2377 +
  1.2378 +        // Resizing
  1.2379 +        BOOST_UBLAS_INLINE
  1.2380 +        void resize (size_type size, bool preserve = true) {
  1.2381 +            size1_ = size;
  1.2382 +            size2_ = size;
  1.2383 +        }
  1.2384 +        BOOST_UBLAS_INLINE
  1.2385 +        void resize (size_type size1, size_type size2, bool /*preserve*/ = true) {
  1.2386 +            size1_ = size1;
  1.2387 +            size2_ = size2;
  1.2388 +        }
  1.2389 +
  1.2390 +        // Element access
  1.2391 +        BOOST_UBLAS_INLINE
  1.2392 +        const_reference operator () (size_type i, size_type j) const {
  1.2393 +            if (i == j)
  1.2394 +                return one_;
  1.2395 +            else
  1.2396 +                return zero_;
  1.2397 +        }
  1.2398 +
  1.2399 +        // Assignment
  1.2400 +        BOOST_UBLAS_INLINE
  1.2401 +        identity_matrix &operator = (const identity_matrix &m) {
  1.2402 +            size1_ = m.size1_;
  1.2403 +            size2_ = m.size2_;
  1.2404 +            return *this;
  1.2405 +        }
  1.2406 +        BOOST_UBLAS_INLINE
  1.2407 +        identity_matrix &assign_temporary (identity_matrix &m) { 
  1.2408 +            swap (m);
  1.2409 +            return *this;
  1.2410 +        }
  1.2411 +
  1.2412 +        // Swapping
  1.2413 +        BOOST_UBLAS_INLINE
  1.2414 +        void swap (identity_matrix &m) {
  1.2415 +            if (this != &m) {
  1.2416 +                std::swap (size1_, m.size1_);
  1.2417 +                std::swap (size2_, m.size2_);
  1.2418 +            }
  1.2419 +        }
  1.2420 +        BOOST_UBLAS_INLINE
  1.2421 +        friend void swap (identity_matrix &m1, identity_matrix &m2) {
  1.2422 +            m1.swap (m2);
  1.2423 +        }
  1.2424 +
  1.2425 +        // Iterator types
  1.2426 +    private:
  1.2427 +        // Use an index
  1.2428 +        typedef size_type const_subiterator_type;
  1.2429 +
  1.2430 +    public:
  1.2431 +        class const_iterator1;
  1.2432 +        class const_iterator2;
  1.2433 +        typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
  1.2434 +        typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
  1.2435 +
  1.2436 +        // Element lookup
  1.2437 +        BOOST_UBLAS_INLINE
  1.2438 +        const_iterator1 find1 (int rank, size_type i, size_type j) const {
  1.2439 +            if (rank == 1) {
  1.2440 +                i = (std::max) (i, j);
  1.2441 +                i = (std::min) (i, j + 1);
  1.2442 +            }
  1.2443 +            return const_iterator1 (*this, i);
  1.2444 +        }
  1.2445 +        BOOST_UBLAS_INLINE
  1.2446 +        const_iterator2 find2 (int rank, size_type i, size_type j) const {
  1.2447 +            if (rank == 1) {
  1.2448 +                j = (std::max) (j, i);
  1.2449 +                j = (std::min) (j, i + 1);
  1.2450 +            }
  1.2451 +            return const_iterator2 (*this, j);
  1.2452 +        }
  1.2453 +
  1.2454 +
  1.2455 +        class const_iterator1:
  1.2456 +            public container_const_reference<identity_matrix>,
  1.2457 +            public bidirectional_iterator_base<sparse_bidirectional_iterator_tag,
  1.2458 +                                               const_iterator1, value_type> {
  1.2459 +        public:
  1.2460 +            typedef typename identity_matrix::value_type value_type;
  1.2461 +            typedef typename identity_matrix::difference_type difference_type;
  1.2462 +            typedef typename identity_matrix::const_reference reference;
  1.2463 +            typedef typename identity_matrix::const_pointer pointer;
  1.2464 +
  1.2465 +            typedef const_iterator2 dual_iterator_type;
  1.2466 +            typedef const_reverse_iterator2 dual_reverse_iterator_type;
  1.2467 +
  1.2468 +            // Construction and destruction
  1.2469 +            BOOST_UBLAS_INLINE
  1.2470 +            const_iterator1 ():
  1.2471 +                container_const_reference<self_type> (), it_ () {}
  1.2472 +            BOOST_UBLAS_INLINE
  1.2473 +            const_iterator1 (const self_type &m, const const_subiterator_type &it):
  1.2474 +                container_const_reference<self_type> (m), it_ (it) {}
  1.2475 +
  1.2476 +            // Arithmetic
  1.2477 +            BOOST_UBLAS_INLINE
  1.2478 +            const_iterator1 &operator ++ () {
  1.2479 +                BOOST_UBLAS_CHECK (it_ < (*this) ().size1 (), bad_index ());
  1.2480 +                ++it_;
  1.2481 +                return *this;
  1.2482 +            }
  1.2483 +            BOOST_UBLAS_INLINE
  1.2484 +            const_iterator1 &operator -- () {
  1.2485 +                BOOST_UBLAS_CHECK (it_ > 0, bad_index ());
  1.2486 +                --it_;
  1.2487 +                return *this;
  1.2488 +            }
  1.2489 +
  1.2490 +            // Dereference
  1.2491 +            BOOST_UBLAS_INLINE
  1.2492 +            const_reference operator * () const {
  1.2493 +                return one_;
  1.2494 +            }
  1.2495 +
  1.2496 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
  1.2497 +            BOOST_UBLAS_INLINE
  1.2498 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2499 +            typename self_type::
  1.2500 +#endif
  1.2501 +            const_iterator2 begin () const {
  1.2502 +                return const_iterator2 ((*this) (), it_); 
  1.2503 +            }
  1.2504 +            BOOST_UBLAS_INLINE
  1.2505 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2506 +            typename self_type::
  1.2507 +#endif
  1.2508 +            const_iterator2 end () const {
  1.2509 +                return const_iterator2 ((*this) (), it_ + 1); 
  1.2510 +            }
  1.2511 +            BOOST_UBLAS_INLINE
  1.2512 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2513 +            typename self_type::
  1.2514 +#endif
  1.2515 +            const_reverse_iterator2 rbegin () const {
  1.2516 +                return const_reverse_iterator2 (end ());
  1.2517 +            }
  1.2518 +            BOOST_UBLAS_INLINE
  1.2519 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2520 +            typename self_type::
  1.2521 +#endif
  1.2522 +            const_reverse_iterator2 rend () const {
  1.2523 +                return const_reverse_iterator2 (begin ());
  1.2524 +            }
  1.2525 +#endif
  1.2526 +
  1.2527 +            // Indices
  1.2528 +            BOOST_UBLAS_INLINE
  1.2529 +            size_type index1 () const {
  1.2530 +                return it_;
  1.2531 +            }
  1.2532 +            BOOST_UBLAS_INLINE
  1.2533 +            size_type index2 () const {
  1.2534 +                return it_;
  1.2535 +            }
  1.2536 +
  1.2537 +            // Assignment
  1.2538 +            BOOST_UBLAS_INLINE
  1.2539 +            const_iterator1 &operator = (const const_iterator1 &it) {
  1.2540 +                container_const_reference<self_type>::assign (&it ());
  1.2541 +                it_ = it.it_;
  1.2542 +                return *this;
  1.2543 +            }
  1.2544 +
  1.2545 +            // Comparison
  1.2546 +            BOOST_UBLAS_INLINE
  1.2547 +            bool operator == (const const_iterator1 &it) const {
  1.2548 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.2549 +                return it_ == it.it_;
  1.2550 +            }
  1.2551 +
  1.2552 +        private:
  1.2553 +            const_subiterator_type it_;
  1.2554 +        };
  1.2555 +
  1.2556 +        typedef const_iterator1 iterator1;
  1.2557 +
  1.2558 +        BOOST_UBLAS_INLINE
  1.2559 +        const_iterator1 begin1 () const {
  1.2560 +            return const_iterator1 (*this, 0);
  1.2561 +        }
  1.2562 +        BOOST_UBLAS_INLINE
  1.2563 +        const_iterator1 end1 () const {
  1.2564 +            return const_iterator1 (*this, size_common_);
  1.2565 +        }
  1.2566 +
  1.2567 +        class const_iterator2:
  1.2568 +            public container_const_reference<identity_matrix>,
  1.2569 +            public bidirectional_iterator_base<sparse_bidirectional_iterator_tag,
  1.2570 +                                               const_iterator2, value_type> {
  1.2571 +        public:
  1.2572 +            typedef typename identity_matrix::value_type value_type;
  1.2573 +            typedef typename identity_matrix::difference_type difference_type;
  1.2574 +            typedef typename identity_matrix::const_reference reference;
  1.2575 +            typedef typename identity_matrix::const_pointer pointer;
  1.2576 +
  1.2577 +            typedef const_iterator1 dual_iterator_type;
  1.2578 +            typedef const_reverse_iterator1 dual_reverse_iterator_type;
  1.2579 +
  1.2580 +            // Construction and destruction
  1.2581 +            BOOST_UBLAS_INLINE
  1.2582 +            const_iterator2 ():
  1.2583 +                container_const_reference<self_type> (), it_ () {}
  1.2584 +            BOOST_UBLAS_INLINE
  1.2585 +            const_iterator2 (const self_type &m, const const_subiterator_type &it):
  1.2586 +                container_const_reference<self_type> (m), it_ (it) {}
  1.2587 +
  1.2588 +            // Arithmetic
  1.2589 +            BOOST_UBLAS_INLINE
  1.2590 +            const_iterator2 &operator ++ () {
  1.2591 +                BOOST_UBLAS_CHECK (it_ < (*this) ().size_common_, bad_index ());
  1.2592 +                ++it_;
  1.2593 +                return *this;
  1.2594 +            }
  1.2595 +            BOOST_UBLAS_INLINE
  1.2596 +            const_iterator2 &operator -- () {
  1.2597 +                BOOST_UBLAS_CHECK (it_ > 0, bad_index ());
  1.2598 +                --it_;
  1.2599 +                return *this;
  1.2600 +            }
  1.2601 +
  1.2602 +            // Dereference
  1.2603 +            BOOST_UBLAS_INLINE
  1.2604 +            const_reference operator * () const {
  1.2605 +                return one_;
  1.2606 +            }
  1.2607 +
  1.2608 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
  1.2609 +            BOOST_UBLAS_INLINE
  1.2610 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2611 +            typename self_type::
  1.2612 +#endif
  1.2613 +            const_iterator1 begin () const {
  1.2614 +                return const_iterator1 ((*this) (), it_); 
  1.2615 +            }
  1.2616 +            BOOST_UBLAS_INLINE
  1.2617 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2618 +            typename self_type::
  1.2619 +#endif
  1.2620 +            const_iterator1 end () const {
  1.2621 +                return const_iterator1 ((*this) (), it_ + 1); 
  1.2622 +            }
  1.2623 +            BOOST_UBLAS_INLINE
  1.2624 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2625 +            typename self_type::
  1.2626 +#endif
  1.2627 +            const_reverse_iterator1 rbegin () const {
  1.2628 +                return const_reverse_iterator1 (end ());
  1.2629 +            }
  1.2630 +            BOOST_UBLAS_INLINE
  1.2631 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2632 +            typename self_type::
  1.2633 +#endif
  1.2634 +            const_reverse_iterator1 rend () const {
  1.2635 +                return const_reverse_iterator1 (begin ());
  1.2636 +            }
  1.2637 +#endif
  1.2638 +
  1.2639 +            // Indices
  1.2640 +            BOOST_UBLAS_INLINE
  1.2641 +            size_type index1 () const {
  1.2642 +                return it_;
  1.2643 +            }
  1.2644 +            BOOST_UBLAS_INLINE
  1.2645 +            size_type index2 () const {
  1.2646 +                return it_;
  1.2647 +            }
  1.2648 +
  1.2649 +            // Assignment
  1.2650 +            BOOST_UBLAS_INLINE
  1.2651 +            const_iterator2 &operator = (const const_iterator2 &it) {
  1.2652 +                container_const_reference<self_type>::assign (&it ());
  1.2653 +                it_ = it.it_;
  1.2654 +                return *this;
  1.2655 +            }
  1.2656 +
  1.2657 +            // Comparison
  1.2658 +            BOOST_UBLAS_INLINE
  1.2659 +            bool operator == (const const_iterator2 &it) const {
  1.2660 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.2661 +                return it_ == it.it_;
  1.2662 +            }
  1.2663 +
  1.2664 +        private:
  1.2665 +            const_subiterator_type it_;
  1.2666 +        };
  1.2667 +
  1.2668 +        typedef const_iterator2 iterator2;
  1.2669 +
  1.2670 +        BOOST_UBLAS_INLINE
  1.2671 +        const_iterator2 begin2 () const {
  1.2672 +            return const_iterator2 (*this, 0);
  1.2673 +        }
  1.2674 +        BOOST_UBLAS_INLINE
  1.2675 +        const_iterator2 end2 () const {
  1.2676 +            return const_iterator2 (*this, size_common_);
  1.2677 +        }
  1.2678 +
  1.2679 +        // Reverse iterators
  1.2680 +
  1.2681 +        BOOST_UBLAS_INLINE
  1.2682 +        const_reverse_iterator1 rbegin1 () const {
  1.2683 +            return const_reverse_iterator1 (end1 ());
  1.2684 +        }
  1.2685 +        BOOST_UBLAS_INLINE
  1.2686 +        const_reverse_iterator1 rend1 () const {
  1.2687 +            return const_reverse_iterator1 (begin1 ());
  1.2688 +        }
  1.2689 +
  1.2690 +        BOOST_UBLAS_INLINE
  1.2691 +        const_reverse_iterator2 rbegin2 () const {
  1.2692 +            return const_reverse_iterator2 (end2 ());
  1.2693 +        }
  1.2694 +        BOOST_UBLAS_INLINE
  1.2695 +        const_reverse_iterator2 rend2 () const {
  1.2696 +            return const_reverse_iterator2 (begin2 ());
  1.2697 +        }
  1.2698 +
  1.2699 +    private:
  1.2700 +        size_type size1_;
  1.2701 +        size_type size2_;
  1.2702 +        size_type size_common_;
  1.2703 +        static const value_type zero_;
  1.2704 +        static const value_type one_;
  1.2705 +    };
  1.2706 +
  1.2707 +    template<class T>
  1.2708 +    const typename identity_matrix<T>::value_type identity_matrix<T>::zero_ (0);
  1.2709 +    template<class T>
  1.2710 +    const typename identity_matrix<T>::value_type identity_matrix<T>::one_ (1);
  1.2711 +
  1.2712 +
  1.2713 +    // Scalar matrix class
  1.2714 +    template<class T>
  1.2715 +    class scalar_matrix:
  1.2716 +        public matrix_container<scalar_matrix<T> > {
  1.2717 +
  1.2718 +        typedef const T *const_pointer;
  1.2719 +        typedef scalar_matrix<T> self_type;
  1.2720 +    public:
  1.2721 +#ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
  1.2722 +        using matrix_container<self_type>::operator ();
  1.2723 +#endif
  1.2724 +        typedef std::size_t size_type;
  1.2725 +        typedef std::ptrdiff_t difference_type;
  1.2726 +        typedef T value_type;
  1.2727 +        typedef const T &const_reference;
  1.2728 +        typedef T &reference;
  1.2729 +        typedef const matrix_reference<const self_type> const_closure_type;
  1.2730 +        typedef dense_tag storage_category;
  1.2731 +        typedef unknown_orientation_tag orientation_category;
  1.2732 +
  1.2733 +        // Construction and destruction
  1.2734 +        BOOST_UBLAS_INLINE
  1.2735 +        scalar_matrix ():
  1.2736 +            matrix_container<self_type> (),
  1.2737 +            size1_ (0), size2_ (0), value_ () {}
  1.2738 +        BOOST_UBLAS_INLINE
  1.2739 +        scalar_matrix (size_type size1, size_type size2, const value_type &value = value_type(1)):
  1.2740 +            matrix_container<self_type> (),
  1.2741 +            size1_ (size1), size2_ (size2), value_ (value) {}
  1.2742 +        BOOST_UBLAS_INLINE
  1.2743 +        scalar_matrix (const scalar_matrix &m):
  1.2744 +            matrix_container<self_type> (),
  1.2745 +            size1_ (m.size1_), size2_ (m.size2_), value_ (m.value_) {}
  1.2746 +
  1.2747 +        // Accessors
  1.2748 +        BOOST_UBLAS_INLINE
  1.2749 +        size_type size1 () const {
  1.2750 +            return size1_;
  1.2751 +        }
  1.2752 +        BOOST_UBLAS_INLINE
  1.2753 +        size_type size2 () const {
  1.2754 +            return size2_;
  1.2755 +        }
  1.2756 +
  1.2757 +        // Resizing
  1.2758 +        BOOST_UBLAS_INLINE
  1.2759 +        void resize (size_type size1, size_type size2, bool /*preserve*/ = true) {
  1.2760 +            size1_ = size1;
  1.2761 +            size2_ = size2;
  1.2762 +        }
  1.2763 +
  1.2764 +        // Element access
  1.2765 +        BOOST_UBLAS_INLINE
  1.2766 +        const_reference operator () (size_type /*i*/, size_type /*j*/) const {
  1.2767 +            return value_; 
  1.2768 +        }
  1.2769 +
  1.2770 +        // Assignment
  1.2771 +        BOOST_UBLAS_INLINE
  1.2772 +        scalar_matrix &operator = (const scalar_matrix &m) {
  1.2773 +            size1_ = m.size1_;
  1.2774 +            size2_ = m.size2_;
  1.2775 +            value_ = m.value_;
  1.2776 +            return *this;
  1.2777 +        }
  1.2778 +        BOOST_UBLAS_INLINE
  1.2779 +        scalar_matrix &assign_temporary (scalar_matrix &m) { 
  1.2780 +            swap (m);
  1.2781 +            return *this;
  1.2782 +        }
  1.2783 +
  1.2784 +        // Swapping
  1.2785 +        BOOST_UBLAS_INLINE
  1.2786 +        void swap (scalar_matrix &m) {
  1.2787 +            if (this != &m) {
  1.2788 +                std::swap (size1_, m.size1_);
  1.2789 +                std::swap (size2_, m.size2_);
  1.2790 +                std::swap (value_, m.value_);
  1.2791 +            }
  1.2792 +        }
  1.2793 +        BOOST_UBLAS_INLINE
  1.2794 +        friend void swap (scalar_matrix &m1, scalar_matrix &m2) {
  1.2795 +            m1.swap (m2);
  1.2796 +        }
  1.2797 +
  1.2798 +        // Iterator types
  1.2799 +    private:
  1.2800 +        // Use an index
  1.2801 +        typedef size_type const_subiterator_type;
  1.2802 +
  1.2803 +    public:
  1.2804 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.2805 +        typedef indexed_const_iterator1<self_type, dense_random_access_iterator_tag> iterator1;
  1.2806 +        typedef indexed_const_iterator2<self_type, dense_random_access_iterator_tag> iterator2;
  1.2807 +        typedef indexed_const_iterator1<self_type, dense_random_access_iterator_tag> const_iterator1;
  1.2808 +        typedef indexed_const_iterator2<self_type, dense_random_access_iterator_tag> const_iterator2;
  1.2809 +#else
  1.2810 +        class const_iterator1;
  1.2811 +        class const_iterator2;
  1.2812 +#endif
  1.2813 +        typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
  1.2814 +        typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
  1.2815 +
  1.2816 +        // Element lookup
  1.2817 +        BOOST_UBLAS_INLINE
  1.2818 +        const_iterator1 find1 (int /*rank*/, size_type i, size_type j) const {
  1.2819 +            return const_iterator1 (*this, i, j);
  1.2820 +        }
  1.2821 +        BOOST_UBLAS_INLINE
  1.2822 +        const_iterator2 find2 (int /*rank*/, size_type i, size_type j) const {
  1.2823 +            return const_iterator2 (*this, i, j);
  1.2824 +        }   
  1.2825 +
  1.2826 +
  1.2827 +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.2828 +        class const_iterator1:
  1.2829 +            public container_const_reference<scalar_matrix>,
  1.2830 +            public random_access_iterator_base<dense_random_access_iterator_tag,
  1.2831 +                                               const_iterator1, value_type> {
  1.2832 +        public:
  1.2833 +            typedef typename scalar_matrix::value_type value_type;
  1.2834 +            typedef typename scalar_matrix::difference_type difference_type;
  1.2835 +            typedef typename scalar_matrix::const_reference reference;
  1.2836 +            typedef typename scalar_matrix::const_pointer pointer;
  1.2837 +
  1.2838 +            typedef const_iterator2 dual_iterator_type;
  1.2839 +            typedef const_reverse_iterator2 dual_reverse_iterator_type;
  1.2840 +
  1.2841 +            // Construction and destruction
  1.2842 +            BOOST_UBLAS_INLINE
  1.2843 +            const_iterator1 ():
  1.2844 +                container_const_reference<scalar_matrix> (), it1_ (), it2_ () {}
  1.2845 +            BOOST_UBLAS_INLINE
  1.2846 +            const_iterator1 (const scalar_matrix &m, const const_subiterator_type &it1, const const_subiterator_type &it2):
  1.2847 +                container_const_reference<scalar_matrix> (m), it1_ (it1), it2_ (it2) {}
  1.2848 +
  1.2849 +            // Arithmetic
  1.2850 +            BOOST_UBLAS_INLINE
  1.2851 +            const_iterator1 &operator ++ () {
  1.2852 +                ++ it1_;
  1.2853 +                return *this;
  1.2854 +            }
  1.2855 +            BOOST_UBLAS_INLINE
  1.2856 +            const_iterator1 &operator -- () {
  1.2857 +                -- it1_;
  1.2858 +                return *this;
  1.2859 +            }
  1.2860 +            BOOST_UBLAS_INLINE
  1.2861 +            const_iterator1 &operator += (difference_type n) {
  1.2862 +                it1_ += n;
  1.2863 +                return *this;
  1.2864 +            }
  1.2865 +            BOOST_UBLAS_INLINE
  1.2866 +            const_iterator1 &operator -= (difference_type n) {
  1.2867 +                it1_ -= n;
  1.2868 +                return *this;
  1.2869 +            }
  1.2870 +            BOOST_UBLAS_INLINE
  1.2871 +            difference_type operator - (const const_iterator1 &it) const {
  1.2872 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.2873 +                BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ());
  1.2874 +                return it1_ - it.it1_;
  1.2875 +            }
  1.2876 +
  1.2877 +            // Dereference
  1.2878 +            BOOST_UBLAS_INLINE
  1.2879 +            const_reference operator * () const {
  1.2880 +                BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());
  1.2881 +                BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ());
  1.2882 +                return (*this) () (index1 (), index2 ());
  1.2883 +            }
  1.2884 +            BOOST_UBLAS_INLINE
  1.2885 +            const_reference operator [] (difference_type n) const {
  1.2886 +                return *(*this + n);
  1.2887 +            }
  1.2888 +
  1.2889 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
  1.2890 +            BOOST_UBLAS_INLINE
  1.2891 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2892 +            typename self_type::
  1.2893 +#endif
  1.2894 +            const_iterator2 begin () const {
  1.2895 +                const scalar_matrix &m = (*this) ();
  1.2896 +                return m.find2 (1, index1 (), 0);
  1.2897 +            }
  1.2898 +            BOOST_UBLAS_INLINE
  1.2899 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2900 +            typename self_type::
  1.2901 +#endif
  1.2902 +            const_iterator2 end () const {
  1.2903 +                const scalar_matrix &m = (*this) ();
  1.2904 +                return m.find2 (1, index1 (), m.size2 ());
  1.2905 +            }
  1.2906 +            BOOST_UBLAS_INLINE
  1.2907 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2908 +            typename self_type::
  1.2909 +#endif
  1.2910 +            const_reverse_iterator2 rbegin () const {
  1.2911 +                return const_reverse_iterator2 (end ());
  1.2912 +            }
  1.2913 +            BOOST_UBLAS_INLINE
  1.2914 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.2915 +            typename self_type::
  1.2916 +#endif
  1.2917 +            const_reverse_iterator2 rend () const {
  1.2918 +                return const_reverse_iterator2 (begin ());
  1.2919 +            }
  1.2920 +#endif
  1.2921 +
  1.2922 +            // Indices
  1.2923 +            BOOST_UBLAS_INLINE
  1.2924 +            size_type index1 () const {
  1.2925 +                return it1_;
  1.2926 +            }
  1.2927 +            BOOST_UBLAS_INLINE
  1.2928 +            size_type index2 () const {
  1.2929 +                return it2_;
  1.2930 +            }
  1.2931 +
  1.2932 +            // Assignment
  1.2933 +            BOOST_UBLAS_INLINE
  1.2934 +            const_iterator1 &operator = (const const_iterator1 &it) {
  1.2935 +                container_const_reference<scalar_matrix>::assign (&it ());
  1.2936 +                it1_ = it.it1_;
  1.2937 +                it2_ = it.it2_;
  1.2938 +                return *this;
  1.2939 +            }
  1.2940 +
  1.2941 +            // Comparison
  1.2942 +            BOOST_UBLAS_INLINE
  1.2943 +            bool operator == (const const_iterator1 &it) const {
  1.2944 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.2945 +                BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ());
  1.2946 +                return it1_ == it.it1_;
  1.2947 +            }
  1.2948 +            BOOST_UBLAS_INLINE
  1.2949 +            bool operator < (const const_iterator1 &it) const {
  1.2950 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.2951 +                BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ());
  1.2952 +                return it1_ < it.it1_;
  1.2953 +            }
  1.2954 +
  1.2955 +        private:
  1.2956 +            const_subiterator_type it1_;
  1.2957 +            const_subiterator_type it2_;
  1.2958 +        };
  1.2959 +
  1.2960 +        typedef const_iterator1 iterator1;
  1.2961 +#endif
  1.2962 +
  1.2963 +        BOOST_UBLAS_INLINE
  1.2964 +        const_iterator1 begin1 () const {
  1.2965 +            return find1 (0, 0, 0);
  1.2966 +        }
  1.2967 +        BOOST_UBLAS_INLINE
  1.2968 +        const_iterator1 end1 () const {
  1.2969 +            return find1 (0, size1_, 0);
  1.2970 +        }
  1.2971 +
  1.2972 +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.2973 +        class const_iterator2:
  1.2974 +            public container_const_reference<scalar_matrix>,
  1.2975 +            public random_access_iterator_base<dense_random_access_iterator_tag,
  1.2976 +                                               const_iterator2, value_type> {
  1.2977 +        public:
  1.2978 +            typedef typename scalar_matrix::value_type value_type;
  1.2979 +            typedef typename scalar_matrix::difference_type difference_type;
  1.2980 +            typedef typename scalar_matrix::const_reference reference;
  1.2981 +            typedef typename scalar_matrix::const_pointer pointer;
  1.2982 +
  1.2983 +            typedef const_iterator1 dual_iterator_type;
  1.2984 +            typedef const_reverse_iterator1 dual_reverse_iterator_type;
  1.2985 +
  1.2986 +            // Construction and destruction
  1.2987 +            BOOST_UBLAS_INLINE
  1.2988 +            const_iterator2 ():
  1.2989 +                container_const_reference<scalar_matrix> (), it1_ (), it2_ () {}
  1.2990 +            BOOST_UBLAS_INLINE
  1.2991 +            const_iterator2 (const scalar_matrix &m, const const_subiterator_type &it1, const const_subiterator_type &it2):
  1.2992 +                container_const_reference<scalar_matrix> (m), it1_ (it1), it2_ (it2) {}
  1.2993 +
  1.2994 +            // Arithmetic
  1.2995 +            BOOST_UBLAS_INLINE
  1.2996 +            const_iterator2 &operator ++ () {
  1.2997 +                ++ it2_;
  1.2998 +                return *this;
  1.2999 +            }
  1.3000 +            BOOST_UBLAS_INLINE
  1.3001 +            const_iterator2 &operator -- () {
  1.3002 +                -- it2_;
  1.3003 +                return *this;
  1.3004 +            }
  1.3005 +            BOOST_UBLAS_INLINE
  1.3006 +            const_iterator2 &operator += (difference_type n) {
  1.3007 +                it2_ += n;
  1.3008 +                return *this;
  1.3009 +            }
  1.3010 +            BOOST_UBLAS_INLINE
  1.3011 +            const_iterator2 &operator -= (difference_type n) {
  1.3012 +                it2_ -= n;
  1.3013 +                return *this;
  1.3014 +            }
  1.3015 +            BOOST_UBLAS_INLINE
  1.3016 +            difference_type operator - (const const_iterator2 &it) const {
  1.3017 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.3018 +                BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ());
  1.3019 +                return it2_ - it.it2_;
  1.3020 +            }
  1.3021 +
  1.3022 +            // Dereference
  1.3023 +            BOOST_UBLAS_INLINE
  1.3024 +            const_reference operator * () const {
  1.3025 +                BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());
  1.3026 +                BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ());
  1.3027 +                return (*this) () (index1 (), index2 ());
  1.3028 +            }
  1.3029 +            BOOST_UBLAS_INLINE
  1.3030 +            const_reference operator [] (difference_type n) const {
  1.3031 +                return *(*this + n);
  1.3032 +            }
  1.3033 +
  1.3034 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
  1.3035 +            BOOST_UBLAS_INLINE
  1.3036 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3037 +            typename self_type::
  1.3038 +#endif
  1.3039 +            const_iterator1 begin () const {
  1.3040 +                const scalar_matrix &m = (*this) ();
  1.3041 +                return m.find1 (1, 0, index2 ());
  1.3042 +            }
  1.3043 +            BOOST_UBLAS_INLINE
  1.3044 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3045 +            typename self_type::
  1.3046 +#endif
  1.3047 +            const_iterator1 end () const {
  1.3048 +                const scalar_matrix &m = (*this) ();
  1.3049 +                return m.find1 (1, m.size1 (), index2 ());
  1.3050 +            }
  1.3051 +            BOOST_UBLAS_INLINE
  1.3052 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3053 +            typename self_type::
  1.3054 +#endif
  1.3055 +            const_reverse_iterator1 rbegin () const {
  1.3056 +                return const_reverse_iterator1 (end ());
  1.3057 +            }
  1.3058 +            BOOST_UBLAS_INLINE
  1.3059 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3060 +            typename self_type::
  1.3061 +#endif
  1.3062 +            const_reverse_iterator1 rend () const {
  1.3063 +                return const_reverse_iterator1 (begin ());
  1.3064 +            }
  1.3065 +#endif
  1.3066 +
  1.3067 +            // Indices
  1.3068 +            BOOST_UBLAS_INLINE
  1.3069 +            size_type index1 () const {
  1.3070 +                return it1_;
  1.3071 +            }
  1.3072 +            BOOST_UBLAS_INLINE
  1.3073 +            size_type index2 () const {
  1.3074 +                return it2_;
  1.3075 +            }
  1.3076 +
  1.3077 +            // Assignment
  1.3078 +            BOOST_UBLAS_INLINE
  1.3079 +            const_iterator2 &operator = (const const_iterator2 &it) {
  1.3080 +                container_const_reference<scalar_matrix>::assign (&it ());
  1.3081 +                it1_ = it.it1_;
  1.3082 +                it2_ = it.it2_;
  1.3083 +                return *this;
  1.3084 +            }
  1.3085 +
  1.3086 +            // Comparison
  1.3087 +            BOOST_UBLAS_INLINE
  1.3088 +            bool operator == (const const_iterator2 &it) const {
  1.3089 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.3090 +                BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ());
  1.3091 +                return it2_ == it.it2_;
  1.3092 +            }
  1.3093 +            BOOST_UBLAS_INLINE
  1.3094 +            bool operator < (const const_iterator2 &it) const {
  1.3095 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.3096 +                BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ());
  1.3097 +                return it2_ < it.it2_;
  1.3098 +            }
  1.3099 +
  1.3100 +        private:
  1.3101 +            const_subiterator_type it1_;
  1.3102 +            const_subiterator_type it2_;
  1.3103 +        };
  1.3104 +
  1.3105 +        typedef const_iterator2 iterator2;
  1.3106 +#endif
  1.3107 +
  1.3108 +        BOOST_UBLAS_INLINE
  1.3109 +        const_iterator2 begin2 () const {
  1.3110 +            return find2 (0, 0, 0);
  1.3111 +        }
  1.3112 +        BOOST_UBLAS_INLINE
  1.3113 +        const_iterator2 end2 () const {
  1.3114 +            return find2 (0, 0, size2_);
  1.3115 +        }
  1.3116 +
  1.3117 +        // Reverse iterators
  1.3118 +
  1.3119 +        BOOST_UBLAS_INLINE
  1.3120 +        const_reverse_iterator1 rbegin1 () const {
  1.3121 +            return const_reverse_iterator1 (end1 ());
  1.3122 +        }
  1.3123 +        BOOST_UBLAS_INLINE
  1.3124 +        const_reverse_iterator1 rend1 () const {
  1.3125 +            return const_reverse_iterator1 (begin1 ());
  1.3126 +        }
  1.3127 +
  1.3128 +        BOOST_UBLAS_INLINE
  1.3129 +        const_reverse_iterator2 rbegin2 () const {
  1.3130 +            return const_reverse_iterator2 (end2 ());
  1.3131 +        }
  1.3132 +        BOOST_UBLAS_INLINE
  1.3133 +        const_reverse_iterator2 rend2 () const {
  1.3134 +            return const_reverse_iterator2 (begin2 ());
  1.3135 +        }
  1.3136 +
  1.3137 +    private:
  1.3138 +        size_type size1_;
  1.3139 +        size_type size2_;
  1.3140 +        value_type value_;
  1.3141 +    };
  1.3142 +
  1.3143 +
  1.3144 +    // Array based matrix class
  1.3145 +    template<class T, std::size_t N, std::size_t M>
  1.3146 +    class c_matrix:
  1.3147 +        public matrix_container<c_matrix<T, N, M> > {
  1.3148 +
  1.3149 +        typedef c_matrix<T, N, M> self_type;
  1.3150 +    public:
  1.3151 +#ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
  1.3152 +        using matrix_container<self_type>::operator ();
  1.3153 +#endif
  1.3154 +        typedef std::size_t size_type;
  1.3155 +        typedef std::ptrdiff_t difference_type;
  1.3156 +        typedef T value_type;
  1.3157 +        typedef const T &const_reference;
  1.3158 +        typedef T &reference;
  1.3159 +        typedef const T *const_pointer;
  1.3160 +        typedef T *pointer;
  1.3161 +        typedef const matrix_reference<const self_type> const_closure_type;
  1.3162 +        typedef matrix_reference<self_type> closure_type;
  1.3163 +        typedef c_vector<T, N * M> vector_temporary_type;     // vector able to store all elements of c_matrix
  1.3164 +        typedef self_type matrix_temporary_type;
  1.3165 +        typedef dense_tag storage_category;
  1.3166 +        // This could be better for performance,
  1.3167 +        // typedef typename unknown_orientation_tag orientation_category;
  1.3168 +        // but others depend on the orientation information...
  1.3169 +        typedef row_major_tag orientation_category;
  1.3170 +
  1.3171 +        // Construction and destruction
  1.3172 +        BOOST_UBLAS_INLINE
  1.3173 +        c_matrix ():
  1.3174 +            size1_ (N), size2_ (M) /* , data_ () */ {
  1.3175 +        }
  1.3176 +        BOOST_UBLAS_INLINE
  1.3177 +        c_matrix (size_type size1, size_type size2):
  1.3178 +            size1_ (size1), size2_ (size2) /* , data_ () */ {
  1.3179 +            if (size1_ > N || size2_ > M)
  1.3180 +                bad_size ().raise ();
  1.3181 +        }
  1.3182 +        BOOST_UBLAS_INLINE
  1.3183 +        c_matrix (const c_matrix &m):
  1.3184 +            size1_ (m.size1_), size2_ (m.size2_) /* , data_ () */ {
  1.3185 +            if (size1_ > N || size2_ > M)
  1.3186 +                bad_size ().raise ();
  1.3187 +            *this = m;
  1.3188 +        }
  1.3189 +        template<class AE>
  1.3190 +        BOOST_UBLAS_INLINE
  1.3191 +        c_matrix (const matrix_expression<AE> &ae):
  1.3192 +            size1_ (ae ().size1 ()), size2_ (ae ().size2 ()) /* , data_ () */ {
  1.3193 +            if (size1_ > N || size2_ > M)
  1.3194 +                bad_size ().raise ();
  1.3195 +            matrix_assign<scalar_assign> (*this, ae);
  1.3196 +        }
  1.3197 +
  1.3198 +        // Accessors
  1.3199 +        BOOST_UBLAS_INLINE
  1.3200 +        size_type size1 () const {
  1.3201 +            return size1_;
  1.3202 +        }
  1.3203 +        BOOST_UBLAS_INLINE
  1.3204 +        size_type size2 () const {
  1.3205 +            return size2_;
  1.3206 +        }
  1.3207 +        BOOST_UBLAS_INLINE
  1.3208 +        const_pointer data () const {
  1.3209 +            return reinterpret_cast<const_pointer> (data_);
  1.3210 +        }
  1.3211 +        BOOST_UBLAS_INLINE
  1.3212 +        pointer data () {
  1.3213 +            return reinterpret_cast<pointer> (data_);
  1.3214 +        }
  1.3215 +
  1.3216 +        // Resizing
  1.3217 +        BOOST_UBLAS_INLINE
  1.3218 +        void resize (size_type size1, size_type size2, bool preserve = true) {
  1.3219 +            if (size1 > N || size2 > M)
  1.3220 +                bad_size ().raise ();
  1.3221 +            if (preserve) {
  1.3222 +                self_type temporary (size1, size2);
  1.3223 +                // Common elements to preserve
  1.3224 +                const size_type size1_min = (std::min) (size1, size1_);
  1.3225 +                const size_type size2_min = (std::min) (size2, size2_);
  1.3226 +                for (size_type i = 0; i != size1_min; ++i) {    // indexing copy over major
  1.3227 +                    for (size_type j = 0; j != size2_min; ++j) {
  1.3228 +                        temporary.data_[i][j] = data_[i][j];
  1.3229 +                    }
  1.3230 +                }
  1.3231 +                assign_temporary (temporary);
  1.3232 +            }
  1.3233 +            else {
  1.3234 +                size1_ = size1;
  1.3235 +                size2_ = size2;
  1.3236 +            }
  1.3237 +        }
  1.3238 +
  1.3239 +        // Element access
  1.3240 +        BOOST_UBLAS_INLINE
  1.3241 +        const_reference operator () (size_type i, size_type j) const {
  1.3242 +            BOOST_UBLAS_CHECK (i < size1_, bad_index ());
  1.3243 +            BOOST_UBLAS_CHECK (j < size2_, bad_index ());
  1.3244 +            return data_ [i] [j];
  1.3245 +        }
  1.3246 +        BOOST_UBLAS_INLINE
  1.3247 +        reference at_element (size_type i, size_type j) {
  1.3248 +            BOOST_UBLAS_CHECK (i < size1_, bad_index ());
  1.3249 +            BOOST_UBLAS_CHECK (j < size2_, bad_index ());
  1.3250 +            return data_ [i] [j];
  1.3251 +        }
  1.3252 +        BOOST_UBLAS_INLINE
  1.3253 +        reference operator () (size_type i, size_type j) {
  1.3254 +            return at_element (i, j);
  1.3255 +        }
  1.3256 +
  1.3257 +        // Element assignment
  1.3258 +        BOOST_UBLAS_INLINE
  1.3259 +        reference insert_element (size_type i, size_type j, const_reference t) {
  1.3260 +            return (at_element (i, j) = t);
  1.3261 +        }
  1.3262 +        
  1.3263 +        // Zeroing
  1.3264 +        BOOST_UBLAS_INLINE
  1.3265 +        void clear () {
  1.3266 +            for (size_type i = 0; i < size1_; ++ i)
  1.3267 +                std::fill (data_ [i], data_ [i] + size2_, value_type/*zero*/());
  1.3268 +        }
  1.3269 +
  1.3270 +        // Assignment
  1.3271 +        BOOST_UBLAS_INLINE
  1.3272 +        c_matrix &operator = (const c_matrix &m) {
  1.3273 +            size1_ = m.size1_;
  1.3274 +            size2_ = m.size2_;
  1.3275 +            for (size_type i = 0; i < m.size1_; ++ i)
  1.3276 +                std::copy (m.data_ [i], m.data_ [i] + m.size2_, data_ [i]);
  1.3277 +            return *this;
  1.3278 +        }
  1.3279 +        template<class C>          // Container assignment without temporary
  1.3280 +        BOOST_UBLAS_INLINE
  1.3281 +        c_matrix &operator = (const matrix_container<C> &m) {
  1.3282 +            resize (m ().size1 (), m ().size2 (), false);
  1.3283 +            assign (m);
  1.3284 +            return *this;
  1.3285 +        }
  1.3286 +        BOOST_UBLAS_INLINE
  1.3287 +        c_matrix &assign_temporary (c_matrix &m) {
  1.3288 +            swap (m);
  1.3289 +            return *this;
  1.3290 +        }
  1.3291 +        template<class AE>
  1.3292 +        BOOST_UBLAS_INLINE
  1.3293 +        c_matrix &operator = (const matrix_expression<AE> &ae) { 
  1.3294 +            self_type temporary (ae);
  1.3295 +            return assign_temporary (temporary);
  1.3296 +        }
  1.3297 +        template<class AE>
  1.3298 +        BOOST_UBLAS_INLINE
  1.3299 +        c_matrix &assign (const matrix_expression<AE> &ae) { 
  1.3300 +            matrix_assign<scalar_assign> (*this, ae); 
  1.3301 +            return *this;
  1.3302 +        }
  1.3303 +        template<class AE>
  1.3304 +        BOOST_UBLAS_INLINE
  1.3305 +        c_matrix& operator += (const matrix_expression<AE> &ae) {
  1.3306 +            self_type temporary (*this + ae);
  1.3307 +            return assign_temporary (temporary);
  1.3308 +        }
  1.3309 +        template<class C>          // Container assignment without temporary
  1.3310 +        BOOST_UBLAS_INLINE
  1.3311 +        c_matrix &operator += (const matrix_container<C> &m) {
  1.3312 +            plus_assign (m);
  1.3313 +            return *this;
  1.3314 +        }
  1.3315 +        template<class AE>
  1.3316 +        BOOST_UBLAS_INLINE
  1.3317 +        c_matrix &plus_assign (const matrix_expression<AE> &ae) { 
  1.3318 +            matrix_assign<scalar_plus_assign> (*this, ae); 
  1.3319 +            return *this;
  1.3320 +        }
  1.3321 +        template<class AE>
  1.3322 +        BOOST_UBLAS_INLINE
  1.3323 +        c_matrix& operator -= (const matrix_expression<AE> &ae) {
  1.3324 +            self_type temporary (*this - ae);
  1.3325 +            return assign_temporary (temporary);
  1.3326 +        }
  1.3327 +        template<class C>          // Container assignment without temporary
  1.3328 +        BOOST_UBLAS_INLINE
  1.3329 +        c_matrix &operator -= (const matrix_container<C> &m) {
  1.3330 +            minus_assign (m);
  1.3331 +            return *this;
  1.3332 +        }
  1.3333 +        template<class AE>
  1.3334 +        BOOST_UBLAS_INLINE
  1.3335 +        c_matrix &minus_assign (const matrix_expression<AE> &ae) { 
  1.3336 +            matrix_assign<scalar_minus_assign> (*this, ae); 
  1.3337 +            return *this;
  1.3338 +        }
  1.3339 +        template<class AT>
  1.3340 +        BOOST_UBLAS_INLINE
  1.3341 +        c_matrix& operator *= (const AT &at) {
  1.3342 +            matrix_assign_scalar<scalar_multiplies_assign> (*this, at);
  1.3343 +            return *this;
  1.3344 +        }
  1.3345 +        template<class AT>
  1.3346 +        BOOST_UBLAS_INLINE
  1.3347 +        c_matrix& operator /= (const AT &at) {
  1.3348 +            matrix_assign_scalar<scalar_divides_assign> (*this, at);
  1.3349 +            return *this;
  1.3350 +        }
  1.3351 +
  1.3352 +        // Swapping
  1.3353 +        BOOST_UBLAS_INLINE
  1.3354 +        void swap (c_matrix &m) {
  1.3355 +            if (this != &m) {
  1.3356 +                BOOST_UBLAS_CHECK (size1_ == m.size1_, bad_size ());
  1.3357 +                BOOST_UBLAS_CHECK (size2_ == m.size2_, bad_size ());
  1.3358 +                std::swap (size1_, m.size1_);
  1.3359 +                std::swap (size2_, m.size2_);
  1.3360 +                for (size_type i = 0; i < size1_; ++ i)
  1.3361 +                    std::swap_ranges (data_ [i], data_ [i] + size2_, m.data_ [i]);
  1.3362 +            }
  1.3363 +        }
  1.3364 +        BOOST_UBLAS_INLINE
  1.3365 +        friend void swap (c_matrix &m1, c_matrix &m2) {
  1.3366 +            m1.swap (m2);
  1.3367 +        }
  1.3368 +
  1.3369 +        // Iterator types
  1.3370 +    private:
  1.3371 +        // Use pointers for iterator
  1.3372 +        typedef const_pointer const_subiterator_type;
  1.3373 +        typedef pointer subiterator_type;
  1.3374 +
  1.3375 +    public:
  1.3376 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.3377 +        typedef indexed_iterator1<self_type, dense_random_access_iterator_tag> iterator1;
  1.3378 +        typedef indexed_iterator2<self_type, dense_random_access_iterator_tag> iterator2;
  1.3379 +        typedef indexed_const_iterator1<self_type, dense_random_access_iterator_tag> const_iterator1;
  1.3380 +        typedef indexed_const_iterator2<self_type, dense_random_access_iterator_tag> const_iterator2;
  1.3381 +#else
  1.3382 +        class const_iterator1;
  1.3383 +        class iterator1;
  1.3384 +        class const_iterator2;
  1.3385 +        class iterator2;
  1.3386 +#endif
  1.3387 +        typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
  1.3388 +        typedef reverse_iterator_base1<iterator1> reverse_iterator1;
  1.3389 +        typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
  1.3390 +        typedef reverse_iterator_base2<iterator2> reverse_iterator2;
  1.3391 +
  1.3392 +        // Element lookup
  1.3393 +        BOOST_UBLAS_INLINE
  1.3394 +        const_iterator1 find1 (int rank, size_type i, size_type j) const {
  1.3395 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.3396 +            return const_iterator1 (*this, i, j);
  1.3397 +#else
  1.3398 +            return const_iterator1 (*this, &data_ [i] [j]);
  1.3399 +#endif
  1.3400 +        }
  1.3401 +        BOOST_UBLAS_INLINE
  1.3402 +        iterator1 find1 (int rank, size_type i, size_type j) {
  1.3403 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.3404 +            return iterator1 (*this, i, j);
  1.3405 +#else
  1.3406 +            return iterator1 (*this, &data_ [i] [j]);
  1.3407 +#endif
  1.3408 +        }
  1.3409 +        BOOST_UBLAS_INLINE
  1.3410 +        const_iterator2 find2 (int rank, size_type i, size_type j) const {
  1.3411 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.3412 +            return const_iterator2 (*this, i, j);
  1.3413 +#else
  1.3414 +            return const_iterator2 (*this, &data_ [i] [j]);
  1.3415 +#endif
  1.3416 +        }
  1.3417 +        BOOST_UBLAS_INLINE
  1.3418 +        iterator2 find2 (int rank, size_type i, size_type j) {
  1.3419 +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.3420 +            return iterator2 (*this, i, j);
  1.3421 +#else
  1.3422 +            return iterator2 (*this, &data_ [i] [j]);
  1.3423 +#endif
  1.3424 +        }
  1.3425 +
  1.3426 +
  1.3427 +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.3428 +        class const_iterator1:
  1.3429 +            public container_const_reference<c_matrix>,
  1.3430 +            public random_access_iterator_base<dense_random_access_iterator_tag,
  1.3431 +                                               const_iterator1, value_type> {
  1.3432 +        public:
  1.3433 +            typedef typename c_matrix::difference_type difference_type;
  1.3434 +            typedef typename c_matrix::value_type value_type;
  1.3435 +            typedef typename c_matrix::const_reference reference;
  1.3436 +            typedef typename c_matrix::const_pointer pointer;
  1.3437 +
  1.3438 +            typedef const_iterator2 dual_iterator_type;
  1.3439 +            typedef const_reverse_iterator2 dual_reverse_iterator_type;
  1.3440 +
  1.3441 +            // Construction and destruction
  1.3442 +            BOOST_UBLAS_INLINE
  1.3443 +            const_iterator1 ():
  1.3444 +                container_const_reference<self_type> (), it_ () {}
  1.3445 +            BOOST_UBLAS_INLINE
  1.3446 +            const_iterator1 (const self_type &m, const const_subiterator_type &it):
  1.3447 +                container_const_reference<self_type> (m), it_ (it) {}
  1.3448 +            BOOST_UBLAS_INLINE
  1.3449 +            const_iterator1 (const iterator1 &it):
  1.3450 +                container_const_reference<self_type> (it ()), it_ (it.it_) {}
  1.3451 +
  1.3452 +            // Arithmetic
  1.3453 +            BOOST_UBLAS_INLINE
  1.3454 +            const_iterator1 &operator ++ () {
  1.3455 +                it_ += M;
  1.3456 +                return *this;
  1.3457 +            }
  1.3458 +            BOOST_UBLAS_INLINE
  1.3459 +            const_iterator1 &operator -- () {
  1.3460 +                it_ -= M;
  1.3461 +                return *this;
  1.3462 +            }
  1.3463 +            BOOST_UBLAS_INLINE
  1.3464 +            const_iterator1 &operator += (difference_type n) {
  1.3465 +                it_ += n * M;
  1.3466 +                return *this;
  1.3467 +            }
  1.3468 +            BOOST_UBLAS_INLINE
  1.3469 +            const_iterator1 &operator -= (difference_type n) {
  1.3470 +                it_ -= n * M;
  1.3471 +                return *this;
  1.3472 +            }
  1.3473 +            BOOST_UBLAS_INLINE
  1.3474 +            difference_type operator - (const const_iterator1 &it) const {
  1.3475 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.3476 +                return (it_ - it.it_) / M;
  1.3477 +            }
  1.3478 +
  1.3479 +            // Dereference
  1.3480 +            BOOST_UBLAS_INLINE
  1.3481 +            const_reference operator * () const {
  1.3482 +                BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());
  1.3483 +                BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ());
  1.3484 +                return *it_;
  1.3485 +            }
  1.3486 +            BOOST_UBLAS_INLINE
  1.3487 +            const_reference operator [] (difference_type n) const {
  1.3488 +                return *(*this + n);
  1.3489 +            }
  1.3490 +
  1.3491 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
  1.3492 +            BOOST_UBLAS_INLINE
  1.3493 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3494 +            typename self_type::
  1.3495 +#endif
  1.3496 +            const_iterator2 begin () const {
  1.3497 +                const self_type &m = (*this) ();
  1.3498 +                return m.find2 (1, index1 (), 0);
  1.3499 +            }
  1.3500 +            BOOST_UBLAS_INLINE
  1.3501 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3502 +            typename self_type::
  1.3503 +#endif
  1.3504 +            const_iterator2 end () const {
  1.3505 +                const self_type &m = (*this) ();
  1.3506 +                return m.find2 (1, index1 (), m.size2 ());
  1.3507 +            }
  1.3508 +            BOOST_UBLAS_INLINE
  1.3509 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3510 +            typename self_type::
  1.3511 +#endif
  1.3512 +            const_reverse_iterator2 rbegin () const {
  1.3513 +                return const_reverse_iterator2 (end ());
  1.3514 +            }
  1.3515 +            BOOST_UBLAS_INLINE
  1.3516 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3517 +            typename self_type::
  1.3518 +#endif
  1.3519 +            const_reverse_iterator2 rend () const {
  1.3520 +                return const_reverse_iterator2 (begin ());
  1.3521 +            }
  1.3522 +#endif
  1.3523 +
  1.3524 +            // Indices
  1.3525 +            BOOST_UBLAS_INLINE
  1.3526 +            size_type index1 () const {
  1.3527 +                const self_type &m = (*this) ();
  1.3528 +                return (it_ - m.begin1 ().it_) / M;
  1.3529 +            }
  1.3530 +            BOOST_UBLAS_INLINE
  1.3531 +            size_type index2 () const {
  1.3532 +                const self_type &m = (*this) ();
  1.3533 +                return (it_ - m.begin1 ().it_) % M;
  1.3534 +            }
  1.3535 +
  1.3536 +            // Assignment
  1.3537 +            BOOST_UBLAS_INLINE
  1.3538 +            const_iterator1 &operator = (const const_iterator1 &it) {
  1.3539 +                container_const_reference<self_type>::assign (&it ());
  1.3540 +                it_ = it.it_;
  1.3541 +                return *this;
  1.3542 +            }
  1.3543 +
  1.3544 +            // Comparison
  1.3545 +            BOOST_UBLAS_INLINE
  1.3546 +            bool operator == (const const_iterator1 &it) const {
  1.3547 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.3548 +                return it_ == it.it_;
  1.3549 +            }
  1.3550 +            BOOST_UBLAS_INLINE
  1.3551 +            bool operator < (const const_iterator1 &it) const {
  1.3552 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.3553 +                return it_ < it.it_;
  1.3554 +            }
  1.3555 +
  1.3556 +        private:
  1.3557 +            const_subiterator_type it_;
  1.3558 +
  1.3559 +            friend class iterator1;
  1.3560 +        };
  1.3561 +#endif
  1.3562 +
  1.3563 +        BOOST_UBLAS_INLINE
  1.3564 +        const_iterator1 begin1 () const {
  1.3565 +            return find1 (0, 0, 0);
  1.3566 +        }
  1.3567 +        BOOST_UBLAS_INLINE
  1.3568 +        const_iterator1 end1 () const {
  1.3569 +            return find1 (0, size1_, 0);
  1.3570 +        }
  1.3571 +
  1.3572 +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.3573 +        class iterator1:
  1.3574 +            public container_reference<c_matrix>,
  1.3575 +            public random_access_iterator_base<dense_random_access_iterator_tag,
  1.3576 +                                               iterator1, value_type> {
  1.3577 +        public:
  1.3578 +
  1.3579 +            typedef typename c_matrix::difference_type difference_type;
  1.3580 +            typedef typename c_matrix::value_type value_type;
  1.3581 +            typedef typename c_matrix::reference reference;
  1.3582 +            typedef typename c_matrix::pointer pointer;
  1.3583 +
  1.3584 +            typedef iterator2 dual_iterator_type;
  1.3585 +            typedef reverse_iterator2 dual_reverse_iterator_type;
  1.3586 +
  1.3587 +            // Construction and destruction
  1.3588 +            BOOST_UBLAS_INLINE
  1.3589 +            iterator1 ():
  1.3590 +                container_reference<self_type> (), it_ () {}
  1.3591 +            BOOST_UBLAS_INLINE
  1.3592 +            iterator1 (self_type &m, const subiterator_type &it):
  1.3593 +                container_reference<self_type> (m), it_ (it) {}
  1.3594 +
  1.3595 +            // Arithmetic
  1.3596 +            BOOST_UBLAS_INLINE
  1.3597 +            iterator1 &operator ++ () {
  1.3598 +                it_ += M;
  1.3599 +                return *this;
  1.3600 +            }
  1.3601 +            BOOST_UBLAS_INLINE
  1.3602 +            iterator1 &operator -- () {
  1.3603 +                it_ -= M;
  1.3604 +                return *this;
  1.3605 +            }
  1.3606 +            BOOST_UBLAS_INLINE
  1.3607 +            iterator1 &operator += (difference_type n) {
  1.3608 +                it_ += n * M;
  1.3609 +                return *this;
  1.3610 +            }
  1.3611 +            BOOST_UBLAS_INLINE
  1.3612 +            iterator1 &operator -= (difference_type n) {
  1.3613 +                it_ -= n * M;
  1.3614 +                return *this;
  1.3615 +            }
  1.3616 +            BOOST_UBLAS_INLINE
  1.3617 +            difference_type operator - (const iterator1 &it) const {
  1.3618 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.3619 +                return (it_ - it.it_) / M;
  1.3620 +            }
  1.3621 +
  1.3622 +            // Dereference
  1.3623 +            BOOST_UBLAS_INLINE
  1.3624 +            reference operator * () const {
  1.3625 +                BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());
  1.3626 +                BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ());
  1.3627 +                return *it_;
  1.3628 +            }
  1.3629 +            BOOST_UBLAS_INLINE
  1.3630 +            reference operator [] (difference_type n) const {
  1.3631 +                return *(*this + n);
  1.3632 +            }
  1.3633 +
  1.3634 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
  1.3635 +            BOOST_UBLAS_INLINE
  1.3636 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3637 +            typename self_type::
  1.3638 +#endif
  1.3639 +            iterator2 begin () const {
  1.3640 +                self_type &m = (*this) ();
  1.3641 +                return m.find2 (1, index1 (), 0);
  1.3642 +            }
  1.3643 +            BOOST_UBLAS_INLINE
  1.3644 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3645 +            typename self_type::
  1.3646 +#endif
  1.3647 +            iterator2 end () const {
  1.3648 +                self_type &m = (*this) ();
  1.3649 +                return m.find2 (1, index1 (), m.size2 ());
  1.3650 +            }
  1.3651 +            BOOST_UBLAS_INLINE
  1.3652 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3653 +            typename self_type::
  1.3654 +#endif
  1.3655 +            reverse_iterator2 rbegin () const {
  1.3656 +                return reverse_iterator2 (end ());
  1.3657 +            }
  1.3658 +            BOOST_UBLAS_INLINE
  1.3659 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3660 +            typename self_type::
  1.3661 +#endif
  1.3662 +            reverse_iterator2 rend () const {
  1.3663 +                return reverse_iterator2 (begin ());
  1.3664 +            }
  1.3665 +#endif
  1.3666 +
  1.3667 +            // Indices
  1.3668 +            BOOST_UBLAS_INLINE
  1.3669 +            size_type index1 () const {
  1.3670 +                const self_type &m = (*this) ();
  1.3671 +                return (it_ - m.begin1 ().it_) / M;
  1.3672 +            }
  1.3673 +            BOOST_UBLAS_INLINE
  1.3674 +            size_type index2 () const {
  1.3675 +                const self_type &m = (*this) ();
  1.3676 +                return (it_ - m.begin1 ().it_) % M;
  1.3677 +            }
  1.3678 +
  1.3679 +            // Assignment
  1.3680 +            BOOST_UBLAS_INLINE
  1.3681 +            iterator1 &operator = (const iterator1 &it) {
  1.3682 +                container_reference<self_type>::assign (&it ());
  1.3683 +                it_ = it.it_;
  1.3684 +                return *this;
  1.3685 +            }
  1.3686 +
  1.3687 +            // Comparison
  1.3688 +            BOOST_UBLAS_INLINE
  1.3689 +            bool operator == (const iterator1 &it) const {
  1.3690 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.3691 +                return it_ == it.it_;
  1.3692 +            }
  1.3693 +            BOOST_UBLAS_INLINE
  1.3694 +            bool operator < (const iterator1 &it) const {
  1.3695 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.3696 +                return it_ < it.it_;
  1.3697 +            }
  1.3698 +
  1.3699 +        private:
  1.3700 +            subiterator_type it_;
  1.3701 +
  1.3702 +            friend class const_iterator1;
  1.3703 +        };
  1.3704 +#endif
  1.3705 +
  1.3706 +        BOOST_UBLAS_INLINE
  1.3707 +        iterator1 begin1 () {
  1.3708 +            return find1 (0, 0, 0);
  1.3709 +        }
  1.3710 +        BOOST_UBLAS_INLINE
  1.3711 +        iterator1 end1 () {
  1.3712 +            return find1 (0, size1_, 0);
  1.3713 +        }
  1.3714 +
  1.3715 +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.3716 +        class const_iterator2:
  1.3717 +            public container_const_reference<c_matrix>,
  1.3718 +            public random_access_iterator_base<dense_random_access_iterator_tag,
  1.3719 +                                               const_iterator2, value_type> {
  1.3720 +        public:
  1.3721 +            typedef typename c_matrix::difference_type difference_type;
  1.3722 +            typedef typename c_matrix::value_type value_type;
  1.3723 +            typedef typename c_matrix::const_reference reference;
  1.3724 +            typedef typename c_matrix::const_reference pointer;
  1.3725 +
  1.3726 +            typedef const_iterator1 dual_iterator_type;
  1.3727 +            typedef const_reverse_iterator1 dual_reverse_iterator_type;
  1.3728 +
  1.3729 +            // Construction and destruction
  1.3730 +            BOOST_UBLAS_INLINE
  1.3731 +            const_iterator2 ():
  1.3732 +                container_const_reference<self_type> (), it_ () {}
  1.3733 +            BOOST_UBLAS_INLINE
  1.3734 +            const_iterator2 (const self_type &m, const const_subiterator_type &it):
  1.3735 +                container_const_reference<self_type> (m), it_ (it) {}
  1.3736 +            BOOST_UBLAS_INLINE
  1.3737 +            const_iterator2 (const iterator2 &it):
  1.3738 +                container_const_reference<self_type> (it ()), it_ (it.it_) {}
  1.3739 +
  1.3740 +            // Arithmetic
  1.3741 +            BOOST_UBLAS_INLINE
  1.3742 +            const_iterator2 &operator ++ () {
  1.3743 +                ++ it_;
  1.3744 +                return *this;
  1.3745 +            }
  1.3746 +            BOOST_UBLAS_INLINE
  1.3747 +            const_iterator2 &operator -- () {
  1.3748 +                -- it_;
  1.3749 +                return *this;
  1.3750 +            }
  1.3751 +            BOOST_UBLAS_INLINE
  1.3752 +            const_iterator2 &operator += (difference_type n) {
  1.3753 +                it_ += n;
  1.3754 +                return *this;
  1.3755 +            }
  1.3756 +            BOOST_UBLAS_INLINE
  1.3757 +            const_iterator2 &operator -= (difference_type n) {
  1.3758 +                it_ -= n;
  1.3759 +                return *this;
  1.3760 +            }
  1.3761 +            BOOST_UBLAS_INLINE
  1.3762 +            difference_type operator - (const const_iterator2 &it) const {
  1.3763 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.3764 +                return it_ - it.it_;
  1.3765 +            }
  1.3766 +
  1.3767 +            // Dereference
  1.3768 +            BOOST_UBLAS_INLINE
  1.3769 +            const_reference operator * () const {
  1.3770 +                BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());
  1.3771 +                BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ());
  1.3772 +                return *it_;
  1.3773 +            }
  1.3774 +            BOOST_UBLAS_INLINE
  1.3775 +            const_reference operator [] (difference_type n) const {
  1.3776 +                return *(*this + n);
  1.3777 +            }
  1.3778 +
  1.3779 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
  1.3780 +            BOOST_UBLAS_INLINE
  1.3781 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3782 +            typename self_type::
  1.3783 +#endif
  1.3784 +            const_iterator1 begin () const {
  1.3785 +                const self_type &m = (*this) ();
  1.3786 +                return m.find1 (1, 0, index2 ());
  1.3787 +            }
  1.3788 +            BOOST_UBLAS_INLINE
  1.3789 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3790 +            typename self_type::
  1.3791 +#endif
  1.3792 +            const_iterator1 end () const {
  1.3793 +                const self_type &m = (*this) ();
  1.3794 +                return m.find1 (1, m.size1 (), index2 ());
  1.3795 +            }
  1.3796 +            BOOST_UBLAS_INLINE
  1.3797 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3798 +            typename self_type::
  1.3799 +#endif
  1.3800 +            const_reverse_iterator1 rbegin () const {
  1.3801 +                return const_reverse_iterator1 (end ());
  1.3802 +            }
  1.3803 +            BOOST_UBLAS_INLINE
  1.3804 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3805 +            typename self_type::
  1.3806 +#endif
  1.3807 +            const_reverse_iterator1 rend () const {
  1.3808 +                return const_reverse_iterator1 (begin ());
  1.3809 +            }
  1.3810 +#endif
  1.3811 +
  1.3812 +            // Indices
  1.3813 +            BOOST_UBLAS_INLINE
  1.3814 +            size_type index1 () const {
  1.3815 +                const self_type &m = (*this) ();
  1.3816 +                return (it_ - m.begin2 ().it_) / M;
  1.3817 +            }
  1.3818 +            BOOST_UBLAS_INLINE
  1.3819 +            size_type index2 () const {
  1.3820 +                const self_type &m = (*this) ();
  1.3821 +                return (it_ - m.begin2 ().it_) % M;
  1.3822 +            }
  1.3823 +
  1.3824 +            // Assignment
  1.3825 +            BOOST_UBLAS_INLINE
  1.3826 +            const_iterator2 &operator = (const const_iterator2 &it) {
  1.3827 +                container_const_reference<self_type>::assign (&it ());
  1.3828 +                it_ = it.it_;
  1.3829 +                return *this;
  1.3830 +            }
  1.3831 +
  1.3832 +            // Comparison
  1.3833 +            BOOST_UBLAS_INLINE
  1.3834 +            bool operator == (const const_iterator2 &it) const {
  1.3835 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.3836 +                return it_ == it.it_;
  1.3837 +            }
  1.3838 +            BOOST_UBLAS_INLINE
  1.3839 +            bool operator < (const const_iterator2 &it) const {
  1.3840 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.3841 +                return it_ < it.it_;
  1.3842 +            }
  1.3843 +
  1.3844 +        private:
  1.3845 +            const_subiterator_type it_;
  1.3846 +
  1.3847 +            friend class iterator2;
  1.3848 +        };
  1.3849 +#endif
  1.3850 +
  1.3851 +        BOOST_UBLAS_INLINE
  1.3852 +        const_iterator2 begin2 () const {
  1.3853 +            return find2 (0, 0, 0);
  1.3854 +        }
  1.3855 +        BOOST_UBLAS_INLINE
  1.3856 +        const_iterator2 end2 () const {
  1.3857 +            return find2 (0, 0, size2_);
  1.3858 +        }
  1.3859 +
  1.3860 +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
  1.3861 +        class iterator2:
  1.3862 +            public container_reference<c_matrix>,
  1.3863 +            public random_access_iterator_base<dense_random_access_iterator_tag,
  1.3864 +                                               iterator2, value_type> {
  1.3865 +        public:
  1.3866 +            typedef typename c_matrix::difference_type difference_type;
  1.3867 +            typedef typename c_matrix::value_type value_type;
  1.3868 +            typedef typename c_matrix::reference reference;
  1.3869 +            typedef typename c_matrix::pointer pointer;
  1.3870 +
  1.3871 +            typedef iterator1 dual_iterator_type;
  1.3872 +            typedef reverse_iterator1 dual_reverse_iterator_type;
  1.3873 +
  1.3874 +            // Construction and destruction
  1.3875 +            BOOST_UBLAS_INLINE
  1.3876 +            iterator2 ():
  1.3877 +                container_reference<self_type> (), it_ () {}
  1.3878 +            BOOST_UBLAS_INLINE
  1.3879 +            iterator2 (self_type &m, const subiterator_type &it):
  1.3880 +                container_reference<self_type> (m), it_ (it) {}
  1.3881 +
  1.3882 +            // Arithmetic
  1.3883 +            BOOST_UBLAS_INLINE
  1.3884 +            iterator2 &operator ++ () {
  1.3885 +                ++ it_;
  1.3886 +                return *this;
  1.3887 +            }
  1.3888 +            BOOST_UBLAS_INLINE
  1.3889 +            iterator2 &operator -- () {
  1.3890 +                -- it_;
  1.3891 +                return *this;
  1.3892 +            }
  1.3893 +            BOOST_UBLAS_INLINE
  1.3894 +            iterator2 &operator += (difference_type n) {
  1.3895 +                it_ += n;
  1.3896 +                return *this;
  1.3897 +            }
  1.3898 +            BOOST_UBLAS_INLINE
  1.3899 +            iterator2 &operator -= (difference_type n) {
  1.3900 +                it_ -= n;
  1.3901 +                return *this;
  1.3902 +            }
  1.3903 +            BOOST_UBLAS_INLINE
  1.3904 +            difference_type operator - (const iterator2 &it) const {
  1.3905 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.3906 +                return it_ - it.it_;
  1.3907 +            }
  1.3908 +
  1.3909 +            // Dereference
  1.3910 +            BOOST_UBLAS_INLINE
  1.3911 +            reference operator * () const {
  1.3912 +                BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());
  1.3913 +                BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ());
  1.3914 +                return *it_;
  1.3915 +            }
  1.3916 +            BOOST_UBLAS_INLINE
  1.3917 +            reference operator [] (difference_type n) const {
  1.3918 +                return *(*this + n);
  1.3919 +            }
  1.3920 +
  1.3921 +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
  1.3922 +            BOOST_UBLAS_INLINE
  1.3923 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3924 +            typename self_type::
  1.3925 +#endif
  1.3926 +            iterator1 begin () const {
  1.3927 +                self_type &m = (*this) ();
  1.3928 +                return m.find1 (1, 0, index2 ());
  1.3929 +            }
  1.3930 +            BOOST_UBLAS_INLINE
  1.3931 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3932 +            typename self_type::
  1.3933 +#endif
  1.3934 +            iterator1 end () const {
  1.3935 +                self_type &m = (*this) ();
  1.3936 +                return m.find1 (1, m.size1 (), index2 ());
  1.3937 +            }
  1.3938 +            BOOST_UBLAS_INLINE
  1.3939 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3940 +            typename self_type::
  1.3941 +#endif
  1.3942 +            reverse_iterator1 rbegin () const {
  1.3943 +                return reverse_iterator1 (end ());
  1.3944 +            }
  1.3945 +            BOOST_UBLAS_INLINE
  1.3946 +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
  1.3947 +            typename self_type::
  1.3948 +#endif
  1.3949 +            reverse_iterator1 rend () const {
  1.3950 +                return reverse_iterator1 (begin ());
  1.3951 +            }
  1.3952 +#endif
  1.3953 +
  1.3954 +            // Indices
  1.3955 +            BOOST_UBLAS_INLINE
  1.3956 +            size_type index1 () const {
  1.3957 +                const self_type &m = (*this) ();
  1.3958 +                return (it_ - m.begin2 ().it_) / M;
  1.3959 +            }
  1.3960 +            BOOST_UBLAS_INLINE
  1.3961 +            size_type index2 () const {
  1.3962 +                const self_type &m = (*this) ();
  1.3963 +                return (it_ - m.begin2 ().it_) % M;
  1.3964 +            }
  1.3965 +
  1.3966 +            // Assignment
  1.3967 +            BOOST_UBLAS_INLINE
  1.3968 +            iterator2 &operator = (const iterator2 &it) {
  1.3969 +                container_reference<self_type>::assign (&it ());
  1.3970 +                it_ = it.it_;
  1.3971 +                return *this;
  1.3972 +            }
  1.3973 +
  1.3974 +            // Comparison
  1.3975 +            BOOST_UBLAS_INLINE
  1.3976 +            bool operator == (const iterator2 &it) const {
  1.3977 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.3978 +                return it_ == it.it_;
  1.3979 +            }
  1.3980 +            BOOST_UBLAS_INLINE
  1.3981 +            bool operator < (const iterator2 &it) const {
  1.3982 +                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
  1.3983 +                return it_ < it.it_;
  1.3984 +            }
  1.3985 +
  1.3986 +        private:
  1.3987 +            subiterator_type it_;
  1.3988 +
  1.3989 +            friend class const_iterator2;
  1.3990 +        };
  1.3991 +#endif
  1.3992 +
  1.3993 +        BOOST_UBLAS_INLINE
  1.3994 +        iterator2 begin2 () {
  1.3995 +            return find2 (0, 0, 0);
  1.3996 +        }
  1.3997 +        BOOST_UBLAS_INLINE
  1.3998 +        iterator2 end2 () {
  1.3999 +            return find2 (0, 0, size2_);
  1.4000 +        }
  1.4001 +
  1.4002 +        // Reverse iterators
  1.4003 +
  1.4004 +        BOOST_UBLAS_INLINE
  1.4005 +        const_reverse_iterator1 rbegin1 () const {
  1.4006 +            return const_reverse_iterator1 (end1 ());
  1.4007 +        }
  1.4008 +        BOOST_UBLAS_INLINE
  1.4009 +        const_reverse_iterator1 rend1 () const {
  1.4010 +            return const_reverse_iterator1 (begin1 ());
  1.4011 +        }
  1.4012 +
  1.4013 +        BOOST_UBLAS_INLINE
  1.4014 +        reverse_iterator1 rbegin1 () {
  1.4015 +            return reverse_iterator1 (end1 ());
  1.4016 +        }
  1.4017 +        BOOST_UBLAS_INLINE
  1.4018 +        reverse_iterator1 rend1 () {
  1.4019 +            return reverse_iterator1 (begin1 ());
  1.4020 +        }
  1.4021 +
  1.4022 +        BOOST_UBLAS_INLINE
  1.4023 +        const_reverse_iterator2 rbegin2 () const {
  1.4024 +            return const_reverse_iterator2 (end2 ());
  1.4025 +        }
  1.4026 +        BOOST_UBLAS_INLINE
  1.4027 +        const_reverse_iterator2 rend2 () const {
  1.4028 +            return const_reverse_iterator2 (begin2 ());
  1.4029 +        }
  1.4030 +
  1.4031 +        BOOST_UBLAS_INLINE
  1.4032 +        reverse_iterator2 rbegin2 () {
  1.4033 +            return reverse_iterator2 (end2 ());
  1.4034 +        }
  1.4035 +        BOOST_UBLAS_INLINE
  1.4036 +        reverse_iterator2 rend2 () {
  1.4037 +            return reverse_iterator2 (begin2 ());
  1.4038 +        }
  1.4039 +
  1.4040 +    private:
  1.4041 +        size_type size1_;
  1.4042 +        size_type size2_;
  1.4043 +        value_type data_ [N] [M];
  1.4044 +    };
  1.4045 +
  1.4046 +}}}
  1.4047 +
  1.4048 +#endif