X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=boost%2Fnumeric%2Fublas%2Fmatrix.hpp;h=d06391077a6311cc7c1ed00f2c6f48601169ca1f;hb=08c1e93fa36a49f49325a07fe91ff92c964c2b6c;hp=355fda6bff53f10f8cd8f636b3e37a00b7824ad1;hpb=bb4dd8289b351fae6b55e303f189127a394a1edd;p=platform%2Fupstream%2Fboost.git diff --git a/boost/numeric/ublas/matrix.hpp b/boost/numeric/ublas/matrix.hpp index 355fda6..d063910 100644 --- a/boost/numeric/ublas/matrix.hpp +++ b/boost/numeric/ublas/matrix.hpp @@ -1,6 +1,7 @@ // // Copyright (c) 2000-2010 // Joerg Walter, Mathias Koch, Gunter Winkler, David Bellot +// Copyright (c) 2014, Athanasios Iliopoulos // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -13,6 +14,7 @@ #ifndef _BOOST_UBLAS_MATRIX_ #define _BOOST_UBLAS_MATRIX_ +#include #include #include #include @@ -116,138 +118,1262 @@ namespace boost { namespace numeric { // Construction and destruction /// Default dense matrix constructor. Make a dense matrix of size (0,0) + BOOST_UBLAS_INLINE + matrix (): + matrix_container (), + size1_ (0), size2_ (0), data_ () {} + + /** Dense matrix constructor with defined size + * \param size1 number of rows + * \param size2 number of columns + */ + BOOST_UBLAS_INLINE + matrix (size_type size1, size_type size2): + matrix_container (), + size1_ (size1), size2_ (size2), data_ (layout_type::storage_size (size1, size2)) { + } + + /** Dense matrix constructor with defined size a initial value for all the matrix elements + * \param size1 number of rows + * \param size2 number of columns + * \param init initial value assigned to all elements + */ + matrix (size_type size1, size_type size2, const value_type &init): + matrix_container (), + size1_ (size1), size2_ (size2), data_ (layout_type::storage_size (size1, size2), init) { + } + + /** Dense matrix constructor with defined size and an initial data array + * \param size1 number of rows + * \param size2 number of columns + * \param data array to copy into the matrix. Must have the same dimension as the matrix + */ + BOOST_UBLAS_INLINE + matrix (size_type size1, size_type size2, const array_type &data): + matrix_container (), + size1_ (size1), size2_ (size2), data_ (data) {} + + /** Copy-constructor of a dense matrix + * \param m is a dense matrix + */ + BOOST_UBLAS_INLINE + matrix (const matrix &m): + matrix_container (), + size1_ (m.size1_), size2_ (m.size2_), data_ (m.data_) {} + + /** Copy-constructor of a dense matrix from a matrix expression + * \param ae is a matrix expression + */ + template + BOOST_UBLAS_INLINE + matrix (const matrix_expression &ae): + matrix_container (), + size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ (layout_type::storage_size (size1_, size2_)) { + matrix_assign (*this, ae); + } + + // Accessors + /** Return the number of rows of the matrix + * You can also use the free size<>() function in operation/size.hpp as size<1>(m) where m is a matrix + */ + BOOST_UBLAS_INLINE + size_type size1 () const { + return size1_; + } + + /** Return the number of colums of the matrix + * You can also use the free size<>() function in operation/size.hpp as size<2>(m) where m is a matrix + */ + BOOST_UBLAS_INLINE + size_type size2 () const { + return size2_; + } + + // Storage accessors + /** Return a constant reference to the internal storage of a dense matrix, i.e. the raw data + * It's type depends on the type used by the matrix to store its data + */ + BOOST_UBLAS_INLINE + const array_type &data () const { + return data_; + } + /** Return a reference to the internal storage of a dense matrix, i.e. the raw data + * It's type depends on the type used by the matrix to store its data + */ + BOOST_UBLAS_INLINE + array_type &data () { + return data_; + } + + // Resizing + /** Resize a matrix to new dimensions + * If data are preserved, then if the size if bigger at least on one dimension, extra values are filled with zeros. + * If data are not preserved, then nothing has to be assumed regarding the content of the matrix after resizing. + * \param size1 the new number of rows + * \param size2 the new number of colums + * \param preserve a boolean to say if one wants the data to be preserved during the resizing. Default is true. + */ + BOOST_UBLAS_INLINE + void resize (size_type size1, size_type size2, bool preserve = true) { + if (preserve) { + self_type temporary (size1, size2); + detail::matrix_resize_preserve (*this, temporary); + } + else { + data ().resize (layout_type::storage_size (size1, size2)); + size1_ = size1; + size2_ = size2; + } + } + + // Element access + + /** Access a matrix element. Here we return a const reference + * \param i the first coordinate of the element. By default it's the row + * \param j the second coordinate of the element. By default it's the column + * \return a const reference to the element + */ + BOOST_UBLAS_INLINE + const_reference operator () (size_type i, size_type j) const { + return data () [layout_type::element (i, size1_, j, size2_)]; + } + + /** Access a matrix element. Here we return a reference + * \param i the first coordinate of the element. By default it's the row + * \param j the second coordinate of the element. By default it's the column + * \return a reference to the element + */ + BOOST_UBLAS_INLINE + reference at_element (size_type i, size_type j) { + return data () [layout_type::element (i, size1_, j, size2_)]; + } + + /** Access a matrix element. Here we return a reference + * \param i the first coordinate of the element. By default it's the row + * \param j the second coordinate of the element. By default it's the column + * \return a reference to the element + */ + BOOST_UBLAS_INLINE + reference operator () (size_type i, size_type j) { + return at_element (i, j); + } + + // Element assignment + + /** Change the value of a matrix element. Return back a reference to it + * \param i the first coordinate of the element. By default it's the row + * \param j the second coordinate of the element. By default it's the column + * \param t the new value of the element + * \return a reference to the newly changed element + */ + BOOST_UBLAS_INLINE + reference insert_element (size_type i, size_type j, const_reference t) { + return (at_element (i, j) = t); + } + + /** Erase the element + * For most types (int, double, etc...) it means setting 0 (zero) the element at zero in fact. + * For user-defined types, it could be another value if you decided it. Your type in that case must + * contain a default null value. + * \param i the first coordinate of the element. By default it's the row + * \param j the second coordinate of the element. By default it's the column + */ + void erase_element (size_type i, size_type j) { + at_element (i, j) = value_type/*zero*/(); + } + + // Zeroing + /** Erase all elements in the matrix + * For most types (int, double, etc...) it means writing 0 (zero) everywhere. + * For user-defined types, it could be another value if you decided it. Your type in that case must + * contain a default null value. + */ + BOOST_UBLAS_INLINE + void clear () { + std::fill (data ().begin (), data ().end (), value_type/*zero*/()); + } + + // Assignment +#ifdef BOOST_UBLAS_MOVE_SEMANTICS + + /*! @note "pass by value" the key idea to enable move semantics */ + BOOST_UBLAS_INLINE + matrix &operator = (matrix m) { + assign_temporary(m); + return *this; + } +#else + BOOST_UBLAS_INLINE + matrix &operator = (const matrix &m) { + size1_ = m.size1_; + size2_ = m.size2_; + data () = m.data (); + return *this; + } +#endif + template // Container assignment without temporary + BOOST_UBLAS_INLINE + matrix &operator = (const matrix_container &m) { + resize (m ().size1 (), m ().size2 (), false); + assign (m); + return *this; + } + BOOST_UBLAS_INLINE + matrix &assign_temporary (matrix &m) { + swap (m); + return *this; + } + template + BOOST_UBLAS_INLINE + matrix &operator = (const matrix_expression &ae) { + self_type temporary (ae); + return assign_temporary (temporary); + } + template + BOOST_UBLAS_INLINE + matrix &assign (const matrix_expression &ae) { + matrix_assign (*this, ae); + return *this; + } + template + BOOST_UBLAS_INLINE + matrix& operator += (const matrix_expression &ae) { + self_type temporary (*this + ae); + return assign_temporary (temporary); + } + template // Container assignment without temporary + BOOST_UBLAS_INLINE + matrix &operator += (const matrix_container &m) { + plus_assign (m); + return *this; + } + template + BOOST_UBLAS_INLINE + matrix &plus_assign (const matrix_expression &ae) { + matrix_assign (*this, ae); + return *this; + } + template + BOOST_UBLAS_INLINE + matrix& operator -= (const matrix_expression &ae) { + self_type temporary (*this - ae); + return assign_temporary (temporary); + } + template // Container assignment without temporary + BOOST_UBLAS_INLINE + matrix &operator -= (const matrix_container &m) { + minus_assign (m); + return *this; + } + template + BOOST_UBLAS_INLINE + matrix &minus_assign (const matrix_expression &ae) { + matrix_assign (*this, ae); + return *this; + } + template + BOOST_UBLAS_INLINE + matrix& operator *= (const AT &at) { + matrix_assign_scalar (*this, at); + return *this; + } + template + BOOST_UBLAS_INLINE + matrix& operator /= (const AT &at) { + matrix_assign_scalar (*this, at); + return *this; + } + + // Swapping + BOOST_UBLAS_INLINE + void swap (matrix &m) { + if (this != &m) { + std::swap (size1_, m.size1_); + std::swap (size2_, m.size2_); + data ().swap (m.data ()); + } + } + BOOST_UBLAS_INLINE + friend void swap (matrix &m1, matrix &m2) { + m1.swap (m2); + } + + // Iterator types + private: + // Use the storage array iterator + typedef typename A::const_iterator const_subiterator_type; + typedef typename A::iterator subiterator_type; + + public: +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR + typedef indexed_iterator1 iterator1; + typedef indexed_iterator2 iterator2; + typedef indexed_const_iterator1 const_iterator1; + typedef indexed_const_iterator2 const_iterator2; +#else + class const_iterator1; + class iterator1; + class const_iterator2; + class iterator2; +#endif + typedef reverse_iterator_base1 const_reverse_iterator1; + typedef reverse_iterator_base1 reverse_iterator1; + typedef reverse_iterator_base2 const_reverse_iterator2; + typedef reverse_iterator_base2 reverse_iterator2; + + // Element lookup + BOOST_UBLAS_INLINE + const_iterator1 find1 (int /* rank */, size_type i, size_type j) const { +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR + return const_iterator1 (*this, i, j); +#else + return const_iterator1 (*this, data ().begin () + layout_type::address (i, size1_, j, size2_)); +#endif + } + BOOST_UBLAS_INLINE + iterator1 find1 (int /* rank */, size_type i, size_type j) { +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR + return iterator1 (*this, i, j); +#else + return iterator1 (*this, data ().begin () + layout_type::address (i, size1_, j, size2_)); +#endif + } + BOOST_UBLAS_INLINE + const_iterator2 find2 (int /* rank */, size_type i, size_type j) const { +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR + return const_iterator2 (*this, i, j); +#else + return const_iterator2 (*this, data ().begin () + layout_type::address (i, size1_, j, size2_)); +#endif + } + BOOST_UBLAS_INLINE + iterator2 find2 (int /* rank */, size_type i, size_type j) { +#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR + return iterator2 (*this, i, j); +#else + return iterator2 (*this, data ().begin () + layout_type::address (i, size1_, j, size2_)); +#endif + } + + +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR + class const_iterator1: + public container_const_reference, + public random_access_iterator_base { + public: + typedef typename matrix::value_type value_type; + typedef typename matrix::difference_type difference_type; + typedef typename matrix::const_reference reference; + typedef const typename matrix::pointer pointer; + + typedef const_iterator2 dual_iterator_type; + typedef const_reverse_iterator2 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + const_iterator1 (): + container_const_reference (), it_ () {} + BOOST_UBLAS_INLINE + const_iterator1 (const self_type &m, const const_subiterator_type &it): + container_const_reference (m), it_ (it) {} + BOOST_UBLAS_INLINE + const_iterator1 (const iterator1 &it): + container_const_reference (it ()), it_ (it.it_) {} + + // Arithmetic + BOOST_UBLAS_INLINE + const_iterator1 &operator ++ () { + layout_type::increment_i (it_, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + const_iterator1 &operator -- () { + layout_type::decrement_i (it_, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + const_iterator1 &operator += (difference_type n) { + layout_type::increment_i (it_, n, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + const_iterator1 &operator -= (difference_type n) { + layout_type::decrement_i (it_, n, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const const_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return layout_type::distance_i (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ()); + } + + // Dereference + BOOST_UBLAS_INLINE + const_reference operator * () const { + BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); + BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); + return *it_; + } + BOOST_UBLAS_INLINE + const_reference operator [] (difference_type n) const { + return *(*this + n); + } + +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator2 begin () const { + const self_type &m = (*this) (); + return m.find2 (1, index1 (), 0); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator2 cbegin () const { + return begin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator2 end () const { + const self_type &m = (*this) (); + return m.find2 (1, index1 (), m.size2 ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator2 cend () const { + return end (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator2 rbegin () const { + return const_reverse_iterator2 (end ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator2 crbegin () const { + return rbegin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator2 rend () const { + return const_reverse_iterator2 (begin ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator2 crend () const { + return rend (); + } +#endif + + // Indices + BOOST_UBLAS_INLINE + size_type index1 () const { + const self_type &m = (*this) (); + return layout_type::index_i (it_ - m.begin1 ().it_, m.size1 (), m.size2 ()); + } + BOOST_UBLAS_INLINE + size_type index2 () const { + const self_type &m = (*this) (); + return layout_type::index_j (it_ - m.begin1 ().it_, m.size1 (), m.size2 ()); + } + + // Assignment + BOOST_UBLAS_INLINE + const_iterator1 &operator = (const const_iterator1 &it) { + container_const_reference::assign (&it ()); + it_ = it.it_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const const_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ == it.it_; + } + BOOST_UBLAS_INLINE + bool operator < (const const_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ < it.it_; + } + + private: + const_subiterator_type it_; + + friend class iterator1; + }; +#endif + + BOOST_UBLAS_INLINE + const_iterator1 begin1 () const { + return find1 (0, 0, 0); + } + BOOST_UBLAS_INLINE + const_iterator1 cbegin1 () const { + return begin1 (); + } + BOOST_UBLAS_INLINE + const_iterator1 end1 () const { + return find1 (0, size1_, 0); + } + BOOST_UBLAS_INLINE + const_iterator1 cend1 () const { + return end1 (); + } + +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR + class iterator1: + public container_reference, + public random_access_iterator_base { + public: + typedef typename matrix::value_type value_type; + typedef typename matrix::difference_type difference_type; + typedef typename matrix::reference reference; + typedef typename matrix::pointer pointer; + + typedef iterator2 dual_iterator_type; + typedef reverse_iterator2 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + iterator1 (): + container_reference (), it_ () {} + BOOST_UBLAS_INLINE + iterator1 (self_type &m, const subiterator_type &it): + container_reference (m), it_ (it) {} + + // Arithmetic + BOOST_UBLAS_INLINE + iterator1 &operator ++ () { + layout_type::increment_i (it_, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + iterator1 &operator -- () { + layout_type::decrement_i (it_, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + iterator1 &operator += (difference_type n) { + layout_type::increment_i (it_, n, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + iterator1 &operator -= (difference_type n) { + layout_type::decrement_i (it_, n, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return layout_type::distance_i (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ()); + } + + // Dereference + BOOST_UBLAS_INLINE + reference operator * () const { + BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); + BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); + return *it_; + } + BOOST_UBLAS_INLINE + reference operator [] (difference_type n) const { + return *(*this + n); + } + +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + iterator2 begin () const { + self_type &m = (*this) (); + return m.find2 (1, index1 (), 0); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + iterator2 end () const { + self_type &m = (*this) (); + return m.find2 (1, index1 (), m.size2 ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + reverse_iterator2 rbegin () const { + return reverse_iterator2 (end ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + reverse_iterator2 rend () const { + return reverse_iterator2 (begin ()); + } +#endif + + // Indices + BOOST_UBLAS_INLINE + size_type index1 () const { + self_type &m = (*this) (); + return layout_type::index_i (it_ - m.begin1 ().it_, m.size1 (), m.size2 ()); + } + BOOST_UBLAS_INLINE + size_type index2 () const { + self_type &m = (*this) (); + return layout_type::index_j (it_ - m.begin1 ().it_, m.size1 (), m.size2 ()); + } + + // Assignment + BOOST_UBLAS_INLINE + iterator1 &operator = (const iterator1 &it) { + container_reference::assign (&it ()); + it_ = it.it_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ == it.it_; + } + BOOST_UBLAS_INLINE + bool operator < (const iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ < it.it_; + } + + private: + subiterator_type it_; + + friend class const_iterator1; + }; +#endif + + BOOST_UBLAS_INLINE + iterator1 begin1 () { + return find1 (0, 0, 0); + } + BOOST_UBLAS_INLINE + iterator1 end1 () { + return find1 (0, size1_, 0); + } + +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR + class const_iterator2: + public container_const_reference, + public random_access_iterator_base { + public: + typedef typename matrix::value_type value_type; + typedef typename matrix::difference_type difference_type; + typedef typename matrix::const_reference reference; + typedef const typename matrix::pointer pointer; + + typedef const_iterator1 dual_iterator_type; + typedef const_reverse_iterator1 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + const_iterator2 (): + container_const_reference (), it_ () {} + BOOST_UBLAS_INLINE + const_iterator2 (const self_type &m, const const_subiterator_type &it): + container_const_reference (m), it_ (it) {} + BOOST_UBLAS_INLINE + const_iterator2 (const iterator2 &it): + container_const_reference (it ()), it_ (it.it_) {} + + // Arithmetic + BOOST_UBLAS_INLINE + const_iterator2 &operator ++ () { + layout_type::increment_j (it_, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + const_iterator2 &operator -- () { + layout_type::decrement_j (it_, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + const_iterator2 &operator += (difference_type n) { + layout_type::increment_j (it_, n, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + const_iterator2 &operator -= (difference_type n) { + layout_type::decrement_j (it_, n, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const const_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return layout_type::distance_j (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ()); + } + + // Dereference + BOOST_UBLAS_INLINE + const_reference operator * () const { + BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); + BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); + return *it_; + } + BOOST_UBLAS_INLINE + const_reference operator [] (difference_type n) const { + return *(*this + n); + } + +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator1 begin () const { + const self_type &m = (*this) (); + return m.find1 (1, 0, index2 ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator1 cbegin () const { + return begin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator1 end () const { + const self_type &m = (*this) (); + return m.find1 (1, m.size1 (), index2 ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator1 cend () const { + return end (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator1 rbegin () const { + return const_reverse_iterator1 (end ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator1 crbegin () const { + return rbegin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator1 rend () const { + return const_reverse_iterator1 (begin ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator1 crend () const { + return rend (); + } +#endif + + // Indices + BOOST_UBLAS_INLINE + size_type index1 () const { + const self_type &m = (*this) (); + return layout_type::index_i (it_ - m.begin2 ().it_, m.size1 (), m.size2 ()); + } + BOOST_UBLAS_INLINE + size_type index2 () const { + const self_type &m = (*this) (); + return layout_type::index_j (it_ - m.begin2 ().it_, m.size1 (), m.size2 ()); + } + + // Assignment + BOOST_UBLAS_INLINE + const_iterator2 &operator = (const const_iterator2 &it) { + container_const_reference::assign (&it ()); + it_ = it.it_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const const_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ == it.it_; + } + BOOST_UBLAS_INLINE + bool operator < (const const_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ < it.it_; + } + + private: + const_subiterator_type it_; + + friend class iterator2; + }; +#endif + + BOOST_UBLAS_INLINE + const_iterator2 begin2 () const { + return find2 (0, 0, 0); + } + BOOST_UBLAS_INLINE + const_iterator2 cbegin2 () const { + return begin2 (); + } + BOOST_UBLAS_INLINE + const_iterator2 end2 () const { + return find2 (0, 0, size2_); + } + BOOST_UBLAS_INLINE + const_iterator2 cend2 () const { + return end2 (); + } + +#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR + class iterator2: + public container_reference, + public random_access_iterator_base { + public: + typedef typename matrix::value_type value_type; + typedef typename matrix::difference_type difference_type; + typedef typename matrix::reference reference; + typedef typename matrix::pointer pointer; + + typedef iterator1 dual_iterator_type; + typedef reverse_iterator1 dual_reverse_iterator_type; + + // Construction and destruction + BOOST_UBLAS_INLINE + iterator2 (): + container_reference (), it_ () {} + BOOST_UBLAS_INLINE + iterator2 (self_type &m, const subiterator_type &it): + container_reference (m), it_ (it) {} + + // Arithmetic + BOOST_UBLAS_INLINE + iterator2 &operator ++ () { + layout_type::increment_j (it_, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + iterator2 &operator -- () { + layout_type::decrement_j (it_, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + iterator2 &operator += (difference_type n) { + layout_type::increment_j (it_, n, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + iterator2 &operator -= (difference_type n) { + layout_type::decrement_j (it_, n, (*this) ().size1 (), (*this) ().size2 ()); + return *this; + } + BOOST_UBLAS_INLINE + difference_type operator - (const iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return layout_type::distance_j (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ()); + } + + // Dereference + BOOST_UBLAS_INLINE + reference operator * () const { + BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); + BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); + return *it_; + } + BOOST_UBLAS_INLINE + reference operator [] (difference_type n) const { + return *(*this + n); + } + +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + iterator1 begin () const { + self_type &m = (*this) (); + return m.find1 (1, 0, index2 ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + iterator1 end () const { + self_type &m = (*this) (); + return m.find1 (1, m.size1 (), index2 ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + reverse_iterator1 rbegin () const { + return reverse_iterator1 (end ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + reverse_iterator1 rend () const { + return reverse_iterator1 (begin ()); + } +#endif + + // Indices + BOOST_UBLAS_INLINE + size_type index1 () const { + self_type &m = (*this) (); + return layout_type::index_i (it_ - m.begin2 ().it_, m.size1 (), m.size2 ()); + } + BOOST_UBLAS_INLINE + size_type index2 () const { + self_type &m = (*this) (); + return layout_type::index_j (it_ - m.begin2 ().it_, m.size1 (), m.size2 ()); + } + + // Assignment + BOOST_UBLAS_INLINE + iterator2 &operator = (const iterator2 &it) { + container_reference::assign (&it ()); + it_ = it.it_; + return *this; + } + + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ == it.it_; + } + BOOST_UBLAS_INLINE + bool operator < (const iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ < it.it_; + } + + private: + subiterator_type it_; + + friend class const_iterator2; + }; +#endif + + BOOST_UBLAS_INLINE + iterator2 begin2 () { + return find2 (0, 0, 0); + } + BOOST_UBLAS_INLINE + iterator2 end2 () { + return find2 (0, 0, size2_); + } + + // Reverse iterators + + BOOST_UBLAS_INLINE + const_reverse_iterator1 rbegin1 () const { + return const_reverse_iterator1 (end1 ()); + } + BOOST_UBLAS_INLINE + const_reverse_iterator1 crbegin1 () const { + return rbegin1 (); + } + BOOST_UBLAS_INLINE + const_reverse_iterator1 rend1 () const { + return const_reverse_iterator1 (begin1 ()); + } + BOOST_UBLAS_INLINE + const_reverse_iterator1 crend1 () const { + return rend1 (); + } + + BOOST_UBLAS_INLINE + reverse_iterator1 rbegin1 () { + return reverse_iterator1 (end1 ()); + } + BOOST_UBLAS_INLINE + reverse_iterator1 rend1 () { + return reverse_iterator1 (begin1 ()); + } + + BOOST_UBLAS_INLINE + const_reverse_iterator2 rbegin2 () const { + return const_reverse_iterator2 (end2 ()); + } + BOOST_UBLAS_INLINE + const_reverse_iterator2 crbegin2 () const { + return rbegin2 (); + } + BOOST_UBLAS_INLINE + const_reverse_iterator2 rend2 () const { + return const_reverse_iterator2 (begin2 ()); + } + BOOST_UBLAS_INLINE + const_reverse_iterator2 crend2 () const { + return rend2 (); + } + + BOOST_UBLAS_INLINE + reverse_iterator2 rbegin2 () { + return reverse_iterator2 (end2 ()); + } + BOOST_UBLAS_INLINE + reverse_iterator2 rend2 () { + return reverse_iterator2 (begin2 ()); + } + + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + + // we need to copy to a collection_size_type to get a portable + // and efficient serialization + serialization::collection_size_type s1 (size1_); + serialization::collection_size_type s2 (size2_); + + // serialize the sizes + ar & serialization::make_nvp("size1",s1) + & serialization::make_nvp("size2",s2); + + // copy the values back if loading + if (Archive::is_loading::value) { + size1_ = s1; + size2_ = s2; + } + ar & serialization::make_nvp("data",data_); + } + + private: + size_type size1_; + size_type size2_; + array_type data_; + }; + + +#ifdef BOOST_UBLAS_CPP_GE_2011 + /** \brief A fixed size dense matrix of values of type \c T. Equivalent to a c-style 2 dimensional array. + * + * For a \f$(m \times n)\f$-dimensional fixed_matrix and \f$ 0 \leq i < m, 0 \leq j < n\f$, every element \f$ m_{i,j} \f$ is mapped to + * the \f$(i.n + j)\f$-th element of the container for row major orientation or the \f$ (i + j.m) \f$-th element of + * the container for column major orientation. In a dense matrix all elements are represented in memory in a + * contiguous chunk of memory by definition. + * + * Orientation and storage can also be specified, otherwise \c row_major and \c std::array are used. It is \b not + * required by the storage container to initialize elements of the matrix. + * + * \tparam T the type of object stored in the matrix (like double, float, std::complex, etc...) + * \tparam L the storage organization. It can be either \c row_major or \c column_major. Default is \c row_major + * \tparam A the type of Storage array. Default is \c std::array + */ + template + class fixed_matrix: + public matrix_container > { + + typedef T *pointer; + typedef L layout_type; + typedef fixed_matrix self_type; + public: +#ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS + using matrix_container::operator (); +#endif + typedef typename A::size_type size_type; + typedef typename A::difference_type difference_type; + typedef T value_type; + typedef const T &const_reference; + typedef T &reference; + typedef A array_type; + typedef const matrix_reference const_closure_type; + typedef matrix_reference closure_type; + typedef vector vector_temporary_type; + typedef self_type matrix_temporary_type; + typedef dense_tag storage_category; + // This could be better for performance, + // typedef typename unknown_orientation_tag orientation_category; + // but others depend on the orientation information... + typedef typename L::orientation_category orientation_category; + + // Construction and destruction + + /// Default dense fixed_matrix constructor. Make a dense fixed_matrix of size M x N BOOST_UBLAS_INLINE - matrix (): + fixed_matrix (): matrix_container (), - size1_ (0), size2_ (0), data_ () {} + data_ () {} - /** Dense matrix constructor with defined size - * \param size1 number of rows - * \param size2 number of columns - */ - BOOST_UBLAS_INLINE - matrix (size_type size1, size_type size2): + /// \brief Construct a fixed_matrix from a list of values + /// The list may be included in curly braces. Typical syntax is choices are : + /// fixed_matrix v = { 1, 2, 3, 4 } or fixed_matrix v( {1, 2, 3, 4} ) or fixed_matrix v( 1, 2, 3, 4 ) + template + fixed_matrix(value_type v0, Types... vrest) : matrix_container (), - size1_ (size1), size2_ (size2), data_ (layout_type::storage_size (size1, size2)) { - } + data_{ { v0, vrest... } } {} - /** Dense matrix constructor with defined size a initial value for all the matrix elements - * \param size1 number of rows - * \param size2 number of columns - * \param init initial value assigned to all elements - */ - matrix (size_type size1, size_type size2, const value_type &init): + /** Dense fixed_matrix constructor with defined initial value for all the matrix elements + * \param init initial value assigned to all elements + */ + fixed_matrix (const value_type &init): matrix_container (), - size1_ (size1), size2_ (size2), data_ (layout_type::storage_size (size1, size2), init) { + data_ ( ) { + data_.fill(init); } - /** Dense matrix constructor with defined size and an initial data array - * \param size1 number of rows - * \param size2 number of columns - * \param data array to copy into the matrix. Must have the same dimension as the matrix - */ + /** Dense matrix constructor with defined initial data array + * \param data array to copy into the matrix. Must have the same dimension as the matrix + */ BOOST_UBLAS_INLINE - matrix (size_type size1, size_type size2, const array_type &data): + fixed_matrix (const array_type &data): matrix_container (), - size1_ (size1), size2_ (size2), data_ (data) {} + data_ (data) {} - /** Copy-constructor of a dense matrix - * \param m is a dense matrix - */ + /** Copy-constructor of a dense fixed_matrix + * \param m is a dense fixed_matrix + */ BOOST_UBLAS_INLINE - matrix (const matrix &m): + fixed_matrix (const fixed_matrix &m): matrix_container (), - size1_ (m.size1_), size2_ (m.size2_), data_ (m.data_) {} + data_ (m.data_) {} - /** Copy-constructor of a dense matrix from a matrix expression - * \param ae is a matrix expression - */ + /** Copy-constructor of a dense matrix from a matrix expression + * \param ae is a matrix expression + */ template BOOST_UBLAS_INLINE - matrix (const matrix_expression &ae): + fixed_matrix (const matrix_expression &ae): matrix_container (), - size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ (layout_type::storage_size (size1_, size2_)) { + data_ () { matrix_assign (*this, ae); } // Accessors - /** Return the number of rows of the matrix - * You can also use the free size<>() function in operation/size.hpp as size<1>(m) where m is a matrix - */ + /** Return the number of rows of the fixed_matrix + * You can also use the free size<>() function in operation/size.hpp as size<1>(m) where m is a fixed_matrix + */ BOOST_UBLAS_INLINE - size_type size1 () const { - return size1_; + BOOST_CONSTEXPR size_type size1 () const { + return M; } - /** Return the number of colums of the matrix - * You can also use the free size<>() function in operation/size.hpp as size<2>(m) where m is a matrix - */ + /** Return the number of colums of the fixed_matrix + * You can also use the free size<>() function in operation/size.hpp as size<2>(m) where m is a fixed_matrix + */ BOOST_UBLAS_INLINE - size_type size2 () const { - return size2_; + BOOST_CONSTEXPR size_type size2 () const { + return N; } // Storage accessors - /** Return a constant reference to the internal storage of a dense matrix, i.e. the raw data - * It's type depends on the type used by the matrix to store its data - */ + /** Return a constant reference to the internal storage of a dense matrix, i.e. the raw data + * It's type depends on the type used by the matrix to store its data + */ BOOST_UBLAS_INLINE const array_type &data () const { return data_; } - /** Return a reference to the internal storage of a dense matrix, i.e. the raw data - * It's type depends on the type used by the matrix to store its data - */ + /** Return a reference to the internal storage of a dense fixed_matrix, i.e. the raw data + * It's type depends on the type used by the fixed_matrix to store its data + */ BOOST_UBLAS_INLINE array_type &data () { return data_; } - // Resizing - /** Resize a matrix to new dimensions - * If data are preserved, then if the size if bigger at least on one dimension, extra values are filled with zeros. - * If data are not preserved, then nothing has to be assumed regarding the content of the matrix after resizing. - * \param size1 the new number of rows - * \param size2 the new number of colums - * \param preserve a boolean to say if one wants the data to be preserved during the resizing. Default is true. - */ - BOOST_UBLAS_INLINE - void resize (size_type size1, size_type size2, bool preserve = true) { - if (preserve) { - self_type temporary (size1, size2); - detail::matrix_resize_preserve (*this, temporary); - } - else { - data ().resize (layout_type::storage_size (size1, size2)); - size1_ = size1; - size2_ = size2; - } - } // Element access + + /** Access a fixed_matrix element. Here we return a const reference + * \param i the first coordinate of the element. By default it's the row + * \param j the second coordinate of the element. By default it's the column + * \return a const reference to the element + */ BOOST_UBLAS_INLINE const_reference operator () (size_type i, size_type j) const { - return data () [layout_type::element (i, size1_, j, size2_)]; + return data () [layout_type::element (i, M, j, N)]; // Fixme: add static lookup for element(...) i.e.: element(i,j) } + + /** Access a fixed_matrix element. Here we return a reference + * \param i the first coordinate of the element. By default it's the row + * \param j the second coordinate of the element. By default it's the column + * \return a reference to the element + */ BOOST_UBLAS_INLINE reference at_element (size_type i, size_type j) { - return data () [layout_type::element (i, size1_, j, size2_)]; + return data () [layout_type::element (i, M, j, N)]; } + + /** Access a fixed_matrix element. Here we return a reference + * \param i the first coordinate of the element. By default it's the row + * \param j the second coordinate of the element. By default it's the column + * \return a reference to the element + */ BOOST_UBLAS_INLINE reference operator () (size_type i, size_type j) { return at_element (i, j); } // Element assignment + + /** Change the value of a fixed_matrix element. Return back a reference to it + * \param i the first coordinate of the element. By default it's the row + * \param j the second coordinate of the element. By default it's the column + * \param t the new value of the element + * \return a reference to the newly changed element + */ BOOST_UBLAS_INLINE reference insert_element (size_type i, size_type j, const_reference t) { return (at_element (i, j) = t); } + + /** Erase the element + * For most types (int, double, etc...) it means setting 0 (zero) the element at zero in fact. + * For user-defined types, it could be another value if you decided it. Your type in that case must + * contain a default null value. + * \param i the first coordinate of the element. By default it's the row + * \param j the second coordinate of the element. By default it's the column + */ void erase_element (size_type i, size_type j) { at_element (i, j) = value_type/*zero*/(); } // Zeroing + /** Erase all elements in the fixed_matrix + * For most types (int, double, etc...) it means writing 0 (zero) everywhere. + * For user-defined types, it could be another value if you decided it. Your type in that case must + * contain a default null value. + */ BOOST_UBLAS_INLINE void clear () { std::fill (data ().begin (), data ().end (), value_type/*zero*/()); @@ -258,103 +1384,99 @@ namespace boost { namespace numeric { /*! @note "pass by value" the key idea to enable move semantics */ BOOST_UBLAS_INLINE - matrix &operator = (matrix m) { + fixed_matrix &operator = (matrix m) { assign_temporary(m); return *this; } #else BOOST_UBLAS_INLINE - matrix &operator = (const matrix &m) { - size1_ = m.size1_; - size2_ = m.size2_; + fixed_matrix &operator = (const fixed_matrix &m) { data () = m.data (); return *this; } #endif template // Container assignment without temporary BOOST_UBLAS_INLINE - matrix &operator = (const matrix_container &m) { + fixed_matrix &operator = (const matrix_container &m) { resize (m ().size1 (), m ().size2 (), false); assign (m); return *this; } BOOST_UBLAS_INLINE - matrix &assign_temporary (matrix &m) { + fixed_matrix &assign_temporary (fixed_matrix &m) { swap (m); return *this; } template BOOST_UBLAS_INLINE - matrix &operator = (const matrix_expression &ae) { + fixed_matrix &operator = (const matrix_expression &ae) { self_type temporary (ae); return assign_temporary (temporary); } template BOOST_UBLAS_INLINE - matrix &assign (const matrix_expression &ae) { + fixed_matrix &assign (const matrix_expression &ae) { matrix_assign (*this, ae); return *this; } template BOOST_UBLAS_INLINE - matrix& operator += (const matrix_expression &ae) { + fixed_matrix& operator += (const matrix_expression &ae) { self_type temporary (*this + ae); return assign_temporary (temporary); } template // Container assignment without temporary BOOST_UBLAS_INLINE - matrix &operator += (const matrix_container &m) { + fixed_matrix &operator += (const matrix_container &m) { plus_assign (m); return *this; } template BOOST_UBLAS_INLINE - matrix &plus_assign (const matrix_expression &ae) { + fixed_matrix &plus_assign (const matrix_expression &ae) { matrix_assign (*this, ae); return *this; } template BOOST_UBLAS_INLINE - matrix& operator -= (const matrix_expression &ae) { + fixed_matrix& operator -= (const matrix_expression &ae) { self_type temporary (*this - ae); return assign_temporary (temporary); } template // Container assignment without temporary BOOST_UBLAS_INLINE - matrix &operator -= (const matrix_container &m) { + fixed_matrix &operator -= (const matrix_container &m) { minus_assign (m); return *this; } template BOOST_UBLAS_INLINE - matrix &minus_assign (const matrix_expression &ae) { + fixed_matrix &minus_assign (const matrix_expression &ae) { matrix_assign (*this, ae); return *this; } template BOOST_UBLAS_INLINE - matrix& operator *= (const AT &at) { + fixed_matrix& operator *= (const AT &at) { matrix_assign_scalar (*this, at); return *this; } template BOOST_UBLAS_INLINE - matrix& operator /= (const AT &at) { + fixed_matrix& operator /= (const AT &at) { matrix_assign_scalar (*this, at); return *this; } // Swapping BOOST_UBLAS_INLINE - void swap (matrix &m) { + void swap (fixed_matrix &m) { if (this != &m) { - std::swap (size1_, m.size1_); - std::swap (size2_, m.size2_); data ().swap (m.data ()); } } BOOST_UBLAS_INLINE - friend void swap (matrix &m1, matrix &m2) { + friend void swap (fixed_matrix &m1, fixed_matrix &m2) { m1.swap (m2); } @@ -387,7 +1509,7 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator1 (*this, i, j); #else - return const_iterator1 (*this, data ().begin () + layout_type::address (i, size1_, j, size2_)); + return const_iterator1 (*this, data ().begin () + layout_type::address (i, M, j, N)); #endif } BOOST_UBLAS_INLINE @@ -395,7 +1517,7 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator1 (*this, i, j); #else - return iterator1 (*this, data ().begin () + layout_type::address (i, size1_, j, size2_)); + return iterator1 (*this, data ().begin () + layout_type::address (i, M, j, N)); #endif } BOOST_UBLAS_INLINE @@ -403,7 +1525,7 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator2 (*this, i, j); #else - return const_iterator2 (*this, data ().begin () + layout_type::address (i, size1_, j, size2_)); + return const_iterator2 (*this, data ().begin () + layout_type::address (i, M, j, N)); #endif } BOOST_UBLAS_INLINE @@ -411,21 +1533,21 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator2 (*this, i, j); #else - return iterator2 (*this, data ().begin () + layout_type::address (i, size1_, j, size2_)); + return iterator2 (*this, data ().begin () + layout_type::address (i, M, j, N)); #endif } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator1: - public container_const_reference, + public container_const_reference, public random_access_iterator_base { public: - typedef typename matrix::value_type value_type; - typedef typename matrix::difference_type difference_type; - typedef typename matrix::const_reference reference; - typedef const typename matrix::pointer pointer; + typedef typename fixed_matrix::value_type value_type; + typedef typename fixed_matrix::difference_type difference_type; + typedef typename fixed_matrix::const_reference reference; + typedef const typename fixed_matrix::pointer pointer; typedef const_iterator2 dual_iterator_type; typedef const_reverse_iterator2 dual_reverse_iterator_type; @@ -493,6 +1615,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator2 cbegin () const { + return begin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_iterator2 end () const { const self_type &m = (*this) (); return m.find2 (1, index1 (), m.size2 ()); @@ -501,6 +1630,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator2 cend () const { + return end (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator2 rbegin () const { return const_reverse_iterator2 (end ()); } @@ -508,9 +1644,23 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_reverse_iterator2 crbegin () const { + return rbegin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator2 rend () const { return const_reverse_iterator2 (begin ()); } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator2 crend () const { + return rend (); + } #endif // Indices @@ -557,20 +1707,28 @@ namespace boost { namespace numeric { return find1 (0, 0, 0); } BOOST_UBLAS_INLINE + const_iterator1 cbegin1 () const { + return begin1 (); + } + BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find1 (0, size1_, 0); + return find1 (0, M, 0); + } + BOOST_UBLAS_INLINE + const_iterator1 cend1 () const { + return end1 (); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class iterator1: - public container_reference, + public container_reference, public random_access_iterator_base { public: - typedef typename matrix::value_type value_type; - typedef typename matrix::difference_type difference_type; - typedef typename matrix::reference reference; - typedef typename matrix::pointer pointer; + typedef typename fixed_matrix::value_type value_type; + typedef typename fixed_matrix::difference_type difference_type; + typedef typename fixed_matrix::reference reference; + typedef typename fixed_matrix::pointer pointer; typedef iterator2 dual_iterator_type; typedef reverse_iterator2 dual_reverse_iterator_type; @@ -700,19 +1858,19 @@ namespace boost { namespace numeric { } BOOST_UBLAS_INLINE iterator1 end1 () { - return find1 (0, size1_, 0); + return find1 (0, M, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator2: - public container_const_reference, + public container_const_reference, public random_access_iterator_base { public: - typedef typename matrix::value_type value_type; - typedef typename matrix::difference_type difference_type; - typedef typename matrix::const_reference reference; - typedef const typename matrix::pointer pointer; + typedef typename fixed_matrix::value_type value_type; + typedef typename fixed_matrix::difference_type difference_type; + typedef typename fixed_matrix::const_reference reference; + typedef const typename fixed_matrix::pointer pointer; typedef const_iterator1 dual_iterator_type; typedef const_reverse_iterator1 dual_reverse_iterator_type; @@ -780,6 +1938,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator1 cbegin () const { + return begin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_iterator1 end () const { const self_type &m = (*this) (); return m.find1 (1, m.size1 (), index2 ()); @@ -788,6 +1953,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator1 cend () const { + return end (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator1 rbegin () const { return const_reverse_iterator1 (end ()); } @@ -795,9 +1967,23 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_reverse_iterator1 crbegin () const { + return rbegin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator1 rend () const { return const_reverse_iterator1 (begin ()); } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator1 crend () const { + return rend (); + } #endif // Indices @@ -844,20 +2030,28 @@ namespace boost { namespace numeric { return find2 (0, 0, 0); } BOOST_UBLAS_INLINE + const_iterator2 cbegin2 () const { + return begin2 (); + } + BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find2 (0, 0, size2_); + return find2 (0, 0, N); + } + BOOST_UBLAS_INLINE + const_iterator2 cend2 () const { + return end2 (); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class iterator2: - public container_reference, + public container_reference, public random_access_iterator_base { public: - typedef typename matrix::value_type value_type; - typedef typename matrix::difference_type difference_type; - typedef typename matrix::reference reference; - typedef typename matrix::pointer pointer; + typedef typename fixed_matrix::value_type value_type; + typedef typename fixed_matrix::difference_type difference_type; + typedef typename fixed_matrix::reference reference; + typedef typename fixed_matrix::pointer pointer; typedef iterator1 dual_iterator_type; typedef reverse_iterator1 dual_reverse_iterator_type; @@ -987,7 +2181,7 @@ namespace boost { namespace numeric { } BOOST_UBLAS_INLINE iterator2 end2 () { - return find2 (0, 0, size2_); + return find2 (0, 0, N); } // Reverse iterators @@ -997,9 +2191,17 @@ namespace boost { namespace numeric { return const_reverse_iterator1 (end1 ()); } BOOST_UBLAS_INLINE + const_reverse_iterator1 crbegin1 () const { + return rbegin1 (); + } + BOOST_UBLAS_INLINE const_reverse_iterator1 rend1 () const { return const_reverse_iterator1 (begin1 ()); } + BOOST_UBLAS_INLINE + const_reverse_iterator1 crend1 () const { + return rend1 (); + } BOOST_UBLAS_INLINE reverse_iterator1 rbegin1 () { @@ -1015,9 +2217,17 @@ namespace boost { namespace numeric { return const_reverse_iterator2 (end2 ()); } BOOST_UBLAS_INLINE + const_reverse_iterator2 crbegin2 () const { + return rbegin2 (); + } + BOOST_UBLAS_INLINE const_reverse_iterator2 rend2 () const { return const_reverse_iterator2 (begin2 ()); } + BOOST_UBLAS_INLINE + const_reverse_iterator2 crend2 () const { + return rend2 (); + } BOOST_UBLAS_INLINE reverse_iterator2 rbegin2 () { @@ -1031,30 +2241,15 @@ namespace boost { namespace numeric { // Serialization template void serialize(Archive & ar, const unsigned int /* file_version */){ - - // we need to copy to a collection_size_type to get a portable - // and efficient serialization - serialization::collection_size_type s1 (size1_); - serialization::collection_size_type s2 (size2_); - - // serialize the sizes - ar & serialization::make_nvp("size1",s1) - & serialization::make_nvp("size2",s2); - - // copy the values back if loading - if (Archive::is_loading::value) { - size1_ = s1; - size2_ = s2; - } ar & serialization::make_nvp("data",data_); } private: - size_type size1_; - size_type size2_; array_type data_; }; +#endif // BOOST_UBLAS_CPP_GE_2011 + /** \brief A dense matrix of values of type \c T with a variable size bounded to a maximum of \f$M\f$ by \f$N\f$. * * For a \f$(m \times n)\f$-dimensional matrix and \f$ 0 \leq i < m, 0 \leq j < n\f$, every element \f$m_{i,j}\f$ is mapped @@ -1138,6 +2333,7 @@ namespace boost { namespace numeric { } }; + /** \brief A dense matrix of values of type \c T stored as a vector of vectors. * * Rows or columns are not stored into contiguous chunks of memory but data inside rows (or columns) are. @@ -1517,6 +2713,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator2 cbegin () const { + return begin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_iterator2 end () const { const self_type &m = (*this) (); return m.find2 (1, index1 (), m.size2 ()); @@ -1525,6 +2728,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator2 cend () const { + return end (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator2 rbegin () const { return const_reverse_iterator2 (end ()); } @@ -1532,9 +2742,23 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_reverse_iterator2 crbegin () const { + return rbegin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator2 rend () const { return const_reverse_iterator2 (begin ()); } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator2 crend () const { + return rend (); + } #endif // Indices @@ -1583,9 +2807,17 @@ namespace boost { namespace numeric { return find1 (0, 0, 0); } BOOST_UBLAS_INLINE + const_iterator1 cbegin1 () const { + return begin1 (); + } + BOOST_UBLAS_INLINE const_iterator1 end1 () const { return find1 (0, size1_, 0); } + BOOST_UBLAS_INLINE + const_iterator1 cend1 () const { + return end1 (); + } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class iterator1: @@ -1838,9 +3070,23 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif - const_iterator1 end () const { - const self_type &m = (*this) (); - return m.find1 (1, m.size1 (), index2 ()); + const_iterator1 cbegin () const { + return begin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator1 end () const { + const self_type &m = (*this) (); + return m.find1 (1, m.size1 (), index2 ()); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_iterator1 cend () const { + return end (); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1853,9 +3099,23 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_reverse_iterator1 crbegin () const { + return rbegin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator1 rend () const { return const_reverse_iterator1 (begin ()); } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator2 crend () const { + return rend (); + } #endif // Indices @@ -1904,9 +3164,17 @@ namespace boost { namespace numeric { return find2 (0, 0, 0); } BOOST_UBLAS_INLINE + const_iterator2 cbegin2 () const { + return begin2 (); + } + BOOST_UBLAS_INLINE const_iterator2 end2 () const { return find2 (0, 0, size2_); } + BOOST_UBLAS_INLINE + const_iterator2 cend2 () const { + return end2 (); + } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class iterator2: @@ -2074,9 +3342,17 @@ namespace boost { namespace numeric { return const_reverse_iterator1 (end1 ()); } BOOST_UBLAS_INLINE + const_reverse_iterator1 crbegin1 () const { + return rbegin1 (); + } + BOOST_UBLAS_INLINE const_reverse_iterator1 rend1 () const { return const_reverse_iterator1 (begin1 ()); } + BOOST_UBLAS_INLINE + const_reverse_iterator1 crend1 () const { + return rend1 (); + } BOOST_UBLAS_INLINE reverse_iterator1 rbegin1 () { @@ -2092,9 +3368,17 @@ namespace boost { namespace numeric { return const_reverse_iterator2 (end2 ()); } BOOST_UBLAS_INLINE + const_reverse_iterator2 crbegin2 () const { + return rbegin2 (); + } + BOOST_UBLAS_INLINE const_reverse_iterator2 rend2 () const { return const_reverse_iterator2 (begin2 ()); } + BOOST_UBLAS_INLINE + const_reverse_iterator2 crend2 () const { + return rend2 (); + } BOOST_UBLAS_INLINE reverse_iterator2 rbegin2 () { @@ -2191,7 +3475,7 @@ namespace boost { namespace numeric { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size, bool preserve = true) { + void resize (size_type size, bool /*preserve*/ = true) { size1_ = size; size2_ = size; } @@ -2302,6 +3586,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator2 cbegin () const { + return begin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_iterator2 end () const { return const_iterator2 ((*this) ()); } @@ -2309,6 +3600,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator2 cend () const { + return end (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator2 rbegin () const { return const_reverse_iterator2 (end ()); } @@ -2316,9 +3614,23 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_reverse_iterator2 crbegin () const { + return rbegin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator2 rend () const { return const_reverse_iterator2 (begin ()); } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator2 crend () const { + return rend (); + } #endif // Indices @@ -2356,9 +3668,17 @@ namespace boost { namespace numeric { return const_iterator1 (*this); } BOOST_UBLAS_INLINE + const_iterator1 cbegin1 () const { + return begin1 (); + } + BOOST_UBLAS_INLINE const_iterator1 end1 () const { return const_iterator1 (*this); } + BOOST_UBLAS_INLINE + const_iterator1 cend1 () const { + return end1 (); + } class const_iterator2: public container_const_reference, @@ -2412,6 +3732,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator1 cbegin () const { + return begin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_iterator1 end () const { return const_iterator1 ((*this) ()); } @@ -2419,6 +3746,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator1 cend () const { + return end (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator1 rbegin () const { return const_reverse_iterator1 (end ()); } @@ -2426,9 +3760,23 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_reverse_iterator1 crbegin () const { + return rbegin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator1 rend () const { return const_reverse_iterator1 (begin ()); } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator1 crend () const { + return rend (); + } #endif // Indices @@ -2466,9 +3814,17 @@ namespace boost { namespace numeric { return find2 (0, 0, 0); } BOOST_UBLAS_INLINE + const_iterator2 cbegin2 () const { + return begin2 (); + } + BOOST_UBLAS_INLINE const_iterator2 end2 () const { return find2 (0, 0, size2_); } + BOOST_UBLAS_INLINE + const_iterator2 cend2 () const { + return end2 (); + } // Reverse iterators @@ -2477,18 +3833,34 @@ namespace boost { namespace numeric { return const_reverse_iterator1 (end1 ()); } BOOST_UBLAS_INLINE + const_reverse_iterator1 crbegin1 () const { + return rbegin1 (); + } + BOOST_UBLAS_INLINE const_reverse_iterator1 rend1 () const { return const_reverse_iterator1 (begin1 ()); } + BOOST_UBLAS_INLINE + const_reverse_iterator1 crend1 () const { + return rend1 (); + } BOOST_UBLAS_INLINE const_reverse_iterator2 rbegin2 () const { return const_reverse_iterator2 (end2 ()); } BOOST_UBLAS_INLINE + const_reverse_iterator2 crbegin2 () const { + return rbegin2 (); + } + BOOST_UBLAS_INLINE const_reverse_iterator2 rend2 () const { return const_reverse_iterator2 (begin2 ()); } + BOOST_UBLAS_INLINE + const_reverse_iterator2 crend2 () const { + return rend2 (); + } // Serialization template @@ -2578,7 +3950,7 @@ namespace boost { namespace numeric { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size, bool preserve = true) { + void resize (size_type size, bool /*preserve*/ = true) { size1_ = size; size2_ = size; size_common_ = ((std::min)(size1_, size2_)); @@ -2710,6 +4082,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator2 cbegin () const { + return begin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_iterator2 end () const { return const_iterator2 ((*this) (), it_ + 1); } @@ -2717,6 +4096,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator2 cend () const { + return end (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator2 rbegin () const { return const_reverse_iterator2 (end ()); } @@ -2724,9 +4110,23 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_reverse_iterator2 crbegin () const { + return rbegin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator2 rend () const { return const_reverse_iterator2 (begin ()); } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator2 crend () const { + return rend (); + } #endif // Indices @@ -2765,9 +4165,17 @@ namespace boost { namespace numeric { return const_iterator1 (*this, 0); } BOOST_UBLAS_INLINE + const_iterator1 cbegin1 () const { + return begin1 (); + } + BOOST_UBLAS_INLINE const_iterator1 end1 () const { return const_iterator1 (*this, size_common_); } + BOOST_UBLAS_INLINE + const_iterator1 cend1 () const { + return end1 (); + } class const_iterator2: public container_const_reference, @@ -2822,6 +4230,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator1 cbegin () const { + return begin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_iterator1 end () const { return const_iterator1 ((*this) (), it_ + 1); } @@ -2829,6 +4244,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator1 cend () const { + return end (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator1 rbegin () const { return const_reverse_iterator1 (end ()); } @@ -2836,9 +4258,23 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_reverse_iterator1 crbegin () const { + return rbegin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator1 rend () const { return const_reverse_iterator1 (begin ()); } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator1 crend () const { + return rend (); + } #endif // Indices @@ -2877,9 +4313,17 @@ namespace boost { namespace numeric { return const_iterator2 (*this, 0); } BOOST_UBLAS_INLINE + const_iterator2 cbegin2 () const { + return begin2 (); + } + BOOST_UBLAS_INLINE const_iterator2 end2 () const { return const_iterator2 (*this, size_common_); } + BOOST_UBLAS_INLINE + const_iterator2 cend2 () const { + return end2 (); + } // Reverse iterators @@ -2888,18 +4332,34 @@ namespace boost { namespace numeric { return const_reverse_iterator1 (end1 ()); } BOOST_UBLAS_INLINE + const_reverse_iterator1 crbegin1 () const { + return rbegin1 (); + } + BOOST_UBLAS_INLINE const_reverse_iterator1 rend1 () const { return const_reverse_iterator1 (begin1 ()); } + BOOST_UBLAS_INLINE + const_reverse_iterator1 crend1 () const { + return rend1 (); + } BOOST_UBLAS_INLINE const_reverse_iterator2 rbegin2 () const { return const_reverse_iterator2 (end2 ()); } BOOST_UBLAS_INLINE + const_reverse_iterator2 crbegin2 () const { + return rbegin2 (); + } + BOOST_UBLAS_INLINE const_reverse_iterator2 rend2 () const { return const_reverse_iterator2 (begin2 ()); } + BOOST_UBLAS_INLINE + const_reverse_iterator2 crend2 () const { + return rend2 (); + } // Serialization template @@ -3133,6 +4593,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator2 cbegin () const { + return begin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_iterator2 end () const { const scalar_matrix &m = (*this) (); return m.find2 (1, index1 (), m.size2 ()); @@ -3141,6 +4608,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator2 cend () const { + return end (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator2 rbegin () const { return const_reverse_iterator2 (end ()); } @@ -3148,9 +4622,23 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_reverse_iterator2 crbegin () const { + return rbegin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator2 rend () const { return const_reverse_iterator2 (begin ()); } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator2 crend () const { + return rend (); + } #endif // Indices @@ -3199,9 +4687,17 @@ namespace boost { namespace numeric { return find1 (0, 0, 0); } BOOST_UBLAS_INLINE + const_iterator1 cbegin1 () const { + return begin1 (); + } + BOOST_UBLAS_INLINE const_iterator1 end1 () const { return find1 (0, size1_, 0); } + BOOST_UBLAS_INLINE + const_iterator1 cend1 () const { + return end1 (); + } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator2: @@ -3278,6 +4774,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator1 cbegin () const { + return begin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_iterator1 end () const { const scalar_matrix &m = (*this) (); return m.find1 (1, m.size1 (), index2 ()); @@ -3286,6 +4789,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator1 cend () const { + return end (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator1 rbegin () const { return const_reverse_iterator1 (end ()); } @@ -3293,9 +4803,23 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_reverse_iterator1 crbegin () const { + return rbegin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator1 rend () const { return const_reverse_iterator1 (begin ()); } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator1 crend () const { + return rend (); + } #endif // Indices @@ -3344,9 +4868,17 @@ namespace boost { namespace numeric { return find2 (0, 0, 0); } BOOST_UBLAS_INLINE + const_iterator2 cbegin2 () const { + return begin2 (); + } + BOOST_UBLAS_INLINE const_iterator2 end2 () const { return find2 (0, 0, size2_); } + BOOST_UBLAS_INLINE + const_iterator2 cend2 () const { + return end2 (); + } // Reverse iterators @@ -3355,18 +4887,34 @@ namespace boost { namespace numeric { return const_reverse_iterator1 (end1 ()); } BOOST_UBLAS_INLINE + const_reverse_iterator1 crbegin1 () const { + return rbegin1 (); + } + BOOST_UBLAS_INLINE const_reverse_iterator1 rend1 () const { return const_reverse_iterator1 (begin1 ()); } + BOOST_UBLAS_INLINE + const_reverse_iterator1 crend1 () const { + return rend1 (); + } BOOST_UBLAS_INLINE const_reverse_iterator2 rbegin2 () const { return const_reverse_iterator2 (end2 ()); } BOOST_UBLAS_INLINE + const_reverse_iterator2 crbegin2 () const { + return rbegin2 (); + } + BOOST_UBLAS_INLINE const_reverse_iterator2 rend2 () const { return const_reverse_iterator2 (begin2 ()); } + BOOST_UBLAS_INLINE + const_reverse_iterator2 crend2 () const { + return rend2 (); + } // Serialization template @@ -3673,7 +5221,7 @@ namespace boost { namespace numeric { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find1 (int rank, size_type i, size_type j) const { + const_iterator1 find1 (int /*rank*/, size_type i, size_type j) const { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator1 (*this, i, j); #else @@ -3681,7 +5229,7 @@ namespace boost { namespace numeric { #endif } BOOST_UBLAS_INLINE - iterator1 find1 (int rank, size_type i, size_type j) { + iterator1 find1 (int /*rank*/, size_type i, size_type j) { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator1 (*this, i, j); #else @@ -3689,7 +5237,7 @@ namespace boost { namespace numeric { #endif } BOOST_UBLAS_INLINE - const_iterator2 find2 (int rank, size_type i, size_type j) const { + const_iterator2 find2 (int /*rank*/, size_type i, size_type j) const { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator2 (*this, i, j); #else @@ -3697,7 +5245,7 @@ namespace boost { namespace numeric { #endif } BOOST_UBLAS_INLINE - iterator2 find2 (int rank, size_type i, size_type j) { + iterator2 find2 (int /*rank*/, size_type i, size_type j) { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator2 (*this, i, j); #else @@ -3783,6 +5331,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator2 cbegin () const { + return begin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_iterator2 end () const { const self_type &m = (*this) (); return m.find2 (1, index1 (), m.size2 ()); @@ -3791,6 +5346,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator2 cend () const { + return end (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator2 rbegin () const { return const_reverse_iterator2 (end ()); } @@ -3798,9 +5360,23 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_reverse_iterator2 crbegin () const { + return rbegin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator2 rend () const { return const_reverse_iterator2 (begin ()); } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator2 crend () const { + return rend (); + } #endif // Indices @@ -3847,9 +5423,17 @@ namespace boost { namespace numeric { return find1 (0, 0, 0); } BOOST_UBLAS_INLINE + const_iterator1 cbegin1 () const { + return begin1 (); + } + BOOST_UBLAS_INLINE const_iterator1 end1 () const { return find1 (0, size1_, 0); } + BOOST_UBLAS_INLINE + const_iterator1 cend1 () const { + return end1 (); + } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class iterator1: @@ -4071,6 +5655,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator1 cbegin () const { + return begin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_iterator1 end () const { const self_type &m = (*this) (); return m.find1 (1, m.size1 (), index2 ()); @@ -4079,6 +5670,13 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_iterator1 cend () const { + return end (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator1 rbegin () const { return const_reverse_iterator1 (end ()); } @@ -4086,9 +5684,23 @@ namespace boost { namespace numeric { #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif + const_reverse_iterator1 crbegin () const { + return rbegin (); + } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif const_reverse_iterator1 rend () const { return const_reverse_iterator1 (begin ()); } + BOOST_UBLAS_INLINE +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION + typename self_type:: +#endif + const_reverse_iterator1 crend () const { + return rend (); + } #endif // Indices @@ -4135,9 +5747,17 @@ namespace boost { namespace numeric { return find2 (0, 0, 0); } BOOST_UBLAS_INLINE + const_iterator2 cbegin2 () const { + return begin2 (); + } + BOOST_UBLAS_INLINE const_iterator2 end2 () const { return find2 (0, 0, size2_); } + BOOST_UBLAS_INLINE + const_iterator2 cend2 () const { + return end2 (); + } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class iterator2: @@ -4288,9 +5908,17 @@ namespace boost { namespace numeric { return const_reverse_iterator1 (end1 ()); } BOOST_UBLAS_INLINE + const_reverse_iterator1 crbegin1 () const { + return rbegin1 (); + } + BOOST_UBLAS_INLINE const_reverse_iterator1 rend1 () const { return const_reverse_iterator1 (begin1 ()); } + BOOST_UBLAS_INLINE + const_reverse_iterator1 crend1 () const { + return rend1 (); + } BOOST_UBLAS_INLINE reverse_iterator1 rbegin1 () { @@ -4306,9 +5934,17 @@ namespace boost { namespace numeric { return const_reverse_iterator2 (end2 ()); } BOOST_UBLAS_INLINE + const_reverse_iterator2 crbegin2 () const { + return rbegin2 (); + } + BOOST_UBLAS_INLINE const_reverse_iterator2 rend2 () const { return const_reverse_iterator2 (begin2 ()); } + BOOST_UBLAS_INLINE + const_reverse_iterator2 crend2 () const { + return rend2 (); + } BOOST_UBLAS_INLINE reverse_iterator2 rbegin2 () {