Boost.uBlas 1.49
Linear Algebra in C++: matrices, vectors and numeric algorithms

end.hpp

Go to the documentation of this file.
00001 
00018 #ifndef BOOST_NUMERIC_UBLAS_OPERATION_END_HPP
00019 #define BOOST_NUMERIC_UBLAS_OPERATION_END_HPP
00020 
00021 
00022 #include <boost/numeric/ublas/expression_types.hpp>
00023 #include <boost/numeric/ublas/fwd.hpp>
00024 #include <boost/numeric/ublas/traits/const_iterator_type.hpp>
00025 #include <boost/numeric/ublas/traits/iterator_type.hpp>
00026 
00027 
00028 namespace boost { namespace numeric { namespace ublas {
00029 
00030     namespace detail {
00031 
00038         template <typename CategoryT, typename TagT=void, typename OrientationT=void>
00039         struct end_impl;
00040 
00041 
00043         template <>
00044         struct end_impl<vector_tag,void,void>
00045         {
00053             template <typename ExprT>
00054             static typename ExprT::iterator apply(ExprT& e)
00055             {
00056                 return e.end();
00057             }
00058 
00059 
00068             template <typename ExprT>
00069             static typename ExprT::const_iterator apply(ExprT const& e)
00070             {
00071                 return e.end();
00072             }
00073         };
00074 
00075 
00078         template <>
00079         struct end_impl<matrix_tag,tag::major,row_major_tag>
00080         {
00089             template <typename ExprT>
00090             static typename ExprT::iterator1 apply(ExprT& e)
00091             {
00092                 return e.end1();
00093             }
00094 
00095 
00104             template <typename ExprT>
00105             static typename ExprT::const_iterator1 apply(ExprT const& e)
00106             {
00107                 return e.end1();
00108             }
00109         };
00110 
00111 
00114         template <>
00115         struct end_impl<matrix_tag,tag::major,column_major_tag>
00116         {
00125             template <typename ExprT>
00126             static typename ExprT::iterator2 apply(ExprT& e)
00127             {
00128                 return e.end2();
00129             }
00130 
00131 
00140             template <typename ExprT>
00141             static typename ExprT::const_iterator2 apply(ExprT const& e)
00142             {
00143                 return e.end2();
00144             }
00145         };
00146 
00147 
00150         template <>
00151         struct end_impl<matrix_tag,tag::minor,row_major_tag>
00152         {
00161             template <typename ExprT>
00162             static typename ExprT::iterator2 apply(ExprT& e)
00163             {
00164                 return e.end2();
00165             }
00166 
00167 
00176             template <typename ExprT>
00177             static typename ExprT::const_iterator2 apply(ExprT const& e)
00178             {
00179                 return e.end2();
00180             }
00181         };
00182 
00183 
00186         template <>
00187         struct end_impl<matrix_tag,tag::minor,column_major_tag>
00188         {
00197             template <typename ExprT>
00198             static typename ExprT::iterator1 apply(ExprT& e)
00199             {
00200                 return e.end1();
00201             }
00202 
00203 
00212             template <typename ExprT>
00213             static typename ExprT::const_iterator1 apply(ExprT const& e)
00214             {
00215                 return e.end1();
00216             }
00217         };
00218 
00219     } // Namespace detail
00220 
00221 
00228     template <typename ExprT>
00229     BOOST_UBLAS_INLINE
00230     typename ExprT::iterator end(vector_expression<ExprT>& e)
00231     {
00232         return detail::end_impl<typename ExprT::type_category>::apply(e());
00233     }
00234 
00235 
00242     template <typename ExprT>
00243     BOOST_UBLAS_INLINE
00244     typename ExprT::const_iterator end(vector_expression<ExprT> const& e)
00245     {
00246         return detail::end_impl<typename ExprT::type_category>::apply(e());
00247     }
00248 
00249 
00259     template <typename TagT, typename ExprT>
00260     BOOST_UBLAS_INLINE
00261     typename iterator_type<ExprT,TagT>::type end(matrix_expression<ExprT>& e)
00262     {
00263         return detail::end_impl<typename ExprT::type_category, TagT, typename ExprT::orientation_category>::apply(e());
00264     }
00265 
00266 
00276     template <typename TagT, typename ExprT>
00277     BOOST_UBLAS_INLINE
00278     typename const_iterator_type<ExprT,TagT>::type end(matrix_expression<ExprT> const& e)
00279     {
00280         return detail::end_impl<typename ExprT::type_category, TagT, typename ExprT::orientation_category>::apply(e());
00281     }
00282 
00283 
00292     template <typename IteratorT>
00293     BOOST_UBLAS_INLINE
00294     typename IteratorT::dual_iterator_type end(IteratorT& it)
00295     {
00296         return it.end();
00297     }
00298 
00299 
00308     template <typename IteratorT>
00309     BOOST_UBLAS_INLINE
00310     typename IteratorT::dual_iterator_type end(IteratorT const& it)
00311     {
00312         return it.end();
00313     }
00314 
00315 }}} // Namespace boost::numeric::ublas
00316 
00317 
00318 #endif // BOOST_NUMERIC_UBLAS_OPERATION_END_HPP