Boost logo

Boost-Commit :

From: thomas.klimpel_at_[hidden]
Date: 2008-04-08 17:57:00


Author: klimpel
Date: 2008-04-08 17:57:00 EDT (Tue, 08 Apr 2008)
New Revision: 44115
URL: http://svn.boost.org/trac/boost/changeset/44115

Log:
enriched ublas_ordering to solve problems with one1 and one2 for ublas

looked at ublas-banded format in detail:
-row_major is indeed the same as the lapack format
-The strides should now also be correct fur column_major,
 but this is not important, since only row_major will work with lapack
-The macro BOOST_UBLAS_OWN_BANDED should not be defined (currently not checked),
 since the corresponding format doesn't allow to define strides.

Text files modified:
   sandbox/boost/numeric/bindings/traits/detail/ublas_ordering.hpp | 40 ++++++++++++++++++++++++++++++++++++++++
   sandbox/boost/numeric/bindings/traits/ublas_banded.hpp | 11 ++++-------
   2 files changed, 44 insertions(+), 7 deletions(-)

Modified: sandbox/boost/numeric/bindings/traits/detail/ublas_ordering.hpp
==============================================================================
--- sandbox/boost/numeric/bindings/traits/detail/ublas_ordering.hpp (original)
+++ sandbox/boost/numeric/bindings/traits/detail/ublas_ordering.hpp 2008-04-08 17:57:00 EDT (Tue, 08 Apr 2008)
@@ -68,6 +68,46 @@
       }
     };
 
+ template <typename StOrdTag>
+ struct ublas_banded_ordering {};
+
+ template<>
+ struct ublas_banded_ordering<boost::numeric::ublas::row_major_tag> {
+
+ template <typename M>
+ static int leading_dimension( M const& m ) {
+ return m.lower() + m.upper() + 1 ;
+ }
+
+ template <typename M>
+ static int stride1( M const& m ) {
+ return 1 ;
+ }
+
+ template <typename M>
+ static int stride2( M const& m ) {
+ return leading_dimension(m)-1 ;
+ }
+ };
+
+ template<>
+ struct ublas_banded_ordering<boost::numeric::ublas::column_major_tag> {
+
+ template <typename M>
+ static int leading_dimension( M const& m ) {
+ return m.size2() ;
+ }
+
+ template <typename M>
+ static int stride1( M const& m ) {
+ return leading_dimension(m) ;
+ }
+
+ template <typename M>
+ static int stride2( M const& m ) {
+ return 1-leading_dimension(m) ;
+ }
+ };
   }
 
 }}}}

Modified: sandbox/boost/numeric/bindings/traits/ublas_banded.hpp
==============================================================================
--- sandbox/boost/numeric/bindings/traits/ublas_banded.hpp (original)
+++ sandbox/boost/numeric/bindings/traits/ublas_banded.hpp 2008-04-08 17:57:00 EDT (Tue, 08 Apr 2008)
@@ -74,22 +74,19 @@
     static int upper_bandwidth (matrix_type& m) { return m.upper() ; }
     static int storage_size (matrix_type& m) { return size1 (m) * size2 (m); }
     static int leading_dimension (matrix_type& m) {
- // g++ 2.95.4 and 3.0.4 (with -pedantic) dislike
- // identifier_type::functor_type::size2()
- return lower_bandwidth(m) + upper_bandwidth(m) + 1 ;
+ typedef typename identifier_type::orientation_category orientation_category;
+ return detail::ublas_banded_ordering<orientation_category>::leading_dimension(m) ;
     }
 
     // stride1 == distance (m (i, j), m (i+1, j))
     static int stride1 (matrix_type& m) {
       typedef typename identifier_type::orientation_category orientation_category;
- typedef typename detail::ublas_ordering<orientation_category>::functor_type functor_t ;
- return functor_t::one2 ( std::max(m.size1(), m.size2()), leading_dimension(m)-1 ) ;
+ return detail::ublas_banded_ordering<orientation_category>::stride1(m) ;
     }
     // stride2 == distance (m (i, j), m (i, j+1))
     static int stride2 (matrix_type& m) {
       typedef typename identifier_type::orientation_category orientation_category;
- typedef typename detail::ublas_ordering<orientation_category>::functor_type functor_t ;
- return functor_t::one1 ( std::max(m.size1(), m.size2()), leading_dimension(m)-1 ) ;
+ return detail::ublas_banded_ordering<orientation_category>::stride2(m) ;
     }
   };
 


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