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_MTL_DENSE_VECTOR_HPP
10 #define BOOST_NUMERIC_BINDINGS_MTL_DENSE_VECTOR_HPP
11 
12 #include <boost/numeric/bindings/detail/adaptor.hpp>
13 #include <boost/numeric/bindings/mtl/detail/convert_to.hpp>
14 #include <boost/numeric/mtl/vector/dense_vector.hpp>
15 
16 namespace boost {
17 namespace numeric {
18 namespace bindings {
19 namespace detail {
20 
21 template< typename Dimension >
22 struct mtl_vector_size_type {
23     typedef std::ptrdiff_t type;
24 };
25 
26 template< std::size_t Size >
27 struct mtl_vector_size_type< mtl::vector::fixed::dimension< Size > > {
28     typedef mpl::int_< Size > type;
29 };
30 
31 template< typename T, typename Parameters, typename Id, typename Enable >
32 struct adaptor< mtl::dense_vector< T, Parameters >, Id, Enable > {
33 
34     typedef typename copy_const< Id, T >::type value_type;
35     typedef typename convert_to<
36             tag::data_order,
37             typename Parameters::orientation
38     >::type data_order;
39     typedef typename mtl_vector_size_type<
40         typename Parameters::dimension
41     >::type size_type1;
42 
43     typedef mpl::map<
44         mpl::pair< tag::value_type, value_type >,
45         mpl::pair< tag::entity, tag::vector >,
46         mpl::pair< tag::size_type<1>, size_type1 >,
47         mpl::pair< tag::data_structure, tag::linear_array >,
48         mpl::pair< tag::data_order, data_order >,
49         mpl::pair< tag::stride_type<1>, tag::contiguous >
50     > property_map;
51 
size1boost::numeric::bindings::detail::adaptor52     static std::ptrdiff_t size1( const Id& id ) {
53         return id.size();
54     }
55 
begin_valueboost::numeric::bindings::detail::adaptor56     static value_type* begin_value( Id& id ) {
57         return id.begin();
58     }
59 
end_valueboost::numeric::bindings::detail::adaptor60     static value_type* end_value( Id& id ) {
61         return id.end();
62     }
63 
64 };
65 
66 } // namespace detail
67 } // namespace bindings
68 } // namespace numeric
69 } // namespace boost
70 
71 #endif
72