Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57743 - in sandbox/numeric_bindings/boost/numeric/bindings: . detail
From: rutger_at_[hidden]
Date: 2009-11-18 07:50:39


Author: rutger
Date: 2009-11-18 07:50:37 EST (Wed, 18 Nov 2009)
New Revision: 57743
URL: http://svn.boost.org/trac/boost/changeset/57743

Log:
Merging new traits structure [2]

Added:
   sandbox/numeric_bindings/boost/numeric/bindings/detail/
   sandbox/numeric_bindings/boost/numeric/bindings/detail/adaptor.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/detail/dense.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/detail/pod.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/is_complex.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/is_numeric.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/is_real.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/matrix.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/std.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/tensor_rank.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/tensor_size.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/ublas.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/value_type.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/vector.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/vector_size.hpp (contents, props changed)

Added: sandbox/numeric_bindings/boost/numeric/bindings/detail/adaptor.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/detail/adaptor.hpp 2009-11-18 07:50:37 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,41 @@
+//
+// 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_ADAPTOR_HPP
+#define BOOST_NUMERIC_BINDINGS_DETAIL_ADAPTOR_HPP
+
+#include <boost/utility/enable_if.hpp>
+#include <boost/numeric/bindings/is_numeric.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+namespace detail {
+
+template< typename T, typename Id, typename Enable = void >
+struct adaptor {};
+
+template< typename T, typename Enable = void >
+struct adaptor_access {};
+
+template< typename T >
+struct adaptor_access< T,
+ typename boost::enable_if< is_numeric< typename adaptor<
+ typename boost::remove_const<T>::type, T >::value_type > >::type >:
+ adaptor< typename boost::remove_const<T>::type, T > {};
+
+} // detail
+} // bindings
+} // numeric
+} // boost
+
+// Include support for POD types
+#include <boost/numeric/bindings/detail/pod.hpp>
+
+#endif

Added: sandbox/numeric_bindings/boost/numeric/bindings/detail/dense.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/detail/dense.hpp 2009-11-18 07:50:37 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,31 @@
+//
+// 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_HPP
+#define BOOST_NUMERIC_BINDINGS_DETAIL_DENSE_HPP
+
+#include <boost/mpl/int.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+namespace detail {
+
+// Storage layout tags
+struct dense_tag {};
+
+// Dense stuff
+struct column_major_tag {};
+struct row_major_tag {};
+
+} // detail
+} // bindings
+} // numeric
+} // boost
+
+#endif

Added: sandbox/numeric_bindings/boost/numeric/bindings/detail/pod.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/detail/pod.hpp 2009-11-18 07:50:37 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,64 @@
+//
+// 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_POD_HPP
+#define BOOST_NUMERIC_BINDINGS_DETAIL_POD_HPP
+
+#include <boost/numeric/bindings/is_numeric.hpp>
+#include <boost/numeric/bindings/detail/adaptor.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+namespace detail {
+
+template< typename T, typename Id >
+struct adaptor< T, Id, typename boost::enable_if< is_numeric<T> >::type > {
+
+ // Generic information
+ typedef T value_type;
+ typedef boost::mpl::int_<0> tensor_rank;
+
+};
+
+template< typename T, std::size_t N, typename Id >
+struct adaptor< T[N], Id, typename boost::enable_if< is_numeric<T> >::type > {
+
+ // Generic information
+ typedef T value_type;
+ typedef boost::mpl::int_<1> tensor_rank;
+
+ static std::ptrdiff_t size1( Id const& t ) {
+ return N;
+ }
+
+};
+
+template< typename T, std::size_t N, std::size_t M, typename Id >
+struct adaptor< T[N][M], Id, typename boost::enable_if< is_numeric<T> >::type > {
+
+ // Generic information
+ typedef T value_type;
+ typedef boost::mpl::int_<2> tensor_rank;
+
+ static std::ptrdiff_t size1( Id const& t ) {
+ return N;
+ }
+
+ static std::ptrdiff_t size2( Id const& t ) {
+ return M;
+ }
+
+};
+
+} // detail
+} // bindings
+} // numeric
+} // boost
+
+#endif

Added: sandbox/numeric_bindings/boost/numeric/bindings/is_complex.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/is_complex.hpp 2009-11-18 07:50:37 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,25 @@
+//
+// 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_IS_COMPLEX_HPP
+#define BOOST_NUMERIC_BINDINGS_IS_COMPLEX_HPP
+
+#include <boost/type_traits/is_complex.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+
+template< typename T >
+struct is_complex: boost::is_complex<T> {};
+
+} // bindings
+} // numeric
+} // boost
+
+#endif

Added: sandbox/numeric_bindings/boost/numeric/bindings/is_numeric.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/is_numeric.hpp 2009-11-18 07:50:37 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,28 @@
+//
+// 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_IS_NUMERIC_HPP
+#define BOOST_NUMERIC_BINDINGS_IS_NUMERIC_HPP
+
+#include <boost/mpl/or.hpp>
+#include <boost/numeric/bindings/is_real.hpp>
+#include <boost/numeric/bindings/is_complex.hpp>
+#include <boost/type_traits/is_integral.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+
+template< typename T >
+struct is_numeric: mpl::or_< is_real<T>, is_complex<T>, is_integral<T> > {};
+
+} // bindings
+} // numeric
+} // boost
+
+#endif

Added: sandbox/numeric_bindings/boost/numeric/bindings/is_real.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/is_real.hpp 2009-11-18 07:50:37 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,25 @@
+//
+// 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_IS_REAL_HPP
+#define BOOST_NUMERIC_BINDINGS_IS_REAL_HPP
+
+#include <boost/type_traits/is_floating_point.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+
+template< typename T >
+struct is_real: boost::is_floating_point<T> {};
+
+} // bindings
+} // numeric
+} // boost
+
+#endif

Added: sandbox/numeric_bindings/boost/numeric/bindings/matrix.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/matrix.hpp 2009-11-18 07:50:37 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,15 @@
+//
+// 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_MATRIX_HPP
+#define BOOST_NUMERIC_BINDINGS_MATRIX_HPP
+
+#include <boost/numeric/bindings/matrix_num_rows.hpp>
+#include <boost/numeric/bindings/matrix_num_columns.hpp>
+
+#endif

Added: sandbox/numeric_bindings/boost/numeric/bindings/std.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/std.hpp 2009-11-18 07:50:37 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,15 @@
+//
+// 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_STD_HPP
+#define BOOST_NUMERIC_BINDINGS_STD_HPP
+
+#include <boost/numeric/bindings/std/vector.hpp>
+#include <boost/numeric/bindings/std/valarray.hpp>
+
+#endif

Added: sandbox/numeric_bindings/boost/numeric/bindings/tensor_rank.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/tensor_rank.hpp 2009-11-18 07:50:37 EST (Wed, 18 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_TENSOR_RANK_HPP
+#define BOOST_NUMERIC_BINDINGS_TENSOR_RANK_HPP
+
+#include <boost/numeric/bindings/detail/adaptor.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+
+template< typename T >
+struct tensor_rank: detail::adaptor_access< T >::tensor_rank {};
+
+} // bindings
+} // numeric
+} // boost
+
+#endif

Added: sandbox/numeric_bindings/boost/numeric/bindings/tensor_size.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/tensor_size.hpp 2009-11-18 07:50:37 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,68 @@
+//
+// 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_TENSOR_SIZE_HPP
+#define BOOST_NUMERIC_BINDINGS_TENSOR_SIZE_HPP
+
+#include <boost/mpl/less.hpp>
+#include <boost/mpl/greater_equal.hpp>
+
+#include <boost/numeric/bindings/tensor_rank.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+
+template< typename T, int Dimension, typename Enable = void >
+struct tensor_size_impl {};
+
+
+template< typename T, int Dimension >
+struct tensor_size_impl< T, Dimension,
+ typename boost::enable_if< boost::mpl::greater_equal< tensor_rank<T>, mpl::int_<Dimension> > >::type > {
+
+ static std::ptrdiff_t size1( T const& t ) {
+ return detail::adaptor_access<T>::size1( t );
+ }
+
+ static std::ptrdiff_t size2( T const& t ) {
+ return detail::adaptor_access<T>::size2( t );
+ }
+
+};
+
+template< typename T, int Dimension >
+struct tensor_size_impl< T, Dimension,
+ typename boost::enable_if< boost::mpl::less< tensor_rank<T>, mpl::int_<Dimension> > >::type > {
+
+ static std::ptrdiff_t size1( T const& t ) {
+ return 1;
+ }
+
+ static std::ptrdiff_t size2( T const& t ) {
+ return std::min< std::ptrdiff_t >( tensor_size_impl<T,1>::size1(t), 1 );
+ }
+
+};
+
+template< typename T >
+inline std::ptrdiff_t tensor_size1( T const& t ) {
+ return tensor_size_impl<T,1>::size1( t );
+}
+
+template< typename T >
+inline std::ptrdiff_t tensor_size2( T const& t ) {
+ return tensor_size_impl<T,2>::size2( t );
+}
+
+} // bindings
+} // numeric
+} // boost
+
+#endif
+

Added: sandbox/numeric_bindings/boost/numeric/bindings/ublas.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas.hpp 2009-11-18 07:50:37 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,15 @@
+//
+// 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_HPP
+#define BOOST_NUMERIC_BINDINGS_UBLAS_HPP
+
+#include <boost/numeric/bindings/ublas/vector.hpp>
+#include <boost/numeric/bindings/ublas/matrix.hpp>
+
+#endif

Added: sandbox/numeric_bindings/boost/numeric/bindings/value_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/value_type.hpp 2009-11-18 07:50:37 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,27 @@
+//
+// 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_VALUE_TYPE_HPP
+#define BOOST_NUMERIC_BINDINGS_VALUE_TYPE_HPP
+
+#include <boost/numeric/bindings/detail/adaptor.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+
+template< typename T >
+struct value_type {
+ typedef typename detail::adaptor_access< T >::value_type type;
+};
+
+} // bindings
+} // numeric
+} // boost
+
+#endif

Added: sandbox/numeric_bindings/boost/numeric/bindings/vector.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/vector.hpp 2009-11-18 07:50:37 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,15 @@
+//
+// 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_VECTOR_HPP
+#define BOOST_NUMERIC_BINDINGS_VECTOR_HPP
+
+#include <boost/numeric/bindings/vector_size.hpp>
+#include <boost/numeric/bindings/vector_stride.hpp>
+
+#endif

Added: sandbox/numeric_bindings/boost/numeric/bindings/vector_size.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/vector_size.hpp 2009-11-18 07:50:37 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,52 @@
+//
+// 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_VECTOR_SIZE_HPP
+#define BOOST_NUMERIC_BINDINGS_VECTOR_SIZE_HPP
+
+#include <boost/assert.hpp>
+#include <boost/numeric/bindings/tensor_size.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+
+template< typename T, typename Enable = void >
+struct vector_size_impl {};
+
+template< typename T >
+struct vector_size_impl< T,
+ typename boost::enable_if< boost::mpl::less< tensor_rank<T>, mpl::int_<2> > >::type > {
+
+ static std::ptrdiff_t size( T const& t ) {
+ return tensor_size1( t );
+ }
+};
+
+template< typename T >
+struct vector_size_impl< T,
+ typename boost::enable_if< boost::mpl::greater_equal< tensor_rank<T>, mpl::int_<2> > >::type > {
+
+ static std::ptrdiff_t size( T const& t ) {
+ BOOST_ASSERT( tensor_size2( t )==1 );
+ return tensor_size1( t );
+ }
+
+};
+
+template< typename T >
+inline std::ptrdiff_t vector_size( T const& t ) {
+ return vector_size_impl<T>::size( t );
+}
+
+} // 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