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_TRIANGULAR_HPP
10 #define BOOST_NUMERIC_BINDINGS_UBLAS_TRIANGULAR_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/basic_ublas_adaptor.hpp>
16 #include <boost/numeric/bindings/ublas/detail/convert_to.hpp>
17 #include <boost/numeric/bindings/value_type.hpp>
18 #include <boost/numeric/bindings/ublas/matrix_expression.hpp>
19 #include <boost/numeric/ublas/triangular.hpp>
20 
21 namespace boost {
22 namespace numeric {
23 namespace bindings {
24 namespace detail {
25 
26 template< typename T, typename F1, typename F2, typename A, typename Id, typename Enable >
27 struct adaptor< ublas::triangular_matrix< T, F1, F2, A >, Id, Enable > {
28 
29     typedef typename copy_const< Id, T >::type value_type;
30     typedef mpl::map<
31         mpl::pair< tag::value_type, value_type >,
32         mpl::pair< tag::entity, tag::matrix >,
33         mpl::pair< tag::size_type<1>, std::ptrdiff_t >,
34         mpl::pair< tag::size_type<2>, std::ptrdiff_t >,
35         mpl::pair< tag::matrix_type, typename convert_to< tag::matrix_type, F1 >::type >,
36         mpl::pair< tag::data_structure, tag::triangular_array >,
37         mpl::pair< tag::data_side, typename convert_to< tag::data_side, F1 >::type >,
38         mpl::pair< tag::data_order, typename convert_to< tag::data_order, F2 >::type >
39     > property_map;
40 
size1boost::numeric::bindings::detail::adaptor41     static std::ptrdiff_t size1( const Id& t ) {
42         return t.size1();
43     }
44 
size2boost::numeric::bindings::detail::adaptor45     static std::ptrdiff_t size2( const Id& t ) {
46         return t.size2();
47     }
48 
begin_valueboost::numeric::bindings::detail::adaptor49     static value_type* begin_value( Id& t ) {
50         return bindings::begin_value( t.data() );
51     }
52 
end_valueboost::numeric::bindings::detail::adaptor53     static value_type* end_value( Id& t ) {
54         return bindings::end_value( t.data() );
55     }
56 
57 };
58 
59 template< typename T, typename F, typename Id, typename Enable >
60 struct adaptor< ublas::triangular_adaptor< T, F >, Id, Enable >:
61     basic_ublas_adaptor<
62         T,
63         Id,
64         mpl::pair< tag::matrix_type, typename convert_to< tag::matrix_type, F >::type >,
65         mpl::pair< tag::data_side, typename convert_to< tag::data_side, F >::type >
66     > {};
67 
68 } // detail
69 } // bindings
70 } // numeric
71 } // boost
72 
73 #endif
74