1 // 2 // Copyright (c) 2009 Rutger ter Borg 3 // 4 // Distributed under the Boost Software License, Version 1.0. 5 // (See accompanying file LICENSE_1_0.txt or copy at 6 // http://www.boost.org/LICENSE_1_0.txt) 7 // 8 9 #ifndef BOOST_NUMERIC_BINDINGS_GLAS_DENSE_MATRIX_HPP 10 #define BOOST_NUMERIC_BINDINGS_GLAS_DENSE_MATRIX_HPP 11 12 #include <boost/numeric/bindings/detail/adaptor.hpp> 13 #include <boost/numeric/bindings/detail/if_row_major.hpp> 14 #include <boost/numeric/bindings/glas/detail/convert_to.hpp> 15 #include <glas/container/dense_matrix.hpp> 16 17 namespace boost { 18 namespace numeric { 19 namespace bindings { 20 namespace detail { 21 22 template< typename T, typename O, typename Id, typename Enable > 23 struct adaptor< glas::dense_matrix< T, O >, Id, Enable > { 24 25 typedef typename copy_const< Id, T >::type value_type; 26 typedef typename convert_to< tag::data_order, O >::type data_order; 27 typedef mpl::map< 28 mpl::pair< tag::value_type, value_type >, 29 mpl::pair< tag::entity, tag::matrix >, 30 mpl::pair< tag::size_type<1>, std::ptrdiff_t >, 31 mpl::pair< tag::size_type<2>, std::ptrdiff_t >, 32 mpl::pair< tag::data_structure, tag::linear_array >, 33 mpl::pair< tag::data_order, data_order >, 34 mpl::pair< tag::stride_type<1>, 35 typename if_row_major< data_order, std::ptrdiff_t, tag::contiguous >::type >, 36 mpl::pair< tag::stride_type<2>, 37 typename if_row_major< data_order, tag::contiguous, std::ptrdiff_t >::type > 38 > property_map; 39 size1boost::numeric::bindings::detail::adaptor40 static std::ptrdiff_t size1( const Id& id ) { 41 return id.num_rows(); 42 } 43 size2boost::numeric::bindings::detail::adaptor44 static std::ptrdiff_t size2( const Id& id ) { 45 return id.num_columns(); 46 } 47 begin_valueboost::numeric::bindings::detail::adaptor48 static value_type* begin_value( Id& id ) { 49 return id.storage_ptr(); 50 } 51 end_valueboost::numeric::bindings::detail::adaptor52 static value_type* end_value( Id& id ) { 53 return id.storage_ptr() + id.num_rows() * id.num_columns(); 54 } 55 stride1boost::numeric::bindings::detail::adaptor56 static std::ptrdiff_t stride1( const Id& id ) { 57 return id.num_columns(); 58 } 59 stride2boost::numeric::bindings::detail::adaptor60 static std::ptrdiff_t stride2( const Id& id ) { 61 return id.num_rows(); 62 } 63 64 }; 65 66 } // namespace detail 67 } // namespace bindings 68 } // namespace numeric 69 } // namespace boost 70 71 #endif 72