|
||||
File indexing completed on 2025-01-18 09:43:01
0001 /** 0002 * -*- c++ -*- 0003 * 0004 * \file end.hpp 0005 * 0006 * \brief The \c end operation. 0007 * 0008 * Copyright (c) 2009, Marco Guazzone 0009 * 0010 * Distributed under the Boost Software License, Version 1.0. (See 0011 * accompanying file LICENSE_1_0.txt or copy at 0012 * http://www.boost.org/LICENSE_1_0.txt) 0013 * 0014 * \author Marco Guazzone, marco.guazzone@gmail.com 0015 */ 0016 0017 0018 #ifndef BOOST_NUMERIC_UBLAS_OPERATION_END_HPP 0019 #define BOOST_NUMERIC_UBLAS_OPERATION_END_HPP 0020 0021 0022 #include <boost/numeric/ublas/expression_types.hpp> 0023 #include <boost/numeric/ublas/fwd.hpp> 0024 #include <boost/numeric/ublas/traits/const_iterator_type.hpp> 0025 #include <boost/numeric/ublas/traits/iterator_type.hpp> 0026 0027 0028 namespace boost { namespace numeric { namespace ublas { 0029 0030 namespace detail { 0031 0032 /** 0033 * \brief Auxiliary class for implementing the \c end operation. 0034 * \tparam CategoryT The expression category type (e.g., vector_tag). 0035 * \tparam TagT The dimension type tag (e.g., tag::major). 0036 * \tparam OrientationT The orientation category type (e.g., row_major_tag). 0037 */ 0038 template <typename CategoryT, typename TagT=void, typename OrientationT=void> 0039 struct end_impl; 0040 0041 0042 /// \brief Specialization of \c end_impl for iterating vector expressions. 0043 template <> 0044 struct end_impl<vector_tag,void,void> 0045 { 0046 /** 0047 * \brief Return an iterator to the last element of the given vector 0048 * expression. 0049 * \tparam ExprT A model of VectorExpression type. 0050 * \param e A vector expression. 0051 * \return An iterator over the given vector expression. 0052 */ 0053 template <typename ExprT> 0054 static typename ExprT::iterator apply(ExprT& e) 0055 { 0056 return e.end(); 0057 } 0058 0059 0060 /** 0061 * \brief Return a const iterator to the last element of the given vector 0062 * expression. 0063 * \tparam ExprT A model of VectorExpression type. 0064 * \param e A vector expression. 0065 * \return A const iterator to the first element of the given vector 0066 * expression. 0067 */ 0068 template <typename ExprT> 0069 static typename ExprT::const_iterator apply(ExprT const& e) 0070 { 0071 return e.end(); 0072 } 0073 }; 0074 0075 0076 /// \brief Specialization of \c end_impl for iterating matrix expressions with a 0077 /// row-major orientation over the major dimension. 0078 template <> 0079 struct end_impl<matrix_tag,tag::major,row_major_tag> 0080 { 0081 /** 0082 * \brief Return an iterator to the last element of the given row-major 0083 * matrix expression over the major dimension. 0084 * \tparam ExprT A model of MatrixExpression type. 0085 * \param e A matrix expression. 0086 * \return An iterator over the major dimension of the given matrix 0087 * expression. 0088 */ 0089 template <typename ExprT> 0090 static typename ExprT::iterator1 apply(ExprT& e) 0091 { 0092 return e.end1(); 0093 } 0094 0095 0096 /** 0097 * \brief Return a const iterator to the last element of the given row-major 0098 * matrix expression over the major dimension. 0099 * \tparam ExprT A model of MatrixExpression type. 0100 * \param e A matrix expression. 0101 * \return A const iterator over the major dimension of the given matrix 0102 * expression. 0103 */ 0104 template <typename ExprT> 0105 static typename ExprT::const_iterator1 apply(ExprT const& e) 0106 { 0107 return e.end1(); 0108 } 0109 }; 0110 0111 0112 /// \brief Specialization of \c end_impl for iterating matrix expressions with a 0113 /// column-major orientation over the major dimension. 0114 template <> 0115 struct end_impl<matrix_tag,tag::major,column_major_tag> 0116 { 0117 /** 0118 * \brief Return an iterator to the last element of the given column-major 0119 * matrix expression over the major dimension. 0120 * \tparam ExprT A model of MatrixExpression type. 0121 * \param e A matrix expression. 0122 * \return An iterator over the major dimension of the given matrix 0123 * expression. 0124 */ 0125 template <typename ExprT> 0126 static typename ExprT::iterator2 apply(ExprT& e) 0127 { 0128 return e.end2(); 0129 } 0130 0131 0132 /** 0133 * \brief Return a const iterator to the last element of the given 0134 * column-major matrix expression over the major dimension. 0135 * \tparam ExprT A model of MatrixExpression type. 0136 * \param e A matrix expression. 0137 * \return A const iterator over the major dimension of the given matrix 0138 * expression. 0139 */ 0140 template <typename ExprT> 0141 static typename ExprT::const_iterator2 apply(ExprT const& e) 0142 { 0143 return e.end2(); 0144 } 0145 }; 0146 0147 0148 /// \brief Specialization of \c end_impl for iterating matrix expressions with a 0149 /// row-major orientation over the minor dimension. 0150 template <> 0151 struct end_impl<matrix_tag,tag::minor,row_major_tag> 0152 { 0153 /** 0154 * \brief Return an iterator to the last element of the given row-major 0155 * matrix expression over the minor dimension. 0156 * \tparam ExprT A model of MatrixExpression type. 0157 * \param e A matrix expression. 0158 * \return An iterator over the minor dimension of the given matrix 0159 * expression. 0160 */ 0161 template <typename ExprT> 0162 static typename ExprT::iterator2 apply(ExprT& e) 0163 { 0164 return e.end2(); 0165 } 0166 0167 0168 /** 0169 * \brief Return a const iterator to the last element of the given 0170 * row-minor matrix expression over the major dimension. 0171 * \tparam ExprT A model of MatrixExpression type. 0172 * \param e A matrix expression. 0173 * \return A const iterator over the minor dimension of the given matrix 0174 * expression. 0175 */ 0176 template <typename ExprT> 0177 static typename ExprT::const_iterator2 apply(ExprT const& e) 0178 { 0179 return e.end2(); 0180 } 0181 }; 0182 0183 0184 /// \brief Specialization of \c end_impl for iterating matrix expressions with a 0185 /// column-major orientation over the minor dimension. 0186 template <> 0187 struct end_impl<matrix_tag,tag::minor,column_major_tag> 0188 { 0189 /** 0190 * \brief Return an iterator to the last element of the given column-major 0191 * matrix expression over the minor dimension. 0192 * \tparam ExprT A model of MatrixExpression type. 0193 * \param e A matrix expression. 0194 * \return An iterator over the minor dimension of the given matrix 0195 * expression. 0196 */ 0197 template <typename ExprT> 0198 static typename ExprT::iterator1 apply(ExprT& e) 0199 { 0200 return e.end1(); 0201 } 0202 0203 0204 /** 0205 * \brief Return a const iterator to the last element of the given 0206 * column-minor matrix expression over the major dimension. 0207 * \tparam ExprT A model of MatrixExpression type. 0208 * \param e A matrix expression. 0209 * \return A const iterator over the minor dimension of the given matrix 0210 * expression. 0211 */ 0212 template <typename ExprT> 0213 static typename ExprT::const_iterator1 apply(ExprT const& e) 0214 { 0215 return e.end1(); 0216 } 0217 }; 0218 0219 } // Namespace detail 0220 0221 0222 /** 0223 * \brief An iterator to the last element of the given vector expression. 0224 * \tparam ExprT A model of VectorExpression type. 0225 * \param e A vector expression. 0226 * \return An iterator to the last element of the given vector expression. 0227 */ 0228 template <typename ExprT> 0229 BOOST_UBLAS_INLINE 0230 typename ExprT::iterator end(vector_expression<ExprT>& e) 0231 { 0232 return detail::end_impl<typename ExprT::type_category>::apply(e()); 0233 } 0234 0235 0236 /** 0237 * \brief A const iterator to the last element of the given vector expression. 0238 * \tparam ExprT A model of VectorExpression type. 0239 * \param e A vector expression. 0240 * \return A const iterator to the last element of the given vector expression. 0241 */ 0242 template <typename ExprT> 0243 BOOST_UBLAS_INLINE 0244 typename ExprT::const_iterator end(vector_expression<ExprT> const& e) 0245 { 0246 return detail::end_impl<typename ExprT::type_category>::apply(e()); 0247 } 0248 0249 0250 /** 0251 * \brief An iterator to the last element of the given matrix expression 0252 * according to its orientation. 0253 * \tparam DimTagT A dimension tag type (e.g., tag::major). 0254 * \tparam ExprT A model of MatrixExpression type. 0255 * \param e A matrix expression. 0256 * \return An iterator to the last element of the given matrix expression 0257 * according to its orientation. 0258 */ 0259 template <typename TagT, typename ExprT> 0260 BOOST_UBLAS_INLINE 0261 typename iterator_type<ExprT,TagT>::type end(matrix_expression<ExprT>& e) 0262 { 0263 return detail::end_impl<typename ExprT::type_category, TagT, typename ExprT::orientation_category>::apply(e()); 0264 } 0265 0266 0267 /** 0268 * \brief A const iterator to the last element of the given matrix expression 0269 * according to its orientation. 0270 * \tparam TagT A dimension tag type (e.g., tag::major). 0271 * \tparam ExprT A model of MatrixExpression type. 0272 * \param e A matrix expression. 0273 * \return A const iterator to the last element of the given matrix expression 0274 * according to its orientation. 0275 */ 0276 template <typename TagT, typename ExprT> 0277 BOOST_UBLAS_INLINE 0278 typename const_iterator_type<ExprT,TagT>::type end(matrix_expression<ExprT> const& e) 0279 { 0280 return detail::end_impl<typename ExprT::type_category, TagT, typename ExprT::orientation_category>::apply(e()); 0281 } 0282 0283 0284 /** 0285 * \brief An iterator to the last element over the dual dimension of the given 0286 * iterator. 0287 * \tparam IteratorT A model of Iterator type. 0288 * \param it An iterator. 0289 * \return An iterator to the last element over the dual dimension of the given 0290 * iterator. 0291 */ 0292 template <typename IteratorT> 0293 BOOST_UBLAS_INLINE 0294 typename IteratorT::dual_iterator_type end(IteratorT& it) 0295 { 0296 return it.end(); 0297 } 0298 0299 0300 /** 0301 * \brief A const iterator to the last element over the dual dimension of the 0302 * given iterator. 0303 * \tparam IteratorT A model of Iterator type. 0304 * \param it An iterator. 0305 * \return A const iterator to the last element over the dual dimension of the 0306 * given iterator. 0307 */ 0308 template <typename IteratorT> 0309 BOOST_UBLAS_INLINE 0310 typename IteratorT::dual_iterator_type end(IteratorT const& it) 0311 { 0312 return it.end(); 0313 } 0314 0315 }}} // Namespace boost::numeric::ublas 0316 0317 0318 #endif // BOOST_NUMERIC_UBLAS_OPERATION_END_HPP
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |