Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58997 - in sandbox/numeric_bindings/boost/numeric/bindings: eigen mtl mtl/detail ublas
From: rutger_at_[hidden]
Date: 2010-01-14 06:18:16


Author: rutger
Date: 2010-01-14 06:18:15 EST (Thu, 14 Jan 2010)
New Revision: 58997
URL: http://svn.boost.org/trac/boost/changeset/58997

Log:
Added support for MTL dense2D and dense_vector containers.

Added:
   sandbox/numeric_bindings/boost/numeric/bindings/mtl/
   sandbox/numeric_bindings/boost/numeric/bindings/mtl/dense2D.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/mtl/dense_vector.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/mtl/detail/
   sandbox/numeric_bindings/boost/numeric/bindings/mtl/detail/convert_to.hpp (contents, props changed)
Text files modified:
   sandbox/numeric_bindings/boost/numeric/bindings/eigen/matrix.hpp | 34 +++++++++++++++++-----------------
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector.hpp | 12 ++++++------
   2 files changed, 23 insertions(+), 23 deletions(-)

Modified: sandbox/numeric_bindings/boost/numeric/bindings/eigen/matrix.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/eigen/matrix.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/eigen/matrix.hpp 2010-01-14 06:18:15 EST (Thu, 14 Jan 2010)
@@ -20,7 +20,7 @@
 namespace detail {
 
 template< int Value >
-struct select_size_type {
+struct eigen_size_type {
     typedef typename mpl::if_<
         mpl::bool_< Value == Eigen::Dynamic >,
         std::ptrdiff_t,
@@ -29,7 +29,7 @@
 };
 
 template< int Value >
-struct select_data_order {
+struct eigen_data_order {
     typedef typename mpl::if_<
         mpl::bool_< Value & Eigen::RowMajorBit >,
         tag::row_major,
@@ -42,9 +42,9 @@
 struct adaptor< Eigen::Matrix< T, Rows, Cols, Options >, Id, Enable > {
 
     typedef typename copy_const< Id, T >::type value_type;
- typedef typename select_size_type< Rows >::type size_type1;
- typedef typename select_size_type< Cols >::type size_type2;
- typedef typename select_data_order< Options >::type data_order;
+ typedef typename eigen_size_type< Rows >::type size_type1;
+ typedef typename eigen_size_type< Cols >::type size_type2;
+ typedef typename eigen_data_order< Options >::type data_order;
     typedef mpl::map<
         mpl::pair< tag::value_type, value_type >,
         mpl::pair< tag::entity, tag::matrix >,
@@ -58,28 +58,28 @@
             typename if_row_major< data_order, tag::contiguous, size_type1 >::type >
> property_map;
 
- static std::ptrdiff_t size1( const Id& t ) {
- return t.rows();
+ static std::ptrdiff_t size1( const Id& id ) {
+ return id.rows();
     }
 
- static std::ptrdiff_t size2( const Id& t ) {
- return t.cols();
+ static std::ptrdiff_t size2( const Id& id ) {
+ return id.cols();
     }
 
- static value_type* begin_value( Id& t ) {
- return t.data();
+ static value_type* begin_value( Id& id ) {
+ return id.data();
     }
 
- static value_type* end_value( Id& t ) {
- return t.data() + t.size();
+ static value_type* end_value( Id& id ) {
+ return id.data() + id.size();
     }
 
- static std::ptrdiff_t stride1( const Id& t ) {
- return t.cols();
+ static std::ptrdiff_t stride1( const Id& id ) {
+ return id.cols();
     }
 
- static std::ptrdiff_t stride2( const Id& t ) {
- return t.rows();
+ static std::ptrdiff_t stride2( const Id& id ) {
+ return id.rows();
     }
 
 };

Added: sandbox/numeric_bindings/boost/numeric/bindings/mtl/dense2D.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/mtl/dense2D.hpp 2010-01-14 06:18:15 EST (Thu, 14 Jan 2010)
@@ -0,0 +1,98 @@
+//
+// Copyright (c) 2009 Rutger ter Borg
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#ifndef BOOST_NUMERIC_BINDINGS_MTL_DENSE2D_HPP
+#define BOOST_NUMERIC_BINDINGS_MTL_DENSE2D_HPP
+
+#include <boost/numeric/bindings/detail/adaptor.hpp>
+#include <boost/numeric/bindings/detail/if_row_major.hpp>
+#include <boost/numeric/bindings/mtl/detail/convert_to.hpp>
+#include <boost/numeric/mtl/matrix/dense2D.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+namespace detail {
+
+template< typename Dimensions, int N >
+struct mtl_matrix_size_type {
+ typedef std::ptrdiff_t type;
+};
+
+template< std::size_t Rows, std::size_t Cols >
+struct mtl_matrix_size_type< mtl::fixed::dimensions< Rows, Cols >, 1 > {
+ typedef mpl::int_< Rows > type;
+};
+
+template< std::size_t Rows, std::size_t Cols >
+struct mtl_matrix_size_type< mtl::fixed::dimensions< Rows, Cols >, 2 > {
+ typedef mpl::int_< Rows > type;
+};
+
+template< typename T, typename Parameters, typename Id, typename Enable >
+struct adaptor< mtl::dense2D< T, Parameters >, Id, Enable > {
+
+ typedef typename copy_const< Id, T >::type value_type;
+ typedef typename convert_to<
+ tag::data_order,
+ typename Parameters::orientation
+ >::type data_order;
+ typedef typename mtl_matrix_size_type<
+ typename Parameters::dimensions,
+ 1
+ >::type size_type1;
+ typedef typename mtl_matrix_size_type<
+ typename Parameters::dimensions,
+ 2
+ >::type size_type2;
+
+ typedef mpl::map<
+ mpl::pair< tag::value_type, value_type >,
+ mpl::pair< tag::entity, tag::matrix >,
+ mpl::pair< tag::size_type<1>, size_type1 >,
+ mpl::pair< tag::size_type<2>, size_type2 >,
+ mpl::pair< tag::data_structure, tag::linear_array >,
+ mpl::pair< tag::data_order, data_order >,
+ mpl::pair< tag::stride_type<1>,
+ typename if_row_major< data_order, size_type2, tag::contiguous >::type >,
+ mpl::pair< tag::stride_type<2>,
+ typename if_row_major< data_order, tag::contiguous, size_type1 >::type >
+ > property_map;
+
+ static std::ptrdiff_t size1( const Id& id ) {
+ return id.num_rows();
+ }
+
+ static std::ptrdiff_t size2( const Id& id ) {
+ return id.num_cols();
+ }
+
+ static value_type* begin_value( Id& id ) {
+ return id.elements();
+ }
+
+ static value_type* end_value( Id& id ) {
+ return id.elements() + id.used_memory();
+ }
+
+ static std::ptrdiff_t stride1( const Id& id ) {
+ return id.num_cols();
+ }
+
+ static std::ptrdiff_t stride2( const Id& id ) {
+ return id.num_rows();
+ }
+
+};
+
+} // namespace detail
+} // namespace bindings
+} // namespace numeric
+} // namespace boost
+
+#endif

Added: sandbox/numeric_bindings/boost/numeric/bindings/mtl/dense_vector.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/mtl/dense_vector.hpp 2010-01-14 06:18:15 EST (Thu, 14 Jan 2010)
@@ -0,0 +1,71 @@
+//
+// Copyright (c) 2009 Rutger ter Borg
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#ifndef BOOST_NUMERIC_BINDINGS_MTL_DENSE_VECTOR_HPP
+#define BOOST_NUMERIC_BINDINGS_MTL_DENSE_VECTOR_HPP
+
+#include <boost/numeric/bindings/detail/adaptor.hpp>
+#include <boost/numeric/bindings/mtl/detail/convert_to.hpp>
+#include <boost/numeric/mtl/vector/dense_vector.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+namespace detail {
+
+template< typename Dimension >
+struct mtl_vector_size_type {
+ typedef std::ptrdiff_t type;
+};
+
+template< std::size_t Size >
+struct mtl_vector_size_type< mtl::vector::fixed::dimension< Size > > {
+ typedef mpl::int_< Size > type;
+};
+
+template< typename T, typename Parameters, typename Id, typename Enable >
+struct adaptor< mtl::dense_vector< T, Parameters >, Id, Enable > {
+
+ typedef typename copy_const< Id, T >::type value_type;
+ typedef typename convert_to<
+ tag::data_order,
+ typename Parameters::orientation
+ >::type data_order;
+ typedef typename mtl_vector_size_type<
+ typename Parameters::dimension
+ >::type size_type1;
+
+ typedef mpl::map<
+ mpl::pair< tag::value_type, value_type >,
+ mpl::pair< tag::entity, tag::vector >,
+ mpl::pair< tag::size_type<1>, size_type1 >,
+ mpl::pair< tag::data_structure, tag::linear_array >,
+ mpl::pair< tag::data_order, data_order >,
+ mpl::pair< tag::stride_type<1>, tag::contiguous >
+ > property_map;
+
+ static std::ptrdiff_t size1( const Id& id ) {
+ return id.size();
+ }
+
+ static value_type* begin_value( Id& id ) {
+ return id.begin();
+ }
+
+ static value_type* end_value( Id& id ) {
+ return id.end();
+ }
+
+};
+
+} // namespace detail
+} // namespace bindings
+} // namespace numeric
+} // namespace boost
+
+#endif

Added: sandbox/numeric_bindings/boost/numeric/bindings/mtl/detail/convert_to.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/mtl/detail/convert_to.hpp 2010-01-14 06:18:15 EST (Thu, 14 Jan 2010)
@@ -0,0 +1,36 @@
+//
+// Copyright (c) 2009 Rutger ter Borg
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#ifndef BOOST_NUMERIC_BINDINGS_MTL_DETAIL_CONVERT_TO_HPP
+#define BOOST_NUMERIC_BINDINGS_MTL_DETAIL_CONVERT_TO_HPP
+
+#include <boost/numeric/bindings/detail/convert_to.hpp>
+#include <boost/numeric/bindings/tag.hpp>
+#include <boost/numeric/mtl/utility/tag.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+namespace detail {
+
+template<>
+struct convert_to< bindings::tag::data_order, mtl::tag::row_major > {
+ typedef bindings::tag::row_major type;
+};
+
+template<>
+struct convert_to< bindings::tag::data_order, mtl::tag::col_major > {
+ typedef bindings::tag::column_major type;
+};
+
+} // namespace detail
+} // namespace bindings
+} // namespace numeric
+} // namespace boost
+
+#endif

Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector.hpp 2010-01-14 06:18:15 EST (Thu, 14 Jan 2010)
@@ -32,16 +32,16 @@
         mpl::pair< tag::stride_type<1>, tag::contiguous >
> property_map;
 
- static std::ptrdiff_t size1( const Id& t ) {
- return t.size();
+ static std::ptrdiff_t size1( const Id& id ) {
+ return id.size();
     }
 
- static value_type* begin_value( Id& t ) {
- return bindings::begin_value( t.data() );
+ static value_type* begin_value( Id& id ) {
+ return bindings::begin_value( id.data() );
     }
 
- static value_type* end_value( Id& t ) {
- return bindings::end_value( t.data() );
+ static value_type* end_value( Id& id ) {
+ return bindings::end_value( id.data() );
     }
 
 };


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk