comparison DEPENDENCIES/generic/include/boost/numeric/ublas/vector.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
1 // 1 //
2 // Copyright (c) 2000-2010 2 // Copyright (c) 2000-2010
3 // Joerg Walter, Mathias Koch, David Bellot 3 // Joerg Walter, Mathias Koch, David Bellot
4 // Copyright (c) 2014, Athanasios Iliopoulos
4 // 5 //
5 // Distributed under the Boost Software License, Version 1.0. (See 6 // Distributed under the Boost Software License, Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at 7 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt) 8 // http://www.boost.org/LICENSE_1_0.txt)
8 // 9 //
14 /// \file vector.hpp Definition for the class vector and its derivative 15 /// \file vector.hpp Definition for the class vector and its derivative
15 16
16 #ifndef _BOOST_UBLAS_VECTOR_ 17 #ifndef _BOOST_UBLAS_VECTOR_
17 #define _BOOST_UBLAS_VECTOR_ 18 #define _BOOST_UBLAS_VECTOR_
18 19
20 #include <boost/config.hpp>
19 #include <boost/numeric/ublas/storage.hpp> 21 #include <boost/numeric/ublas/storage.hpp>
20 #include <boost/numeric/ublas/vector_expression.hpp> 22 #include <boost/numeric/ublas/vector_expression.hpp>
21 #include <boost/numeric/ublas/detail/vector_assign.hpp> 23 #include <boost/numeric/ublas/detail/vector_assign.hpp>
22 #include <boost/serialization/collection_size_type.hpp> 24 #include <boost/serialization/collection_size_type.hpp>
23 #include <boost/serialization/nvp.hpp> 25 #include <boost/serialization/nvp.hpp>
24 26
27 #ifdef BOOST_UBLAS_CPP_GE_2011
28 #include <array>
29 #include <initializer_list>
30 #if defined(BOOST_MSVC) // For std::forward in fixed_vector
31 #include <utility>
32 #endif
33 #endif
25 34
26 // Iterators based on ideas of Jeremy Siek 35 // Iterators based on ideas of Jeremy Siek
27 36
28 namespace boost { namespace numeric { namespace ublas { 37 namespace boost { namespace numeric { namespace ublas {
29 38
81 /// This type has the generic name \c array_typ within the vector definition. 90 /// This type has the generic name \c array_typ within the vector definition.
82 /// \param size initial size of the vector \bug this value is not used 91 /// \param size initial size of the vector \bug this value is not used
83 /// \param data container of type \c A 92 /// \param data container of type \c A
84 /// \todo remove this definition because \c size is not used 93 /// \todo remove this definition because \c size is not used
85 BOOST_UBLAS_INLINE 94 BOOST_UBLAS_INLINE
86 vector (size_type size, const array_type &data): 95 vector (size_type /*size*/, const array_type &data):
87 vector_container<self_type> (), 96 vector_container<self_type> (),
88 data_ (data) {} 97 data_ (data) {}
89 98
90 /// \brief Constructor of a vector by copying from another container 99 /// \brief Constructor of a vector by copying from another container
91 /// This type has the generic name \c array_typ within the vector definition. 100 /// This type has the generic name \c array_typ within the vector definition.
636 BOOST_UBLAS_INLINE 645 BOOST_UBLAS_INLINE
637 const_iterator begin () const { 646 const_iterator begin () const {
638 return find (0); 647 return find (0);
639 } 648 }
640 649
650 /// \brief return an iterator on the first element of the vector
651 BOOST_UBLAS_INLINE
652 const_iterator cbegin () const {
653 return begin ();
654 }
655
641 /// \brief return an iterator after the last element of the vector 656 /// \brief return an iterator after the last element of the vector
642 BOOST_UBLAS_INLINE 657 BOOST_UBLAS_INLINE
643 const_iterator end () const { 658 const_iterator end () const {
644 return find (data_.size ()); 659 return find (data_.size ());
645 } 660 }
661
662 /// \brief return an iterator after the last element of the vector
663 BOOST_UBLAS_INLINE
664 const_iterator cend () const {
665 return end ();
666 }
646 667
647 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR 668 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
648 class iterator: 669 class iterator:
649 public container_reference<vector>, 670 public container_reference<vector>,
650 public random_access_iterator_base<dense_random_access_iterator_tag, 671 public random_access_iterator_base<dense_random_access_iterator_tag,
756 BOOST_UBLAS_INLINE 777 BOOST_UBLAS_INLINE
757 const_reverse_iterator rbegin () const { 778 const_reverse_iterator rbegin () const {
758 return const_reverse_iterator (end ()); 779 return const_reverse_iterator (end ());
759 } 780 }
760 781
782 /// \brief Return a const reverse iterator before the first element of the reversed vector (i.e. end() of normal vector)
783 BOOST_UBLAS_INLINE
784 const_reverse_iterator crbegin () const {
785 return rbegin ();
786 }
787
761 /// \brief Return a const reverse iterator on the end of the reverse vector (i.e. first element of the normal vector) 788 /// \brief Return a const reverse iterator on the end of the reverse vector (i.e. first element of the normal vector)
762 BOOST_UBLAS_INLINE 789 BOOST_UBLAS_INLINE
763 const_reverse_iterator rend () const { 790 const_reverse_iterator rend () const {
764 return const_reverse_iterator (begin ()); 791 return const_reverse_iterator (begin ());
765 } 792 }
766 793
794 /// \brief Return a const reverse iterator on the end of the reverse vector (i.e. first element of the normal vector)
795 BOOST_UBLAS_INLINE
796 const_reverse_iterator crend () const {
797 return rend ();
798 }
799
767 /// \brief Return a const reverse iterator before the first element of the reversed vector (i.e. end() of normal vector) 800 /// \brief Return a const reverse iterator before the first element of the reversed vector (i.e. end() of normal vector)
768 BOOST_UBLAS_INLINE 801 BOOST_UBLAS_INLINE
769 reverse_iterator rbegin () { 802 reverse_iterator rbegin () {
770 return reverse_iterator (end ()); 803 return reverse_iterator (end ());
771 } 804 }
791 private: 824 private:
792 array_type data_; 825 array_type data_;
793 }; 826 };
794 827
795 828
829 #ifdef BOOST_UBLAS_CPP_GE_2011
830 /** \brief A dense vector of values of type \c T.
831 *
832 * For a \f$n\f$-dimensional vector \f$v\f$ and \f$0\leq i < n\f$ every element \f$v_i\f$ is mapped
833 * to the \f$i\f$-th element of the container. A storage type \c A can be specified which defaults to \c std::array.
834 * Elements are constructed by \c A, which need not initialise their value.
835 *
836 * \tparam T type of the objects stored in the vector (like int, double, complex,...)
837 * \tparam A The type of the storage array of the vector. Default is \c std::array<T>.
838 */
839 template<class T, std::size_t N, class A>
840 class fixed_vector:
841 public vector_container<fixed_vector<T, N, A> > {
842
843 typedef fixed_vector<T, N, A> self_type;
844 public:
845 #ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS
846 using vector_container<self_type>::operator ();
847 #endif
848
849 typedef typename A::size_type size_type;
850 typedef typename A::difference_type difference_type;
851 typedef T value_type;
852 typedef typename type_traits<T>::const_reference const_reference;
853 typedef T &reference;
854 typedef T *pointer;
855 typedef const T *const_pointer;
856 typedef A array_type;
857 typedef const vector_reference<const self_type> const_closure_type;
858 typedef vector_reference<self_type> closure_type;
859 typedef self_type vector_temporary_type;
860 typedef dense_tag storage_category;
861
862 // Construction and destruction
863
864 /// \brief Constructor of a fixed_vector
865 BOOST_UBLAS_INLINE
866 fixed_vector ():
867 vector_container<self_type> (),
868 data_ () {}
869
870 /// \brief Constructor of a fixed_vector by copying from another container
871 /// This type uses the generic name \c array_type within the vector definition.
872 /// \param data container of type \c A
873 BOOST_UBLAS_INLINE
874 fixed_vector (const array_type &data):
875 vector_container<self_type> (),
876 data_ (data) {}
877
878 /// \brief Constructor of a fixed_vector with a unique initial value
879 /// \param init value to assign to each element of the vector
880 BOOST_UBLAS_INLINE
881 fixed_vector (const value_type &init):
882 vector_container<self_type> (),
883 data_ () {
884 data_.fill( init );
885 }
886
887 /// \brief Copy-constructor of a fixed_vector
888 /// \param v is the fixed_vector to be duplicated
889 BOOST_UBLAS_INLINE
890 fixed_vector (const fixed_vector &v):
891 vector_container<self_type> (),
892 data_ (v.data_) {}
893
894 /// \brief Copy-constructor of a vector from a vector_expression
895 /// Depending on the vector_expression, this constructor can have the cost of the computations
896 /// of the expression (trivial to say it, but take it must be taken into account in your complexity calculations).
897 /// \param ae the vector_expression which values will be duplicated into the vector
898 template<class AE>
899 BOOST_UBLAS_INLINE
900 fixed_vector (const vector_expression<AE> &ae):
901 vector_container<self_type> (),
902 data_ ( ) {
903 vector_assign<scalar_assign> (*this, ae);
904 }
905
906 /// \brief Construct a fixed_vector from a list of values
907 /// This constructor enables initialization by using any of:
908 /// fixed_vector<double, 3> v = { 1, 2, 3 } or fixed_vector<double,3> v( {1, 2, 3} ) or fixed_vector<double,3> v( 1, 2, 3 )
909 #if defined(BOOST_MSVC)
910 // This may or may not work. Maybe use this for all instead only for MSVC
911 template <typename... U>
912 fixed_vector(U&&... values) :
913 vector_container<self_type> (),
914 data_{{ std::forward<U>(values)... }} {}
915 #else
916 template <typename... Types>
917 fixed_vector(value_type v0, Types... vrest) :
918 vector_container<self_type> (),
919 data_{ { v0, vrest... } } {}
920 #endif
921
922 // -----------------------
923 // Random Access Container
924 // -----------------------
925
926 /// \brief Return the maximum size of the data container.
927 /// Return the upper bound (maximum size) on the data container. Depending on the container, it can be bigger than the current size of the vector.
928 BOOST_UBLAS_INLINE
929 size_type max_size () const {
930 return data_.max_size ();
931 }
932
933 /// \brief Return true if the vector is empty (\c size==0)
934 /// \return \c true if empty, \c false otherwise
935 BOOST_UBLAS_INLINE
936 const bool &empty () const {
937 return data_.empty();
938 }
939
940 // ---------
941 // Accessors
942 // ---------
943
944 /// \brief Return the size of the vector
945 BOOST_UBLAS_INLINE
946 BOOST_CONSTEXPR size_type size () const{ // should have a const after C++14
947 return data_.size ();
948 }
949
950 // -----------------
951 // Storage accessors
952 // -----------------
953
954 /// \brief Return a \c const reference to the container. Useful to access data directly for specific type of container.
955 BOOST_UBLAS_INLINE
956 const array_type &data () const {
957 return data_;
958 }
959
960 /// \brief Return a reference to the container. Useful to speed-up write operations to the data in very specific case.
961 BOOST_UBLAS_INLINE
962 array_type &data () {
963 return data_;
964 }
965
966 // ---------------
967 // Element support
968 // ---------------
969
970 /// \brief Return a pointer to the element \f$i\f$
971 /// \param i index of the element
972 // XXX this semantic is not the one expected by the name of this method
973 BOOST_UBLAS_INLINE
974 pointer find_element (size_type i) {
975 return const_cast<pointer> (const_cast<const self_type&>(*this).find_element (i));
976 }
977
978 /// \brief Return a const pointer to the element \f$i\f$
979 /// \param i index of the element
980 // XXX this semantic is not the one expected by the name of this method
981 BOOST_UBLAS_INLINE
982 const_pointer find_element (size_type i) const {
983 BOOST_UBLAS_CHECK (i < data_.size(), bad_index() ); // Since std:array doesn't check for bounds
984 return & (data () [i]);
985 }
986
987 // --------------
988 // Element access
989 // --------------
990
991 /// \brief Return a const reference to the element \f$i\f$
992 /// Return a const reference to the element \f$i\f$. With some compilers, this notation will be faster than \c[i]
993 /// \param i index of the element
994 BOOST_UBLAS_INLINE
995 const_reference operator () (size_type i) const {
996 BOOST_UBLAS_CHECK (i < data_.size(), bad_index() );
997 return data () [i];
998 }
999
1000 /// \brief Return a reference to the element \f$i\f$
1001 /// Return a reference to the element \f$i\f$. With some compilers, this notation will be faster than \c[i]
1002 /// \param i index of the element
1003 BOOST_UBLAS_INLINE
1004 reference operator () (size_type i) {
1005 BOOST_UBLAS_CHECK (i < data_.size(), bad_index() );
1006 return data () [i];
1007 }
1008
1009 /// \brief Return a const reference to the element \f$i\f$
1010 /// \param i index of the element
1011 BOOST_UBLAS_INLINE
1012 const_reference operator [] (size_type i) const {
1013 BOOST_UBLAS_CHECK (i < data_.size(), bad_index() );
1014 return (*this) (i);
1015 }
1016
1017 /// \brief Return a reference to the element \f$i\f$
1018 /// \param i index of the element
1019 BOOST_UBLAS_INLINE
1020 reference operator [] (size_type i) {
1021 BOOST_UBLAS_CHECK (i < data_.size(), bad_index() );
1022 return (*this) (i);
1023 }
1024
1025 // ------------------
1026 // Element assignment
1027 // ------------------
1028
1029 /// \brief Set element \f$i\f$ to the value \c t
1030 /// \param i index of the element
1031 /// \param t reference to the value to be set
1032 // XXX semantic of this is to insert a new element and therefore size=size+1 ?
1033 BOOST_UBLAS_INLINE
1034 reference insert_element (size_type i, const_reference t) {
1035 BOOST_UBLAS_CHECK (i < data_.size(), bad_index ());
1036 return (data () [i] = t);
1037 }
1038
1039 /// \brief Set element \f$i\f$ to the \e zero value
1040 /// \param i index of the element
1041 BOOST_UBLAS_INLINE
1042 void erase_element (size_type i) {
1043 BOOST_UBLAS_CHECK (i < data_.size(), bad_index ());
1044 data () [i] = value_type/*zero*/();
1045 }
1046
1047 // -------
1048 // Zeroing
1049 // -------
1050
1051 /// \brief Clear the vector, i.e. set all values to the \c zero value.
1052 BOOST_UBLAS_INLINE
1053 void clear () {
1054 std::fill (data ().begin (), data ().end (), value_type/*zero*/());
1055 }
1056
1057 // Assignment
1058 #ifdef BOOST_UBLAS_MOVE_SEMANTICS
1059
1060 /// \brief Assign a full fixed_vector (\e RHS-vector) to the current fixed_vector (\e LHS-vector)
1061 /// \param v is the source vector
1062 /// \return a reference to a fixed_vector (i.e. the destination vector)
1063 /*! @note "pass by value" the key idea to enable move semantics */
1064 BOOST_UBLAS_INLINE
1065 fixed_vector &operator = (fixed_vector v) {
1066 assign_temporary(v);
1067 return *this;
1068 }
1069 #else
1070 /// \brief Assign a full fixed_vector (\e RHS-vector) to the current fixed_vector (\e LHS-vector)
1071 /// \param v is the source fixed_vector
1072 /// \return a reference to a fixed_vector (i.e. the destination vector)
1073 BOOST_UBLAS_INLINE
1074 fixed_vector &operator = (const fixed_vector &v) {
1075 data () = v.data ();
1076 return *this;
1077 }
1078 #endif
1079
1080 /// \brief Assign a full vector (\e RHS-vector) to the current fixed_vector (\e LHS-vector)
1081 /// Assign a full vector (\e RHS-vector) to the current fixed_vector (\e LHS-vector). This method does not create any temporary.
1082 /// \param v is the source vector container
1083 /// \return a reference to a vector (i.e. the destination vector)
1084 template<class C> // Container assignment without temporary
1085 BOOST_UBLAS_INLINE
1086 fixed_vector &operator = (const vector_container<C> &v) {
1087 assign (v);
1088 return *this;
1089 }
1090
1091 /// \brief Assign a full fixed_vector (\e RHS-vector) to the current fixed_vector (\e LHS-vector)
1092 /// \param v is the source fixed_vector
1093 /// \return a reference to a fixed_vector (i.e. the destination fixed_vector)
1094 BOOST_UBLAS_INLINE
1095 fixed_vector &assign_temporary (fixed_vector &v) {
1096 swap ( v );
1097 return *this;
1098 }
1099
1100 /// \brief Assign the result of a vector_expression to the fixed_vector
1101 /// Assign the result of a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression.
1102 /// \tparam AE is the type of the vector_expression
1103 /// \param ae is a const reference to the vector_expression
1104 /// \return a reference to the resulting fixed_vector
1105 template<class AE>
1106 BOOST_UBLAS_INLINE
1107 fixed_vector &operator = (const vector_expression<AE> &ae) {
1108 self_type temporary (ae);
1109 return assign_temporary (temporary);
1110 }
1111
1112 /// \brief Assign the result of a vector_expression to the fixed_vector
1113 /// Assign the result of a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression.
1114 /// \tparam AE is the type of the vector_expression
1115 /// \param ae is a const reference to the vector_expression
1116 /// \return a reference to the resulting fixed_vector
1117 template<class AE>
1118 BOOST_UBLAS_INLINE
1119 fixed_vector &assign (const vector_expression<AE> &ae) {
1120 vector_assign<scalar_assign> (*this, ae);
1121 return *this;
1122 }
1123
1124 // -------------------
1125 // Computed assignment
1126 // -------------------
1127
1128 /// \brief Assign the sum of the fixed_vector and a vector_expression to the fixed_vector
1129 /// Assign the sum of the fixed_vector and a vector_expression to the fixed_vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression.
1130 /// A temporary is created for the computations.
1131 /// \tparam AE is the type of the vector_expression
1132 /// \param ae is a const reference to the vector_expression
1133 /// \return a reference to the resulting fixed_vector
1134 template<class AE>
1135 BOOST_UBLAS_INLINE
1136 fixed_vector &operator += (const vector_expression<AE> &ae) {
1137 self_type temporary (*this + ae);
1138 return assign_temporary (temporary);
1139 }
1140
1141 /// \brief Assign the sum of the fixed_vector and a vector_expression to the fixed_vector
1142 /// Assign the sum of the fixed_vector and a vector_expression to the fixed_vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression.
1143 /// No temporary is created. Computations are done and stored directly into the resulting vector.
1144 /// \tparam AE is the type of the vector_expression
1145 /// \param ae is a const reference to the vector_expression
1146 /// \return a reference to the resulting vector
1147 template<class C> // Container assignment without temporary
1148 BOOST_UBLAS_INLINE
1149 fixed_vector &operator += (const vector_container<C> &v) {
1150 plus_assign (v);
1151 return *this;
1152 }
1153
1154 /// \brief Assign the sum of the fixed_vector and a vector_expression to the fixed_vector
1155 /// Assign the sum of the fixed_vector and a vector_expression to the fixed_vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression.
1156 /// No temporary is created. Computations are done and stored directly into the resulting fixed_vector.
1157 /// \tparam AE is the type of the vector_expression
1158 /// \param ae is a const reference to the vector_expression
1159 /// \return a reference to the resulting vector
1160 template<class AE>
1161 BOOST_UBLAS_INLINE
1162 fixed_vector &plus_assign (const vector_expression<AE> &ae) {
1163 vector_assign<scalar_plus_assign> (*this, ae);
1164 return *this;
1165 }
1166
1167 /// \brief Assign the difference of the fixed_vector and a vector_expression to the fixed_vector
1168 /// Assign the difference of the fixed_vector and a vector_expression to the fixed_vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression.
1169 /// A temporary is created for the computations.
1170 /// \tparam AE is the type of the vector_expression
1171 /// \param ae is a const reference to the vector_expression
1172 template<class AE>
1173 BOOST_UBLAS_INLINE
1174 fixed_vector &operator -= (const vector_expression<AE> &ae) {
1175 self_type temporary (*this - ae);
1176 return assign_temporary (temporary);
1177 }
1178
1179 /// \brief Assign the difference of the fixed_vector and a vector_expression to the fixed_vector
1180 /// Assign the difference of the fixed_vector and a vector_expression to the fixed_vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression.
1181 /// No temporary is created. Computations are done and stored directly into the resulting fixed_vector.
1182 /// \tparam AE is the type of the vector_expression
1183 /// \param ae is a const reference to the vector_expression
1184 /// \return a reference to the resulting vector
1185 template<class C> // Container assignment without temporary
1186 BOOST_UBLAS_INLINE
1187 fixed_vector &operator -= (const vector_container<C> &v) {
1188 minus_assign (v);
1189 return *this;
1190 }
1191
1192 /// \brief Assign the difference of the fixed_vector and a vector_expression to the fixed_vector
1193 /// Assign the difference of the fixed_vector and a vector_expression to the fixed_vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression.
1194 /// No temporary is created. Computations are done and stored directly into the resulting fixed_vector.
1195 /// \tparam AE is the type of the vector_expression
1196 /// \param ae is a const reference to the vector_expression
1197 /// \return a reference to the resulting fixed_vector
1198 template<class AE>
1199 BOOST_UBLAS_INLINE
1200 fixed_vector &minus_assign (const vector_expression<AE> &ae) {
1201 vector_assign<scalar_minus_assign> (*this, ae);
1202 return *this;
1203 }
1204
1205 /// \brief Assign the product of the fixed_vector and a scalar to the fixed_vector
1206 /// Assign the product of the fixed_vector and a scalar to the fixed_vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression.
1207 /// No temporary is created. Computations are done and stored directly into the resulting fixed_vector.
1208 /// \tparam AE is the type of the vector_expression
1209 /// \param at is a const reference to the scalar
1210 /// \return a reference to the resulting fixed_vector
1211 template<class AT>
1212 BOOST_UBLAS_INLINE
1213 fixed_vector &operator *= (const AT &at) {
1214 vector_assign_scalar<scalar_multiplies_assign> (*this, at);
1215 return *this;
1216 }
1217
1218 /// \brief Assign the division of the fixed_vector by a scalar to the fixed_vector
1219 /// Assign the division of the fixed_vector by a scalar to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression.
1220 /// No temporary is created. Computations are done and stored directly into the resulting vector.
1221 /// \tparam AE is the type of the vector_expression
1222 /// \param at is a const reference to the scalar
1223 /// \return a reference to the resulting fixed_vector
1224 template<class AT>
1225 BOOST_UBLAS_INLINE
1226 fixed_vector &operator /= (const AT &at) {
1227 vector_assign_scalar<scalar_divides_assign> (*this, at);
1228 return *this;
1229 }
1230
1231 // --------
1232 // Swapping
1233 // --------
1234
1235 /// \brief Swap the content of the fixed_vector with another vector
1236 /// \param v is the fixed_vector to be swapped with
1237 BOOST_UBLAS_INLINE
1238 void swap (fixed_vector &v) {
1239 if (this != &v) {
1240 data ().swap (v.data ());
1241 }
1242 }
1243
1244 /// \brief Swap the content of two fixed_vectors
1245 /// \param v1 is the first fixed_vector. It takes values from v2
1246 /// \param v2 is the second fixed_vector It takes values from v1
1247 BOOST_UBLAS_INLINE
1248 friend void swap (fixed_vector &v1, fixed_vector &v2) {
1249 v1.swap (v2);
1250 }
1251
1252 // Iterator types
1253 private:
1254 // Use the storage array iterator
1255 typedef typename A::const_iterator const_subiterator_type;
1256 typedef typename A::iterator subiterator_type;
1257
1258 public:
1259 #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
1260 typedef indexed_iterator<self_type, dense_random_access_iterator_tag> iterator;
1261 typedef indexed_const_iterator<self_type, dense_random_access_iterator_tag> const_iterator;
1262 #else
1263 class const_iterator;
1264 class iterator;
1265 #endif
1266
1267 // --------------
1268 // Element lookup
1269 // --------------
1270
1271 /// \brief Return a const iterator to the element \e i
1272 /// \param i index of the element
1273 BOOST_UBLAS_INLINE
1274 const_iterator find (size_type i) const {
1275 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
1276 return const_iterator (*this, data ().begin () + i);
1277 #else
1278 return const_iterator (*this, i);
1279 #endif
1280 }
1281
1282 /// \brief Return an iterator to the element \e i
1283 /// \param i index of the element
1284 BOOST_UBLAS_INLINE
1285 iterator find (size_type i) {
1286 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
1287 return iterator (*this, data ().begin () + i);
1288 #else
1289 return iterator (*this, i);
1290 #endif
1291 }
1292
1293 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
1294 class const_iterator:
1295 public container_const_reference<fixed_vector>,
1296 public random_access_iterator_base<dense_random_access_iterator_tag,
1297 const_iterator, value_type, difference_type> {
1298 public:
1299 typedef typename fixed_vector::difference_type difference_type;
1300 typedef typename fixed_vector::value_type value_type;
1301 typedef typename fixed_vector::const_reference reference;
1302 typedef const typename fixed_vector::pointer pointer;
1303
1304 // ----------------------------
1305 // Construction and destruction
1306 // ----------------------------
1307
1308
1309 BOOST_UBLAS_INLINE
1310 const_iterator ():
1311 container_const_reference<self_type> (), it_ () {}
1312 BOOST_UBLAS_INLINE
1313 const_iterator (const self_type &v, const const_subiterator_type &it):
1314 container_const_reference<self_type> (v), it_ (it) {}
1315 BOOST_UBLAS_INLINE
1316 const_iterator (const typename self_type::iterator &it): // ISSUE vector:: stops VC8 using std::iterator here
1317 container_const_reference<self_type> (it ()), it_ (it.it_) {}
1318
1319 // ----------
1320 // Arithmetic
1321 // ----------
1322
1323 /// \brief Increment by 1 the position of the iterator
1324 /// \return a reference to the const iterator
1325 BOOST_UBLAS_INLINE
1326 const_iterator &operator ++ () {
1327 ++ it_;
1328 return *this;
1329 }
1330
1331 /// \brief Decrement by 1 the position of the iterator
1332 /// \return a reference to the const iterator
1333 BOOST_UBLAS_INLINE
1334 const_iterator &operator -- () {
1335 -- it_;
1336 return *this;
1337 }
1338
1339 /// \brief Increment by \e n the position of the iterator
1340 /// \return a reference to the const iterator
1341 BOOST_UBLAS_INLINE
1342 const_iterator &operator += (difference_type n) {
1343 it_ += n;
1344 return *this;
1345 }
1346
1347 /// \brief Decrement by \e n the position of the iterator
1348 /// \return a reference to the const iterator
1349 BOOST_UBLAS_INLINE
1350 const_iterator &operator -= (difference_type n) {
1351 it_ -= n;
1352 return *this;
1353 }
1354
1355 /// \brief Return the different in number of positions between 2 iterators
1356 BOOST_UBLAS_INLINE
1357 difference_type operator - (const const_iterator &it) const {
1358 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
1359 return it_ - it.it_;
1360 }
1361
1362 /// \brief Dereference an iterator
1363 /// Dereference an iterator: a bounds' check is done before returning the value. A bad_index() expection is returned if out of bounds.
1364 /// \return a const reference to the value pointed by the iterator
1365 BOOST_UBLAS_INLINE
1366 const_reference operator * () const {
1367 BOOST_UBLAS_CHECK (it_ >= (*this) ().begin ().it_ && it_ < (*this) ().end ().it_, bad_index ());
1368 return *it_;
1369 }
1370
1371 /// \brief Dereference an iterator at the n-th forward value
1372 /// Dereference an iterator at the n-th forward value, that is the value pointed by iterator+n.
1373 /// A bounds' check is done before returning the value. A bad_index() expection is returned if out of bounds.
1374 /// \return a const reference
1375 BOOST_UBLAS_INLINE
1376 const_reference operator [] (difference_type n) const {
1377 return *(it_ + n);
1378 }
1379
1380 // Index
1381 /// \brief return the index of the element referenced by the iterator
1382 BOOST_UBLAS_INLINE
1383 size_type index () const {
1384 BOOST_UBLAS_CHECK (it_ >= (*this) ().begin ().it_ && it_ < (*this) ().end ().it_, bad_index ());
1385 return it_ - (*this) ().begin ().it_;
1386 }
1387
1388 // Assignment
1389 BOOST_UBLAS_INLINE
1390 /// \brief assign the value of an iterator to the iterator
1391 const_iterator &operator = (const const_iterator &it) {
1392 container_const_reference<self_type>::assign (&it ());
1393 it_ = it.it_;
1394 return *this;
1395 }
1396
1397 // Comparison
1398 /// \brief compare the value of two itetarors
1399 /// \return true if they reference the same element
1400 BOOST_UBLAS_INLINE
1401 bool operator == (const const_iterator &it) const {
1402 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
1403 return it_ == it.it_;
1404 }
1405
1406
1407 /// \brief compare the value of two iterators
1408 /// \return return true if the left-hand-side iterator refers to a value placed before the right-hand-side iterator
1409 BOOST_UBLAS_INLINE
1410 bool operator < (const const_iterator &it) const {
1411 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
1412 return it_ < it.it_;
1413 }
1414
1415 private:
1416 const_subiterator_type it_;
1417
1418 friend class iterator;
1419 };
1420 #endif
1421
1422 /// \brief return an iterator on the first element of the fixed_vector
1423 BOOST_UBLAS_INLINE
1424 const_iterator begin () const {
1425 return find (0);
1426 }
1427
1428 /// \brief return an iterator on the first element of the fixed_vector
1429 BOOST_UBLAS_INLINE
1430 const_iterator cbegin () const {
1431 return begin ();
1432 }
1433
1434 /// \brief return an iterator after the last element of the fixed_vector
1435 BOOST_UBLAS_INLINE
1436 const_iterator end () const {
1437 return find (data_.size ());
1438 }
1439
1440 /// \brief return an iterator after the last element of the fixed_vector
1441 BOOST_UBLAS_INLINE
1442 const_iterator cend () const {
1443 return end ();
1444 }
1445
1446 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
1447 class iterator:
1448 public container_reference<fixed_vector>,
1449 public random_access_iterator_base<dense_random_access_iterator_tag,
1450 iterator, value_type, difference_type> {
1451 public:
1452 typedef typename fixed_vector::difference_type difference_type;
1453 typedef typename fixed_vector::value_type value_type;
1454 typedef typename fixed_vector::reference reference;
1455 typedef typename fixed_vector::pointer pointer;
1456
1457
1458 // Construction and destruction
1459 BOOST_UBLAS_INLINE
1460 iterator ():
1461 container_reference<self_type> (), it_ () {}
1462 BOOST_UBLAS_INLINE
1463 iterator (self_type &v, const subiterator_type &it):
1464 container_reference<self_type> (v), it_ (it) {}
1465
1466 // Arithmetic
1467 BOOST_UBLAS_INLINE
1468 iterator &operator ++ () {
1469 ++ it_;
1470 return *this;
1471 }
1472 BOOST_UBLAS_INLINE
1473 iterator &operator -- () {
1474 -- it_;
1475 return *this;
1476 }
1477 BOOST_UBLAS_INLINE
1478 iterator &operator += (difference_type n) {
1479 it_ += n;
1480 return *this;
1481 }
1482 BOOST_UBLAS_INLINE
1483 iterator &operator -= (difference_type n) {
1484 it_ -= n;
1485 return *this;
1486 }
1487 BOOST_UBLAS_INLINE
1488 difference_type operator - (const iterator &it) const {
1489 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
1490 return it_ - it.it_;
1491 }
1492
1493 // Dereference
1494 BOOST_UBLAS_INLINE
1495 reference operator * () const {
1496 BOOST_UBLAS_CHECK (it_ >= (*this) ().begin ().it_ && it_ < (*this) ().end ().it_ , bad_index ());
1497 return *it_;
1498 }
1499 BOOST_UBLAS_INLINE
1500 reference operator [] (difference_type n) const {
1501 return *(it_ + n);
1502 }
1503
1504 // Index
1505 BOOST_UBLAS_INLINE
1506 size_type index () const {
1507 BOOST_UBLAS_CHECK (it_ >= (*this) ().begin ().it_ && it_ < (*this) ().end ().it_ , bad_index ());
1508 return it_ - (*this) ().begin ().it_;
1509 }
1510
1511 // Assignment
1512 BOOST_UBLAS_INLINE
1513 iterator &operator = (const iterator &it) {
1514 container_reference<self_type>::assign (&it ());
1515 it_ = it.it_;
1516 return *this;
1517 }
1518
1519 // Comparison
1520 BOOST_UBLAS_INLINE
1521 bool operator == (const iterator &it) const {
1522 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
1523 return it_ == it.it_;
1524 }
1525 BOOST_UBLAS_INLINE
1526 bool operator < (const iterator &it) const {
1527 BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
1528 return it_ < it.it_;
1529 }
1530
1531 private:
1532 subiterator_type it_;
1533
1534 friend class const_iterator;
1535 };
1536 #endif
1537
1538 /// \brief Return an iterator on the first element of the fixed_vector
1539 BOOST_UBLAS_INLINE
1540 iterator begin () {
1541 return find (0);
1542 }
1543
1544 /// \brief Return an iterator at the end of the fixed_vector
1545 BOOST_UBLAS_INLINE
1546 iterator end () {
1547 return find (data_.size ());
1548 }
1549
1550 // Reverse iterator
1551 typedef reverse_iterator_base<const_iterator> const_reverse_iterator;
1552 typedef reverse_iterator_base<iterator> reverse_iterator;
1553
1554 /// \brief Return a const reverse iterator before the first element of the reversed fixed_vector (i.e. end() of normal fixed_vector)
1555 BOOST_UBLAS_INLINE
1556 const_reverse_iterator rbegin () const {
1557 return const_reverse_iterator (end ());
1558 }
1559
1560 /// \brief Return a const reverse iterator before the first element of the reversed fixed_vector (i.e. end() of normal fixed_vector)
1561 BOOST_UBLAS_INLINE
1562 const_reverse_iterator crbegin () const {
1563 return rbegin ();
1564 }
1565
1566 /// \brief Return a const reverse iterator on the end of the reverse fixed_vector (i.e. first element of the normal fixed_vector)
1567 BOOST_UBLAS_INLINE
1568 const_reverse_iterator rend () const {
1569 return const_reverse_iterator (begin ());
1570 }
1571
1572 /// \brief Return a const reverse iterator on the end of the reverse fixed_vector (i.e. first element of the normal fixed_vector)
1573 BOOST_UBLAS_INLINE
1574 const_reverse_iterator crend () const {
1575 return rend ();
1576 }
1577
1578 /// \brief Return a const reverse iterator before the first element of the reversed fixed_vector (i.e. end() of normal fixed_vector)
1579 BOOST_UBLAS_INLINE
1580 reverse_iterator rbegin () {
1581 return reverse_iterator (end ());
1582 }
1583
1584 /// \brief Return a const reverse iterator on the end of the reverse fixed_vector (i.e. first element of the normal fixed_vector)
1585 BOOST_UBLAS_INLINE
1586 reverse_iterator rend () {
1587 return reverse_iterator (begin ());
1588 }
1589
1590 // -------------
1591 // Serialization
1592 // -------------
1593
1594 /// Serialize a fixed_vector into and archive as defined in Boost
1595 /// \param ar Archive object. Can be a flat file, an XML file or any other stream
1596 /// \param file_version Optional file version (not yet used)
1597 template<class Archive>
1598 void serialize(Archive & ar, const unsigned int /* file_version */){
1599 ar & serialization::make_nvp("data",data_);
1600 }
1601
1602 private:
1603 array_type data_;
1604 };
1605
1606 #endif // BOOST_UBLAS_CPP_GE_2011
1607
796 // -------------------- 1608 // --------------------
797 // Bounded vector class 1609 // Bounded vector class
798 // -------------------- 1610 // --------------------
799 1611
800 /// \brief a dense vector of values of type \c T, of variable size but with maximum \f$N\f$. 1612 /// \brief a dense vector of values of type \c T, of variable size but with maximum \f$N\f$.
863 bounded_vector &operator = (const vector_expression<AE> &ae) { 1675 bounded_vector &operator = (const vector_expression<AE> &ae) {
864 vector_type::operator = (ae); 1676 vector_type::operator = (ae);
865 return *this; 1677 return *this;
866 } 1678 }
867 }; 1679 };
1680
868 1681
869 1682
870 // ----------------- 1683 // -----------------
871 // Zero vector class 1684 // Zero vector class
872 // ----------------- 1685 // -----------------
920 size_ = size; 1733 size_ = size;
921 } 1734 }
922 1735
923 // Element support 1736 // Element support
924 BOOST_UBLAS_INLINE 1737 BOOST_UBLAS_INLINE
925 const_pointer find_element (size_type i) const { 1738 const_pointer find_element (size_type /*i*/) const {
926 return & zero_; 1739 return & zero_;
927 } 1740 }
928 1741
929 // Element access 1742 // Element access
930 BOOST_UBLAS_INLINE 1743 BOOST_UBLAS_INLINE
1035 1848
1036 BOOST_UBLAS_INLINE 1849 BOOST_UBLAS_INLINE
1037 const_iterator begin () const { 1850 const_iterator begin () const {
1038 return const_iterator (*this); 1851 return const_iterator (*this);
1039 } 1852 }
1853 BOOST_UBLAS_INLINE
1854 const_iterator cbegin () const {
1855 return begin ();
1856 }
1040 BOOST_UBLAS_INLINE 1857 BOOST_UBLAS_INLINE
1041 const_iterator end () const { 1858 const_iterator end () const {
1042 return const_iterator (*this); 1859 return const_iterator (*this);
1043 } 1860 }
1861 BOOST_UBLAS_INLINE
1862 const_iterator cend () const {
1863 return end ();
1864 }
1044 1865
1045 // Reverse iterator 1866 // Reverse iterator
1046 typedef reverse_iterator_base<const_iterator> const_reverse_iterator; 1867 typedef reverse_iterator_base<const_iterator> const_reverse_iterator;
1047 1868
1048 BOOST_UBLAS_INLINE 1869 BOOST_UBLAS_INLINE
1049 const_reverse_iterator rbegin () const { 1870 const_reverse_iterator rbegin () const {
1050 return const_reverse_iterator (end ()); 1871 return const_reverse_iterator (end ());
1051 } 1872 }
1873 BOOST_UBLAS_INLINE
1874 const_reverse_iterator crbegin () const {
1875 return rbegin ();
1876 }
1052 BOOST_UBLAS_INLINE 1877 BOOST_UBLAS_INLINE
1053 const_reverse_iterator rend () const { 1878 const_reverse_iterator rend () const {
1054 return const_reverse_iterator (begin ()); 1879 return const_reverse_iterator (begin ());
1055 } 1880 }
1881 BOOST_UBLAS_INLINE
1882 const_reverse_iterator crend () const {
1883 return rend ();
1884 }
1056 1885
1057 // Serialization 1886 // Serialization
1058 template<class Archive> 1887 template<class Archive>
1059 void serialize(Archive & ar, const unsigned int /* file_version */){ 1888 void serialize(Archive & ar, const unsigned int /* file_version */){
1060 serialization::collection_size_type s (size_); 1889 serialization::collection_size_type s (size_);
1279 2108
1280 BOOST_UBLAS_INLINE 2109 BOOST_UBLAS_INLINE
1281 const_iterator begin () const { 2110 const_iterator begin () const {
1282 return const_iterator (*this, true); 2111 return const_iterator (*this, true);
1283 } 2112 }
2113 BOOST_UBLAS_INLINE
2114 const_iterator cbegin () const {
2115 return begin ();
2116 }
1284 BOOST_UBLAS_INLINE 2117 BOOST_UBLAS_INLINE
1285 const_iterator end () const { 2118 const_iterator end () const {
1286 return const_iterator (*this, false); 2119 return const_iterator (*this, false);
1287 } 2120 }
2121 BOOST_UBLAS_INLINE
2122 const_iterator cend () const {
2123 return end ();
2124 }
1288 2125
1289 // Reverse iterator 2126 // Reverse iterator
1290 typedef reverse_iterator_base<const_iterator> const_reverse_iterator; 2127 typedef reverse_iterator_base<const_iterator> const_reverse_iterator;
1291 2128
1292 BOOST_UBLAS_INLINE 2129 BOOST_UBLAS_INLINE
1293 const_reverse_iterator rbegin () const { 2130 const_reverse_iterator rbegin () const {
1294 return const_reverse_iterator (end ()); 2131 return const_reverse_iterator (end ());
1295 } 2132 }
2133 BOOST_UBLAS_INLINE
2134 const_reverse_iterator crbegin () const {
2135 return rbegin ();
2136 }
1296 BOOST_UBLAS_INLINE 2137 BOOST_UBLAS_INLINE
1297 const_reverse_iterator rend () const { 2138 const_reverse_iterator rend () const {
1298 return const_reverse_iterator (begin ()); 2139 return const_reverse_iterator (begin ());
1299 } 2140 }
2141 BOOST_UBLAS_INLINE
2142 const_reverse_iterator crend () const {
2143 return rend ();
2144 }
1300 2145
1301 // Serialization 2146 // Serialization
1302 template<class Archive> 2147 template<class Archive>
1303 void serialize(Archive & ar, const unsigned int /* file_version */){ 2148 void serialize(Archive & ar, const unsigned int /* file_version */){
1304 serialization::collection_size_type s (size_); 2149 serialization::collection_size_type s (size_);
1527 2372
1528 BOOST_UBLAS_INLINE 2373 BOOST_UBLAS_INLINE
1529 const_iterator begin () const { 2374 const_iterator begin () const {
1530 return find (0); 2375 return find (0);
1531 } 2376 }
2377 BOOST_UBLAS_INLINE
2378 const_iterator cbegin () const {
2379 return begin ();
2380 }
1532 BOOST_UBLAS_INLINE 2381 BOOST_UBLAS_INLINE
1533 const_iterator end () const { 2382 const_iterator end () const {
1534 return find (size_); 2383 return find (size_);
1535 } 2384 }
2385 BOOST_UBLAS_INLINE
2386 const_iterator cend () const {
2387 return end ();
2388 }
1536 2389
1537 // Reverse iterator 2390 // Reverse iterator
1538 typedef reverse_iterator_base<const_iterator> const_reverse_iterator; 2391 typedef reverse_iterator_base<const_iterator> const_reverse_iterator;
1539 2392
1540 BOOST_UBLAS_INLINE 2393 BOOST_UBLAS_INLINE
1541 const_reverse_iterator rbegin () const { 2394 const_reverse_iterator rbegin () const {
1542 return const_reverse_iterator (end ()); 2395 return const_reverse_iterator (end ());
1543 } 2396 }
2397 BOOST_UBLAS_INLINE
2398 const_reverse_iterator crbegin () const {
2399 return rbegin ();
2400 }
1544 BOOST_UBLAS_INLINE 2401 BOOST_UBLAS_INLINE
1545 const_reverse_iterator rend () const { 2402 const_reverse_iterator rend () const {
1546 return const_reverse_iterator (begin ()); 2403 return const_reverse_iterator (begin ());
1547 } 2404 }
2405 BOOST_UBLAS_INLINE
2406 const_reverse_iterator crend () const {
2407 return rend ();
2408 }
1548 2409
1549 // Serialization 2410 // Serialization
1550 template<class Archive> 2411 template<class Archive>
1551 void serialize(Archive & ar, const unsigned int /* file_version */){ 2412 void serialize(Archive & ar, const unsigned int /* file_version */){
1552 serialization::collection_size_type s (size_); 2413 serialization::collection_size_type s (size_);
1595 size_ (N) /* , data_ () */ {} 2456 size_ (N) /* , data_ () */ {}
1596 explicit BOOST_UBLAS_INLINE 2457 explicit BOOST_UBLAS_INLINE
1597 c_vector (size_type size): 2458 c_vector (size_type size):
1598 size_ (size) /* , data_ () */ { 2459 size_ (size) /* , data_ () */ {
1599 if (size_ > N) 2460 if (size_ > N)
1600 bad_size ().raise (); 2461 bad_size ().raise ();
1601 } 2462 }
1602 BOOST_UBLAS_INLINE 2463 BOOST_UBLAS_INLINE
1603 c_vector (const c_vector &v): 2464 c_vector (const c_vector &v):
1604 size_ (v.size_) /* , data_ () */ { 2465 size_ (v.size_) /* , data_ () */ {
1605 if (size_ > N) 2466 if (size_ > N)
1606 bad_size ().raise (); 2467 bad_size ().raise ();
1607 assign(v); 2468 assign(v);
1608 } 2469 }
1609 template<class AE> 2470 template<class AE>
1610 BOOST_UBLAS_INLINE 2471 BOOST_UBLAS_INLINE
1611 c_vector (const vector_expression<AE> &ae): 2472 c_vector (const vector_expression<AE> &ae):
1612 size_ (ae ().size ()) /* , data_ () */ { 2473 size_ (ae ().size ()) /* , data_ () */ {
1613 if (size_ > N) 2474 if (size_ > N)
1614 bad_size ().raise (); 2475 bad_size ().raise ();
1615 vector_assign<scalar_assign> (*this, ae); 2476 vector_assign<scalar_assign> (*this, ae);
1616 } 2477 }
1617 2478
1618 // Accessors 2479 // Accessors
1619 BOOST_UBLAS_INLINE 2480 BOOST_UBLAS_INLINE
1629 return data_; 2490 return data_;
1630 } 2491 }
1631 2492
1632 // Resizing 2493 // Resizing
1633 BOOST_UBLAS_INLINE 2494 BOOST_UBLAS_INLINE
1634 void resize (size_type size, bool preserve = true) { 2495 void resize (size_type size, bool /*preserve*/ = true) {
1635 if (size > N) 2496 if (size > N)
1636 bad_size ().raise (); 2497 bad_size ().raise ();
1637 size_ = size; 2498 size_ = size;
1638 } 2499 }
1639 2500
1640 // Element support 2501 // Element support
1641 BOOST_UBLAS_INLINE 2502 BOOST_UBLAS_INLINE
1780 2641
1781 // Swapping 2642 // Swapping
1782 BOOST_UBLAS_INLINE 2643 BOOST_UBLAS_INLINE
1783 void swap (c_vector &v) { 2644 void swap (c_vector &v) {
1784 if (this != &v) { 2645 if (this != &v) {
1785 BOOST_UBLAS_CHECK (size_ == v.size_, bad_size ()); 2646 BOOST_UBLAS_CHECK (size_ == v.size_, bad_size ());
1786 std::swap (size_, v.size_); 2647 std::swap (size_, v.size_);
1787 std::swap_ranges (data_, data_ + size_, v.data_); 2648 std::swap_ranges (data_, data_ + size_, v.data_);
1788 } 2649 }
1789 } 2650 }
1790 BOOST_UBLAS_INLINE 2651 BOOST_UBLAS_INLINE
1922 2783
1923 BOOST_UBLAS_INLINE 2784 BOOST_UBLAS_INLINE
1924 const_iterator begin () const { 2785 const_iterator begin () const {
1925 return find (0); 2786 return find (0);
1926 } 2787 }
2788 BOOST_UBLAS_INLINE
2789 const_iterator cbegin () const {
2790 return begin ();
2791 }
1927 BOOST_UBLAS_INLINE 2792 BOOST_UBLAS_INLINE
1928 const_iterator end () const { 2793 const_iterator end () const {
1929 return find (size_); 2794 return find (size_);
1930 } 2795 }
2796 BOOST_UBLAS_INLINE
2797 const_iterator cend () const {
2798 return end ();
2799 }
1931 2800
1932 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR 2801 #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR
1933 class iterator: 2802 class iterator:
1934 public container_reference<c_vector>, 2803 public container_reference<c_vector>,
1935 public random_access_iterator_base<dense_random_access_iterator_tag, 2804 public random_access_iterator_base<dense_random_access_iterator_tag,
2037 2906
2038 BOOST_UBLAS_INLINE 2907 BOOST_UBLAS_INLINE
2039 const_reverse_iterator rbegin () const { 2908 const_reverse_iterator rbegin () const {
2040 return const_reverse_iterator (end ()); 2909 return const_reverse_iterator (end ());
2041 } 2910 }
2911 BOOST_UBLAS_INLINE
2912 const_reverse_iterator crbegin () const {
2913 return rbegin ();
2914 }
2042 BOOST_UBLAS_INLINE 2915 BOOST_UBLAS_INLINE
2043 const_reverse_iterator rend () const { 2916 const_reverse_iterator rend () const {
2044 return const_reverse_iterator (begin ()); 2917 return const_reverse_iterator (begin ());
2045 } 2918 }
2919 BOOST_UBLAS_INLINE
2920 const_reverse_iterator crend () const {
2921 return rend ();
2922 }
2046 BOOST_UBLAS_INLINE 2923 BOOST_UBLAS_INLINE
2047 reverse_iterator rbegin () { 2924 reverse_iterator rbegin () {
2048 return reverse_iterator (end ()); 2925 return reverse_iterator (end ());
2049 } 2926 }
2050 BOOST_UBLAS_INLINE 2927 BOOST_UBLAS_INLINE