ublas_ordering.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef BOOST_NUMERIC_BINDINGS_TRAITS_DETAIL_UBLAS_ORDERING_H
00015 #define BOOST_NUMERIC_BINDINGS_TRAITS_DETAIL_UBLAS_ORDERING_H
00016
00017 #include <boost/numeric/ublas/fwd.hpp>
00018
00019 namespace boost { namespace numeric { namespace bindings { namespace traits {
00020
00021 namespace detail {
00022
00023 template <typename StOrdTag>
00024 struct ublas_ordering {};
00025
00026 template<>
00027 struct ublas_ordering<boost::numeric::ublas::row_major_tag> {
00028 typedef row_major_t type;
00029 typedef boost::numeric::ublas::row_major functor_type;
00030
00031 template <typename M>
00032 static int leading_dimension( M const& m ) {
00033 return m.size2() ;
00034 }
00035
00036 template <typename M>
00037 static int stride1( M const& m ) {
00038 return m.size2() ;
00039 }
00040
00041 template <typename M>
00042 static int stride2( M const& m ) {
00043 return 1 ;
00044 }
00045 };
00046
00047 template<>
00048 struct ublas_ordering<boost::numeric::ublas::column_major_tag> {
00049 typedef column_major_t type;
00050 typedef boost::numeric::ublas::column_major functor_type;
00051
00052 template <typename M>
00053 static int leading_dimension( M const& m ) {
00054 return m.size1() ;
00055 }
00056
00057 template <typename M>
00058 static int stride1( M const& m ) {
00059 return 1 ;
00060 }
00061
00062 template <typename M>
00063 static int stride2( M const& m ) {
00064 return m.size1() ;
00065 }
00066 };
00067
00068 template <typename StOrdTag>
00069 struct ublas_banded_ordering {};
00070
00071 template<>
00072 struct ublas_banded_ordering<boost::numeric::ublas::row_major_tag> {
00073
00074 template <typename M>
00075 static int leading_dimension( M const& m ) {
00076 return m.lower() + m.upper() + 1 ;
00077 }
00078
00079 template <typename M>
00080 static int stride1( M const& m ) {
00081 return 1 ;
00082 }
00083
00084 template <typename M>
00085 static int stride2( M const& m ) {
00086 return leading_dimension(m)-1 ;
00087 }
00088 };
00089
00090 template<>
00091 struct ublas_banded_ordering<boost::numeric::ublas::column_major_tag> {
00092
00093 template <typename M>
00094 static int leading_dimension( M const& m ) {
00095 return m.size2() ;
00096 }
00097
00098 template <typename M>
00099 static int stride1( M const& m ) {
00100 return leading_dimension(m) ;
00101 }
00102
00103 template <typename M>
00104 static int stride2( M const& m ) {
00105 return 1-leading_dimension(m) ;
00106 }
00107 };
00108 }
00109
00110 }}}}
00111
00112 #endif