ublas_hermitian.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_HERMITIAN_H
00015 #define BOOST_NUMERIC_BINDINGS_TRAITS_UBLAS_HERMITIAN_H
00016
00017 #include <boost/numeric/bindings/traits/traits.hpp>
00018
00019 #ifndef BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS
00020
00021 #ifndef BOOST_UBLAS_HAVE_BINDINGS
00022 # include <boost/numeric/ublas/hermitian.hpp>
00023 #endif
00024 #include <boost/numeric/bindings/traits/ublas_matrix.hpp>
00025 #include <boost/numeric/bindings/traits/detail/ublas_uplo.hpp>
00026
00027
00028 namespace boost { namespace numeric { namespace bindings { namespace traits {
00029
00030
00031 template <typename T, typename F1, typename F2, typename A, typename M>
00032 struct matrix_detail_traits<boost::numeric::ublas::hermitian_matrix<T, F1, F2, A>, M>
00033 {
00034 #ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK
00035 BOOST_STATIC_ASSERT( (boost::is_same<boost::numeric::ublas::hermitian_matrix<T, F1, F2, A>, typename boost::remove_const<M>::type>::value) );
00036 #endif
00037 #ifdef BOOST_BINDINGS_FORTRAN
00038 BOOST_STATIC_ASSERT((boost::is_same<
00039 typename F2::orientation_category,
00040 boost::numeric::ublas::column_major_tag
00041 >::value));
00042 #endif
00043
00044 typedef boost::numeric::ublas::hermitian_matrix<T, F1, F2, A> identifier_type;
00045 typedef M matrix_type;
00046
00047 typedef hermitian_packed_t matrix_structure;
00048 typedef typename detail::ublas_ordering<
00049 typename F2::orientation_category
00050 >::type ordering_type;
00051 typedef typename detail::ublas_uplo< F1 >::type uplo_type;
00052
00053 typedef T value_type ;
00054 typedef typename detail::generate_const<M,T>::type* pointer ;
00055
00056 static pointer storage (matrix_type& hm) {
00057 typedef typename detail::generate_const<M,A>::type array_type ;
00058 return vector_traits<array_type>::storage (hm.data());
00059 }
00060 static int size1 (matrix_type& hm) { return hm.size1(); }
00061 static int size2 (matrix_type& hm) { return hm.size2(); }
00062 static int storage_size (matrix_type& hm) {
00063 return (size1 (hm) + 1) * size2 (hm) / 2;
00064 }
00065 };
00066
00067
00068 namespace detail {
00069 template <typename M>
00070 int matrix_bandwidth( M const& m, upper_t ) {
00071 return matrix_traits<M const>::upper_bandwidth( m ) ;
00072 }
00073
00074 template <typename M>
00075 int matrix_bandwidth( M const& m, lower_t ) {
00076
00077
00078 assert( 0 == matrix_traits<M const>::upper_bandwidth( m ) ) ;
00079 return matrix_traits<M const>::lower_bandwidth( m ) ;
00080 }
00081 }
00082
00083
00084 template <typename M, typename F1, typename MA>
00085 struct matrix_detail_traits<boost::numeric::ublas::hermitian_adaptor<M, F1>, MA>
00086 {
00087 #ifndef BOOST_NUMERIC_BINDINGS_NO_SANITY_CHECK
00088 BOOST_STATIC_ASSERT( (boost::is_same<boost::numeric::ublas::hermitian_adaptor<M, F1>, typename boost::remove_const<MA>::type>::value) );
00089 #endif
00090
00091 typedef boost::numeric::ublas::hermitian_adaptor<M, F1> identifier_type;
00092 typedef MA matrix_type;
00093 typedef hermitian_t matrix_structure;
00094 typedef typename matrix_traits<M>::ordering_type ordering_type;
00095 typedef typename detail::ublas_uplo< F1 >::type uplo_type;
00096
00097 typedef typename M::value_type value_type;
00098 typedef typename detail::generate_const<MA, value_type>::type* pointer;
00099
00100 private:
00101 typedef typename detail::generate_const<MA, typename MA::matrix_closure_type>::type m_type;
00102
00103 public:
00104 static pointer storage (matrix_type& hm) {
00105 return matrix_traits<m_type>::storage (hm.data());
00106 }
00107 static int size1 (matrix_type& hm) { return hm.size1(); }
00108 static int size2 (matrix_type& hm) { return hm.size2(); }
00109 static int storage_size (matrix_type& hm) {
00110 return size1 (hm) * size2 (hm);
00111 }
00112 static int leading_dimension (matrix_type& hm) {
00113 return matrix_traits<m_type>::leading_dimension (hm.data());
00114 }
00115
00116 static int upper_bandwidth(matrix_type& hm) {
00117 return detail::matrix_bandwidth( hm.data(), uplo_type() );
00118 }
00119 static int lower_bandwidth(matrix_type& hm) {
00120 return detail::matrix_bandwidth( hm.data(), uplo_type() );
00121 }
00122 };
00123
00124 }}}}
00125
00126 #endif // BOOST_NUMERIC_BINDINGS_POOR_MANS_TRAITS
00127
00128 #endif // BOOST_NUMERIC_BINDINGS_TRAITS_UBLAS_HERMITIAN_H