Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58102 - in sandbox/numeric_bindings/boost/numeric/bindings: . detail eigen std tnt ublas
From: rutger_at_[hidden]
Date: 2009-12-02 14:58:49


Author: rutger
Date: 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
New Revision: 58102
URL: http://svn.boost.org/trac/boost/changeset/58102

Log:
Bugfix on overloads on begin() free functions

Text files modified:
   sandbox/numeric_bindings/boost/numeric/bindings/begin.hpp | 62 ++++++++++++++++-----------------------
   sandbox/numeric_bindings/boost/numeric/bindings/column.hpp | 2
   sandbox/numeric_bindings/boost/numeric/bindings/detail/pod.hpp | 6 +-
   sandbox/numeric_bindings/boost/numeric/bindings/eigen/matrix.hpp | 2
   sandbox/numeric_bindings/boost/numeric/bindings/end.hpp | 2
   sandbox/numeric_bindings/boost/numeric/bindings/noop.hpp | 4 +-
   sandbox/numeric_bindings/boost/numeric/bindings/remove_imaginary.hpp | 5 +++
   sandbox/numeric_bindings/boost/numeric/bindings/row.hpp | 4 +-
   sandbox/numeric_bindings/boost/numeric/bindings/std/valarray.hpp | 2
   sandbox/numeric_bindings/boost/numeric/bindings/std/vector.hpp | 2
   sandbox/numeric_bindings/boost/numeric/bindings/tag.hpp | 3 +
   sandbox/numeric_bindings/boost/numeric/bindings/tnt/array1d.hpp | 2
   sandbox/numeric_bindings/boost/numeric/bindings/tnt/array2d.hpp | 2
   sandbox/numeric_bindings/boost/numeric/bindings/tnt/fortran_array1d.hpp | 2
   sandbox/numeric_bindings/boost/numeric/bindings/tnt/fortran_array2d.hpp | 2
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/compressed_matrix.hpp | 4 +-
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/compressed_vector.hpp | 4 +-
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix.hpp | 4 +-
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/symmetric.hpp | 4 +-
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/triangular.hpp | 4 +-
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/unbounded_array.hpp | 2
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/vector.hpp | 4 +-
   22 files changed, 62 insertions(+), 66 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-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -29,21 +29,14 @@
 namespace detail {
 
 template< typename T, typename Tag >
-struct begin_impl {
- typedef typename value<T>::type* result_type;
-
- static result_type invoke( T& t ) {
- return adaptor_access<T>::begin_value_array( t );
- }
-
-};
+struct begin_impl {};
 
 template< typename T >
 struct begin_impl< T, tag::value > {
     typedef typename value<T>::type* result_type;
 
     static result_type invoke( T& t ) {
- return adaptor_access<T>::begin_value_array( t );
+ return adaptor_access<T>::begin_value( t );
     }
 
 };
@@ -95,74 +88,69 @@
 
 template< int Dimension, typename T >
 typename result_of::begin<T, mpl::int_<Dimension> >::type begin( T& t ) {
- return begin< mpl::int_<Dimension> >( t );
+ return detail::begin_impl<T, mpl::int_<Dimension> >( t );
 }
 
 template< int Dimension, typename T >
 typename result_of::begin<const T, mpl::int_<Dimension> >::type begin( const T& t ) {
- return begin< mpl::int_<Dimension> >( t );
+ return detail::begin_impl<const T, mpl::int_<Dimension> >( t );
 }
 
 // Overloads for types with rank <= 1 (scalars, vectors)
-// In this case, just begin() will be equal to begin1
+// In theory, we could provide overloads for matrices here, too,
+// if their minimal_rank is at most 1.
 
 template< typename T >
 typename boost::enable_if< mpl::less< rank<T>, mpl::int_<2> >,
     typename result_of::begin< T, mpl::int_<1> >::type >::type
 begin( T& t ) {
- return begin< mpl::int_<1> >( t );
+ return detail::begin_impl<T,mpl::int_<1> >::invoke( t );
 }
 
 template< typename T >
 typename boost::enable_if< mpl::less< rank<T>, mpl::int_<2> >,
- typename result_of::begin< const T, mpl::int_<1> >::type >::type
+ typename result_of::begin< const T >::type >::type
 begin( const T& t ) {
- return begin< mpl::int_<1> >( t );
+ return detail::begin_impl<const T,mpl::int_<1> >::invoke( t );
 }
 
 //
 // Convenience functions
 //
 
-// Begin of value array
-
-template< typename T >
-typename result_of::begin<T, tag::value>::type begin_value( T& t ) {
- return detail::begin_impl<T, tag::value>::invoke( t );
-}
-
-template< typename T >
-typename result_of::begin<const T, tag::value>::type begin_value( const T& t ) {
- return detail::begin_impl<const T, tag::value>::invoke( t );
-}
-
-#define GENERATE_BEGIN( z, which, unused ) \
+#define GENERATE_BEGIN( suffix, tag ) \
 \
 namespace result_of {\
 \
 template< typename T > \
-struct BOOST_PP_CAT( begin, which ) { \
- typedef typename detail::begin_impl<T,mpl::int_<which> >::result_type type;\
+struct BOOST_PP_CAT( begin, suffix ) { \
+ typedef typename detail::begin_impl<T,tag>::result_type type;\
 }; \
 \
 }\
 \
 template< typename T >\
-typename BOOST_PP_CAT( result_of::begin, which )<T>::type \
-BOOST_PP_CAT( begin, which )( T& t ) {\
- return detail::begin_impl<T, mpl::int_<which> >::\
+typename BOOST_PP_CAT( result_of::begin, suffix )<T>::type \
+BOOST_PP_CAT( begin, suffix )( T& t ) {\
+ return detail::begin_impl<T, tag >::\
         invoke( t );\
 }\
 \
 template< typename T >\
-typename BOOST_PP_CAT( result_of::begin, which )<const T>::type \
-BOOST_PP_CAT( begin, which )( const T& t ) {\
- return detail::begin_impl<const T, mpl::int_<which> >::\
+typename BOOST_PP_CAT( result_of::begin, suffix )<const T>::type \
+BOOST_PP_CAT( begin, suffix )( const T& t ) {\
+ return detail::begin_impl<const T, tag >::\
         invoke( t );\
 }
 
-BOOST_PP_REPEAT_FROM_TO(1,2,GENERATE_BEGIN,~)
+#define GENERATE_BEGIN_INDEX( z, which, unused ) \
+GENERATE_BEGIN( which, mpl::int_<which> )
+
 
+BOOST_PP_REPEAT_FROM_TO(1,2,GENERATE_BEGIN_INDEX,~)
+GENERATE_BEGIN( _value, tag::value )
+GENERATE_BEGIN( _row, mpl::int_<1> )
+GENERATE_BEGIN( _column, mpl::int_<2> )
 
 } // namespace bindings
 } // namespace numeric

Modified: sandbox/numeric_bindings/boost/numeric/bindings/column.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/column.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/column.hpp 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -49,7 +49,7 @@
         return size<1>( id.get() );
     }
 
- static typename result_of::begin<T,tag::value>::type begin_value_array( Id& id ) {
+ static typename result_of::begin<T,tag::value>::type begin_value( Id& id ) {
         return begin<tag::value>( id.get() ) + id.m_index * stride<2>( id.get() );
     }
 

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-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -28,7 +28,7 @@
         mpl::pair< tag::stride_type<1>, mpl::int_<0> >
> property_map;
 
- static value_type* begin_value_array( Id& t ) {
+ static value_type* begin_value( Id& t ) {
         return &t;
     }
 
@@ -46,7 +46,7 @@
         mpl::pair< tag::stride_type<1>, tag::contiguous >
> property_map;
 
- static value_type* begin_value_array( Id& t ) {
+ static value_type* begin_value( Id& t ) {
         return &t[0];
     }
 
@@ -68,7 +68,7 @@
         mpl::pair< tag::stride_type<2>, tag::contiguous >
> property_map;
 
- static value_type* begin_value_array( Id& t ) {
+ static value_type* begin_value( Id& t ) {
         return &t[0][0];
     }
 

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 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -66,7 +66,7 @@
         return t.cols();
     }
 
- static value_type* begin_value_array( Id& t ) {
+ static value_type* begin_value( Id& t ) {
         return t.data();
     }
 

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-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -26,7 +26,7 @@
     typedef typename value<T>::type* result_type;
 
     static result_type invoke( T& t ) {
- return adaptor_access<T>::begin_value_array( t );
+ return adaptor_access<T>::begin_value( t );
     }
 
 };

Modified: sandbox/numeric_bindings/boost/numeric/bindings/noop.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/noop.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/noop.hpp 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -37,8 +37,8 @@
         return size<1>( id.get() );
     }
 
- static typename result_of::begin< T, tag::value >::type begin_value_array( Id& id ) {
- return begin< tag::value >( id.get() );
+ static typename result_of::begin< T, tag::value >::type begin_value( Id& id ) {
+ return bindings::begin_value( id.get() );
     }
 
 };

Modified: sandbox/numeric_bindings/boost/numeric/bindings/remove_imaginary.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/remove_imaginary.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/remove_imaginary.hpp 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -23,6 +23,11 @@
     typedef T type;
 };
 
+template< typename T >
+struct remove_imaginary< const std::complex<T> > {
+ typedef const T type;
+};
+
 } // namespace bindings
 } // namespace numeric
 } // namespace boost

Modified: sandbox/numeric_bindings/boost/numeric/bindings/row.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/row.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/row.hpp 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -49,8 +49,8 @@
         return size<2>( id.get() );
     }
 
- static typename result_of::begin<T,tag::value>::type begin_value_array( Id& id ) {
- return begin< tag::value >( id.get() ) + id.m_index * stride<1>( id.get() );
+ static typename result_of::begin<T,tag::value>::type begin_value( Id& id ) {
+ return bindings::begin_value( id.get() ) + id.m_index * stride<1>( id.get() );
     }
 
     static typename result_of::stride<T,2>::type stride1( const Id& id ) {

Modified: sandbox/numeric_bindings/boost/numeric/bindings/std/valarray.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/std/valarray.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/std/valarray.hpp 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -32,7 +32,7 @@
         return t.size();
     }
 
- static value_type* begin_value_array( Id& t ) {
+ static value_type* begin_value( Id& t ) {
         return &t.front();
     }
 

Modified: sandbox/numeric_bindings/boost/numeric/bindings/std/vector.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/std/vector.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/std/vector.hpp 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -33,7 +33,7 @@
         return t.size();
     }
 
- static value_type* begin_value_array( Id& t ) {
+ static value_type* begin_value( Id& t ) {
         return &t.front();
     }
 

Modified: sandbox/numeric_bindings/boost/numeric/bindings/tag.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/tag.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/tag.hpp 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -39,6 +39,9 @@
 template< int Dimension >
 struct stride_type: mpl::int_< Dimension > {};
 
+template< int Dimension >
+struct index: mpl::int_< Dimension > {};
+
 struct contiguous: mpl::int_<1> {};
 
 // Supported data structures

Modified: sandbox/numeric_bindings/boost/numeric/bindings/tnt/array1d.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/tnt/array1d.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/tnt/array1d.hpp 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -33,7 +33,7 @@
         return t.dim();
     }
 
- static value_type* begin_value_array( Id& t ) {
+ static value_type* begin_value( Id& t ) {
         return &t[0];
     }
 

Modified: sandbox/numeric_bindings/boost/numeric/bindings/tnt/array2d.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/tnt/array2d.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/tnt/array2d.hpp 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -40,7 +40,7 @@
         return t.dim2();
     }
 
- static value_type* begin_value_array( Id& t ) {
+ static value_type* begin_value( Id& t ) {
         return &t[0];
     }
 

Modified: sandbox/numeric_bindings/boost/numeric/bindings/tnt/fortran_array1d.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/tnt/fortran_array1d.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/tnt/fortran_array1d.hpp 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -33,7 +33,7 @@
         return t.dim();
     }
 
- static value_type* begin_value_array( Id& t ) {
+ static value_type* begin_value( Id& t ) {
         return &t(1);
     }
 

Modified: sandbox/numeric_bindings/boost/numeric/bindings/tnt/fortran_array2d.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/tnt/fortran_array2d.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/tnt/fortran_array2d.hpp 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -41,7 +41,7 @@
         return t.dim2();
     }
 
- static value_type* begin_value_array( Id& t ) {
+ static value_type* begin_value( Id& t ) {
         return &t(1,1);
     }
 

Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/compressed_matrix.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/compressed_matrix.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/compressed_matrix.hpp 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -44,8 +44,8 @@
         return t.index_data()
     }*/
 
- static value_type* begin_value_array( Id& t ) {
- return begin< tag::value >( t.value_data() );
+ static value_type* begin_value( Id& t ) {
+ return bindings::begin_value( t.value_data() );
     }
 
 };

Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/compressed_vector.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/compressed_vector.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/compressed_vector.hpp 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -38,8 +38,8 @@
 // }
 //
 
- static value_type* begin_value_array( Id& t ) {
- return begin< tag::value >( t.value_data() );
+ static value_type* begin_value( Id& t ) {
+ return bindings::begin_value( t.value_data() );
     }
 
 };

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-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -47,8 +47,8 @@
         return t.size2();
     }
 
- static value_type* begin_value_array( Id& t ) {
- return begin< tag::value >( t.data() );
+ static value_type* begin_value( Id& t ) {
+ return bindings::begin_value( t.data() );
     }
 
     static std::ptrdiff_t stride1( const Id& 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-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -41,8 +41,8 @@
         return t.size2();
     }
 
- static value_type* begin_value_array( Id& t ) {
- return begin< tag::value >( t.data() );
+ static value_type* begin_value( Id& t ) {
+ return bindings::begin_value( t.data() );
     }
 
 };

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-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -42,8 +42,8 @@
         return t.size2();
     }
 
- static value_type* begin_value_array( Id& t ) {
- return begin< tag::value >( t.data() );
+ static value_type* begin_value( Id& t ) {
+ return bindings::begin_value( t.data() );
     }
 
 };

Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/unbounded_array.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/unbounded_array.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/unbounded_array.hpp 2009-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -33,7 +33,7 @@
         return t.size();
     }
 
- static value_type* begin_value_array( Id& t ) {
+ static value_type* begin_value( Id& t ) {
         return t.begin();
     }
 

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-12-02 14:58:47 EST (Wed, 02 Dec 2009)
@@ -33,8 +33,8 @@
         return t.size();
     }
 
- static value_type* begin_value_array( Id& t ) {
- return begin< tag::value >( t.data() );
+ static value_type* begin_value( Id& t ) {
+ return bindings::begin_value( t.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