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

begin.hpp

Go to the documentation of this file.
00001 
00017 #ifndef BOOST_NUMERIC_UBLAS_OPERATION_BEGIN_HPP
00018 #define BOOST_NUMERIC_UBLAS_OPERATION_BEGIN_HPP
00019 
00020 
00021 #include <boost/numeric/ublas/expression_types.hpp>
00022 #include <boost/numeric/ublas/fwd.hpp>
00023 #include <boost/numeric/ublas/traits/const_iterator_type.hpp>
00024 #include <boost/numeric/ublas/traits/iterator_type.hpp>
00025 
00026 
00027 namespace boost { namespace numeric { namespace ublas {
00028 
00029     namespace detail {
00030 
00037         template <typename CategoryT, typename TagT=void, typename OrientationT=void>
00038         struct begin_impl;
00039 
00040 
00042         template <>
00043         struct begin_impl<vector_tag,void,void>
00044         {
00052             template <typename ExprT>
00053             static typename ExprT::iterator apply(ExprT& e)
00054             {
00055                 return e.begin();
00056             }
00057 
00058 
00067             template <typename ExprT>
00068             static typename ExprT::const_iterator apply(ExprT const& e)
00069             {
00070                 return e.begin();
00071             }
00072         };
00073 
00074 
00077         template <>
00078         struct begin_impl<matrix_tag,tag::major,row_major_tag>
00079         {
00088             template <typename ExprT>
00089             static typename ExprT::iterator1 apply(ExprT& e)
00090             {
00091                 return e.begin1();
00092             }
00093 
00094 
00103             template <typename ExprT>
00104             static typename ExprT::const_iterator1 apply(ExprT const& e)
00105             {
00106                 return e.begin1();
00107             }
00108         };
00109 
00110 
00113         template <>
00114         struct begin_impl<matrix_tag,tag::major,column_major_tag>
00115         {
00124             template <typename ExprT>
00125             static typename ExprT::iterator2 apply(ExprT& e)
00126             {
00127                 return e.begin2();
00128             }
00129 
00130 
00139             template <typename ExprT>
00140             static typename ExprT::const_iterator2 apply(ExprT const& e)
00141             {
00142                 return e.begin2();
00143             }
00144         };
00145 
00146 
00149         template <>
00150         struct begin_impl<matrix_tag,tag::minor,row_major_tag>
00151         {
00160             template <typename ExprT>
00161             static typename ExprT::iterator2 apply(ExprT& e)
00162             {
00163                 return e.begin2();
00164             }
00165 
00166 
00175             template <typename ExprT>
00176             static typename ExprT::const_iterator2 apply(ExprT const& e)
00177             {
00178                 return e.begin2();
00179             }
00180         };
00181 
00182 
00183 
00186         template <>
00187         struct begin_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.begin1();
00201             }
00202 
00203 
00212             template <typename ExprT>
00213             static typename ExprT::const_iterator1 apply(ExprT const& e)
00214             {
00215                 return e.begin1();
00216             }
00217         };
00218 
00219     } // Namespace detail
00220 
00221 
00228     template <typename ExprT>
00229     BOOST_UBLAS_INLINE
00230     typename ExprT::iterator begin(vector_expression<ExprT>& e)
00231     {
00232         return detail::begin_impl<typename ExprT::type_category>::apply(e());
00233     }
00234 
00235 
00242     template <typename ExprT>
00243     BOOST_UBLAS_INLINE
00244     typename ExprT::const_iterator begin(vector_expression<ExprT> const& e)
00245     {
00246         return detail::begin_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 begin(matrix_expression<ExprT>& e)
00262     {
00263         return detail::begin_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 begin(matrix_expression<ExprT> const& e)
00279     {
00280         return detail::begin_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 begin(IteratorT& it)
00295     {
00296         return it.begin();
00297     }
00298 
00299 
00308     template <typename IteratorT>
00309     BOOST_UBLAS_INLINE
00310     typename IteratorT::dual_iterator_type begin(IteratorT const& it)
00311     {
00312         return it.begin();
00313     }
00314 
00315 }}} // Namespace boost::numeric::ublas
00316 
00317 
00318 #endif // BOOST_NUMERIC_UBLAS_OPERATION_BEGIN_HPP