From b3465b4c7a5941402fada7da2ead199d3543b09d Mon Sep 17 00:00:00 2001 From: nasos Date: Fri, 2 Aug 2013 13:27:10 -0400 Subject: [PATCH] Added a new majority_from_orientation traits type and modifed baded_adaptor to reflect the new layout scheme --- include/boost/numeric/ublas/banded.hpp | 17 ++++++++++++++--- include/boost/numeric/ublas/traits.hpp | 13 +++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/include/boost/numeric/ublas/banded.hpp b/include/boost/numeric/ublas/banded.hpp index 45e0e321..525b283d 100644 --- a/include/boost/numeric/ublas/banded.hpp +++ b/include/boost/numeric/ublas/banded.hpp @@ -245,6 +245,7 @@ public: #endif return zero_; } + BOOST_UBLAS_INLINE reference at_element (size_type i, size_type j) { BOOST_UBLAS_CHECK (i < size1_, bad_index ()); @@ -1151,6 +1152,7 @@ public: public matrix_expression > { typedef banded_adaptor self_type; + typedef majority_from_orientation closure_layout_type; public: #ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS using matrix_expression::operator (); @@ -1226,12 +1228,15 @@ public: if (k < (std::max) (size1 (), size2 ()) && l < lower_ + 1 + upper_) return data () (i, j); -#else +#elif BOOST_UBLAS_LEGACY_BANDED size_type k = j; size_type l = upper_ + i - j; if (k < size2 () && l < lower_ + 1 + upper_) return data () (i, j); +#else + if (hidden::banded_indexing::valid_index(size1(), size2(), lower_, upper_, i, j)) + return data () (i, j); #endif return zero_; } @@ -1245,12 +1250,15 @@ public: if (k < (std::max) (size1 (), size2 ()) && l < lower_ + 1 + upper_) return data () (i, j); -#else +#elif BOOST_UBLAS_LEGACY_BANDED size_type k = j; size_type l = upper_ + i - j; if (k < size2 () && l < lower_ + 1 + upper_) return data () (i, j); +#else + if (hidden::banded_indexing::valid_index(size1(), size2(), lower_, upper_, i, j)) + return data () (i, j); #endif #ifndef BOOST_UBLAS_REFERENCE_CONST_MEMBER bad_index ().raise (); @@ -1268,12 +1276,15 @@ public: if (k < (std::max) (size1 (), size2 ()) && l < lower_ + 1 + upper_) return data () (i, j); -#else +#elif BOOST_UBLAS_LEGACY_BANDED size_type k = j; size_type l = upper_ + i - j; if (k < size2 () && l < lower_ + 1 + upper_) return data () (i, j); +#else + if (hidden::banded_indexing::valid_index(size1(), size2(), lower_, upper_, i, j)) + return data () (i, j); #endif #ifndef BOOST_UBLAS_REFERENCE_CONST_MEMBER bad_index ().raise (); diff --git a/include/boost/numeric/ublas/traits.hpp b/include/boost/numeric/ublas/traits.hpp index ae020700..2777fc2c 100644 --- a/include/boost/numeric/ublas/traits.hpp +++ b/include/boost/numeric/ublas/traits.hpp @@ -747,6 +747,19 @@ namespace boost { namespace numeric { namespace ublas { // Note: specializations for T[N] and T[M][N] have been moved to traits/c_array.hpp + template + struct majority_from_orientation { }; + + template <> + struct majority_from_orientation { + typedef column_major type; + }; + + template <> + struct majority_from_orientation { + typedef row_major type; + }; + }}} #endif