From 6ad45f69ae570958607ae0d7799bebf5b2bd81d5 Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Tue, 5 Jul 2005 19:42:18 +0000 Subject: [PATCH] FIX const correctness of projections restored [SVN r29898] --- .../boost/numeric/ublas/matrix_expression.hpp | 28 +++++++++++-------- .../boost/numeric/ublas/vector_expression.hpp | 12 ++++---- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/include/boost/numeric/ublas/matrix_expression.hpp b/include/boost/numeric/ublas/matrix_expression.hpp index c668bee7..66f3e80e 100644 --- a/include/boost/numeric/ublas/matrix_expression.hpp +++ b/include/boost/numeric/ublas/matrix_expression.hpp @@ -53,11 +53,17 @@ namespace boost { namespace numeric { namespace ublas { private: // projection types typedef vector_range vector_range_type; + typedef const vector_range const_vector_range_type; typedef vector_slice vector_slice_type; + typedef const vector_slice const vector_slice_type; typedef matrix_row matrix_row_type; + typedef const matrix_row const_matrix_row_type; typedef matrix_column matrix_column_type; + typedefconst matrix_column const_matrix_column_type; typedef matrix_range matrix_range_type; + typedef const matrix_range const_matrix_range_type; typedef matrix_slice matrix_slice_type; + typedef const matrix_slice const_matrix_slice_type; // matrix_indirect_type will depend on the A template parameter typedef basic_range<> default_range; typedef basic_slice<> default_slice; @@ -65,7 +71,7 @@ namespace boost { namespace numeric { namespace ublas { public: // projection functions - projects must be constructable from default size_t, range and slice types BOOST_UBLAS_INLINE - const matrix_row_type operator [] (std::size_t i) const { + const_matrix_row_type operator [] (std::size_t i) const { return matrix_row_type (operator () (), i); } BOOST_UBLAS_INLINE @@ -73,7 +79,7 @@ namespace boost { namespace numeric { namespace ublas { return matrix_row_type (operator () (), i); } BOOST_UBLAS_INLINE - const matrix_row_type row (std::size_t i) const { + const_matrix_row_type row (std::size_t i) const { return matrix_row_type (operator () (), i); } BOOST_UBLAS_INLINE @@ -81,7 +87,7 @@ namespace boost { namespace numeric { namespace ublas { return matrix_row_type (operator () (), i); } BOOST_UBLAS_INLINE - const matrix_column_type column (std::size_t j) const { + const_matrix_column_type column (std::size_t j) const { return matrix_column_type (operator () (), j); } BOOST_UBLAS_INLINE @@ -89,7 +95,7 @@ namespace boost { namespace numeric { namespace ublas { return matrix_column_type (operator () (), j); } BOOST_UBLAS_INLINE - const matrix_range_type range (std::size_t start1, std::size_t stop1, std::size_t start2, std::size_t stop2) const { + const_matrix_range_type range (std::size_t start1, std::size_t stop1, std::size_t start2, std::size_t stop2) const { return matrix_range_type (operator () (), default_range (start1, stop1), default_range (start2, stop2)); } BOOST_UBLAS_INLINE @@ -97,7 +103,7 @@ namespace boost { namespace numeric { namespace ublas { return matrix_range_type (operator () (), default_range (start1, stop1), default_range (start2, stop2)); } BOOST_UBLAS_INLINE - const matrix_slice_type slice (std::size_t start1, std::ptrdiff_t stride1, std::size_t size1, std::size_t start2, std::ptrdiff_t stride2, std::size_t size2) const { + const_matrix_slice_type slice (std::size_t start1, std::ptrdiff_t stride1, std::size_t size1, std::size_t start2, std::ptrdiff_t stride2, std::size_t size2) const { return matrix_slice_type (operator () (), default_slice (start1, stride1, size1), default_slice (start2, stride2, size2)); } BOOST_UBLAS_INLINE @@ -106,7 +112,7 @@ namespace boost { namespace numeric { namespace ublas { } #ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS BOOST_UBLAS_INLINE - const matrix_range_type operator () (const default_range &r1, const default_range &r2) const { + const_matrix_range_type operator () (const default_range &r1, const default_range &r2) const { return matrix_range_type (operator () (), r1, r2); } BOOST_UBLAS_INLINE @@ -114,7 +120,7 @@ namespace boost { namespace numeric { namespace ublas { return matrix_range_type (operator () (), r1, r2); } BOOST_UBLAS_INLINE - const matrix_slice_type operator () (const default_slice &s1, const default_slice &s2) const { + const_matrix_slice_type operator () (const default_slice &s1, const default_slice &s2) const { return matrix_slice_type (operator () (), s1, s2); } BOOST_UBLAS_INLINE @@ -123,7 +129,7 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - const matrix_indirect operator () (const indirect_array &ia1, const indirect_array &ia2) const { + const_matrix_indirect operator () (const indirect_array &ia1, const indirect_array &ia2) const { return matrix_indirect (operator () (), ia1, ia2); } template @@ -133,7 +139,7 @@ namespace boost { namespace numeric { namespace ublas { } #endif BOOST_UBLAS_INLINE - const matrix_range_type project (const default_range &r1, const default_range &r2) const { + const_matrix_range_type project (const default_range &r1, const default_range &r2) const { return matrix_range_type (operator () (), r1, r2); } BOOST_UBLAS_INLINE @@ -141,7 +147,7 @@ namespace boost { namespace numeric { namespace ublas { return matrix_range_type (operator () (), r1, r2); } BOOST_UBLAS_INLINE - const matrix_slice_type project (const default_slice &s1, const default_slice &s2) const { + const_matrix_slice_type project (const default_slice &s1, const default_slice &s2) const { return matrix_slice_type (operator () (), s1, s2); } BOOST_UBLAS_INLINE @@ -150,7 +156,7 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - const matrix_indirect project (const indirect_array &ia1, const indirect_array &ia2) const { + const_matrix_indirect project (const indirect_array &ia1, const indirect_array &ia2) const { return matrix_indirect (operator () (), ia1, ia2); } template diff --git a/include/boost/numeric/ublas/vector_expression.hpp b/include/boost/numeric/ublas/vector_expression.hpp index 366bdc94..45147eb3 100644 --- a/include/boost/numeric/ublas/vector_expression.hpp +++ b/include/boost/numeric/ublas/vector_expression.hpp @@ -200,14 +200,16 @@ namespace boost { namespace numeric { namespace ublas { private: // projection types typedef vector_range vector_range_type; + typedef const vector_range const_vector_range_type; typedef vector_slice vector_slice_type; + typedef const vector_slice const_vector_slice_type; // vector_indirect_type will depend on the A template parameter typedef basic_range<> default_range; typedef basic_slice<> default_slice; public: // projection functions - projects must be constructable from default size_t, range and slice types BOOST_UBLAS_INLINE - const vector_range_type range (std::size_t start, std::size_t stop) const { + const_vector_range_type range (std::size_t start, std::size_t stop) const { return vector_range_type (operator () (), default_range (start, stop)); } BOOST_UBLAS_INLINE @@ -216,7 +218,7 @@ namespace boost { namespace numeric { namespace ublas { } #ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS BOOST_UBLAS_INLINE - const vector_range_type operator () (const default_range &r) const { + const_vector_range_type operator () (const default_range &r) const { return vector_range_type (operator () (), r); } BOOST_UBLAS_INLINE @@ -224,7 +226,7 @@ namespace boost { namespace numeric { namespace ublas { return vector_range_type (operator () (), r); } BOOST_UBLAS_INLINE - const vector_slice_type operator () (const default_slice &s) const { + const_vector_slice_type operator () (const default_slice &s) const { return vector_slice_type (operator () (), s); } BOOST_UBLAS_INLINE @@ -243,7 +245,7 @@ namespace boost { namespace numeric { namespace ublas { } #endif BOOST_UBLAS_INLINE - const vector_range_type project (const default_range &r) const { + const_vector_range_type project (const default_range &r) const { return vector_range_type (operator () (), r); } BOOST_UBLAS_INLINE @@ -251,7 +253,7 @@ namespace boost { namespace numeric { namespace ublas { return vector_range_type (operator () (), r); } BOOST_UBLAS_INLINE - const vector_slice_type project (const default_slice &s) const { + const_vector_slice_type project (const default_slice &s) const { return vector_slice_type (operator () (), s); } BOOST_UBLAS_INLINE