|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r58457 - in sandbox/numeric_bindings/boost/numeric/bindings: . detail eigen
From: rutger_at_[hidden]
Date: 2009-12-18 10:52:09
Author: rutger
Date: 2009-12-18 10:52:08 EST (Fri, 18 Dec 2009)
New Revision: 58457
URL: http://svn.boost.org/trac/boost/changeset/58457
Log:
added index_major, index_minor meta funcs
Added:
sandbox/numeric_bindings/boost/numeric/bindings/index_major.hpp (contents, props changed)
sandbox/numeric_bindings/boost/numeric/bindings/index_minor.hpp (contents, props changed)
Text files modified:
sandbox/numeric_bindings/boost/numeric/bindings/detail/generate_functions.hpp | 2 +-
sandbox/numeric_bindings/boost/numeric/bindings/eigen/matrix.hpp | 4 ++++
sandbox/numeric_bindings/boost/numeric/bindings/end.hpp | 10 +++++-----
sandbox/numeric_bindings/boost/numeric/bindings/size.hpp | 6 ++++++
sandbox/numeric_bindings/boost/numeric/bindings/stride.hpp | 6 ++++++
5 files changed, 22 insertions(+), 6 deletions(-)
Modified: sandbox/numeric_bindings/boost/numeric/bindings/detail/generate_functions.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/detail/generate_functions.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/detail/generate_functions.hpp 2009-12-18 10:52:08 EST (Fri, 18 Dec 2009)
@@ -24,7 +24,7 @@
struct BOOST_PP_CAT( function_name, suffix ) { \
typedef typename detail::\
BOOST_PP_CAT( function_name, _impl ) \
- <T,tag>::result_type type; \
+ <T, tag >::result_type type; \
}; \
\
}\
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-18 10:52:08 EST (Fri, 18 Dec 2009)
@@ -70,6 +70,10 @@
return t.data();
}
+ static value_type* end_value( Id& t ) {
+ return t.data() + t.size();
+ }
+
static std::ptrdiff_t stride1( const Id& t ) {
return t.cols();
}
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-18 10:52:08 EST (Fri, 18 Dec 2009)
@@ -33,15 +33,15 @@
template< typename T, int N >
struct end_impl< T, tag::index<N> > {
- typedef tag::index<N> index_type;
+ typedef tag::index<N> tag_type;
typedef linear_iterator<
typename value<T>::type,
- typename result_of::stride< T, index_type >::type
+ typename result_of::stride< T, tag_type >::type
> result_type;
static result_type invoke( T& t ) {
- return result_type( end_value( t ), stride(t, index_type() ) );
+ return result_type( end_value( t ), stride(t, tag_type() ) );
}
};
@@ -99,8 +99,8 @@
BOOST_PP_REPEAT_FROM_TO(1,3,GENERATE_END_INDEX,~)
GENERATE_FUNCTIONS( end, _value, tag::value )
-GENERATE_FUNCTIONS( end, _row, mpl::int_<1> )
-GENERATE_FUNCTIONS( end, _column, mpl::int_<2> )
+GENERATE_FUNCTIONS( end, _row, tag::index<1> )
+GENERATE_FUNCTIONS( end, _column, tag::index<2> )
} // namespace bindings
Added: sandbox/numeric_bindings/boost/numeric/bindings/index_major.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/index_major.hpp 2009-12-18 10:52:08 EST (Fri, 18 Dec 2009)
@@ -0,0 +1,34 @@
+//
+// Copyright (c) 2009 by 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_INDEX_MAJOR_HPP
+#define BOOST_NUMERIC_BINDINGS_INDEX_MAJOR_HPP
+
+#include <boost/mpl/if.hpp>
+#include <boost/numeric/bindings/rank.hpp>
+#include <boost/numeric/bindings/is_row_major.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+
+template< typename T >
+struct index_major:
+ mpl::if_<
+ is_row_major< T >,
+ tag::index<1>,
+ tag::index<
+ rank< T >::value
+ >
+ >::type {};
+
+} // namespace bindings
+} // namespace numeric
+} // namespace boost
+
+#endif
Added: sandbox/numeric_bindings/boost/numeric/bindings/index_minor.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/index_minor.hpp 2009-12-18 10:52:08 EST (Fri, 18 Dec 2009)
@@ -0,0 +1,34 @@
+//
+// Copyright (c) 2009 by 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_INDEX_MINOR_HPP
+#define BOOST_NUMERIC_BINDINGS_INDEX_MINOR_HPP
+
+#include <boost/mpl/if.hpp>
+#include <boost/numeric/bindings/rank.hpp>
+#include <boost/numeric/bindings/is_column_major.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+
+template< typename T >
+struct index_minor:
+ mpl::if_<
+ is_column_major< T >,
+ tag::index<1>,
+ tag::index<
+ rank< T >::value
+ >
+ >::type {};
+
+} // namespace bindings
+} // namespace numeric
+} // namespace boost
+
+#endif
Modified: sandbox/numeric_bindings/boost/numeric/bindings/size.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/size.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/size.hpp 2009-12-18 10:52:08 EST (Fri, 18 Dec 2009)
@@ -12,10 +12,13 @@
#include <boost/numeric/bindings/detail/generate_functions.hpp>
#include <boost/numeric/bindings/detail/get.hpp>
#include <boost/numeric/bindings/rank.hpp>
+#include <boost/numeric/bindings/index_major.hpp>
+#include <boost/numeric/bindings/index_minor.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/min.hpp>
#include <boost/mpl/greater.hpp>
#include <boost/mpl/less_equal.hpp>
+#include <boost/static_assert.hpp>
namespace boost {
namespace numeric {
@@ -106,6 +109,9 @@
BOOST_PP_REPEAT_FROM_TO(1,3,GENERATE_SIZE_INDEX,~)
+GENERATE_FUNCTIONS( size, _major, typename index_major<T>::type )
+GENERATE_FUNCTIONS( size, _minor, typename index_minor<T>::type )
+
} // namespace bindings
} // namespace numeric
} // namespace boost
Modified: sandbox/numeric_bindings/boost/numeric/bindings/stride.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/stride.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/stride.hpp 2009-12-18 10:52:08 EST (Fri, 18 Dec 2009)
@@ -12,11 +12,14 @@
#include <boost/numeric/bindings/detail/generate_functions.hpp>
#include <boost/numeric/bindings/detail/adaptor.hpp>
#include <boost/numeric/bindings/detail/get.hpp>
+#include <boost/numeric/bindings/index_major.hpp>
+#include <boost/numeric/bindings/index_minor.hpp>
#include <boost/numeric/bindings/rank.hpp>
#include <boost/mpl/min.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/less_equal.hpp>
#include <boost/mpl/greater.hpp>
+#include <boost/static_assert.hpp>
namespace boost {
namespace numeric {
@@ -108,6 +111,9 @@
BOOST_PP_REPEAT_FROM_TO(1,3,GENERATE_STRIDE_INDEX,~)
+GENERATE_FUNCTIONS( stride, _major, typename index_major<T>::type )
+GENERATE_FUNCTIONS( stride, _minor, typename index_minor<T>::type )
+
} // namespace bindings
} // namespace numeric
} // namespace boost
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