Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58936 - in sandbox/numeric_bindings/boost/numeric/bindings/ublas: . detail
From: rutger_at_[hidden]
Date: 2010-01-12 07:33:09


Author: rutger
Date: 2010-01-12 07:33:07 EST (Tue, 12 Jan 2010)
New Revision: 58936
URL: http://svn.boost.org/trac/boost/changeset/58936

Log:
bandwidth traits updates for regression hbev

Text files modified:
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/banded.hpp | 28 +++++++++++++++++++++++++---
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/detail/basic_ublas_adaptor.hpp | 11 +++++++++++
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix_expression.hpp | 9 +++++++++
   sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix_proxy.hpp | 8 ++++++++
   4 files changed, 53 insertions(+), 3 deletions(-)

Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/banded.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/banded.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/banded.hpp 2010-01-12 07:33:07 EST (Tue, 12 Jan 2010)
@@ -1,5 +1,6 @@
 //
-// Copyright (c) 2009 Rutger ter Borg
+// Copyright (c) 2002 Kresimir Fresl
+// Copyright (c) 2010 Rutger ter Borg
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -11,6 +12,7 @@
 
 #include <boost/numeric/bindings/begin.hpp>
 #include <boost/numeric/bindings/detail/adaptor.hpp>
+#include <boost/numeric/bindings/detail/if_row_major.hpp>
 #include <boost/numeric/bindings/end.hpp>
 #include <boost/numeric/bindings/ublas/detail/basic_ublas_adaptor.hpp>
 #include <boost/numeric/bindings/ublas/detail/convert_to.hpp>
@@ -26,7 +28,14 @@
 template< typename T, typename F, typename A, typename Id, typename Enable >
 struct adaptor< ublas::banded_matrix< T, F, A >, Id, Enable > {
 
+ // The ublas banded row_major format corresponds to the LAPACK band format.
+ // LAPACK is column_major; so we flip the data order reported by uBLAS.
     typedef typename copy_const< Id, T >::type value_type;
+ typedef typename if_row_major<
+ typename convert_to< tag::data_order, F >::type,
+ tag::column_major,
+ tag::row_major
+ >::type data_order;
     typedef mpl::map<
         mpl::pair< tag::value_type, value_type >,
         mpl::pair< tag::entity, tag::matrix >,
@@ -34,9 +43,13 @@
         mpl::pair< tag::size_type<2>, std::ptrdiff_t >,
         mpl::pair< tag::matrix_type, tag::band >,
         mpl::pair< tag::data_structure, tag::band_array >,
- mpl::pair< tag::data_order, typename convert_to< tag::data_order, F >::type >,
+ mpl::pair< tag::data_order, data_order >,
         mpl::pair< tag::bandwidth_type<1>, std::ptrdiff_t >,
- mpl::pair< tag::bandwidth_type<2>, std::ptrdiff_t >
+ mpl::pair< tag::bandwidth_type<2>, std::ptrdiff_t >,
+ 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( const Id& id ) {
@@ -65,6 +78,15 @@
         return id.upper();
     }
 
+ static std::ptrdiff_t stride1( const Id& id ) {
+ // ?
+ return 1;
+ }
+
+ static std::ptrdiff_t stride2( const Id& id ) {
+ return id.lower() + id.upper() + 1;
+ }
+
 };
 
 

Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/detail/basic_ublas_adaptor.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/detail/basic_ublas_adaptor.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/detail/basic_ublas_adaptor.hpp 2010-01-12 07:33:07 EST (Tue, 12 Jan 2010)
@@ -50,6 +50,17 @@
         return bindings::stride2( id.data() );
     }
 
+ // A.k.a. left half-bandwidth
+ static std::ptrdiff_t bandwidth1( const Id& id ) {
+ return bindings::bandwidth1( id.data() );
+ }
+
+ // A.k.a. right half-bandwidth
+ static std::ptrdiff_t bandwidth2( const Id& id ) {
+ return bindings::bandwidth2( id.data() );
+ }
+
+
 };
 
 } // detail

Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix_expression.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix_expression.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix_expression.hpp 2010-01-12 07:33:07 EST (Tue, 12 Jan 2010)
@@ -9,6 +9,7 @@
 #ifndef BOOST_NUMERIC_BINDINGS_UBLAS_MATRIX_EXPRESSION_HPP
 #define BOOST_NUMERIC_BINDINGS_UBLAS_MATRIX_EXPRESSION_HPP
 
+#include <boost/numeric/bindings/bandwidth.hpp>
 #include <boost/numeric/bindings/begin.hpp>
 #include <boost/numeric/bindings/detail/adaptor.hpp>
 #include <boost/numeric/bindings/detail/property_map.hpp>
@@ -51,6 +52,14 @@
         return bindings::stride2( id.expression() );
     }
 
+ static std::ptrdiff_t bandwidth1( const Id& id ) {
+ return bindings::bandwidth1( id.expression() );
+ }
+
+ static std::ptrdiff_t bandwidth2( const Id& id ) {
+ return bindings::bandwidth2( id.expression() );
+ }
+
 };
 
 } // namespace detail

Modified: sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix_proxy.hpp
==============================================================================
--- sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix_proxy.hpp (original)
+++ sandbox/numeric_bindings/boost/numeric/bindings/ublas/matrix_proxy.hpp 2010-01-12 07:33:07 EST (Tue, 12 Jan 2010)
@@ -54,6 +54,14 @@
         return bindings::stride2( id.data() );
     }
 
+ static std::ptrdiff_t bandwidth1( const Id& id ) {
+ return bindings::bandwidth1( id.data() );
+ }
+
+ static std::ptrdiff_t bandwidth2( const Id& id ) {
+ return bindings::bandwidth2( id.data() );
+ }
+
 };
 
 } // namespace detail


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