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_UBLAS_SYMMETRIC_HPP
10 #define BOOST_NUMERIC_BINDINGS_UBLAS_SYMMETRIC_HPP
11 
12 #include <boost/numeric/bindings/begin.hpp>
13 #include <boost/numeric/bindings/detail/adaptor.hpp>
14 #include <boost/numeric/bindings/end.hpp>
15 #include <boost/numeric/bindings/ublas/detail/convert_to.hpp>
16 #include <boost/numeric/bindings/ublas/detail/basic_ublas_adaptor.hpp>
17 #include <boost/numeric/bindings/ublas/matrix.hpp>
18 #include <boost/numeric/bindings/ublas/triangular.hpp>
19 #include <boost/numeric/bindings/value_type.hpp>
20 #include <boost/numeric/ublas/symmetric.hpp>
21 
22 namespace boost {
23 namespace numeric {
24 namespace bindings {
25 namespace detail {
26 
27 template< typename T, typename F1, typename F2, typename A, typename Id, typename Enable >
28 struct adaptor< ublas::symmetric_matrix< T, F1, F2, A >, Id, Enable > {
29 
30     typedef typename copy_const< Id, T >::type value_type;
31     typedef mpl::map<
32         mpl::pair< tag::value_type, value_type >,
33         mpl::pair< tag::entity, tag::matrix >,
34         mpl::pair< tag::size_type<1>, std::ptrdiff_t >,
35         mpl::pair< tag::size_type<2>, std::ptrdiff_t >,
36         mpl::pair< tag::matrix_type, tag::symmetric >,
37         mpl::pair< tag::data_structure, tag::triangular_array >,
38         mpl::pair< tag::data_side, typename convert_to< tag::data_side, F1 >::type >,
39         mpl::pair< tag::data_order, typename convert_to< tag::data_order, F2 >::type >
40     > property_map;
41 
size1boost::numeric::bindings::detail::adaptor42     static std::ptrdiff_t size1( const Id& t ) {
43         return t.size1();
44     }
45 
size2boost::numeric::bindings::detail::adaptor46     static std::ptrdiff_t size2( const Id& t ) {
47         return t.size2();
48     }
49 
begin_valueboost::numeric::bindings::detail::adaptor50     static value_type* begin_value( Id& t ) {
51         return bindings::begin_value( t.data() );
52     }
53 
end_valueboost::numeric::bindings::detail::adaptor54     static value_type* end_value( Id& t ) {
55         return bindings::end_value( t.data() );
56     }
57 
58 };
59 
60 template< typename T, typename F, typename Id, typename Enable >
61 struct adaptor< ublas::symmetric_adaptor< T, F >, Id, Enable >:
62     basic_ublas_adaptor<
63         T,
64         Id,
65         mpl::pair< tag::matrix_type, tag::symmetric >,
66         mpl::pair< tag::data_side, typename convert_to< tag::data_side, F >::type >
67     > {
68 
69     typedef typename convert_to< tag::data_side, F >::type data_side;
70 
bandwidth1boost::numeric::bindings::detail::adaptor71     static std::ptrdiff_t bandwidth1( const Id& id ) {
72         return bindings::bandwidth( id.data(), data_side() );
73     }
74 
bandwidth2boost::numeric::bindings::detail::adaptor75     static std::ptrdiff_t bandwidth2( const Id& id ) {
76         return bindings::bandwidth( id.data(), data_side() );
77     }
78 
79 };
80 
81 } // namespace detail
82 } // namespace bindings
83 } // namespace numeric
84 } // namespace boost
85 
86 #endif
87