ublas_vector2.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_UBLAS_VECTOR_AS_MATRIX_H
00015 #define BOOST_NUMERIC_BINDINGS_TRAITS_UBLAS_VECTOR_AS_MATRIX_H
00016
00017 #include <boost/numeric/bindings/traits/config.hpp>
00018
00019 #ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS
00020
00021 #ifndef BOOST_UBLAS_HAVE_BINDINGS
00022 # include <boost/numeric/bindings/traits/ublas_vector.hpp>
00023 #endif
00024 #include <boost/numeric/bindings/traits/matrix_traits.hpp>
00025
00026 #ifndef BOOST_NUMERIC_BINDINGS_NO_STRUCTURE_CHECK
00027 # include <boost/static_assert.hpp>
00028 # include <boost/type_traits/same_traits.hpp>
00029 # include <boost/mpl/if.hpp>
00030 #endif
00031
00032
00033 namespace boost { namespace numeric { namespace bindings { namespace traits {
00034
00035
00036 template <typename T, typename ArrT, typename V>
00037 struct matrix_detail_traits<boost::numeric::ublas::vector<T, ArrT>, V>
00038 {
00039 #ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK
00040 BOOST_STATIC_ASSERT(
00041 (boost::is_same<
00042 boost::numeric::ublas::vector<T, ArrT>,
00043 typename boost::remove_const<V>::type
00044 >::value) );
00045 #endif
00046
00047 typedef boost::numeric::ublas::vector<T, ArrT> identifier_type;
00048 typedef V matrix_type;
00049 typedef general_t matrix_structure;
00050 typedef column_major_t ordering_type;
00051
00052 typedef T value_type;
00053 typedef typename detail::generate_const<V,T>::type* pointer;
00054
00055 static pointer storage (matrix_type& v) {
00056 typedef typename detail::generate_const<V,ArrT>::type array_type;
00057 return vector_traits<array_type>::storage (v.data());
00058 }
00059 static int size1 (matrix_type& v) { return v.size(); }
00060 static int size2 (matrix_type&) { return 1; }
00061 static int storage_size (matrix_type& v) { return v.size(); }
00062 static int leading_dimension (matrix_type& v) { return v.size(); }
00063 };
00064
00065
00066
00067 template <typename T, typename V>
00068 struct matrix_detail_traits<boost::numeric::ublas::vector_range<T>, V>
00069 {
00070 #ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK
00071 BOOST_STATIC_ASSERT(
00072 (boost::is_same<
00073 boost::numeric::ublas::vector_range<T>,
00074 typename boost::remove_const<V>::type
00075 >::value) );
00076 #endif
00077
00078 typedef boost::numeric::ublas::vector_range<T> identifier_type;
00079 typedef V matrix_type;
00080 typedef general_t matrix_structure;
00081 typedef column_major_t ordering_type;
00082
00083 typedef typename T::value_type value_type;
00084 typedef typename detail::generate_const<V,value_type>::type* pointer;
00085
00086 static pointer storage (matrix_type& v) {
00087 return vector_traits<V>::storage (v);
00088 }
00089 static int size1 (matrix_type& v) { return v.size(); }
00090 static int size2 (matrix_type&) { return 1; }
00091 static int storage_size (matrix_type& v) { return v.size(); }
00092 static int leading_dimension (matrix_type& v) { return v.size(); }
00093 };
00094
00095
00096 #ifndef BOOST_NUMERIC_BINDINGS_FORTRAN
00097
00098
00099 template <typename T, std::size_t N, typename V>
00100 struct matrix_detail_traits<boost::numeric::ublas::c_vector<T,N>, V>
00101 {
00102 #ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK
00103 BOOST_STATIC_ASSERT(
00104 (boost::is_same<
00105 boost::numeric::ublas::c_vector<T,N>,
00106 typename boost::remove_const<V>::type
00107 >::value) );
00108 #endif
00109
00110 typedef boost::numeric::ublas::c_vector<T,N> identifier_type;
00111 typedef V matrix_type;
00112 typedef general_t matrix_structure;
00113 typedef row_major_t ordering_type;
00114
00115 typedef T value_type;
00116 typedef typename detail::generate_const<V,T>::type* pointer;
00117
00118 static pointer storage (matrix_type& v) { return v.data(); }
00119 static int size1 (matrix_type&) { return 1; }
00120 static int size2 (matrix_type& v) { return v.size(); }
00121 static int storage_size (matrix_type&) { return N; }
00122 static int leading_dimension (matrix_type&) { return N; }
00123 };
00124
00125 #endif // BOOST_NUMERIC_BINDINGS_FORTRAN
00126
00127 }}}}
00128
00129 #else // BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS
00130
00131 #error with your compiler ublas::vector<> cannot be used as matrix
00132
00133 #endif // BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS
00134
00135 #endif // BOOST_NUMERIC_BINDINGS_TRAITS_UBLAS_VECTOR_AS_MATRIX_H