|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57947 - in sandbox/numeric_bindings/boost/numeric/bindings: . detail eigen tnt ublas ublas/detail
From: rutger_at_[hidden]
Date: 2009-11-26 11:19:20
Author: rutger
Date: 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
New Revision: 57947
URL: http://svn.boost.org/trac/boost/changeset/57947
Log:
Updates to the numeric_bindings traits part
Added:
sandbox/numeric_bindings/boost/numeric/bindings/detail/convert_to.hpp (contents, props changed)
sandbox/numeric_bindings/boost/numeric/bindings/detail/if_row_major.hpp (contents, props changed)
sandbox/numeric_bindings/boost/numeric/bindings/detail/linear_iterator.hpp (contents, props changed)
sandbox/numeric_bindings/boost/numeric/bindings/eigen/
sandbox/numeric_bindings/boost/numeric/bindings/eigen/matrix.hpp (contents, props changed)
sandbox/numeric_bindings/boost/numeric/bindings/tnt/array2d.hpp
- copied unchanged from r57938, /sandbox/numeric_bindings/boost/numeric/bindings/tnt/array_2d.hpp
sandbox/numeric_bindings/boost/numeric/bindings/ublas/compressed_matrix.hpp (contents, props changed)
sandbox/numeric_bindings/boost/numeric/bindings/ublas/compressed_vector.hpp
- copied, changed from r57927, /sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector_sparse.hpp
sandbox/numeric_bindings/boost/numeric/bindings/ublas/detail/convert_to.hpp
- copied, changed from r57927, /sandbox/numeric_bindings/boost/numeric/bindings/ublas/detail/to_bindings_tag.hpp
Removed:
sandbox/numeric_bindings/boost/numeric/bindings/detail/dense_iterator.hpp
sandbox/numeric_bindings/boost/numeric/bindings/tnt/array_2d.hpp
sandbox/numeric_bindings/boost/numeric/bindings/ublas/detail/to_bindings_tag.hpp
sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector_sparse.hpp
Text files modified:
sandbox/numeric_bindings/boost/numeric/bindings/begin.hpp | 20 +++++++++++-------
sandbox/numeric_bindings/boost/numeric/bindings/detail/pod.hpp | 2
sandbox/numeric_bindings/boost/numeric/bindings/detail/tag.hpp | 23 +--------------------
sandbox/numeric_bindings/boost/numeric/bindings/end.hpp | 16 +++++---------
sandbox/numeric_bindings/boost/numeric/bindings/tnt.hpp | 4 +-
sandbox/numeric_bindings/boost/numeric/bindings/ublas.hpp | 6 ++++
sandbox/numeric_bindings/boost/numeric/bindings/ublas/compressed_vector.hpp | 30 ++++++++++++++++++----------
sandbox/numeric_bindings/boost/numeric/bindings/ublas/detail/convert_to.hpp | 41 ++++++++++++++++++++++++++++++---------
sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix.hpp | 37 ++++++-----------------------------
sandbox/numeric_bindings/boost/numeric/bindings/ublas/symmetric.hpp | 6 ++--
sandbox/numeric_bindings/boost/numeric/bindings/ublas/triangular.hpp | 9 +++----
sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector.hpp | 2
12 files changed, 93 insertions(+), 103 deletions(-)
Modified: sandbox/numeric_bindings/boost/numeric/bindings/begin.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/begin.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/begin.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -9,8 +9,11 @@
#ifndef BOOST_NUMERIC_BINDINGS_BEGIN_HPP
#define BOOST_NUMERIC_BINDINGS_BEGIN_HPP
+#include <boost/numeric/bindings/data.hpp>
+#include <boost/numeric/bindings/stride.hpp>
+#include <boost/numeric/bindings/value_type.hpp>
#include <boost/numeric/bindings/detail/adaptor.hpp>
-#include <boost/numeric/bindings/detail/dense_iterator.hpp>
+#include <boost/numeric/bindings/detail/linear_iterator.hpp>
namespace boost {
namespace numeric {
@@ -19,21 +22,22 @@
template< typename T >
struct begin {
- typedef detail::dense_iterator< typename value_type<T>::type > type;
+ typedef detail::linear_iterator<
+ typename value_type<T>::type,
+ typename stride<T,1>::type
+ > type;
};
} // namespace result_of
template< typename T >
-detail::dense_iterator< typename value_type<T>::type > begin( T& t ) {
- return detail::dense_iterator< typename value_type<T>::type >(
- detail::adaptor_access<T>::data( t ) );
+typename result_of::begin<T>::type begin( T& t ) {
+ return typename result_of::begin<T>::type( data( t ), stride<1>( t ) );
}
template< typename T >
-detail::dense_iterator< typename value_type<T const>::type > begin( T const& t ) {
- return detail::dense_iterator< typename value_type<T const>::type>(
- detail::adaptor_access<T const>::data( t ) );
+typename result_of::begin<T const>::type begin( T const& t ) {
+ return typename result_of::begin<T const>::type( data( t ), stride<1>( t ) );
}
} // namespace bindings
Added: sandbox/numeric_bindings/boost/numeric/bindings/detail/convert_to.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/detail/convert_to.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -0,0 +1,25 @@
+//
+// 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_DETAIL_CONVERT_TO_HPP
+#define BOOST_NUMERIC_BINDINGS_DETAIL_CONVERT_TO_HPP
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+namespace detail {
+
+template< typename Target, typename Source >
+struct convert_to {};
+
+} // namespace detail
+} // namespace bindings
+} // namespace numeric
+} // namespace boost
+
+#endif
Deleted: sandbox/numeric_bindings/boost/numeric/bindings/detail/dense_iterator.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/detail/dense_iterator.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
+++ (empty file)
@@ -1,46 +0,0 @@
-//
-// 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_DETAIL_DENSE_ITERATOR_HPP
-#define BOOST_NUMERIC_BINDINGS_DETAIL_DENSE_ITERATOR_HPP
-
-#include <boost/iterator/iterator_adaptor.hpp>
-
-namespace boost {
-namespace numeric {
-namespace bindings {
-namespace detail {
-
-template< typename T >
-class dense_iterator: public boost::iterator_adaptor<
- dense_iterator<T>,
- T* > {
-public:
- dense_iterator():
- dense_iterator::iterator_adaptor_(0) {}
-
- explicit dense_iterator( T* p ):
- dense_iterator::iterator_adaptor_(p) {}
-
- private:
- friend class boost::iterator_core_access;
-
- void increment() {
- ++(this->base_reference());
- }
-
-};
-
-
-} // detail
-} // bindings
-} // numeric
-} // boost
-
-#endif
-
Added: sandbox/numeric_bindings/boost/numeric/bindings/detail/if_row_major.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/detail/if_row_major.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -0,0 +1,34 @@
+//
+// 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_DETAIL_IF_ROW_MAJOR_HPP
+#define BOOST_NUMERIC_BINDINGS_DETAIL_IF_ROW_MAJOR_HPP
+
+#include <boost/numeric/bindings/detail/tag.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+namespace detail {
+
+template< typename Order, typename True, typename False >
+struct if_row_major {
+ typedef False type;
+};
+
+template< typename True, typename False >
+struct if_row_major< tag::row_major, True, False > {
+ typedef True type;
+};
+
+} // namespace detail
+} // namespace bindings
+} // namespace numeric
+} // namespace boost
+
+#endif
Added: sandbox/numeric_bindings/boost/numeric/bindings/detail/linear_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/detail/linear_iterator.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -0,0 +1,89 @@
+//
+// 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_DETAIL_LINEAR_ITERATOR_HPP
+#define BOOST_NUMERIC_BINDINGS_DETAIL_LINEAR_ITERATOR_HPP
+
+#include <boost/iterator/iterator_adaptor.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+namespace detail {
+
+template< typename T, typename StrideType >
+class linear_iterator: public boost::iterator_adaptor<
+ linear_iterator<T, StrideType >,
+ T*, use_default, random_access_traversal_tag > {
+public:
+
+ typedef mpl::int_<StrideType::value> stride_type;
+
+ linear_iterator():
+ linear_iterator::iterator_adaptor_(0) {}
+
+ explicit linear_iterator( T* p, StrideType ignore ):
+ linear_iterator::iterator_adaptor_(p) {}
+
+private:
+ friend class boost::iterator_core_access;
+
+ void advance( int n ) {
+ (this->base_reference()) += n * stride_type::value;
+ }
+
+ void decrement() {
+ (this->base_reference()) -= stride_type::value;
+ }
+
+ void increment() {
+ (this->base_reference()) += stride_type::value;
+ }
+
+};
+
+template< typename T >
+class linear_iterator< T, std::ptrdiff_t >: public boost::iterator_adaptor<
+ linear_iterator< T, std::ptrdiff_t >,
+ T*, use_default, random_access_traversal_tag > {
+public:
+
+ typedef std::ptrdiff_t stride_type;
+
+ linear_iterator():
+ linear_iterator::iterator_adaptor_(0),
+ m_stride(0) {}
+
+ explicit linear_iterator( T* p, std::ptrdiff_t stride ):
+ linear_iterator::iterator_adaptor_(p),
+ m_stride( stride ) {}
+
+private:
+ friend class boost::iterator_core_access;
+
+ void advance( int n ) {
+ (this->base_reference()) += n * m_stride;
+ }
+
+ void decrement() {
+ (this->base_reference()) -= m_stride;
+ }
+
+ void increment() {
+ (this->base_reference()) += m_stride;
+ }
+
+ std::ptrdiff_t m_stride;
+};
+
+} // namespace detail
+} // namespace bindings
+} // namespace numeric
+} // namespace boost
+
+#endif
Modified: sandbox/numeric_bindings/boost/numeric/bindings/detail/pod.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/detail/pod.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/detail/pod.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -64,7 +64,7 @@
mpl::pair< tag::matrix_type, tag::general >,
mpl::pair< tag::data_structure, tag::linear_array >,
mpl::pair< tag::data_order, tag::row_major >,
- mpl::pair< tag::stride_type<1>, mpl::int_<N> >,
+ mpl::pair< tag::stride_type<1>, mpl::int_<M> >,
mpl::pair< tag::stride_type<2>, tag::contiguous >
> property_map;
Modified: sandbox/numeric_bindings/boost/numeric/bindings/detail/tag.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/detail/tag.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/detail/tag.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -41,11 +41,10 @@
struct contiguous: mpl::int_<1> {};
+// Supported data structures
struct linear_array {};
struct triangular_array {};
-struct associative_array {};
-struct compressed {};
-struct coordinate {};
+struct yale_sparse {};
struct structure {};
struct general {};
@@ -64,24 +63,6 @@
} // tag
-template< typename T >
-struct to_bindings_tag {};
-
-template< typename T >
-struct erase_unit {
- typedef T type;
-};
-
-template<>
-struct erase_unit< tag::unit_upper > {
- typedef tag::upper type;
-};
-
-template<>
-struct erase_unit< tag::unit_lower > {
- typedef tag::lower type;
-};
-
} // namespace detail
} // namespace bindings
} // namespace numeric
Added: sandbox/numeric_bindings/boost/numeric/bindings/eigen/matrix.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/eigen/matrix.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -0,0 +1,88 @@
+//
+// 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_EIGEN_MATRIX_HPP
+#define BOOST_NUMERIC_BINDINGS_EIGEN_MATRIX_HPP
+
+#include <boost/mpl/equal.hpp>
+#include <boost/numeric/bindings/detail/adaptor.hpp>
+#include <boost/numeric/bindings/detail/if_row_major.hpp>
+#include <Eigen/Core>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+namespace detail {
+
+template< int Value >
+struct select_size_type {
+ typedef typename mpl::if_<
+ mpl::bool_< Value == Eigen::Dynamic >,
+ std::ptrdiff_t,
+ mpl::int_<Value>
+ >::type type;
+};
+
+template< int Value >
+struct select_data_order {
+ typedef typename mpl::if_<
+ mpl::bool_< Value & Eigen::RowMajorBit >,
+ tag::row_major,
+ tag::column_major
+ >::type type;
+};
+
+template< typename T, int Rows, int Cols, int Options,
+ typename Id, typename Enable >
+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 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( Id const& t ) {
+ return t.rows();
+ }
+
+ static std::ptrdiff_t size2( Id const& t ) {
+ return t.cols();
+ }
+
+ static value_type* data( Id& t ) {
+ return t.data();
+ }
+
+ static std::ptrdiff_t stride1( Id const& t ) {
+ return t.cols();
+ }
+
+ static std::ptrdiff_t stride2( Id const& t ) {
+ return t.rows();
+ }
+
+};
+
+} // namespace detail
+} // namespace bindings
+} // namespace numeric
+} // namespace boost
+
+#endif
Modified: sandbox/numeric_bindings/boost/numeric/bindings/end.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/end.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/end.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -9,9 +9,7 @@
#ifndef BOOST_NUMERIC_BINDINGS_END_HPP
#define BOOST_NUMERIC_BINDINGS_END_HPP
-#include <boost/numeric/bindings/detail/adaptor.hpp>
-#include <boost/numeric/bindings/detail/dense_iterator.hpp>
-#include <boost/numeric/bindings/size.hpp>
+#include <boost/numeric/bindings/begin.hpp>
namespace boost {
namespace numeric {
@@ -20,21 +18,19 @@
template< typename T >
struct end {
- typedef detail::dense_iterator< typename value_type<T>::type > type;
+ typedef typename begin<T>::type type;
};
} // namespace result_of
template< typename T >
-detail::dense_iterator< typename value_type<T>::type > end( T& t ) {
- return detail::dense_iterator< typename value_type<T>::type >(
- detail::adaptor_access<T>::data( t ) ) + size<1>( t );
+typename result_of::end<T>::type end( T& t ) {
+ return typename result_of::end<T>::type( data( t ), stride<1>( t ) ) + size<1>( t );
}
template< typename T >
-detail::dense_iterator< typename value_type<T const>::type > end( T const& t ) {
- return detail::dense_iterator< typename value_type<T const>::type >(
- detail::adaptor_access<T const>::data( t ) ) + size<1>( t );
+typename result_of::end<T const>::type end( T const& t ) {
+ return typename result_of::end<T const>::type( data( t ), stride<1>( t ) ) + size<1>( t );
}
} // namespace bindings
Modified: sandbox/numeric_bindings/boost/numeric/bindings/tnt.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/tnt.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/tnt.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -6,8 +6,8 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef BOOST_NUMERIC_BINDINGS_STD_HPP
-#define BOOST_NUMERIC_BINDINGS_STD_HPP
+#ifndef BOOST_NUMERIC_BINDINGS_TNT_HPP
+#define BOOST_NUMERIC_BINDINGS_TNT_HPP
#include <boost/numeric/bindings/tnt/array1d.hpp>
#include <boost/numeric/bindings/tnt/array2d.hpp>
Deleted: sandbox/numeric_bindings/boost/numeric/bindings/tnt/array_2d.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/tnt/array_2d.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
+++ (empty file)
@@ -1,58 +0,0 @@
-//
-// 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_TNT_ARRAY2D_HPP
-#define BOOST_NUMERIC_BINDINGS_TNT_ARRAY2D_HPP
-
-#include <boost/numeric/bindings/detail/adaptor.hpp>
-#include <tnt_array2d.h>
-
-namespace boost {
-namespace numeric {
-namespace bindings {
-namespace detail {
-
-template< typename T, typename Id, typename Enable >
-struct adaptor< TNT::Array2D< T >, Id, Enable > {
-
- typedef typename copy_const< Id, T >::type value_type;
- typedef mpl::map<
- mpl::pair< tag::value_type, value_type >,
- mpl::pair< tag::entity, tag::matrix >,
- mpl::pair< tag::size_type<1>, std::ptrdiff_t >,
- mpl::pair< tag::size_type<2>, std::ptrdiff_t >,
- mpl::pair< tag::data_structure, tag::linear_array >,
- mpl::pair< tag::data_order, tag::row_major >,
- mpl::pair< tag::stride_type<1>, std::ptrdiff_t >,
- mpl::pair< tag::stride_type<2>, tag::contiguous >
- > property_map;
-
- static std::ptrdiff_t size1( Id const& t ) {
- return t.dim1();
- }
-
- static std::ptrdiff_t size2( Id const& t ) {
- return t.dim2();
- }
-
- static value_type* data( Id& t ) {
- return &t[0];
- }
-
- static std::ptrdiff_t stride1( Id const& t ) {
- return t.dim2();
- }
-
-};
-
-} // namespace detail
-} // namespace bindings
-} // namespace numeric
-} // namespace boost
-
-#endif
Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -9,7 +9,11 @@
#ifndef BOOST_NUMERIC_BINDINGS_UBLAS_HPP
#define BOOST_NUMERIC_BINDINGS_UBLAS_HPP
-#include <boost/numeric/bindings/ublas/vector.hpp>
+#include <boost/numeric/bindings/ublas/compressed_vector.hpp>
+#include <boost/numeric/bindings/ublas/compressed_matrix.hpp>
#include <boost/numeric/bindings/ublas/matrix.hpp>
+#include <boost/numeric/bindings/ublas/symmetric.hpp>
+#include <boost/numeric/bindings/ublas/triangular.hpp>
+#include <boost/numeric/bindings/ublas/vector.hpp>
#endif
Added: sandbox/numeric_bindings/boost/numeric/bindings/ublas/compressed_matrix.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/compressed_matrix.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -0,0 +1,57 @@
+//
+// 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_UBLAS_COMPRESSED_MATRIX_HPP
+#define BOOST_NUMERIC_BINDINGS_UBLAS_COMPRESSED_MATRIX_HPP
+
+#include <boost/numeric/bindings/detail/adaptor.hpp>
+#include <boost/numeric/bindings/ublas/detail/convert_to.hpp>
+#include <boost/numeric/ublas/matrix_sparse.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+namespace detail {
+
+template< typename T, typename F, std::size_t IB, typename IA, typename TA, typename Id, typename Enable >
+struct adaptor< ublas::compressed_matrix< T, F, IB, IA, TA >, Id, Enable > {
+
+ typedef typename convert_to< tag::data_order, F >::type data_order;
+ typedef mpl::map<
+ mpl::pair< tag::value_type, T >,
+ mpl::pair< tag::entity, tag::vector >,
+ mpl::pair< tag::size_type<1>, std::ptrdiff_t >,
+ mpl::pair< tag::size_type<2>, std::ptrdiff_t >,
+ mpl::pair< tag::data_structure, tag::yale_sparse >,
+ mpl::pair< tag::data_order, data_order >
+ > property_map;
+
+ static std::ptrdiff_t size1( Id const& t ) {
+ return t.size1();
+ }
+
+ static std::ptrdiff_t size2( Id const& t ) {
+ return t.size2();
+ }
+/*
+ static void index_data( Id& t ) {
+ return t.index_data()
+ }
+
+ static void value_data( Id& t ) {
+ return t.value_data();
+ }*/
+
+};
+
+} // namespace detail
+} // namespace bindings
+} // namespace numeric
+} // namespace boost
+
+#endif
Copied: sandbox/numeric_bindings/boost/numeric/bindings/ublas/compressed_vector.hpp (from r57927, /sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector_sparse.hpp)
==============================================================================
--- /sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector_sparse.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/compressed_vector.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -6,8 +6,8 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef BOOST_NUMERIC_BINDINGS_UBLAS_VECTOR_SPARSE_HPP
-#define BOOST_NUMERIC_BINDINGS_UBLAS_VECTOR_SPARSE_HPP
+#ifndef BOOST_NUMERIC_BINDINGS_UBLAS_COMPRESSED_VECTOR_HPP
+#define BOOST_NUMERIC_BINDINGS_UBLAS_COMPRESSED_VECTOR_HPP
#include <boost/numeric/bindings/detail/adaptor.hpp>
#include <boost/numeric/ublas/vector_sparse.hpp>
@@ -17,26 +17,34 @@
namespace bindings {
namespace detail {
-template< typename T, typename A, typename Id, typename Enable >
-struct adaptor< ublas::mapped_vector< T, A >, Id, Enable > {
+template< typename T, std::size_t IB, typename IA, typename TA, typename Id, typename Enable >
+struct adaptor< ublas::compressed_vector< T, IB, IA, TA >, Id, Enable > {
+ typedef typename copy_const< Id, T >::type value_type;
typedef mpl::map<
- mpl::pair< tag::value_type, T >,
+ mpl::pair< tag::value_type, value_type >,
mpl::pair< tag::entity, tag::vector >,
mpl::pair< tag::size_type<1>, std::ptrdiff_t >,
- mpl::pair< tag::data_structure, tag::associative_array >
+ mpl::pair< tag::data_structure, tag::yale_sparse >
> property_map;
static std::ptrdiff_t size1( Id const& t ) {
return t.size();
}
+// static void index_data( Id& t ) {
+// // t.index_data();
+// }
+//
+// static void value_data( Id& t ) {
+// //t.value_data();
+// }
+
};
-} // detail
-} // bindings
-} // numeric
-} // boost
+} // namespace detail
+} // namespace bindings
+} // namespace numeric
+} // namespace boost
#endif
-
Copied: sandbox/numeric_bindings/boost/numeric/bindings/ublas/detail/convert_to.hpp (from r57927, /sandbox/numeric_bindings/boost/numeric/bindings/ublas/detail/to_bindings_tag.hpp)
==============================================================================
--- /sandbox/numeric_bindings/boost/numeric/bindings/ublas/detail/to_bindings_tag.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/detail/convert_to.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -6,9 +6,10 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef BOOST_NUMERIC_BINDINGS_UBLAS_DETAIL_TO_BINDINGS_TAG_HPP
-#define BOOST_NUMERIC_BINDINGS_UBLAS_DETAIL_TO_BINDINGS_TAG_HPP
+#ifndef BOOST_NUMERIC_BINDINGS_UBLAS_DETAIL_CONVERT_TO_HPP
+#define BOOST_NUMERIC_BINDINGS_UBLAS_DETAIL_CONVERT_TO_HPP
+#include <boost/numeric/bindings/detail/convert_to.hpp>
#include <boost/numeric/bindings/detail/tag.hpp>
#include <boost/numeric/ublas/fwd.hpp>
@@ -18,33 +19,53 @@
namespace detail {
template<>
-struct to_bindings_tag< ublas::lower > {
+struct convert_to< tag::data_order, ublas::row_major > {
+ typedef tag::row_major type;
+};
+
+template<>
+struct convert_to< tag::data_order, ublas::column_major > {
+ typedef tag::column_major type;
+};
+
+template<>
+struct convert_to< tag::matrix_side, ublas::lower > {
typedef tag::lower type;
};
template<>
-struct to_bindings_tag< ublas::upper > {
+struct convert_to< tag::matrix_side, ublas::upper > {
typedef tag::upper type;
};
template<>
-struct to_bindings_tag< ublas::unit_lower > {
+struct convert_to< tag::matrix_side, ublas::unit_lower > {
typedef tag::unit_lower type;
};
template<>
-struct to_bindings_tag< ublas::unit_upper > {
+struct convert_to< tag::matrix_side, ublas::unit_upper > {
typedef tag::unit_upper type;
};
template<>
-struct to_bindings_tag< ublas::row_major > {
- typedef tag::row_major type;
+struct convert_to< tag::data_side, ublas::lower > {
+ typedef tag::lower type;
};
template<>
-struct to_bindings_tag< ublas::column_major > {
- typedef tag::column_major type;
+struct convert_to< tag::data_side, ublas::upper > {
+ typedef tag::upper type;
+};
+
+template<>
+struct convert_to< tag::data_side, ublas::unit_lower > {
+ typedef tag::lower type;
+};
+
+template<>
+struct convert_to< tag::data_side, ublas::unit_upper > {
+ typedef tag::upper type;
};
} // namespace detail
Deleted: sandbox/numeric_bindings/boost/numeric/bindings/ublas/detail/to_bindings_tag.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/detail/to_bindings_tag.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
+++ (empty file)
@@ -1,55 +0,0 @@
-//
-// 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_UBLAS_DETAIL_TO_BINDINGS_TAG_HPP
-#define BOOST_NUMERIC_BINDINGS_UBLAS_DETAIL_TO_BINDINGS_TAG_HPP
-
-#include <boost/numeric/bindings/detail/tag.hpp>
-#include <boost/numeric/ublas/fwd.hpp>
-
-namespace boost {
-namespace numeric {
-namespace bindings {
-namespace detail {
-
-template<>
-struct to_bindings_tag< ublas::lower > {
- typedef tag::lower type;
-};
-
-template<>
-struct to_bindings_tag< ublas::upper > {
- typedef tag::upper type;
-};
-
-template<>
-struct to_bindings_tag< ublas::unit_lower > {
- typedef tag::unit_lower type;
-};
-
-template<>
-struct to_bindings_tag< ublas::unit_upper > {
- typedef tag::unit_upper type;
-};
-
-template<>
-struct to_bindings_tag< ublas::row_major > {
- typedef tag::row_major type;
-};
-
-template<>
-struct to_bindings_tag< ublas::column_major > {
- typedef tag::column_major type;
-};
-
-} // namespace detail
-} // namespace bindings
-} // namespace numeric
-} // namespace boost
-
-#endif
Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -10,7 +10,8 @@
#define BOOST_NUMERIC_BINDINGS_UBLAS_MATRIX_HPP
#include <boost/numeric/bindings/detail/adaptor.hpp>
-#include <boost/numeric/bindings/ublas/detail/to_bindings_tag.hpp>
+#include <boost/numeric/bindings/detail/if_row_major.hpp>
+#include <boost/numeric/bindings/ublas/detail/convert_to.hpp>
#include <boost/numeric/ublas/matrix.hpp>
namespace boost {
@@ -18,37 +19,11 @@
namespace bindings {
namespace detail {
-template< typename DataOrder, int StrideDimension >
-struct select_stride {};
-
-template<>
-struct select_stride< tag::row_major, 1 > {
- typedef std::ptrdiff_t type;
-};
-
-template<>
-struct select_stride< tag::row_major, 2 > {
- typedef tag::contiguous type;
-};
-
-template<>
-struct select_stride< tag::column_major, 1 > {
- typedef tag::contiguous type;
-};
-
-template<>
-struct select_stride< tag::column_major, 2 > {
- typedef std::ptrdiff_t type;
-};
-
-
-
-
template< typename T, typename F, typename A, typename Id, typename Enable >
struct adaptor< boost::numeric::ublas::matrix< T, F, A >, Id, Enable > {
typedef typename copy_const< Id, T >::type value_type;
- typedef typename detail::to_bindings_tag<F>::type data_order;
+ typedef typename convert_to< tag::data_order, F >::type data_order;
typedef mpl::map<
mpl::pair< tag::value_type, value_type >,
mpl::pair< tag::entity, tag::matrix >,
@@ -56,8 +31,10 @@
mpl::pair< tag::size_type<2>, std::ptrdiff_t >,
mpl::pair< tag::data_structure, tag::linear_array >,
mpl::pair< tag::data_order, data_order >,
- mpl::pair< tag::stride_type<1>, typename select_stride< data_order, 1 >::type >,
- mpl::pair< tag::stride_type<2>, typename select_stride< data_order, 2 >::type >
+ mpl::pair< tag::stride_type<1>,
+ typename if_row_major< data_order, std::ptrdiff_t, tag::contiguous >::type >,
+ mpl::pair< tag::stride_type<2>,
+ typename if_row_major< data_order, tag::contiguous, std::ptrdiff_t >::type >
> property_map;
static std::ptrdiff_t size1( Id const& t ) {
Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/symmetric.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/symmetric.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/symmetric.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -10,7 +10,7 @@
#define BOOST_NUMERIC_BINDINGS_UBLAS_SYMMETRIC_HPP
#include <boost/numeric/bindings/detail/adaptor.hpp>
-#include <boost/numeric/bindings/ublas/detail/to_bindings_tag.hpp>
+#include <boost/numeric/bindings/ublas/detail/convert_to.hpp>
#include <boost/numeric/ublas/symmetric.hpp>
namespace boost {
@@ -29,8 +29,8 @@
mpl::pair< tag::size_type<2>, std::ptrdiff_t >,
mpl::pair< tag::matrix_type, tag::symmetric >,
mpl::pair< tag::data_structure, tag::triangular_array >,
- mpl::pair< tag::data_side, typename to_bindings_tag<F1>::type >,
- mpl::pair< tag::data_order, typename to_bindings_tag<F2>::type >
+ mpl::pair< tag::data_side, typename convert_to< tag::data_side, F1 >::type >,
+ mpl::pair< tag::data_order, typename convert_to< tag::data_order, F2 >::type >
> property_map;
static std::ptrdiff_t size1( Id const& t ) {
Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/triangular.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/triangular.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/triangular.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -10,7 +10,7 @@
#define BOOST_NUMERIC_BINDINGS_UBLAS_TRIANGULAR_HPP
#include <boost/numeric/bindings/detail/adaptor.hpp>
-#include <boost/numeric/bindings/ublas/detail/to_bindings_tag.hpp>
+#include <boost/numeric/bindings/ublas/detail/convert_to.hpp>
#include <boost/numeric/ublas/triangular.hpp>
namespace boost {
@@ -28,11 +28,10 @@
mpl::pair< tag::size_type<1>, std::ptrdiff_t >,
mpl::pair< tag::size_type<2>, std::ptrdiff_t >,
mpl::pair< tag::matrix_type, tag::triangular >,
- mpl::pair< tag::matrix_side, typename to_bindings_tag<F1>::type >,
+ mpl::pair< tag::matrix_side, typename convert_to< tag::matrix_side, F1 >::type >,
mpl::pair< tag::data_structure, tag::triangular_array >,
- mpl::pair< tag::data_side, typename erase_unit<
- typename to_bindings_tag<F1>::type >::type >,
- mpl::pair< tag::data_order, typename to_bindings_tag<F2>::type >
+ mpl::pair< tag::data_side, typename convert_to< tag::data_side, F1 >::type >,
+ mpl::pair< tag::data_order, typename convert_to< tag::data_order, F2 >::type >
> property_map;
static std::ptrdiff_t size1( Id const& t ) {
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 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
@@ -18,7 +18,7 @@
namespace detail {
template< typename T, typename Alloc, typename Id, typename Enable >
-struct adaptor< boost::numeric::ublas::vector< T, Alloc >, Id, Enable > {
+struct adaptor< ublas::vector< T, Alloc >, Id, Enable > {
typedef typename copy_const< Id, T >::type value_type;
typedef mpl::map<
Deleted: sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector_sparse.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector_sparse.hpp 2009-11-26 11:19:17 EST (Thu, 26 Nov 2009)
+++ (empty file)
@@ -1,42 +0,0 @@
-//
-// 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_UBLAS_VECTOR_SPARSE_HPP
-#define BOOST_NUMERIC_BINDINGS_UBLAS_VECTOR_SPARSE_HPP
-
-#include <boost/numeric/bindings/detail/adaptor.hpp>
-#include <boost/numeric/ublas/vector_sparse.hpp>
-
-namespace boost {
-namespace numeric {
-namespace bindings {
-namespace detail {
-
-template< typename T, typename A, typename Id, typename Enable >
-struct adaptor< ublas::mapped_vector< T, A >, Id, Enable > {
-
- typedef mpl::map<
- mpl::pair< tag::value_type, T >,
- mpl::pair< tag::entity, tag::vector >,
- mpl::pair< tag::size_type<1>, std::ptrdiff_t >,
- mpl::pair< tag::data_structure, tag::associative_array >
- > property_map;
-
- static std::ptrdiff_t size1( Id const& t ) {
- return t.size();
- }
-
-};
-
-} // detail
-} // bindings
-} // numeric
-} // boost
-
-#endif
-
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