Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57744 - sandbox/numeric_bindings/boost/numeric/bindings
From: rutger_at_[hidden]
Date: 2009-11-18 07:54:42


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

Log:
Added matrix_num_rows, matrix_num_columns and transpose wrapper

Added:
   sandbox/numeric_bindings/boost/numeric/bindings/matrix_num_columns.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/matrix_num_rows.hpp (contents, props changed)
   sandbox/numeric_bindings/boost/numeric/bindings/transpose.hpp (contents, props changed)

Added: sandbox/numeric_bindings/boost/numeric/bindings/matrix_num_columns.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/matrix_num_columns.hpp 2009-11-18 07:54:40 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,28 @@
+//
+// 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_NUM_COLUMNS_HPP
+#define BOOST_NUMERIC_BINDINGS_MATRIX_NUM_COLUMNS_HPP
+
+#include <boost/numeric/bindings/tensor_size.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+
+template< typename T >
+inline std::ptrdiff_t matrix_num_columns( T const& t ) {
+ return tensor_size2( t );
+}
+
+} // bindings
+} // numeric
+} // boost
+
+#endif
+

Added: sandbox/numeric_bindings/boost/numeric/bindings/matrix_num_rows.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/matrix_num_rows.hpp 2009-11-18 07:54:40 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,28 @@
+//
+// 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_NUM_ROWS_HPP
+#define BOOST_NUMERIC_BINDINGS_MATRIX_NUM_ROWS_HPP
+
+#include <boost/numeric/bindings/tensor_size.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+
+template< typename T >
+inline std::ptrdiff_t matrix_num_rows( T const& t ) {
+ return tensor_size1( t );
+}
+
+} // bindings
+} // numeric
+} // boost
+
+#endif
+

Added: sandbox/numeric_bindings/boost/numeric/bindings/transpose.hpp
==============================================================================
--- (empty file)
+++ sandbox/numeric_bindings/boost/numeric/bindings/transpose.hpp 2009-11-18 07:54:40 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,73 @@
+//
+// 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_TRANSPOSE_HPP
+#define BOOST_NUMERIC_BINDINGS_TRANSPOSE_HPP
+
+#include <boost/numeric/bindings/detail/adaptor.hpp>
+#include <boost/mpl/max.hpp>
+
+namespace boost {
+namespace numeric {
+namespace bindings {
+
+namespace detail {
+
+template< typename T >
+struct transpose_wrapper {
+
+ typedef T type;
+
+ transpose_wrapper( T& t ):
+ m_ref( t ) {}
+
+ T& get() {
+ return m_ref;
+ }
+
+ T const& get() const {
+ return m_ref;
+ }
+
+private:
+ T& m_ref;
+};
+
+template< typename T, typename Id, typename Enable >
+struct adaptor< transpose_wrapper<T>, Id, Enable > {
+
+ typedef typename adaptor_access<T>::value_type value_type;
+ typedef typename boost::mpl::max<
+ boost::mpl::int_<2>,
+ typename adaptor_access<T>::tensor_rank
+ >::type tensor_rank;
+
+ static std::ptrdiff_t size1( Id const& t ) {
+ return tensor_size2( t.get() );
+ }
+
+ static std::ptrdiff_t size2( Id const& t ) {
+ return tensor_size1( t.get() );
+ }
+
+};
+
+} // namespace detail
+
+
+template< typename T >
+detail::transpose_wrapper<T> trans( T& underlying ) {
+ return detail::transpose_wrapper<T>( underlying );
+}
+
+} // 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