From 4e4e2a4959cf1ce35d069797cc1dd9873c41b103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Walter?= Date: Tue, 12 Aug 2003 08:56:47 +0000 Subject: [PATCH] Maintenance release. svn path=/trunk/boost/boost/numeric/ublas/; revision=19544 --- Jamfile | 5 +- bench1/Jamfile | 3 +- bench1/bench1.hpp | 2 +- bench2/Jamfile | 1 + bench3/Jamfile | 1 + bench4/Jamfile | 1 + include/boost/numeric/ublas/banded.hpp | 194 ++--- include/boost/numeric/ublas/concepts.hpp | 36 +- include/boost/numeric/ublas/config.hpp | 45 +- include/boost/numeric/ublas/functional.hpp | 31 +- include/boost/numeric/ublas/hermitian.hpp | 244 +++---- include/boost/numeric/ublas/iterator.hpp | 78 ++- include/boost/numeric/ublas/lu.hpp | 136 +++- include/boost/numeric/ublas/matrix.hpp | 501 +++++-------- include/boost/numeric/ublas/matrix_assign.hpp | 42 +- .../boost/numeric/ublas/matrix_expression.hpp | 562 ++++++--------- include/boost/numeric/ublas/matrix_proxy.hpp | 547 +++++++-------- include/boost/numeric/ublas/matrix_sparse.hpp | 492 +++++-------- include/boost/numeric/ublas/new.hpp | 51 ++ include/boost/numeric/ublas/raw.hpp | 663 +++++++++++++++++- include/boost/numeric/ublas/storage.hpp | 373 ++++++++-- .../boost/numeric/ublas/storage_sparse.hpp | 140 ++-- include/boost/numeric/ublas/symmetric.hpp | 242 +++---- include/boost/numeric/ublas/traits.hpp | 80 +-- include/boost/numeric/ublas/triangular.hpp | 223 +++--- include/boost/numeric/ublas/vector.hpp | 113 +-- include/boost/numeric/ublas/vector_assign.hpp | 18 +- .../boost/numeric/ublas/vector_expression.hpp | 188 ++--- include/boost/numeric/ublas/vector_proxy.hpp | 179 ++--- include/boost/numeric/ublas/vector_sparse.hpp | 164 ++--- test1/Jamfile | 1 + test2/Jamfile | 1 + test3/Jamfile | 1 + test4/Jamfile | 1 + test4/test43.cpp | 8 +- test5/Jamfile | 1 + test6/Jamfile | 1 + test7/Jamfile | 1 + 38 files changed, 2854 insertions(+), 2516 deletions(-) create mode 100644 include/boost/numeric/ublas/new.hpp diff --git a/Jamfile b/Jamfile index 09c5a9b6..8d04bc99 100644 --- a/Jamfile +++ b/Jamfile @@ -32,7 +32,10 @@ SOURCES = concepts ; exe concepts : $(SOURCES).cpp : $(BOOST_ROOT) - : EXTERNAL + $(BOOST_ROOT) + EXTERNAL +# <*>"-fabi-version=0" + <*>"-Xc" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" ; diff --git a/bench1/Jamfile b/bench1/Jamfile index 26b99cb5..06cd6372 100644 --- a/bench1/Jamfile +++ b/bench1/Jamfile @@ -24,7 +24,8 @@ exe bench1 $(BOOST_ROOT) # "-s -static -fomit-frame-pointer -fexpensive-optimizations -funroll-loops -malign-double -fschedule-insns2 -march=pentium4 -msse -mfpmath=sse -finline-functions -finline-limit=2048" # "-Xc" - "-march=pentium4" +# <*>"-fabi-version=0" + "-unroll -march=pentium4 -Zp16" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" ; diff --git a/bench1/bench1.hpp b/bench1/bench1.hpp index 8b63941a..350fb94e 100644 --- a/bench1/bench1.hpp +++ b/bench1/bench1.hpp @@ -159,7 +159,7 @@ struct bench_3 { struct safe_tag {}; struct fast_tag {}; -// #define USE_FLOAT +#define USE_FLOAT #define USE_DOUBLE // #define USE_STD_COMPLEX diff --git a/bench2/Jamfile b/bench2/Jamfile index 63a9c016..4afca8a2 100644 --- a/bench2/Jamfile +++ b/bench2/Jamfile @@ -22,6 +22,7 @@ exe bench2 : $(SOURCES).cpp : $(BOOST_ROOT) $(BOOST_ROOT) +# <*>"-fabi-version=0" <*>"-Xc" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" diff --git a/bench3/Jamfile b/bench3/Jamfile index 9dbd1ffa..1682b3cb 100644 --- a/bench3/Jamfile +++ b/bench3/Jamfile @@ -22,6 +22,7 @@ exe bench3 : $(SOURCES).cpp : $(BOOST_ROOT) $(BOOST_ROOT) +# <*>"-fabi-version=0" <*>"-Xc" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" diff --git a/bench4/Jamfile b/bench4/Jamfile index d7631121..b8853a67 100644 --- a/bench4/Jamfile +++ b/bench4/Jamfile @@ -23,6 +23,7 @@ exe bench4 : $(BOOST_ROOT) $(BOOST_ROOT) BOOST_UBLAS_USE_INTERVAL +# <*>"-fabi-version=0" <*>"-Xc" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" diff --git a/include/boost/numeric/ublas/banded.hpp b/include/boost/numeric/ublas/banded.hpp index 84dd8578..af43ec68 100644 --- a/include/boost/numeric/ublas/banded.hpp +++ b/include/boost/numeric/ublas/banded.hpp @@ -63,25 +63,28 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE banded_matrix (size_type size1, size_type size2, size_type lower = 0, size_type upper = 0): size1_ (size1), size2_ (size2), - lower_ (lower), upper_ (upper), - data_ (std::max (size1, size2) * (lower + 1 + upper)) {} + lower_ (lower), upper_ (upper), data_ (0) { + resize (size1, size2, lower, upper); + } BOOST_UBLAS_INLINE - banded_matrix (size_type size1, size_type size2, size_type lower, size_type upper, const array_type &data): + banded_matrix (size_type size1, size_type size2, size_type lower, size_type upper, const array_type &data): size1_ (size1), size2_ (size2), - lower_ (lower), upper_ (upper), - data_ (data) {} + lower_ (lower), upper_ (upper), data_ (data) {} BOOST_UBLAS_INLINE - banded_matrix (const banded_matrix &m): - size1_ (m.size1_), size2_ (m.size2_), - lower_ (m.lower_), upper_ (m.upper_), - data_ (m.data_) {} + banded_matrix (const banded_matrix &m): + size1_ (m.size1_), size2_ (m.size2_), + lower_ (m.lower_), upper_ (m.upper_), data_ (m.data_) {} template BOOST_UBLAS_INLINE - banded_matrix (const matrix_expression &ae, size_type lower = 0, size_type upper = 0): + banded_matrix (const matrix_expression &ae, size_type lower = 0, size_type upper = 0): size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), - lower_ (lower), upper_ (upper), - data_ (std::max (ae ().size1 (), ae ().size2 ()) * (lower + 1 + upper)) { - matrix_assign (scalar_assign (), *this, ae); + lower_ (lower), upper_ (upper), data_ (0) { +#ifndef BOOST_UBLAS_TYPE_CHECK + resize (ae ().size1 (), ae ().size2 (), lower, upper, false); +#else + resize (ae ().size1 (), ae ().size2 (), lower, upper, true); +#endif + matrix_assign (scalar_assign (), *this, ae); } // Accessors @@ -112,12 +115,12 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size1, size_type size2, size_type lower = 0, size_type upper = 0) { + void resize (size_type size1, size_type size2, size_type lower = 0, size_type upper = 0, bool preserve = true) { size1_ = size1; size2_ = size2; lower_ = lower; upper_ = upper; - data ().resize (std::max (size1, size2) * (lower + 1 + upper)); + detail::resize (data (), std::max (size1, size2) * (lower + 1 + upper), preserve); } // Element access @@ -204,7 +207,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE banded_matrix &reset (const matrix_expression &ae) { self_type temporary (ae, lower_, upper_); - resize (temporary.size1 (), temporary.size2 (), lower_, upper_); + resize (temporary.size1 (), temporary.size2 (), lower_, upper_, false); return assign_temporary (temporary); } template @@ -407,38 +410,6 @@ namespace boost { namespace numeric { namespace ublas { } return iterator2 (*this, i, j); } - BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j); - } // Iterators simply are indices. @@ -511,14 +482,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator2 begin () const { - return (*this) ().find_first2 (1, it1_, 0); + return (*this) ().find2 (1, it1_, 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { - return (*this) ().find_first2 (1, it1_, (*this) ().size2 ()); + return (*this) ().find2 (1, it1_, (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -577,11 +548,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -648,14 +619,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator2 begin () const { - return (*this) ().find_first2 (1, it1_, 0); + return (*this) ().find2 (1, it1_, 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator2 end () const { - return (*this) ().find_first2 (1, it1_, (*this) ().size2 ()); + return (*this) ().find2 (1, it1_, (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -716,11 +687,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -792,14 +763,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator1 begin () const { - return (*this) ().find_first1 (1, 0, it2_); + return (*this) ().find1 (1, 0, it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), it2_); + return (*this) ().find1 (1, (*this) ().size1 (), it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -858,11 +829,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -929,14 +900,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator1 begin () const { - return (*this) ().find_first1 (1, 0, it2_); + return (*this) ().find1 (1, 0, it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), it2_); + return (*this) ().find1 (1, (*this) ().size1 (), it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -997,11 +968,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } // Reverse iterators @@ -1258,7 +1229,7 @@ namespace boost { namespace numeric { namespace ublas { // Raising exceptions abstracted as requested during review. // throw external_logic (); external_logic ().raise (); -#endif +#endif return zero_; } #endif @@ -1323,6 +1294,11 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // Comparison + bool operator == (const banded_adaptor &ba) const { + return (*this).data () == ba.data (); + } + // Swapping BOOST_UBLAS_INLINE void swap (banded_adaptor &m) { @@ -1366,84 +1342,44 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { + const_iterator1 find1 (int rank, size_type i, size_type j) const { if (rank == 1) { size_type lower_i = std::max (difference_type (j - upper_), difference_type (0)); i = std::max (i, lower_i); size_type upper_i = std::min (j + 1 + lower_, size1 ()); i = std::min (i, upper_i); } - return const_iterator1 (*this, data ().find_first1 (rank, i, j)); + return const_iterator1 (*this, data ().find1 (rank, i, j)); } BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { + iterator1 find1 (int rank, size_type i, size_type j) { if (rank == 1) { size_type lower_i = std::max (difference_type (j - upper_), difference_type (0)); i = std::max (i, lower_i); size_type upper_i = std::min (j + 1 + lower_, size1 ()); i = std::min (i, upper_i); } - return iterator1 (*this, data ().find_first1 (rank, i, j)); + return iterator1 (*this, data ().find1 (rank, i, j)); } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - if (rank == 1) { - size_type lower_i = std::max (difference_type (j - upper_), difference_type (0)); - i = std::max (i, lower_i); - size_type upper_i = std::min (j + 1 + lower_, size1 ()); - i = std::min (i, upper_i); - } - return const_iterator1 (*this, data ().find_last1 (rank, i, j)); - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - if (rank == 1) { - size_type lower_i = std::max (difference_type (j - upper_), difference_type (0)); - i = std::max (i, lower_i); - size_type upper_i = std::min (j + 1 + lower_, size1 ()); - i = std::min (i, upper_i); - } - return iterator1 (*this, data ().find_last1 (rank, i, j)); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { + const_iterator2 find2 (int rank, size_type i, size_type j) const { if (rank == 1) { size_type lower_j = std::max (difference_type (i - lower_), difference_type (0)); j = std::max (j, lower_j); size_type upper_j = std::min (i + 1 + upper_, size2 ()); j = std::min (j, upper_j); } - return const_iterator2 (*this, data ().find_first2 (rank, i, j)); + return const_iterator2 (*this, data ().find2 (rank, i, j)); } BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { + iterator2 find2 (int rank, size_type i, size_type j) { if (rank == 1) { size_type lower_j = std::max (difference_type (i - lower_), difference_type (0)); j = std::max (j, lower_j); size_type upper_j = std::min (i + 1 + upper_, size2 ()); j = std::min (j, upper_j); } - return iterator2 (*this, data ().find_first2 (rank, i, j)); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - if (rank == 1) { - size_type lower_j = std::max (difference_type (i - lower_), difference_type (0)); - j = std::max (j, lower_j); - size_type upper_j = std::min (i + 1 + upper_, size2 ()); - j = std::min (j, upper_j); - } - return const_iterator2 (*this, data ().find_last2 (rank, i, j)); - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { - if (rank == 1) { - size_type lower_j = std::max (difference_type (i - lower_), difference_type (0)); - j = std::max (j, lower_j); - size_type upper_j = std::min (i + 1 + upper_, size2 ()); - j = std::min (j, upper_j); - } - return iterator2 (*this, data ().find_last2 (rank, i, j)); + return iterator2 (*this, data ().find2 (rank, i, j)); } // Iterators simply are indices. @@ -1536,14 +1472,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator2 begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1598,11 +1534,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1689,14 +1625,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator2 begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator2 end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1753,11 +1689,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1848,14 +1784,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator1 begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1910,11 +1846,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -2001,14 +1937,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator1 begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -2065,11 +2001,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } // Reverse iterators diff --git a/include/boost/numeric/ublas/concepts.hpp b/include/boost/numeric/ublas/concepts.hpp index 1b696102..5584b040 100644 --- a/include/boost/numeric/ublas/concepts.hpp +++ b/include/boost/numeric/ublas/concepts.hpp @@ -589,8 +589,7 @@ namespace boost { namespace numeric { namespace ublas { size_type n (0), i (0); value_type t = value_type (); // Find (internal?) - const_iterator_type cit_lower (v.find_first (i)); - const_iterator_type cit_upper (v.find_last (i)); + const_iterator_type cit (v.find (i)); // Beginning of range const_iterator_type cit_begin (v.begin ()); // End of range @@ -613,8 +612,7 @@ namespace boost { namespace numeric { namespace ublas { // Element access t = v (i); ignore_unused_variable_warning (n); - ignore_unused_variable_warning (cit_lower); - ignore_unused_variable_warning (cit_upper); + ignore_unused_variable_warning (cit); ignore_unused_variable_warning (cit_begin); ignore_unused_variable_warning (cit_end); ignore_unused_variable_warning (crit_begin); @@ -638,8 +636,7 @@ namespace boost { namespace numeric { namespace ublas { size_type i (0); value_type t = value_type (); // Find (internal?) - iterator_type it_lower (v.find_first (i)); - iterator_type it_upper (v.find_last (i)); + iterator_type it (v.find (i)); // Beginning of range iterator_type it_begin (v.begin ()); // End of range @@ -658,8 +655,7 @@ namespace boost { namespace numeric { namespace ublas { v2 -= v1; v2.minus_assign (v1); v *= t; - ignore_unused_variable_warning (it_lower); - ignore_unused_variable_warning (it_upper); + ignore_unused_variable_warning (it); ignore_unused_variable_warning (it_begin); ignore_unused_variable_warning (it_end); ignore_unused_variable_warning (rit_begin); @@ -684,10 +680,8 @@ namespace boost { namespace numeric { namespace ublas { size_type n (0), i (0), j (0); value_type t = value_type (); // Find (internal?) - const_iterator1_type cit1_lower (m.find_first1 (0, i, j)); - const_iterator1_type cit1_upper (m.find_last1 (0, i, j)); - const_iterator2_type cit2_lower (m.find_first2 (0, i, j)); - const_iterator2_type cit2_upper (m.find_last2 (0, i, j)); + const_iterator1_type cit1 (m.find1 (0, i, j)); + const_iterator2_type cit2 (m.find2 (0, i, j)); // Beginning of range const_iterator1_type cit1_begin (m.begin1 ()); const_iterator2_type cit2_begin (m.begin2 ()); @@ -717,10 +711,8 @@ namespace boost { namespace numeric { namespace ublas { // Element access t = m (i, j); ignore_unused_variable_warning (n); - ignore_unused_variable_warning (cit1_lower); - ignore_unused_variable_warning (cit1_upper); - ignore_unused_variable_warning (cit2_lower); - ignore_unused_variable_warning (cit2_upper); + ignore_unused_variable_warning (cit1); + ignore_unused_variable_warning (cit2); ignore_unused_variable_warning (cit1_begin); ignore_unused_variable_warning (cit2_begin); ignore_unused_variable_warning (cit1_end); @@ -750,10 +742,8 @@ namespace boost { namespace numeric { namespace ublas { size_type i (0), j (0); value_type t = value_type (); // Find (internal?) - iterator1_type it1_lower (m.find_first1 (0, i, j)); - iterator1_type it1_upper (m.find_last1 (0, i, j)); - iterator2_type it2_lower (m.find_first2 (0, i, j)); - iterator2_type it2_upper (m.find_last2 (0, i, j)); + iterator1_type it1 (m.find1 (0, i, j)); + iterator2_type it2 (m.find2 (0, i, j)); // Beginning of range iterator1_type it1_begin (m.begin1 ()); iterator2_type it2_begin (m.begin2 ()); @@ -776,10 +766,8 @@ namespace boost { namespace numeric { namespace ublas { m2 -= m1; m2.minus_assign (m1); m *= t; - ignore_unused_variable_warning (it1_lower); - ignore_unused_variable_warning (it1_upper); - ignore_unused_variable_warning (it2_lower); - ignore_unused_variable_warning (it2_upper); + ignore_unused_variable_warning (it1); + ignore_unused_variable_warning (it2); ignore_unused_variable_warning (it1_begin); ignore_unused_variable_warning (it2_begin); ignore_unused_variable_warning (it1_end); diff --git a/include/boost/numeric/ublas/config.hpp b/include/boost/numeric/ublas/config.hpp index cda142b1..5d2a1e9c 100644 --- a/include/boost/numeric/ublas/config.hpp +++ b/include/boost/numeric/ublas/config.hpp @@ -90,12 +90,10 @@ // typedef signed ptrdiff_t; // // template -// BOOST_UBLAS_INLINE // const T &max (const T &t1, const T &t2) { // return t1 > t2 ? t1 : t2; // } // template -// BOOST_UBLAS_INLINE // const T &min (const T &t1, const T &t2) { // return t1 < t2 ? t1 : t2; // } @@ -219,6 +217,28 @@ namespace std { #define BOOST_UBLAS_USE_SIMD +namespace boost { namespace numeric { namespace ublas { + + template + class index_pair; + template + class index_triple; + +}}} + +namespace std { + + template + void swap(boost::numeric::ublas::index_pair i1, boost::numeric::ublas::index_pair i2) { + i1.swap(i2); + } + template + void swap(boost::numeric::ublas::index_triple i1, boost::numeric::ublas::index_triple i2) { + i1.swap(i2); + } + +} + #endif @@ -329,6 +349,12 @@ namespace std { #ifdef BOOST_UBLAS_TYPE_CHECK static bool disable_type_check = false; #endif +#ifndef BOOST_UBLAS_TYPE_CHECK_EPSILON +#define BOOST_UBLAS_TYPE_CHECK_EPSILON (type_traits::sqrt (std::numeric_limits::epsilon ())) +#endif +#ifndef BOOST_UBLAS_TYPE_CHECK_MIN +#define BOOST_UBLAS_TYPE_CHECK_MIN (std::numeric_limits::min ()) +#endif @@ -347,6 +373,10 @@ static bool disable_type_check = false; // Use indexed iterators. // #define BOOST_UBLAS_USE_INDEXED_ITERATOR +// 16 byte aligned arrays (for ICC) +// #define BOOST_UBLAS_ALIGN_16 __declspec (align (16)) +#define BOOST_UBLAS_ALIGN_16 + namespace boost { @@ -526,21 +556,21 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE closure_type &operator= (const E& e) { - lval_.expression ().assign (e); + lval_.assign (e); return lval_; } template BOOST_UBLAS_INLINE closure_type &operator+= (const E& e) { - lval_.expression ().plus_assign (e); + lval_.plus_assign (e); return lval_; } template BOOST_UBLAS_INLINE closure_type &operator-= (const E& e) { - lval_.expression ().minus_assign (e); + lval_.minus_assign (e); return lval_; } @@ -555,6 +585,11 @@ namespace boost { namespace numeric { namespace ublas { noalias_proxy noalias (C& lvalue) { return noalias_proxy (lvalue); } + template + BOOST_UBLAS_INLINE + noalias_proxy noalias (const C& lvalue) { + return noalias_proxy (lvalue); + } template typename V::size_type num_elements (const V &v) { diff --git a/include/boost/numeric/ublas/functional.hpp b/include/boost/numeric/ublas/functional.hpp index f9742bff..e3e554cd 100644 --- a/include/boost/numeric/ublas/functional.hpp +++ b/include/boost/numeric/ublas/functional.hpp @@ -19,6 +19,13 @@ #include +#ifdef BOOST_UBLAS_HAVE_BINDINGS +#include +#include +#include +#include +#endif + #include #include #include @@ -599,12 +606,13 @@ namespace boost { namespace numeric { namespace ublas { result_type operator () (const vector_expression &e1, const vector_expression &e2, concrete_tag) const { +#ifndef BOOST_UBLAS_HAVE_BINDINGS size_type size (BOOST_UBLAS_SAME (e1 ().size (), e2 ().size ())); - result_type t (0); const T1 *data1 = data_const (e1 ()); const T2 *data2 = data_const (e2 ()); size_type s1 = stride (e1 ()); size_type s2 = stride (e2 ()); + result_type t (0); if (s1 == 1 && s2 == 1) { for (size_type i = 0; i < size; ++ i) t += data1 [i] * data2 [i]; @@ -619,6 +627,9 @@ namespace boost { namespace numeric { namespace ublas { t += data1 [i1] * data2 [i2]; } return t; +#else + return boost::numeric::bindings::atlas::dot (e1 (), e2 ()); +#endif } template BOOST_UBLAS_INLINE @@ -735,12 +746,13 @@ namespace boost { namespace numeric { namespace ublas { result_type operator () (const matrix_expression &e1, const vector_expression &e2, size_type i, concrete_tag) const { +#ifndef BOOST_UBLAS_HAVE_BINDINGS size_type size = BOOST_UBLAS_SAME (e1 ().size2 (), e2 ().size ()); - result_type t (0); const T1 *data1 = data_const (e1 ()) + i * stride1 (e1 ()); const T2 *data2 = data_const (e2 ()); size_type s1 = stride2 (e1 ()); size_type s2 = stride (e2 ()); + result_type t (0); if (s1 == 1 && s2 == 1) { for (size_type j = 0; j < size; ++ j) t += data1 [j] * data2 [j]; @@ -755,6 +767,9 @@ namespace boost { namespace numeric { namespace ublas { t += data1 [j1] * data2 [j2]; } return t; +#else + return boost::numeric::bindings::atlas::dot (e1 ().row (i), e2 ()); +#endif } template BOOST_UBLAS_INLINE @@ -882,12 +897,13 @@ namespace boost { namespace numeric { namespace ublas { result_type operator () (const vector_expression &e1, const matrix_expression &e2, size_type i, concrete_tag) const { +#ifndef BOOST_UBLAS_HAVE_BINDINGS size_type size = BOOST_UBLAS_SAME (e1 ().size (), e2 ().size1 ()); - result_type t (0); const T1 *data1 = data_const (e1 ()); const T2 *data2 = data_const (e2 ()) + i * stride2 (e2 ()); size_type s1 = stride (e1 ()); size_type s2 = stride1 (e2 ()); + result_type t (0); if (s1 == 1 && s2 == 1) { for (size_type j = 0; j < size; ++ j) t += data1 [j] * data2 [j]; @@ -902,6 +918,9 @@ namespace boost { namespace numeric { namespace ublas { t += data1 [j1] * data2 [j2]; } return t; +#else + return boost::numeric::bindings::atlas::dot (e1 (), e2 ().column (i)); +#endif } template BOOST_UBLAS_INLINE @@ -1038,12 +1057,13 @@ namespace boost { namespace numeric { namespace ublas { result_type operator () (const matrix_expression &e1, const matrix_expression &e2, size_type i, size_type j, concrete_tag) const { +#ifndef BOOST_UBLAS_HAVE_BINDINGS size_type size = BOOST_UBLAS_SAME (e1 ().size2 (), e2 ().size1 ()); - result_type t (0); const T1 *data1 = data_const (e1 ()) + i * stride1 (e1 ()); const T2 *data2 = data_const (e2 ()) + j * stride2 (e2 ()); size_type s1 = stride2 (e1 ()); size_type s2 = stride1 (e2 ()); + result_type t (0); if (s1 == 1 && s2 == 1) { for (size_type k = 0; k < size; ++ k) t += data1 [k] * data2 [k]; @@ -1058,6 +1078,9 @@ namespace boost { namespace numeric { namespace ublas { t += data1 [k1] * data2 [k2]; } return t; +#else + return boost::numeric::bindings::atlas::dot (e1 ().row (i), e2 ().column (j)); +#endif } template BOOST_UBLAS_INLINE diff --git a/include/boost/numeric/ublas/hermitian.hpp b/include/boost/numeric/ublas/hermitian.hpp index 02ea3f0e..61c69290 100644 --- a/include/boost/numeric/ublas/hermitian.hpp +++ b/include/boost/numeric/ublas/hermitian.hpp @@ -229,29 +229,32 @@ namespace boost { namespace numeric { namespace ublas { // Construction and destruction BOOST_UBLAS_INLINE hermitian_matrix (): - size_ (0), - data_ (0) {} + size_ (0), data_ (0) {} BOOST_UBLAS_INLINE hermitian_matrix (size_type size): - size_ (BOOST_UBLAS_SAME (size, size)), - data_ (functor1_type::packed_size (size, size)) {} + size_ (BOOST_UBLAS_SAME (size, size)), data_ (0) { + resize (size); + } BOOST_UBLAS_INLINE hermitian_matrix (size_type size1, size_type size2): - size_ (BOOST_UBLAS_SAME (size1, size2)), - data_ (functor1_type::packed_size (size1, size2)) {} + size_ (BOOST_UBLAS_SAME (size1, size2)), data_ (0) { + resize (size1, size2); + } BOOST_UBLAS_INLINE - hermitian_matrix (size_type size, const array_type &data): - size_ (size), - data_ (data) {} + hermitian_matrix (size_type size, const array_type &data): + size_ (size), data_ (data) {} BOOST_UBLAS_INLINE - hermitian_matrix (const hermitian_matrix &m): - size_ (m.size_), - data_ (m.data_) {} + hermitian_matrix (const hermitian_matrix &m): + size_ (m.size_), data_ (m.data_) {} template BOOST_UBLAS_INLINE - hermitian_matrix (const matrix_expression &ae): - size_ (BOOST_UBLAS_SAME (ae ().size1 (), ae ().size2 ())), - data_ (functor1_type::packed_size (ae ().size1 (), ae ().size2 ())) { + hermitian_matrix (const matrix_expression &ae): + size_ (BOOST_UBLAS_SAME (ae ().size1 (), ae ().size2 ())), data_ (0) { +#ifndef BOOST_UBLAS_TYPE_CHECK + resize (ae ().size1 (), ae ().size2 (), false); +#else + resize (ae ().size1 (), ae ().size2 (), true); +#endif matrix_assign (scalar_assign (), *this, ae); } @@ -275,14 +278,14 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size) { + void resize (size_type size, bool preserve = true) { size_ = BOOST_UBLAS_SAME (size, size); - data ().resize (functor1_type::packed_size (size, size)); + detail::resize (data (), functor1_type::packed_size (size, size), preserve); } BOOST_UBLAS_INLINE - void resize (size_type size1, size_type size2) { + void resize (size_type size1, size_type size2, bool preserve = true) { size_ = BOOST_UBLAS_SAME (size1, size2); - data ().resize (functor1_type::packed_size (size1, size2)); + detail::resize (data (), functor1_type::packed_size (size1, size2), preserve); } // Element access @@ -360,7 +363,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE hermitian_matrix &reset (const matrix_expression &ae) { self_type temporary (ae); - resize (temporary.size1 (), temporary.size2 ()); + resize (temporary.size1 (), temporary.size2 (), false); return assign_temporary (temporary); } template @@ -514,41 +517,21 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { + const_iterator1 find1 (int rank, size_type i, size_type j) const { return const_iterator1 (*this, i, j); } BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { + iterator1 find1 (int rank, size_type i, size_type j) { if (rank == 1) i = functor1_type::restrict1 (i, j); return iterator1 (*this, i, j); } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - return const_iterator1 (*this, i, j); - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - if (rank == 1) - i = functor1_type::restrict1 (i, j); - return iterator1 (*this, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { + const_iterator2 find2 (int rank, size_type i, size_type j) const { return const_iterator2 (*this, i, j); } BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { - if (rank == 1) - j = functor1_type::restrict2 (i, j); - return iterator2 (*this, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - return const_iterator2 (*this, i, j); - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { + iterator2 find2 (int rank, size_type i, size_type j) { if (rank == 1) j = functor1_type::restrict2 (i, j); return iterator2 (*this, i, j); @@ -625,14 +608,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator2 begin () const { - return (*this) ().find_first2 (1, it1_, 0); + return (*this) ().find2 (1, it1_, 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { - return (*this) ().find_first2 (1, it1_, (*this) ().size2 ()); + return (*this) ().find2 (1, it1_, (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -691,11 +674,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size_, 0); + return find1 (0, size_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -762,14 +745,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator2 begin () const { - return (*this) ().find_first2 (1, it1_, 0); + return (*this) ().find2 (1, it1_, 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator2 end () const { - return (*this) ().find_first2 (1, it1_, (*this) ().size2 ()); + return (*this) ().find2 (1, it1_, (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -830,11 +813,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size_, 0); + return find1 (0, size_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -906,14 +889,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator1 begin () const { - return (*this) ().find_first1 (1, 0, it2_); + return (*this) ().find1 (1, 0, it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), it2_); + return (*this) ().find1 (1, (*this) ().size1 (), it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -972,11 +955,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size_); + return find2 (0, 0, size_); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1043,14 +1026,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator1 begin () const { - return (*this) ().find_first1 (1, 0, it2_); + return (*this) ().find1 (1, 0, it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), it2_); + return (*this) ().find1 (1, (*this) ().size1 (), it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1111,11 +1094,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size_); + return find2 (0, 0, size_); } // Reverse iterators @@ -1438,6 +1421,11 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // Comparison + bool operator == (const hermitian_adaptor &ha) const { + return (*this).data () == ha.data (); + } + // Swapping BOOST_UBLAS_INLINE void swap (hermitian_adaptor &m) { @@ -1478,124 +1466,64 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { + const_iterator1 find1 (int rank, size_type i, size_type j) const { if (functor_type::other (i, j)) { if (functor_type::other (size1 (), j)) { return const_iterator1 (*this, 0, 0, - data ().find_first1 (rank, i, j), data ().find_first1 (rank, size1 (), j), - data ().find_first2 (rank, size2 (), size1 ()), data ().find_first2 (rank, size2 (), size1 ())); + data ().find1 (rank, i, j), data ().find1 (rank, size1 (), j), + data ().find2 (rank, size2 (), size1 ()), data ().find2 (rank, size2 (), size1 ())); } else { return const_iterator1 (*this, 0, 1, - data ().find_first1 (rank, i, j), data ().find_first1 (rank, j, j), - data ().find_first2 (rank, j, j), data ().find_first2 (rank, j, size1 ())); + data ().find1 (rank, i, j), data ().find1 (rank, j, j), + data ().find2 (rank, j, j), data ().find2 (rank, j, size1 ())); } } else { if (functor_type::other (size1 (), j)) { return const_iterator1 (*this, 1, 0, - data ().find_first1 (rank, j, j), data ().find_first1 (rank, size1 (), j), - data ().find_first2 (rank, j, i), data ().find_first2 (rank, j, j)); + data ().find1 (rank, j, j), data ().find1 (rank, size1 (), j), + data ().find2 (rank, j, i), data ().find2 (rank, j, j)); } else { return const_iterator1 (*this, 1, 1, - data ().find_first1 (rank, size1 (), size2 ()), data ().find_first1 (rank, size1 (), size2 ()), - data ().find_first2 (rank, j, i), data ().find_first2 (rank, j, size1 ())); + data ().find1 (rank, size1 (), size2 ()), data ().find1 (rank, size1 (), size2 ()), + data ().find2 (rank, j, i), data ().find2 (rank, j, size1 ())); } } } BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { + iterator1 find1 (int rank, size_type i, size_type j) { if (rank == 1) i = functor_type::restrict1 (i, j); - return iterator1 (*this, data ().find_first1 (rank, i, j)); + return iterator1 (*this, data ().find1 (rank, i, j)); } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - if (functor_type::other (i, j)) { - if (functor_type::other (size1 (), j)) { - return const_iterator1 (*this, 0, 0, - data ().find_last1 (rank, i, j), data ().find_last1 (rank, size1 (), j), - data ().find_last2 (rank, size2 (), size1 ()), data ().find_last2 (rank, size2 (), size1 ())); - } else { - return const_iterator1 (*this, 0, 1, - data ().find_last1 (rank, i, j), data ().find_last1 (rank, j, j), - data ().find_last2 (rank, j, j), data ().find_last2 (rank, j, size1 ())); - } - } else { - if (functor_type::other (size1 (), j)) { - return const_iterator1 (*this, 1, 0, - data ().find_last1 (rank, j, j), data ().find_last1 (rank, size1 (), j), - data ().find_last2 (rank, j, i), data ().find_last2 (rank, j, j)); - } else { - return const_iterator1 (*this, 1, 1, - data ().find_last1 (rank, size1 (), size2 ()), data ().find_last1 (rank, size1 (), size2 ()), - data ().find_last2 (rank, j, i), data ().find_last2 (rank, j, size1 ())); - } - } - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - if (rank == 1) - i = functor_type::restrict1 (i, j); - return iterator1 (*this, data ().find_last1 (rank, i, j)); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { + const_iterator2 find2 (int rank, size_type i, size_type j) const { if (functor_type::other (i, j)) { if (functor_type::other (i, size2 ())) { return const_iterator2 (*this, 1, 1, - data ().find_first1 (rank, size2 (), size1 ()), data ().find_first1 (rank, size2 (), size1 ()), - data ().find_first2 (rank, i, j), data ().find_first2 (rank, i, size2 ())); + data ().find1 (rank, size2 (), size1 ()), data ().find1 (rank, size2 (), size1 ()), + data ().find2 (rank, i, j), data ().find2 (rank, i, size2 ())); } else { return const_iterator2 (*this, 1, 0, - data ().find_first1 (rank, i, i), data ().find_first1 (rank, size2 (), i), - data ().find_first2 (rank, i, j), data ().find_first2 (rank, i, i)); + data ().find1 (rank, i, i), data ().find1 (rank, size2 (), i), + data ().find2 (rank, i, j), data ().find2 (rank, i, i)); } } else { if (functor_type::other (i, size2 ())) { return const_iterator2 (*this, 0, 1, - data ().find_first1 (rank, j, i), data ().find_first1 (rank, i, i), - data ().find_first2 (rank, i, i), data ().find_first2 (rank, i, size2 ())); + data ().find1 (rank, j, i), data ().find1 (rank, i, i), + data ().find2 (rank, i, i), data ().find2 (rank, i, size2 ())); } else { return const_iterator2 (*this, 0, 0, - data ().find_first1 (rank, j, i), data ().find_first1 (rank, size2 (), i), - data ().find_first2 (rank, size1 (), size2 ()), data ().find_first2 (rank, size2 (), size2 ())); + data ().find1 (rank, j, i), data ().find1 (rank, size2 (), i), + data ().find2 (rank, size1 (), size2 ()), data ().find2 (rank, size2 (), size2 ())); } } } BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { + iterator2 find2 (int rank, size_type i, size_type j) { if (rank == 1) j = functor_type::restrict2 (i, j); - return iterator2 (*this, data ().find_first2 (rank, i, j)); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - if (functor_type::other (i, j)) { - if (functor_type::other (i, size2 ())) { - return const_iterator2 (*this, 1, 1, - data ().find_last1 (rank, size2 (), size1 ()), data ().find_last1 (rank, size2 (), size1 ()), - data ().find_last2 (rank, i, j), data ().find_last2 (rank, i, size2 ())); - } else { - return const_iterator2 (*this, 1, 0, - data ().find_last1 (rank, i, i), data ().find_last1 (rank, size2 (), i), - data ().find_last2 (rank, i, j), data ().find_last2 (rank, i, i)); - } - } else { - if (functor_type::other (i, size2 ())) { - return const_iterator2 (*this, 0, 1, - data ().find_last1 (rank, j, i), data ().find_last1 (rank, i, i), - data ().find_last2 (rank, i, i), data ().find_last2 (rank, i, size2 ())); - } else { - return const_iterator2 (*this, 0, 0, - data ().find_last1 (rank, j, i), data ().find_last1 (rank, size2 (), i), - data ().find_last2 (rank, size1 (), size2 ()), data ().find_last2 (rank, size2 (), size2 ())); - } - } - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { - if (rank == 1) - j = functor_type::restrict2 (i, j); - return iterator2 (*this, data ().find_last2 (rank, i, j)); + return iterator2 (*this, data ().find2 (rank, i, j)); } // Iterators simply are indices. @@ -1816,14 +1744,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator2 begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1912,11 +1840,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1986,14 +1914,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator2 begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator2 end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -2050,11 +1978,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -2273,14 +2201,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator1 begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -2369,11 +2297,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -2443,14 +2371,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator1 begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -2507,11 +2435,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } // Reverse iterators diff --git a/include/boost/numeric/ublas/iterator.hpp b/include/boost/numeric/ublas/iterator.hpp index 1e648c23..69ec3946 100644 --- a/include/boost/numeric/ublas/iterator.hpp +++ b/include/boost/numeric/ublas/iterator.hpp @@ -1119,10 +1119,12 @@ namespace boost { namespace numeric { namespace ublas { return it_; } - // Assignment + // Assignment BOOST_UBLAS_INLINE indexed_iterator &operator = (const indexed_iterator &it) { - assign (&it ()); + // FIX: ICC needs full qualification?! + // assign (&it ()); + container_reference::assign (&it ()); it_ = it.it_; return *this; } @@ -1133,6 +1135,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); return it_ == it.it_; } + BOOST_UBLAS_INLINE + bool operator < (const indexed_iterator &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ < it.it_; + } private: size_type it_; @@ -1238,10 +1245,12 @@ namespace boost { namespace numeric { namespace ublas { return it_; } - // Assignment + // Assignment BOOST_UBLAS_INLINE indexed_const_iterator &operator = (const indexed_const_iterator &it) { - assign (&it ()); + // FIX: ICC needs full qualification?! + // assign (&it ()); + container_const_reference::assign (&it ()); it_ = it.it_; return *this; } @@ -1252,6 +1261,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); return it_ == it.it_; } + BOOST_UBLAS_INLINE + bool operator < (const indexed_const_iterator &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + return it_ < it.it_; + } private: size_type it_; @@ -1372,11 +1386,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE dual_iterator_type begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE dual_iterator_type end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE dual_reverse_iterator_type rbegin () const { @@ -1390,7 +1404,9 @@ namespace boost { namespace numeric { namespace ublas { // Assignment BOOST_UBLAS_INLINE indexed_iterator1 &operator = (const indexed_iterator1 &it) { - assign (&it ()); + // FIX: ICC needs full qualification?! + // assign (&it ()); + container_reference::assign (&it ()); it1_ = it.it1_; it2_ = it.it2_; return *this; @@ -1403,6 +1419,12 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); return it1_ == it.it1_; } + BOOST_UBLAS_INLINE + bool operator < (const indexed_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); + return it1_ < it.it1_; + } private: size_type it1_; @@ -1526,11 +1548,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE dual_iterator_type begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE dual_iterator_type end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE dual_reverse_iterator_type rbegin () const { @@ -1544,7 +1566,9 @@ namespace boost { namespace numeric { namespace ublas { // Assignment BOOST_UBLAS_INLINE indexed_const_iterator1 &operator = (const indexed_const_iterator1 &it) { - assign (&it ()); + // FIX: ICC needs full qualification?! + // assign (&it ()); + container_const_reference::assign (&it ()); it1_ = it.it1_; it2_ = it.it2_; return *this; @@ -1557,6 +1581,12 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); return it1_ == it.it1_; } + BOOST_UBLAS_INLINE + bool operator < (const indexed_const_iterator1 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); + return it1_ < it.it1_; + } private: size_type it1_; @@ -1675,11 +1705,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE dual_iterator_type begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE dual_iterator_type end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE dual_reverse_iterator_type rbegin () const { @@ -1693,7 +1723,9 @@ namespace boost { namespace numeric { namespace ublas { // Assignment BOOST_UBLAS_INLINE indexed_iterator2 &operator = (const indexed_iterator2 &it) { - assign (&it ()); + // FIX: ICC needs full qualification?! + // assign (&it ()); + container_reference::assign (&it ()); it1_ = it.it1_; it2_ = it.it2_; return *this; @@ -1706,6 +1738,12 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); return it2_ == it.it2_; } + BOOST_UBLAS_INLINE + bool operator < (const indexed_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); + return it2_ < it.it2_; + } private: size_type it1_; @@ -1826,11 +1864,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE dual_iterator_type begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE dual_iterator_type end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE dual_reverse_iterator_type rbegin () const { @@ -1844,7 +1882,9 @@ namespace boost { namespace numeric { namespace ublas { // Assignment BOOST_UBLAS_INLINE indexed_const_iterator2 &operator = (const indexed_const_iterator2 &it) { - assign (&it ()); + // FIX: ICC needs full qualification?! + // assign (&it ()); + container_const_reference::assign (&it ()); it1_ = it.it1_; it2_ = it.it2_; return *this; @@ -1857,6 +1897,12 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); return it2_ == it.it2_; } + BOOST_UBLAS_INLINE + bool operator < (const indexed_const_iterator2 &it) const { + BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); + return it2_ < it.it2_; + } private: size_type it1_; diff --git a/include/boost/numeric/ublas/lu.hpp b/include/boost/numeric/ublas/lu.hpp index 3e26d7f2..9de5ec84 100644 --- a/include/boost/numeric/ublas/lu.hpp +++ b/include/boost/numeric/ublas/lu.hpp @@ -14,12 +14,14 @@ // GeNeSys mbH & Co. KG in producing this work. // +// LU factorizations in the spirit of LAPACK and Golub & van Loan + #ifndef BOOST_UBLAS_LU_H #define BOOST_UBLAS_LU_H namespace boost { namespace numeric { namespace ublas { - template > + template > class permutation_matrix: public vector { public: @@ -75,6 +77,41 @@ namespace boost { namespace numeric { namespace ublas { swap_rows (pm, mv, BOOST_UBLAS_TYPENAME MV::type_category ()); } + // LU factorization without pivoting + template + typename M::size_type lu_factorize (M &m) { + typedef M matrix_type; + typedef BOOST_UBLAS_TYPENAME M::size_type size_type; + typedef BOOST_UBLAS_TYPENAME M::value_type value_type; + +#ifdef BOOST_UBLAS_TYPE_CHECK + matrix_type cm (m); +#endif + int singular = 0; + size_type size1 = m.size1 (); + size_type size2 = m.size2 (); + size_type size = std::min (size1, size2); + for (size_type i = 0; i < size; ++ i) { + matrix_column mci (column (m, i)); + matrix_row mri (row (m, i)); + if (m (i, i) != value_type ()) { + project (mci, range (i + 1, size1)) *= value_type (1) / m (i, i); + } else if (singular == 0) { + singular = i + 1; + } + project (m, range (i + 1, size1), range (i + 1, size2)).minus_assign ( + outer_prod (project (mci, range (i + 1, size1)), + project (mri, range (i + 1, size2)))); + } +#ifdef BOOST_UBLAS_TYPE_CHECK + BOOST_UBLAS_CHECK (singular != 0 || + equals (prod (triangular_adaptor (m), + triangular_adaptor (m)), cm), internal_logic ()); +#endif + return singular; + } + + // LU factorization with partial pivoting template typename M::size_type lu_factorize (M &m, PM &pm) { typedef M matrix_type; @@ -209,47 +246,88 @@ namespace boost { namespace numeric { namespace ublas { return singular; } + // LU substitution + template + void lu_substitute (const M &m, vector_expression &e) { + typedef const M const_matrix_type; + typedef vector vector_type; + +#ifdef BOOST_UBLAS_TYPE_CHECK + vector_type cv1 (e); +#endif + inplace_solve (m, e, unit_lower_tag ()); +#ifdef BOOST_UBLAS_TYPE_CHECK + BOOST_UBLAS_CHECK (equals (prod (triangular_adaptor (m), e), cv1), internal_logic ()); + vector_type cv2 (e); +#endif + inplace_solve (m, e, upper_tag ()); +#ifdef BOOST_UBLAS_TYPE_CHECK + BOOST_UBLAS_CHECK (equals (prod (triangular_adaptor (m), e), cv2), internal_logic ()); +#endif + } + template + void lu_substitute (const M &m, matrix_expression &e) { + typedef const M const_matrix_type; + typedef matrix matrix_type; + +#ifdef BOOST_UBLAS_TYPE_CHECK + matrix_type cm1 (e); +#endif + inplace_solve (m, e, unit_lower_tag ()); +#ifdef BOOST_UBLAS_TYPE_CHECK + BOOST_UBLAS_CHECK (equals (prod (triangular_adaptor (m), e), cm1), internal_logic ()); + matrix_type cm2 (e); +#endif + inplace_solve (m, e, upper_tag ()); +#ifdef BOOST_UBLAS_TYPE_CHECK + BOOST_UBLAS_CHECK (equals (prod (triangular_adaptor (m), e), cm2), internal_logic ()); +#endif + } template void lu_substitute (const M &m, const permutation_matrix &pm, MV &mv) { - typedef const M const_matrix_type; - typedef typename boost::mpl::if_c::value, - vector, - matrix >::type matrix_vector_type; - swap_rows (pm, mv); + lu_substitute (m, mv); + } + template + void lu_substitute (vector_expression &e, const M &m) { + typedef const M const_matrix_type; + typedef vector vector_type; + #ifdef BOOST_UBLAS_TYPE_CHECK - matrix_vector_type cmv1 (mv); + vector_type cv1 (e); #endif - inplace_solve (m, mv, unit_lower_tag ()); + inplace_solve (e, m, upper_tag ()); #ifdef BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (equals (prod (triangular_adaptor (m), mv), cmv1), internal_logic ()); - matrix_vector_type cmv2 (mv); + BOOST_UBLAS_CHECK (equals (prod (e, triangular_adaptor (m)), cv1), internal_logic ()); + vector_type cv2 (e); #endif - inplace_solve (m, mv, upper_tag ()); + inplace_solve (e, m, unit_lower_tag ()); #ifdef BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (equals (prod (triangular_adaptor (m), mv), cmv2), internal_logic ()); + BOOST_UBLAS_CHECK (equals (prod (e, triangular_adaptor (m)), cv2), internal_logic ()); +#endif + } + template + void lu_substitute (matrix_expression &e, const M &m) { + typedef const M const_matrix_type; + typedef matrix matrix_type; + +#ifdef BOOST_UBLAS_TYPE_CHECK + matrix_type cm1 (e); +#endif + inplace_solve (e, m, upper_tag ()); +#ifdef BOOST_UBLAS_TYPE_CHECK + BOOST_UBLAS_CHECK (equals (prod (e, triangular_adaptor (m)), cm1), internal_logic ()); + matrix_type cm2 (e); +#endif + inplace_solve (e, m, unit_lower_tag ()); +#ifdef BOOST_UBLAS_TYPE_CHECK + BOOST_UBLAS_CHECK (equals (prod (e, triangular_adaptor (m)), cm2), internal_logic ()); #endif } template void lu_substitute (MV &mv, const M &m, const permutation_matrix &pm) { - typedef const M const_matrix_type; - typedef typename boost::mpl::if_c::value, - vector, - matrix >::type matrix_vector_type; - swap_rows (pm, mv); -#ifdef BOOST_UBLAS_TYPE_CHECK - matrix_vector_type cmv1 (mv); -#endif - inplace_solve (mv, m, upper_tag ()); -#ifdef BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (equals (prod (mv, triangular_adaptor (m)), cmv1), internal_logic ()); - matrix_vector_type cmv2 (mv); -#endif - inplace_solve (mv, m, unit_lower_tag ()); -#ifdef BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (equals (prod (mv, triangular_adaptor (m)), cmv2), internal_logic ()); -#endif + lu_substitute (mv, m); } }}} diff --git a/include/boost/numeric/ublas/matrix.hpp b/include/boost/numeric/ublas/matrix.hpp index 5829d700..f89bf090 100644 --- a/include/boost/numeric/ublas/matrix.hpp +++ b/include/boost/numeric/ublas/matrix.hpp @@ -70,7 +70,9 @@ namespace boost { namespace numeric { namespace ublas { size1_ (0), size2_ (0), data_ (0) {} BOOST_UBLAS_INLINE matrix (size_type size1, size_type size2): - size1_ (size1), size2_ (size2), data_ (size1 * size2) {} + size1_ (size1), size2_ (size2), data_ (0) { + resize (size1, size2); + } BOOST_UBLAS_INLINE matrix (size_type size1, size_type size2, const array_type &data): size1_ (size1), size2_ (size2), data_ (data) {} @@ -80,7 +82,12 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE matrix (const matrix_expression &ae): - size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ (ae ().size1 () * ae ().size2 ()) { + size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ (0) { +#ifndef BOOST_UBLAS_TYPE_CHECK + resize (ae ().size1 (), ae ().size2 (), false); +#else + resize (ae ().size1 (), ae ().size2 (), true); +#endif matrix_assign (scalar_assign (), *this, ae); } @@ -104,10 +111,10 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size1, size_type size2) { + void resize (size_type size1, size_type size2, bool preserve = true) { size1_ = size1; size2_ = size2; - data ().resize (size1 * size2); + detail::resize (data (), size1 * size2, preserve); } // Element access @@ -151,7 +158,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE matrix &reset (const matrix_expression &ae) { self_type temporary (ae); - resize (temporary.size1 (), temporary.size2 ()); + resize (temporary.size1 (), temporary.size2 (), false); return assign_temporary (temporary); } template @@ -304,38 +311,6 @@ namespace boost { namespace numeric { namespace ublas { return iterator2 (*this, data ().begin () + functor_type::address (i, size1_, j, size2_)); #endif } - BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j); - } // Iterators simply are pointers. @@ -405,30 +380,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 begin () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator2 rbegin () const { return const_reverse_iterator2 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator2 rend () const { @@ -477,11 +452,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -545,30 +520,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator2 begin () const { self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator2 end () const { self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif reverse_iterator2 rbegin () const { return reverse_iterator2 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif reverse_iterator2 rend () const { @@ -617,11 +592,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -690,30 +665,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 begin () const { const self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { const self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator1 rbegin () const { return const_reverse_iterator1 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator1 rend () const { @@ -762,11 +737,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -830,30 +805,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator1 begin () const { self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator1 end () const { self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif reverse_iterator1 rbegin () const { return reverse_iterator1 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif reverse_iterator1 rend () const { @@ -902,11 +877,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } // Reverse iterators @@ -1021,26 +996,22 @@ namespace boost { namespace numeric { namespace ublas { // Construction and destruction BOOST_UBLAS_INLINE - vector_of_vector (): + vector_of_vector (): size1_ (0), size2_ (0), data_ (1) {} BOOST_UBLAS_INLINE - vector_of_vector (size_type size1, size_type size2): - size1_ (size1), size2_ (size2), - data_ (functor_type::size1 (size1, size2) + 1) { - for (size_type k = 0; k < functor_type::size1 (size1, size2); ++ k) - data_ [k].resize (functor_type::size2 (size1, size2)); + vector_of_vector (size_type size1, size_type size2): + size1_ (size1), size2_ (size2), data_ (1) { + resize (size1, size2); } BOOST_UBLAS_INLINE - vector_of_vector (const vector_of_vector &m): + vector_of_vector (const vector_of_vector &m): size1_ (m.size1_), size2_ (m.size2_), data_ (m.data_) {} template BOOST_UBLAS_INLINE - vector_of_vector (const matrix_expression &ae): - size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), - data_ (functor_type::size1 (ae ().size1 (), ae ().size2 ()) + 1) { - for (size_type k = 0; k < functor_type::size1 (ae ().size1 (), ae ().size2 ()); ++ k) - data_ [k].resize (functor_type::size2 (ae ().size1 (), ae ().size2 ())); - matrix_assign (scalar_assign (), *this, ae); + vector_of_vector (const matrix_expression &ae): + size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ (1) { + resize (ae ().size1 (), ae ().size2 (), false); + matrix_assign (scalar_assign (), *this, ae); } // Accessors @@ -1063,12 +1034,12 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size1, size_type size2) { + void resize (size_type size1, size_type size2, bool preserve = true) { size1_ = size1; size2_ = size2; - data ().resize (functor_type::size1 (size1, size2) + 1); + detail::resize (data (), functor_type::size1 (size1, size2) + 1, preserve); for (size_type k = 0; k < functor_type::size1 (size1, size2); ++ k) - data () [k].resize (functor_type::size2 (size1, size2)); + detail::resize (data () [k], functor_type::size2 (size1, size2), preserve); } // Element access @@ -1112,7 +1083,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE vector_of_vector &reset (const matrix_expression &ae) { self_type temporary (ae); - resize (temporary.size1 (), temporary.size2 ()); + resize (temporary.size1 (), temporary.size2 (), false); return assign_temporary (temporary); } template @@ -1264,38 +1235,6 @@ namespace boost { namespace numeric { namespace ublas { return iterator2 (*this, i, j, data () [functor_type::address1 (i, size1_, j, size2_)].begin () + functor_type::address2 (i, size1_, j, size2_)); #endif } - BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j); - } // Iterators simply are pointers. @@ -1380,30 +1319,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 begin () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator2 rbegin () const { return const_reverse_iterator2 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator2 rend () const { @@ -1454,11 +1393,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1537,30 +1476,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator2 begin () const { self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator2 end () const { self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif reverse_iterator2 rbegin () const { return reverse_iterator2 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif reverse_iterator2 rend () const { @@ -1611,11 +1550,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1699,30 +1638,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 begin () const { const self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { const self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator1 rbegin () const { return const_reverse_iterator1 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator1 rend () const { @@ -1773,11 +1712,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1856,30 +1795,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator1 begin () const { self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator1 end () const { self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif reverse_iterator1 rbegin () const { return reverse_iterator1 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif reverse_iterator1 rend () const { @@ -1930,11 +1869,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } // Reverse iterators @@ -2035,12 +1974,12 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size) { + void resize (size_type size, bool preserve = true) { size1_ = size; size2_ = size; } BOOST_UBLAS_INLINE - void resize (size_type size1, size_type size2) { + void resize (size_type size1, size_type size2, bool preserve = true) { size1_ = size1; size2_ = size2; } @@ -2106,7 +2045,7 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { + const_iterator1 find1 (int rank, size_type i, size_type j) const { if (rank == 1) { i = std::max (i, j); i = std::min (i, j + 1); @@ -2114,23 +2053,7 @@ namespace boost { namespace numeric { namespace ublas { return const_iterator1 (*this, i, j); } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - if (rank == 1) { - i = std::max (i, j); - i = std::min (i, j + 1); - } - return const_iterator1 (*this, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - if (rank == 1) { - j = std::max (j, i); - j = std::min (j, i + 1); - } - return const_iterator2 (*this, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { + const_iterator2 find2 (int rank, size_type i, size_type j) const { if (rank == 1) { j = std::max (j, i); j = std::min (j, i + 1); @@ -2204,30 +2127,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 begin () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator2 rbegin () const { return const_reverse_iterator2 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator2 rend () const { @@ -2278,11 +2201,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -2349,30 +2272,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 begin () const { const self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { const self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator1 rbegin () const { return const_reverse_iterator1 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator1 rend () const { @@ -2423,11 +2346,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } // Reverse iterators @@ -2516,12 +2439,12 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size) { + void resize (size_type size, bool preserve = true) { size1_ = size; size2_ = size; } BOOST_UBLAS_INLINE - void resize (size_type size1, size_type size2) { + void resize (size_type size1, size_type size2, bool preserve = true) { size1_ = size1; size2_ = size2; } @@ -2587,25 +2510,13 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { + const_iterator1 find1 (int rank, size_type i, size_type j) const { if (rank == 1) i = j; return const_iterator1 (*this, i, j); } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - if (rank == 1) - i = j; - return const_iterator1 (*this, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - if (rank == 1) - j = i; - return const_iterator2 (*this, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { + const_iterator2 find2 (int rank, size_type i, size_type j) const { if (rank == 1) j = i; return const_iterator2 (*this, i, j); @@ -2677,30 +2588,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 begin () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator2 rbegin () const { return const_reverse_iterator2 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator2 rend () const { @@ -2745,11 +2656,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -2816,30 +2727,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 begin () const { const self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { const self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator1 rbegin () const { return const_reverse_iterator1 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator1 rend () const { @@ -2890,11 +2801,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } // Reverse iterators @@ -2976,7 +2887,7 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size1, size_type size2) { + void resize (size_type size1, size_type size2, bool preserve = true) { size1_ = size1; size2_ = size2; } @@ -3051,22 +2962,6 @@ namespace boost { namespace numeric { namespace ublas { const_iterator2 find2 (int rank, size_type i, size_type j) const { return const_iterator2 (*this, i, j); } - BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j); - } // Iterators simply are indices. @@ -3134,30 +3029,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 begin () const { const scalar_matrix &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { const scalar_matrix &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator2 rbegin () const { return const_reverse_iterator2 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator2 rend () const { @@ -3208,11 +3103,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -3279,30 +3174,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 begin () const { const scalar_matrix &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { const scalar_matrix &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator1 rbegin () const { return const_reverse_iterator1 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator1 rend () const { @@ -3353,11 +3248,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } // Reverse iterators @@ -3471,12 +3366,12 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE pointer data () { - return data_; + return reinterpret_cast (data_); } // Resizing BOOST_UBLAS_INLINE - void resize (size_type size1, size_type size2) { + void resize (size_type size1, size_type size2, bool preserve = true) { if (size1 > N || size2 > M) // Raising exceptions abstracted as requested during review. // throw std::bad_alloc (); @@ -3530,9 +3425,9 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - c_matrix &reset (const matrix_expression &ae) { + c_matrix &reset (const matrix_expression &ae) { self_type temporary (ae); - resize (temporary.size1 (), temporary.size2 ()); + resize (temporary.size1 (), temporary.size2 (), false); return assign_temporary (temporary); } template @@ -3685,38 +3580,6 @@ namespace boost { namespace numeric { namespace ublas { return iterator2 (*this, &data_ [i] [j]); #endif } - BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j); - } // Iterators simply are pointers. @@ -3786,30 +3649,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 begin () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator2 rbegin () const { return const_reverse_iterator2 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator2 rend () const { @@ -3858,11 +3721,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -3926,30 +3789,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator2 begin () const { self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator2 end () const { self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif reverse_iterator2 rbegin () const { return reverse_iterator2 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif reverse_iterator2 rend () const { @@ -3998,11 +3861,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -4071,30 +3934,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 begin () const { const self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { const self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator1 rbegin () const { return const_reverse_iterator1 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_reverse_iterator1 rend () const { @@ -4143,11 +4006,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -4211,30 +4074,30 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator1 begin () const { self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator1 end () const { self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif reverse_iterator1 rbegin () const { return reverse_iterator1 (end ()); } BOOST_UBLAS_INLINE -#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif reverse_iterator1 rend () const { @@ -4283,11 +4146,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } // Reverse iterators diff --git a/include/boost/numeric/ublas/matrix_assign.hpp b/include/boost/numeric/ublas/matrix_assign.hpp index d0570f78..ee79b4d5 100644 --- a/include/boost/numeric/ublas/matrix_assign.hpp +++ b/include/boost/numeric/ublas/matrix_assign.hpp @@ -29,18 +29,16 @@ namespace boost { namespace numeric { namespace ublas { bool equals (const matrix_expression &e1, const matrix_expression &e2) { typedef BOOST_UBLAS_TYPENAME type_traits::promote_type>::real_type real_type; - // Check, that the values match at least half. - static real_type sqrt_epsilon (type_traits::sqrt (std::numeric_limits::epsilon ())); #ifndef __GNUC__ - return norm_inf (e1 - e2) < sqrt_epsilon * + return norm_inf (e1 - e2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (std::max (norm_inf (e1), norm_inf (e2)), - std::numeric_limits::min ()); + BOOST_UBLAS_TYPE_CHECK_MIN); #else // GCC 3.1, oops?! - return norm_inf (e1 - e2) < sqrt_epsilon * + return norm_inf (e1 - e2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (real_type (std::max (real_type (norm_inf (e1)), real_type (norm_inf (e2)))), - real_type (std::numeric_limits::min ())); + real_type (BOOST_UBLAS_TYPE_CHECK_MIN)); #endif } @@ -50,10 +48,10 @@ namespace boost { namespace numeric { namespace ublas { void restart (const matrix_expression &e, typename E::size_type index1, typename E::size_type index2, typename E::const_iterator1 &it1e, typename E::const_iterator1 &it1e_end, typename E::const_iterator2 &it2e, typename E::const_iterator2 &it2e_end, row_major_tag) { - it1e = e ().find_first1 (0, index1, 0); - it1e_end = e ().find_first1 (0, e ().size1 (), 0); - it2e = e ().find_first2 (1, index1, index2); - it2e_end = e ().find_first2 (1, index1, e ().size2 ()); + it1e = e ().find1 (0, index1, 0); + it1e_end = e ().find1 (0, e ().size1 (), 0); + it2e = e ().find2 (1, index1, index2); + it2e_end = e ().find2 (1, index1, e ().size2 ()); if (it2e != it2e_end && it2e.index2 () == index2) ++ it2e; } @@ -62,10 +60,10 @@ namespace boost { namespace numeric { namespace ublas { void restart (const matrix_expression &e, typename E::size_type index1, typename E::size_type index2, typename E::const_iterator2 &it2e, typename E::const_iterator2 &it2e_end, typename E::const_iterator1 &it1e, typename E::const_iterator1 &it1e_end, column_major_tag) { - it2e = e ().find_first2 (0, 0, index2); - it2e_end = e ().find_first2 (0, 0, e ().size2 ()); - it1e = e ().find_first1 (1, index1, index2); - it1e_end = e ().find_first1 (1, e ().size1 (), index2); + it2e = e ().find2 (0, 0, index2); + it2e_end = e ().find2 (0, 0, e ().size2 ()); + it1e = e ().find1 (1, index1, index2); + it1e_end = e ().find1 (1, e ().size1 (), index2); if (it1e != it1e_end && it1e.index1 () == index1) ++ it1e; } @@ -74,10 +72,10 @@ namespace boost { namespace numeric { namespace ublas { void restart (matrix_expression &e, typename E::size_type index1, typename E::size_type index2, typename E::iterator1 &it1e, typename E::iterator1 &it1e_end, typename E::iterator2 &it2e, typename E::iterator2 &it2e_end, row_major_tag) { - it1e = e ().find_first1 (0, index1, 0); - it1e_end = e ().find_first1 (0, e ().size1 (), 0); - it2e = e ().find_first2 (1, index1, index2); - it2e_end = e ().find_first2 (1, index1, e ().size2 ()); + it1e = e ().find1 (0, index1, 0); + it1e_end = e ().find1 (0, e ().size1 (), 0); + it2e = e ().find2 (1, index1, index2); + it2e_end = e ().find2 (1, index1, e ().size2 ()); if (it2e != it2e_end && it2e.index2 () == index2) ++ it2e; } @@ -86,10 +84,10 @@ namespace boost { namespace numeric { namespace ublas { void restart (matrix_expression &e, typename E::size_type index1, typename E::size_type index2, typename E::iterator2 &it2e, typename E::iterator2 &it2e_end, typename E::iterator1 &it1e, typename E::iterator1 &it1e_end, column_major_tag) { - it2e = e ().find_first2 (0, 0, index2); - it2e_end = e ().find_first2 (0, 0, e ().size2 ()); - it1e = e ().find_first1 (1, index1, index2); - it1e_end = e ().find_first1 (1, e ().size1 (), index2); + it2e = e ().find2 (0, 0, index2); + it2e_end = e ().find2 (0, 0, e ().size2 ()); + it1e = e ().find1 (1, index1, index2); + it1e_end = e ().find1 (1, e ().size1 (), index2); if (it1e != it1e_end && it1e.index1 () == index1) ++ it1e; } diff --git a/include/boost/numeric/ublas/matrix_expression.hpp b/include/boost/numeric/ublas/matrix_expression.hpp index 34c40c11..37f403f9 100644 --- a/include/boost/numeric/ublas/matrix_expression.hpp +++ b/include/boost/numeric/ublas/matrix_expression.hpp @@ -154,12 +154,12 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE typename I::dual_iterator_type begin (const I &it, iterator1_tag) { - return it ().find_first2 (1, it.index1 (), 0); + return it ().find2 (1, it.index1 (), 0); } template BOOST_UBLAS_INLINE typename I::dual_iterator_type end (const I &it, iterator1_tag) { - return it ().find_first2 (1, it.index1 (), it ().size2 ()); + return it ().find2 (1, it.index1 (), it ().size2 ()); } template BOOST_UBLAS_INLINE @@ -175,12 +175,12 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE typename I::dual_iterator_type begin (const I &it, iterator2_tag) { - return it ().find_first1 (1, 0, it.index2 ()); + return it ().find1 (1, 0, it.index2 ()); } template BOOST_UBLAS_INLINE typename I::dual_iterator_type end (const I &it, iterator2_tag) { - return it ().find_first1 (1, it ().size1 (), it.index2 ()); + return it ().find1 (1, it ().size1 (), it.index2 ()); } template BOOST_UBLAS_INLINE @@ -244,6 +244,12 @@ namespace boost { namespace numeric { namespace ublas { return expression () (i, j); } + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const matrix_const_reference &mr) const { + return &(*this).expression () == &mr.expression (); + } + typedef const_iterator1_type const_iterator1; typedef const_iterator1 iterator1; typedef const_iterator2_type const_iterator2; @@ -251,20 +257,12 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - return expression ().find_first1 (rank, i, j); + const_iterator1 find1 (int rank, size_type i, size_type j) const { + return expression ().find1 (rank, i, j); } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - return expression ().find_last1 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - return expression ().find_first2 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - return expression ().find_last2 (rank, i, j); + const_iterator2 find2 (int rank, size_type i, size_type j) const { + return expression ().find2 (rank, i, j); } // Iterators are the iterators of the referenced expression. @@ -357,11 +355,6 @@ namespace boost { namespace numeric { namespace ublas { typedef typename E::reference reference; typedef typename E::const_pointer const_pointer; typedef typename E::pointer pointer; - typedef typename E::orientation_category orientation_category; - typedef typename E::const_iterator1 const_iterator1_type; - typedef typename E::iterator1 iterator1_type; - typedef typename E::const_iterator2 const_iterator2_type; - typedef typename E::iterator2 iterator2_type; #else typedef typename E::const_reference const_reference; typedef typename boost::mpl::if_c::value, @@ -371,7 +364,18 @@ namespace boost { namespace numeric { namespace ublas { typedef typename boost::mpl::if_c::value, typename E::const_pointer, typename E::pointer>::type pointer; +#endif + typedef const matrix_reference const_self_type; + typedef matrix_reference self_type; + typedef const_self_type const_closure_type; + typedef const_closure_type closure_type; typedef typename E::orientation_category orientation_category; +#ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS + typedef typename E::const_iterator1 const_iterator1_type; + typedef typename E::iterator1 iterator1_type; + typedef typename E::const_iterator2 const_iterator2_type; + typedef typename E::iterator2 iterator2_type; +#else typedef typename E::const_iterator1 const_iterator1_type; typedef typename boost::mpl::if_c::value, typename E::const_iterator1, @@ -409,6 +413,12 @@ namespace boost { namespace numeric { namespace ublas { return e_; } + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const matrix_reference &mr) const { + return &(*this).expression () == &mr.expression (); + } + // Resizing #ifndef BOOST_UBLAS_REFERENCE_CONST_MEMBER BOOST_UBLAS_INLINE @@ -439,6 +449,62 @@ namespace boost { namespace numeric { namespace ublas { } #endif + // Assignment + template + BOOST_UBLAS_INLINE + matrix_reference &operator = (const matrix_expression &ae) { + expression ().operator = (ae); + return *this; + } + template + BOOST_UBLAS_INLINE + matrix_reference &reset (const matrix_expression &ae) { + expression ().reset (ae); + return *this; + } + template + BOOST_UBLAS_INLINE + matrix_reference &assign (const matrix_expression &ae) { + expression ().assign (ae); + return *this; + } + template + BOOST_UBLAS_INLINE + matrix_reference &operator += (const matrix_expression &ae) { + expression ().operator += (ae); + return *this; + } + template + BOOST_UBLAS_INLINE + matrix_reference &plus_assign (const matrix_expression &ae) { + expression ().plus_assign (ae); + return *this; + } + template + BOOST_UBLAS_INLINE + matrix_reference &operator -= (const matrix_expression &ae) { + expression ().operator -= (ae); + return *this; + } + template + BOOST_UBLAS_INLINE + matrix_reference &minus_assign (const matrix_expression &ae) { + expression ().minus_assign (ae); + return *this; + } + template + BOOST_UBLAS_INLINE + matrix_reference &operator *= (const AT &at) { + expression ().operator *= (at); + return *this; + } + template + BOOST_UBLAS_INLINE + matrix_reference &operator /= (const AT &at) { + expression ().operator /= (at); + return *this; + } + typedef const_iterator1_type const_iterator1; typedef iterator1_type iterator1; typedef const_iterator2_type const_iterator2; @@ -446,36 +512,20 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - return expression ().find_first1 (rank, i, j); + const_iterator1 find1 (int rank, size_type i, size_type j) const { + return expression ().find1 (rank, i, j); } BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { - return expression ().find_first1 (rank, i, j); + iterator1 find1 (int rank, size_type i, size_type j) { + return expression ().find1 (rank, i, j); } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - return expression ().find_last1 (rank, i, j); + const_iterator2 find2 (int rank, size_type i, size_type j) const { + return expression ().find2 (rank, i, j); } BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - return expression ().find_last1 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - return expression ().find_first2 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { - return expression ().find_first2 (rank, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - return expression ().find_last2 (rank, i, j); - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { - return expression ().find_last2 (rank, i, j); + iterator2 find2 (int rank, size_type i, size_type j) { + return expression ().find2 (rank, i, j); } // Iterators are the iterators of the referenced expression. @@ -669,11 +719,11 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - const_iterator1_type it1 (e1_.find_first (i)); - const_iterator1_type it1_end (e1_.find_first (size1 ())); - const_iterator2_type it2 (e2_.find_first (j)); - const_iterator2_type it2_end (e2_.find_first (size2 ())); + const_iterator1 find1 (int rank, size_type i, size_type j) const { + const_iterator1_type it1 (e1_.find (i)); + const_iterator1_type it1_end (e1_.find (size1 ())); + const_iterator2_type it2 (e2_.find (j)); + const_iterator2_type it2_end (e2_.find (size2 ())); if (it2 == it2_end || (rank == 1 && (it2.index () != j || *it2 == value_type ()))) { it1 = it1_end; it2 = it2_end; @@ -689,51 +739,11 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - const_iterator1_type it1 (e1_.find_last (i)); - const_iterator1_type it1_end (e1_.find_last (size1 ())); - const_iterator2_type it2 (e2_.find_first (j)); - const_iterator2_type it2_end (e2_.find_first (size2 ())); - if (it2 == it2_end || (rank == 1 && (it2.index () != j || *it2 == value_type ()))) { - it1 = it1_end; - it2 = it2_end; - } -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator1 (*this, it1.index (), it2.index ()); -#else -#ifdef BOOST_UBLAS_USE_INVARIANT_HOISTING - return const_iterator1 (*this, it1, it2, it2 != it2_end ? *it2 : value_type ()); -#else - return const_iterator1 (*this, it1, it2); -#endif -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - const_iterator2_type it2 (e2_.find_first (j)); - const_iterator2_type it2_end (e2_.find_first (size2 ())); - const_iterator1_type it1 (e1_.find_first (i)); - const_iterator1_type it1_end (e1_.find_first (size1 ())); - if (it1 == it1_end || (rank == 1 && (it1.index () != i || *it1 == value_type ()))) { - it2 = it2_end; - it1 = it1_end; - } -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator2 (*this, it1.index (), it2.index ()); -#else -#ifdef BOOST_UBLAS_USE_INVARIANT_HOISTING - return const_iterator2 (*this, it1, it2, it1 != it1_end ? *it1 : value_type ()); -#else - return const_iterator2 (*this, it1, it2); -#endif -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - const_iterator2_type it2 (e2_.find_last (j)); - const_iterator2_type it2_end (e2_.find_last (size2 ())); - const_iterator1_type it1 (e1_.find_first (i)); - const_iterator1_type it1_end (e1_.find_first (size1 ())); + const_iterator2 find2 (int rank, size_type i, size_type j) const { + const_iterator2_type it2 (e2_.find (j)); + const_iterator2_type it2_end (e2_.find (size2 ())); + const_iterator1_type it1 (e1_.find (i)); + const_iterator1_type it1_end (e1_.find (size1 ())); if (it1 == it1_end || (rank == 1 && (it1.index () != i || *it1 == value_type ()))) { it2 = it2_end; it1 = it1_end; @@ -839,14 +849,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator2 begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -915,11 +925,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1009,14 +1019,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator1 begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1085,11 +1095,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } // Reverse iterators @@ -1212,8 +1222,8 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - const_iterator1_type it1 (e_.find_first1 (rank, i, j)); + const_iterator1 find1 (int rank, size_type i, size_type j) const { + const_iterator1_type it1 (e_.find1 (rank, i, j)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator1 (*this, it1.index1 (), it1.index2 ()); #else @@ -1221,26 +1231,8 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - const_iterator1_type it1 (e_.find_last1 (rank, i, j)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator1 (*this, it1.index1 (), it1.index2 ()); -#else - return const_iterator1 (*this, it1); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - const_iterator2_type it2 (e_.find_first2 (rank, i, j)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator2 (*this, it2.index1 (), it2.index2 ()); -#else - return const_iterator2 (*this, it2); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - const_iterator2_type it2 (e_.find_last2 (rank, i, j)); + const_iterator2 find2 (int rank, size_type i, size_type j) const { + const_iterator2_type it2 (e_.find2 (rank, i, j)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator2 (*this, it2.index1 (), it2.index2 ()); #else @@ -1321,14 +1313,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator2 begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1383,11 +1375,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1460,14 +1452,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator1 begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1522,11 +1514,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } // Reverse iterators @@ -1674,8 +1666,8 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - const_iterator1_type it1 (e_.find_first2 (rank, j, i)); + const_iterator1 find1 (int rank, size_type i, size_type j) const { + const_iterator1_type it1 (e_.find2 (rank, j, i)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator1 (*this, it1.index2 (), it1.index1 ()); #else @@ -1683,26 +1675,8 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - const_iterator1_type it1 (e_.find_last2 (rank, j, i)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator1 (*this, it1.index2 (), it1.index1 ()); -#else - return const_iterator1 (*this, it1); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - const_iterator2_type it2 (e_.find_first1 (rank, j, i)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator2 (*this, it2.index2 (), it2.index1 ()); -#else - return const_iterator2 (*this, it2); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - const_iterator2_type it2 (e_.find_last1 (rank, j, i)); + const_iterator2 find2 (int rank, size_type i, size_type j) const { + const_iterator2_type it2 (e_.find1 (rank, j, i)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator2 (*this, it2.index2 (), it2.index1 ()); #else @@ -1783,14 +1757,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator2 begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1845,11 +1819,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1922,14 +1896,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator1 begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1984,11 +1958,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } // Reverse iterators @@ -2130,11 +2104,11 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - const_iterator11_type it11 (e1_.find_first1 (rank, i, j)); - const_iterator11_type it11_end (e1_.find_first1 (rank, size1 (), j)); - const_iterator21_type it21 (e2_.find_first1 (rank, i, j)); - const_iterator21_type it21_end (e2_.find_first1 (rank, size1 (), j)); + const_iterator1 find1 (int rank, size_type i, size_type j) const { + const_iterator11_type it11 (e1_.find1 (rank, i, j)); + const_iterator11_type it11_end (e1_.find1 (rank, size1 (), j)); + const_iterator21_type it21 (e2_.find1 (rank, i, j)); + const_iterator21_type it21_end (e2_.find1 (rank, size1 (), j)); BOOST_UBLAS_CHECK (rank == 0 || it11 == it11_end || it11.index2 () == j, internal_logic ()) BOOST_UBLAS_CHECK (rank == 0 || it21 == it21_end || it21.index2 () == j, internal_logic ()) i = std::min (it11 != it11_end ? it11.index1 () : size1 (), @@ -2146,27 +2120,11 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - const_iterator11_type it11 (e1_.find_last1 (rank, i, j)); - const_iterator11_type it11_end (e1_.find_last1 (rank, size1 (), j)); - const_iterator21_type it21 (e2_.find_last1 (rank, i, j)); - const_iterator21_type it21_end (e2_.find_last1 (rank, size1 (), j)); - BOOST_UBLAS_CHECK (rank == 0 || it11 == it11_end || it11.index2 () == j, internal_logic ()) - BOOST_UBLAS_CHECK (rank == 0 || it21 == it21_end || it21.index2 () == j, internal_logic ()) - i = std::max (it11 != it11_end ? it11.index1 () : size1 (), - it21 != it21_end ? it21.index1 () : size1 ()); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator1 (*this, i, j); -#else - return const_iterator1 (*this, i, j, it11, it11_end, it21, it21_end); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - const_iterator12_type it12 (e1_.find_first2 (rank, i, j)); - const_iterator12_type it12_end (e1_.find_first2 (rank, i, size2 ())); - const_iterator22_type it22 (e2_.find_first2 (rank, i, j)); - const_iterator22_type it22_end (e2_.find_first2 (rank, i, size2 ())); + const_iterator2 find2 (int rank, size_type i, size_type j) const { + const_iterator12_type it12 (e1_.find2 (rank, i, j)); + const_iterator12_type it12_end (e1_.find2 (rank, i, size2 ())); + const_iterator22_type it22 (e2_.find2 (rank, i, j)); + const_iterator22_type it22_end (e2_.find2 (rank, i, size2 ())); BOOST_UBLAS_CHECK (rank == 0 || it12 == it12_end || it12.index1 () == i, internal_logic ()) BOOST_UBLAS_CHECK (rank == 0 || it22 == it22_end || it22.index1 () == i, internal_logic ()) j = std::min (it12 != it12_end ? it12.index2 () : size2 (), @@ -2177,22 +2135,6 @@ namespace boost { namespace numeric { namespace ublas { return const_iterator2 (*this, i, j, it12, it12_end, it22, it22_end); #endif } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - const_iterator12_type it12 (e1_.find_last2 (rank, i, j)); - const_iterator12_type it12_end (e1_.find_last2 (rank, i, size2 ())); - const_iterator22_type it22 (e2_.find_last2 (rank, i, j)); - const_iterator22_type it22_end (e2_.find_last2 (rank, i, size2 ())); - BOOST_UBLAS_CHECK (rank == 0 || it12 == it12_end || it12.index1 () == i, internal_logic ()) - BOOST_UBLAS_CHECK (rank == 0 || it22 == it22_end || it22.index1 () == i, internal_logic ()) - j = std::max (it12 != it12_end ? it12.index2 () : size2 (), - it22 != it22_end ? it22.index2 () : size2 ()); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator2 (*this, i, j); -#else - return const_iterator2 (*this, i, j, it12, it12_end, it22, it22_end); -#endif - } // Iterators enhance the iterators of the referenced expression // with the binary functor. @@ -2379,14 +2321,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator2 begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -2456,11 +2398,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -2645,14 +2587,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator1 begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -2722,11 +2664,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } // Reverse iterators @@ -2894,8 +2836,8 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - const_iterator21_type it21 (e2_.find_first1 (rank, i, j)); + const_iterator1 find1 (int rank, size_type i, size_type j) const { + const_iterator21_type it21 (e2_.find1 (rank, i, j)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator1 (*this, it21.index1 (), it21.index2 ()); #else @@ -2903,26 +2845,8 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - const_iterator21_type it21 (e2_.find_last1 (rank, i, j)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator1 (*this, it21.index1 (), it21.index2 ()); -#else - return const_iterator1 (*this, e1_, it21); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - const_iterator22_type it22 (e2_.find_first2 (rank, i, j)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator2 (*this, it22.index1 (), it22.index2 ()); -#else - return const_iterator2 (*this, e1_, it22); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - const_iterator22_type it22 (e2_.find_last2 (rank, i, j)); + const_iterator2 find2 (int rank, size_type i, size_type j) const { + const_iterator22_type it22 (e2_.find2 (rank, i, j)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator2 (*this, it22.index1 (), it22.index2 ()); #else @@ -3005,14 +2929,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator2 begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3073,11 +2997,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -3152,14 +3076,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator1 begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3220,11 +3144,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } // Reverse iterators @@ -3354,8 +3278,8 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - const_iterator11_type it11 (e1_.find_first1 (rank, i, j)); + const_iterator1 find1 (int rank, size_type i, size_type j) const { + const_iterator11_type it11 (e1_.find1 (rank, i, j)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator1 (*this, it11.index1 (), it11.index2 ()); #else @@ -3363,26 +3287,8 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - const_iterator11_type it11 (e1_.find_last1 (rank, i, j)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator1 (*this, it11.index1 (), it11.index2 ()); -#else - return const_iterator1 (*this, it11, e2_); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - const_iterator12_type it12 (e1_.find_first2 (rank, i, j)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator2 (*this, it12.index1 (), it12.index2 ()); -#else - return const_iterator2 (*this, it12, e2_); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - const_iterator12_type it12 (e1_.find_last2 (rank, i, j)); + const_iterator2 find2 (int rank, size_type i, size_type j) const { + const_iterator12_type it12 (e1_.find2 (rank, i, j)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator2 (*this, it12.index1 (), it12.index2 ()); #else @@ -3465,14 +3371,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator2 begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3533,11 +3439,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -3612,14 +3518,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator1 begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3680,11 +3586,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } // Reverse iterators @@ -3807,25 +3713,12 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { + const_iterator find (size_type i) const { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - const_iterator1_type it1 (e1_.find_first1 (0, i, 0)); + const_iterator1_type it1 (e1_.find1 (0, i, 0)); return const_iterator (*this, it1.index1 ()); #else - return const_iterator (*this, e1_.find_first1 (0, i, 0)); -#endif - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - // FIXME: sparse matrix tests fail! - // const_iterator1_type it1 (e1_.find_last1 (0, i, e1_.size2 ())); - const_iterator1_type it1 (e1_.find_last1 (0, i, 0)); - return const_iterator (*this, it1.index1 ()); -#else - // FIXME: sparse matrix tests fail! - // return const_iterator (*this, e1_.find_last1 (0, i, e1_.size2 ())); - return const_iterator (*this, e1_.find_last1 (0, i, 0)); + return const_iterator (*this, e1_.find1 (0, i, 0)); #endif } @@ -4009,11 +3902,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size ()); + return find (size ()); } // Reverse iterator @@ -4205,25 +4098,12 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type j) const { + const_iterator find (size_type j) const { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - const_iterator2_type it2 (e2_.find_first2 (0, 0, j)); + const_iterator2_type it2 (e2_.find2 (0, 0, j)); return const_iterator (*this, it2.index2 ()); #else - return const_iterator (*this, e2_.find_first2 (0, 0, j)); -#endif - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type j) const { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - // FIXME: sparse matrix tests fail! - // const_iterator2_type it2 (e2_.find_last2 (0, e2_.size1 (), j)); - const_iterator2_type it2 (e2_.find_last2 (0, 0, j)); - return const_iterator (*this, it2.index2 ()); -#else - // FIXME: sparse matrix tests fail! - // return const_iterator (*this, e2_.find_last2 (0, e2_.size1 (), j)); - return const_iterator (*this, e2_.find_last2 (0, 0, j)); + return const_iterator (*this, e2_.find2 (0, 0, j)); #endif } @@ -4407,11 +4287,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size ()); + return find (size ()); } // Reverse iterator @@ -4623,58 +4503,30 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { + const_iterator1 find1 (int rank, size_type i, size_type j) const { // FIXME: sparse matrix tests fail! - // const_iterator11_type it11 (e1_.find_first1 (rank, i, 0)); - const_iterator11_type it11 (e1_.find_first1 (0, i, 0)); + // const_iterator11_type it11 (e1_.find1 (rank, i, 0)); + const_iterator11_type it11 (e1_.find1 (0, i, 0)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator1 (*this, it11.index1 (), j); #else // FIXME: sparse matrix tests fail! - // const_iterator22_type it22 (e2_.find_first2 (rank, 0, j)); - const_iterator22_type it22 (e2_.find_first2 (0, 0, j)); + // const_iterator22_type it22 (e2_.find2 (rank, 0, j)); + const_iterator22_type it22 (e2_.find2 (0, 0, j)); return const_iterator1 (*this, it11, it22); #endif } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { + const_iterator2 find2 (int rank, size_type i, size_type j) const { // FIXME: sparse matrix tests fail! - // const_iterator11_type it11 (e1_.find_last1 (rank, i, 0)); - const_iterator11_type it11 (e1_.find_last1 (0, i, 0)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator1 (*this, it11.index1 (), j); -#else - // FIXME: sparse matrix tests fail! - // const_iterator22_type it22 (e2_.find_last2 (rank, 0, j)); - const_iterator22_type it22 (e2_.find_last2 (0, 0, j)); - return const_iterator1 (*this, it11, it22); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - // FIXME: sparse matrix tests fail! - // const_iterator22_type it22 (e2_.find_first2 (rank, 0, j)); - const_iterator22_type it22 (e2_.find_first2 (0, 0, j)); + // const_iterator22_type it22 (e2_.find2 (rank, 0, j)); + const_iterator22_type it22 (e2_.find2 (0, 0, j)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator2 (*this, i, it22.index2 ()); #else // FIXME: sparse matrix tests fail! - // const_iterator11_type it11 (e1_.find_first1 (rank, i, 0)); - const_iterator11_type it11 (e1_.find_first1 (0, i, 0)); - return const_iterator2 (*this, it11, it22); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - // FIXME: sparse matrix tests fail! - // const_iterator22_type it22 (e2_.find_last2 (rank, 0, j)); - const_iterator22_type it22 (e2_.find_last2 (0, 0, j)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator2 (*this, i, it22.index2 ()); -#else - // FIXME: sparse matrix tests fail! - // const_iterator11_type it11 (e1_.find_last1 (rank, i, 0)); - const_iterator11_type it11 (e1_.find_last1 (0, i, 0)); + // const_iterator11_type it11 (e1_.find1 (rank, i, 0)); + const_iterator11_type it11 (e1_.find1 (0, i, 0)); return const_iterator2 (*this, it11, it22); #endif } @@ -4828,14 +4680,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator2 begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -4903,11 +4755,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -5057,14 +4909,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator1 begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -5132,11 +4984,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } // Reverse iterators diff --git a/include/boost/numeric/ublas/matrix_proxy.hpp b/include/boost/numeric/ublas/matrix_proxy.hpp index 014959b9..2dab8de0 100644 --- a/include/boost/numeric/ublas/matrix_proxy.hpp +++ b/include/boost/numeric/ublas/matrix_proxy.hpp @@ -216,6 +216,12 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const matrix_row &mr) const { + return (*this).data () == mr.data () && index () == mr.index (); + } + // Swapping BOOST_UBLAS_INLINE void swap (matrix_row mr) { @@ -247,8 +253,8 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type j) const { - const_iterator_type it2 (data ().find_first2 (1, i_, j)); + const_iterator find (size_type j) const { + const_iterator_type it2 (data ().find2 (1, i_, j)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator (*this, it2.index2 ()); #else @@ -256,26 +262,8 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - iterator find_first (size_type j) { - iterator_type it2 (data ().find_first2 (1, i_, j)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return iterator (*this, it2.index2 ()); -#else - return iterator (*this, it2); -#endif - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type j) const { - const_iterator_type it2 (data ().find_last2 (1, i_, j)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator (*this, it2.index2 ()); -#else - return const_iterator (*this, it2); -#endif - } - BOOST_UBLAS_INLINE - iterator find_last (size_type j) { - iterator_type it2 (data ().find_last2 (1, i_, j)); + iterator find (size_type j) { + iterator_type it2 (data ().find2 (1, i_, j)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator (*this, it2.index2 ()); #else @@ -342,7 +330,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ - it.it_; } @@ -370,12 +358,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ == it.it_; } BOOST_UBLAS_INLINE bool operator < (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ < it.it_; } @@ -386,11 +374,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size ()); + return find (size ()); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -441,7 +429,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ - it.it_; } @@ -469,12 +457,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ == it.it_; } BOOST_UBLAS_INLINE bool operator < (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ < it.it_; } @@ -487,11 +475,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator begin () { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE iterator end () { - return find_first (size ()); + return find (size ()); } // Reverse iterator @@ -745,6 +733,12 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const matrix_column &mc) const { + return (*this).data () == mc.data () && index () == mc.index (); + } + // Swapping BOOST_UBLAS_INLINE void swap (matrix_column mc) { @@ -776,8 +770,8 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { - const_iterator_type it1 (data ().find_first1 (1, i, j_)); + const_iterator find (size_type i) const { + const_iterator_type it1 (data ().find1 (1, i, j_)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator (*this, it1.index1 ()); #else @@ -785,26 +779,8 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - iterator find_first (size_type i) { - iterator_type it1 (data ().find_first1 (1, i, j_)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return iterator (*this, it1.index1 ()); -#else - return iterator (*this, it1); -#endif - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { - const_iterator_type it1 (data ().find_last1 (1, i, j_)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator (*this, it1.index1 ()); -#else - return const_iterator (*this, it1); -#endif - } - BOOST_UBLAS_INLINE - iterator find_last (size_type i) { - iterator_type it1 (data ().find_last1 (1, i, j_)); + iterator find (size_type i) { + iterator_type it1 (data ().find1 (1, i, j_)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator (*this, it1.index1 ()); #else @@ -871,7 +847,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ - it.it_; } @@ -899,12 +875,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ == it.it_; } BOOST_UBLAS_INLINE bool operator < (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ < it.it_; } @@ -915,11 +891,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size ()); + return find (size ()); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -970,7 +946,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ - it.it_; } @@ -998,12 +974,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ == it.it_; } BOOST_UBLAS_INLINE bool operator < (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ < it.it_; } @@ -1016,11 +992,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator begin () { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE iterator end () { - return find_first (size ()); + return find (size ()); } // Reverse iterator @@ -1270,6 +1246,12 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const matrix_vector_range &mvr) const { + return (*this).data () == mvr.data () && r1_ == mvr.r1_ && r2_ == mvr.r2_; + } + // Swapping BOOST_UBLAS_INLINE void swap (matrix_vector_range mvr) { @@ -1294,19 +1276,11 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { + const_iterator find (size_type i) const { return const_iterator (*this, r1_.begin () + i, r2_.begin () + i); } BOOST_UBLAS_INLINE - iterator find_first (size_type i) { - return iterator (*this, r1_.begin () + i, r2_.begin () + i); - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { - return const_iterator (*this, r1_.begin () + i, r2_.begin () + i); - } - BOOST_UBLAS_INLINE - iterator find_last (size_type i) { + iterator find (size_type i) { return iterator (*this, r1_.begin () + i, r2_.begin () + i); } @@ -1379,7 +1353,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return BOOST_UBLAS_SAME (it1_ - it.it1_, it2_ - it.it2_); } @@ -1407,12 +1381,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it1_ == it.it1_ && it2_ == it.it2_; } BOOST_UBLAS_INLINE bool operator < (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it1_ < it.it1_ && it2_ < it.it2_; } @@ -1423,11 +1397,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size ()); + return find (size ()); } class iterator: @@ -1486,7 +1460,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return BOOST_UBLAS_SAME (it1_ - it.it1_, it2_ - it.it2_); } @@ -1514,12 +1488,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it1_ == it.it1_ && it2_ == it.it2_; } BOOST_UBLAS_INLINE bool operator < (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it1_ < it.it1_ && it2_ < it.it2_; } @@ -1532,11 +1506,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator begin () { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE iterator end () { - return find_first (size ()); + return find (size ()); } // Reverse iterator @@ -1771,6 +1745,12 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const matrix_vector_slice &mvs) const { + return (*this).data () == mvs.data () && s1_ == mvs.s1_ && s2_ == mvs.s2_; + } + // Swapping BOOST_UBLAS_INLINE void swap (matrix_vector_slice mvs) { @@ -1795,19 +1775,11 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { + const_iterator find (size_type i) const { return const_iterator (*this, s1_.begin () + i, s2_.begin () + i); } BOOST_UBLAS_INLINE - iterator find_first (size_type i) { - return iterator (*this, s1_.begin () + i, s2_.begin () + i); - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { - return const_iterator (*this, s1_.begin () + i, s2_.begin () + i); - } - BOOST_UBLAS_INLINE - iterator find_last (size_type i) { + iterator find (size_type i) { return iterator (*this, s1_.begin () + i, s2_.begin () + i); } @@ -1880,7 +1852,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); // One of the slices may be stationary. // Thanks to Michael Stevens for this extension. // return BOOST_UBLAS_SAME (it1_ - it.it1_, it2_ - it.it2_); @@ -1914,12 +1886,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it1_ == it.it1_ && it2_ == it.it2_; } BOOST_UBLAS_INLINE bool operator < (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it1_ < it.it1_ && it2_ < it.it2_; } @@ -1930,11 +1902,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size ()); + return find (size ()); } class iterator: @@ -1993,7 +1965,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); // One of the slices may be stationary. // Thanks to Michael Stevens for this extension. // return BOOST_UBLAS_SAME (it1_ - it.it1_, it2_ - it.it2_); @@ -2027,12 +1999,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it1_ == it.it1_ && it2_ == it.it2_; } BOOST_UBLAS_INLINE bool operator < (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it1_ < it.it1_ && it2_ < it.it2_; } @@ -2045,11 +2017,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator begin () { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE iterator end () { - return find_first (size ()); + return find (size ()); } // Reverse iterator @@ -2297,6 +2269,12 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const matrix_vector_indirect &mvi) const { + return (*this).data () == mvi.data () && ia1_ == mvi.ia1_ && ia2_ == mvi.ia2_; + } + // Swapping BOOST_UBLAS_INLINE void swap (matrix_vector_indirect mvi) { @@ -2321,19 +2299,11 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { + const_iterator find (size_type i) const { return const_iterator (*this, ia1_.begin () + i, ia2_.begin () + i); } BOOST_UBLAS_INLINE - iterator find_first (size_type i) { - return iterator (*this, ia1_.begin () + i, ia2_.begin () + i); - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { - return const_iterator (*this, ia1_.begin () + i, ia2_.begin () + i); - } - BOOST_UBLAS_INLINE - iterator find_last (size_type i) { + iterator find (size_type i) { return iterator (*this, ia1_.begin () + i, ia2_.begin () + i); } @@ -2406,7 +2376,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return BOOST_UBLAS_SAME (it1_ - it.it1_, it2_ - it.it2_); } @@ -2434,12 +2404,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it1_ == it.it1_ && it2_ == it.it2_; } BOOST_UBLAS_INLINE bool operator < (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it1_ < it.it1_ && it2_ < it.it2_; } @@ -2450,11 +2420,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size ()); + return find (size ()); } class iterator: @@ -2513,7 +2483,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return BOOST_UBLAS_SAME (it1_ - it.it1_, it2_ - it.it2_); } @@ -2541,12 +2511,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it1_ == it.it1_ && it2_ == it.it2_; } BOOST_UBLAS_INLINE bool operator < (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it1_ < it.it1_ && it2_ < it.it2_; } @@ -2559,11 +2529,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator begin () { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE iterator end () { - return find_first (size ()); + return find (size ()); } // Reverse iterator @@ -2796,8 +2766,8 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - matrix_range &minus_assign (const matrix_expression &ae) { - matrix_assign (scalar_minus_assign (), *this, ae); + matrix_range &minus_assign (const matrix_expression &ae) { + matrix_assign (scalar_minus_assign (), *this, ae); return *this; } template @@ -2813,6 +2783,12 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const matrix_range &mr) const { + return (*this).data () == mr.data () && r1_ == mr.r1_ && r2_ == mr.r2_; + } + // Swapping BOOST_UBLAS_INLINE void swap (matrix_range mr) { @@ -2860,8 +2836,8 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - const_iterator1_type it1 (data ().find_first1 (rank, start1 () + i, start2 () + j)); + const_iterator1 find1 (int rank, size_type i, size_type j) const { + const_iterator1_type it1 (data ().find1 (rank, start1 () + i, start2 () + j)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator1 (*this, it1.index1 (), it1.index2 ()); #else @@ -2869,8 +2845,8 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { - iterator1_type it1 (data ().find_first1 (rank, start1 () + i, start2 () + j)); + iterator1 find1 (int rank, size_type i, size_type j) { + iterator1_type it1 (data ().find1 (rank, start1 () + i, start2 () + j)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator1 (*this, it1.index1 (), it1.index2 ()); #else @@ -2878,26 +2854,8 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - const_iterator1_type it1 (data ().find_last1 (rank, start1 () + i, start2 () + j)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator1 (*this, it1.index1 (), it1.index2 ()); -#else - return const_iterator1 (*this, it1); -#endif - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - iterator1_type it1 (data ().find_last1 (rank, start1 () + i, start2 () + j)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return iterator1 (*this, it1.index1 (), it1.index2 ()); -#else - return iterator1 (*this, it1); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - const_iterator2_type it2 (data ().find_first2 (rank, start1 () + i, start2 () + j)); + const_iterator2 find2 (int rank, size_type i, size_type j) const { + const_iterator2_type it2 (data ().find2 (rank, start1 () + i, start2 () + j)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator2 (*this, it2.index1 (), it2.index2 ()); #else @@ -2905,26 +2863,8 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { - iterator2_type it2 (data ().find_first2 (rank, start1 () + i, start2 () + j)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return iterator2 (*this, it2.index1 (), it2.index2 ()); -#else - return iterator2 (*this, it2); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - const_iterator2_type it2 (data ().find_last2 (rank, start1 () + i, start2 () + j)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator2 (*this, it2.index1 (), it2.index2 ()); -#else - return const_iterator2 (*this, it2); -#endif - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { - iterator2_type it2 (data ().find_last2 (rank, start1 () + i, start2 () + j)); + iterator2 find2 (int rank, size_type i, size_type j) { + iterator2_type it2 (data ().find2 (rank, start1 () + i, start2 () + j)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator2 (*this, it2.index1 (), it2.index2 ()); #else @@ -2992,7 +2932,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ - it.it_; } @@ -3009,7 +2949,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator2 begin () const { const self_type &mr = (*this) (); - return mr.find_first2 (1, index1 (), 0); + return mr.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3017,7 +2957,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator2 end () const { const self_type &mr = (*this) (); - return mr.find_first2 (1, index1 (), mr.size2 ()); + return mr.find2 (1, index1 (), mr.size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3056,12 +2996,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const const_iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ == it.it_; } BOOST_UBLAS_INLINE bool operator < (const const_iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ < it.it_; } @@ -3072,11 +3012,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -3134,7 +3074,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ - it.it_; } @@ -3151,7 +3091,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator2 begin () const { self_type &mr = (*this) (); - return mr.find_first2 (1, index1 (), 0); + return mr.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3159,7 +3099,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator2 end () const { self_type &mr = (*this) (); - return mr.find_first2 (1, index1 (), mr.size2 ()); + return mr.find2 (1, index1 (), mr.size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3198,12 +3138,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ == it.it_; } BOOST_UBLAS_INLINE bool operator < (const iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ < it.it_; } @@ -3216,11 +3156,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -3281,7 +3221,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ - it.it_; } @@ -3298,7 +3238,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator1 begin () const { const self_type &mr = (*this) (); - return mr.find_first1 (1, 0, index2 ()); + return mr.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3306,7 +3246,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator1 end () const { const self_type &mr = (*this) (); - return mr.find_first1 (1, mr.size1 (), index2 ()); + return mr.find1 (1, mr.size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3345,12 +3285,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const const_iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ == it.it_; } BOOST_UBLAS_INLINE bool operator < (const const_iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ < it.it_; } @@ -3361,11 +3301,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -3423,7 +3363,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ - it.it_; } @@ -3440,7 +3380,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator1 begin () const { self_type &mr = (*this) (); - return mr.find_first1 (1, 0, index2 ()); + return mr.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3448,7 +3388,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator1 end () const { self_type &mr = (*this) (); - return mr.find_first1 (1, mr.size1 (), index2 ()); + return mr.find1 (1, mr.size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3487,12 +3427,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ == it.it_; } BOOST_UBLAS_INLINE bool operator < (const iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ < it.it_; } @@ -3505,11 +3445,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } // Reverse iterators @@ -3579,6 +3519,11 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE + matrix_range project (matrix_range &data, const range &r1, const range &r2) { + return data.project (r1, r2); + } + template + BOOST_UBLAS_INLINE matrix_range project (const matrix_range &data, const range &r1, const range &r2) { return data.project (r1, r2); } @@ -3773,8 +3718,8 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - matrix_slice &minus_assign (const matrix_expression &ae) { - matrix_assign (scalar_minus_assign (), *this, ae); + matrix_slice &minus_assign (const matrix_expression &ae) { + matrix_assign (scalar_minus_assign (), *this, ae); return *this; } template @@ -3790,6 +3735,12 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const matrix_slice &ms) const { + return (*this).data () == ms.data () && s1_ == ms.s1_ && s2_ == ms.s2_; + } + // Swapping BOOST_UBLAS_INLINE void swap (matrix_slice ms) { @@ -3837,7 +3788,7 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { + const_iterator1 find1 (int rank, size_type i, size_type j) const { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator1 (*this, i, j); #else @@ -3845,7 +3796,7 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { + iterator1 find1 (int rank, size_type i, size_type j) { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator1 (*this, i, j); #else @@ -3853,23 +3804,7 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator1 (*this, i, j); -#else - return const_iterator1 (*this, s1_.begin () + i, s2_.begin () + j); -#endif - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return iterator1 (*this, i, j); -#else - return iterator1 (*this, s1_.begin () + i, s2_.begin () + j); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { + const_iterator2 find2 (int rank, size_type i, size_type j) const { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator2 (*this, i, j); #else @@ -3877,23 +3812,7 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return iterator2 (*this, i, j); -#else - return iterator2 (*this, s1_.begin () + i, s2_.begin () + j); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator2 (*this, i, j); -#else - return const_iterator2 (*this, s1_.begin () + i, s2_.begin () + j); -#endif - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { + iterator2 find2 (int rank, size_type i, size_type j) { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator2 (*this, i, j); #else @@ -3956,7 +3875,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); return it1_ - it.it1_; } @@ -4020,13 +3939,13 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const const_iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); return it1_ == it.it1_; } BOOST_UBLAS_INLINE bool operator < (const const_iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); return it1_ < it.it1_; } @@ -4039,11 +3958,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -4096,7 +4015,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); return it1_ - it.it1_; } @@ -4160,13 +4079,13 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); return it1_ == it.it1_; } BOOST_UBLAS_INLINE bool operator < (const iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); return it1_ < it.it1_; } @@ -4181,11 +4100,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -4241,7 +4160,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); return it2_ - it.it2_; } @@ -4305,13 +4224,13 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const const_iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); return it2_ == it.it2_; } BOOST_UBLAS_INLINE bool operator < (const const_iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); return it2_ < it.it2_; } @@ -4324,11 +4243,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -4381,7 +4300,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); return it2_ - it.it2_; } @@ -4445,13 +4364,13 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); return it2_ == it.it2_; } BOOST_UBLAS_INLINE bool operator < (const iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); return it2_ < it.it2_; } @@ -4466,11 +4385,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } // Reverse iterators @@ -4523,6 +4442,11 @@ namespace boost { namespace numeric { namespace ublas { // Projections #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template + BOOST_UBLAS_INLINE + matrix_slice project (matrix_slice &data, const range &r1, const range &r2) { + return data.project (r1, r2); + } template BOOST_UBLAS_INLINE matrix_slice project (const matrix_slice &data, const range &r1, const range &r2) { @@ -4547,6 +4471,11 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE + matrix_slice project (matrix_slice &data, const slice &s1, const slice &s2) { + return data.project (s1, s2); + } + template + BOOST_UBLAS_INLINE matrix_slice project (const matrix_slice &data, const slice &s1, const slice &s2) { return data.project (s1, s2); } @@ -4756,6 +4685,12 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const matrix_indirect &mi) const { + return (*this).data () == mi.data () && ia1_ == mi.ia1_ && ia2_ == mi.ia2_; + } + // Swapping BOOST_UBLAS_INLINE void swap (matrix_indirect mi) { @@ -4803,7 +4738,7 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { + const_iterator1 find1 (int rank, size_type i, size_type j) const { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator1 (*this, i, j); #else @@ -4811,7 +4746,7 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { + iterator1 find1 (int rank, size_type i, size_type j) { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator1 (*this, i, j); #else @@ -4819,23 +4754,7 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator1 (*this, i, j); -#else - return const_iterator1 (*this, ia1_.begin () + i, ia2_.begin () + j); -#endif - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return iterator1 (*this, i, j); -#else - return iterator1 (*this, ia1_.begin () + i, ia2_.begin () + j); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { + const_iterator2 find2 (int rank, size_type i, size_type j) const { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator2 (*this, i, j); #else @@ -4843,23 +4762,7 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return iterator2 (*this, i, j); -#else - return iterator2 (*this, ia1_.begin () + i, ia2_.begin () + j); -#endif - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator2 (*this, i, j); -#else - return const_iterator2 (*this, ia1_.begin () + i, ia2_.begin () + j); -#endif - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { + iterator2 find2 (int rank, size_type i, size_type j) { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator2 (*this, i, j); #else @@ -4922,7 +4825,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); return it1_ - it.it1_; } @@ -4986,13 +4889,13 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const const_iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); return it1_ == it.it1_; } BOOST_UBLAS_INLINE bool operator < (const const_iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); return it1_ < it.it1_; } @@ -5005,11 +4908,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -5062,7 +4965,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); return it1_ - it.it1_; } @@ -5126,13 +5029,13 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); return it1_ == it.it1_; } BOOST_UBLAS_INLINE bool operator < (const iterator1 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); return it1_ < it.it1_; } @@ -5147,11 +5050,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -5207,7 +5110,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); return it2_ - it.it2_; } @@ -5271,13 +5174,13 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const const_iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); return it2_ == it.it2_; } BOOST_UBLAS_INLINE bool operator < (const const_iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); return it2_ < it.it2_; } @@ -5290,11 +5193,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -5347,7 +5250,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); return it2_ - it.it2_; } @@ -5411,13 +5314,13 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); return it2_ == it.it2_; } BOOST_UBLAS_INLINE bool operator < (const iterator2 &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); BOOST_UBLAS_CHECK (it1_ == it.it1_, external_logic ()); return it2_ < it.it2_; } @@ -5432,11 +5335,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } // Reverse iterators @@ -5489,6 +5392,11 @@ namespace boost { namespace numeric { namespace ublas { // Projections #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template + BOOST_UBLAS_INLINE + matrix_indirect project (matrix_indirect &data, const range &r1, const range &r2) { + return data.project (r1, r2); + } template BOOST_UBLAS_INLINE matrix_indirect project (const matrix_indirect &data, const range &r1, const range &r2) { @@ -5496,6 +5404,11 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE + matrix_indirect project (matrix_indirect &data, const slice &s1, const slice &s2) { + return data.project (s1, s2); + } + template + BOOST_UBLAS_INLINE matrix_indirect project (const matrix_indirect &data, const slice &s1, const slice &s2) { return data.project (s1, s2); } @@ -5519,6 +5432,11 @@ namespace boost { namespace numeric { namespace ublas { // } // template // BOOST_UBLAS_INLINE + // matrix_indirect project (matrix_indirect &data, const IA &ia1, const IA &ia2) { + // return data.project (ia1, ia2); + // } + // template + // BOOST_UBLAS_INLINE // matrix_indirect project (const matrix_indirect &data, const IA &ia1, const IA &ia2) { // return data.project (ia1, ia2); // } @@ -5541,6 +5459,11 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE + matrix_indirect > project (matrix_indirect > &data, const indirect_array &ia1, const indirect_array &ia2) { + return data.project (ia1, ia2); + } + template + BOOST_UBLAS_INLINE matrix_indirect > project (const matrix_indirect > &data, const indirect_array &ia1, const indirect_array &ia2) { return data.project (ia1, ia2); } diff --git a/include/boost/numeric/ublas/matrix_sparse.hpp b/include/boost/numeric/ublas/matrix_sparse.hpp index d6ac0169..1406e834 100644 --- a/include/boost/numeric/ublas/matrix_sparse.hpp +++ b/include/boost/numeric/ublas/matrix_sparse.hpp @@ -213,7 +213,7 @@ namespace boost { namespace numeric { namespace ublas { #elif defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) typedef sparse_matrix_element > reference; #elif defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) - typedef typename map_traits::reference reference; + typedef typename detail::map_traits::reference reference; #endif typedef const T *const_pointer; typedef T *pointer; @@ -286,9 +286,7 @@ namespace boost { namespace numeric { namespace ublas { // non_zeros_ = std::min (non_zeros_, size1_ * size2_); if (size1_ > 0 && non_zeros_ / size1_ >= size2_) non_zeros_ = size1_ * size2_; -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - map_traits::reserve (data (), non_zeros_); -#endif + detail::reserve (data (), non_zeros_); data ().clear (); } @@ -301,9 +299,7 @@ namespace boost { namespace numeric { namespace ublas { // non_zeros_ = std::min (non_zeros_, size1_ * size2_); if (size1_ > 0 && non_zeros_ / size1_ >= size2_) non_zeros_ = size1_ * size2_; -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - map_traits::reserve (data (), non_zeros_); -#endif + detail::reserve (data (), non_zeros_); } // Proxy support @@ -486,7 +482,7 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - const_iterator1 find1 (int rank, size_type i, size_type j, int direction) const { + const_iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) const { const_iterator_type it (data ().lower_bound (functor_type::address (i, size1_, j, size2_))); const_iterator_type it_end (data ().end ()); size_type index2 = size_type (-1); @@ -525,7 +521,7 @@ namespace boost { namespace numeric { namespace ublas { } // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - iterator1 find1 (int rank, size_type i, size_type j, int direction) { + iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) { iterator_type it (data ().lower_bound (functor_type::address (i, size1_, j, size2_))); iterator_type it_end (data ().end ()); size_type index2 = size_type (-1); @@ -564,7 +560,7 @@ namespace boost { namespace numeric { namespace ublas { } // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - const_iterator2 find2 (int rank, size_type i, size_type j, int direction) const { + const_iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) const { const_iterator_type it (data ().lower_bound (functor_type::address (i, size1_, j, size2_))); const_iterator_type it_end (data ().end ()); size_type index1 = size_type (-1); @@ -603,7 +599,7 @@ namespace boost { namespace numeric { namespace ublas { } // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - iterator2 find2 (int rank, size_type i, size_type j, int direction) { + iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) { iterator_type it (data ().lower_bound (functor_type::address (i, size1_, j, size2_))); iterator_type it_end (data ().end ()); size_type index1 = size_type (-1); @@ -640,38 +636,6 @@ namespace boost { namespace numeric { namespace ublas { } return iterator2 (*this, rank, i, j, it); } - BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j, -1); - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j, -1); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j, -1); - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j, -1); - } // Iterators simply are pointers. @@ -710,7 +674,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1 && functor_type::fast1 ()) ++ it_; else - *this = m.find_first1 (rank_, index1 () + 1, j_); + *this = m.find1 (rank_, index1 () + 1, j_, 1); return *this; } BOOST_UBLAS_INLINE @@ -719,7 +683,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1 && functor_type::fast1 ()) -- it_; else - *this = m.find_last1 (rank_, index1 () - 1, j_); + *this = m.find1 (rank_, index1 () - 1, j_, -1); return *this; } @@ -742,7 +706,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator2 begin () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -750,7 +714,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator2 end () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -820,11 +784,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } class iterator1: @@ -857,7 +821,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1 && functor_type::fast1 ()) ++ it_; else - *this = m.find_first1 (rank_, index1 () + 1, j_); + *this = m.find1 (rank_, index1 () + 1, j_, 1); return *this; } BOOST_UBLAS_INLINE @@ -866,7 +830,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1 && functor_type::fast1 ()) -- it_; else - *this = m.find_last1 (rank_, index1 () - 1, j_); + *this = m.find1 (rank_, index1 () - 1, j_, -1); return *this; } @@ -881,7 +845,7 @@ namespace boost { namespace numeric { namespace ublas { #elif defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) return reference ((*this) (), &(*it_).second, index1 (), index2 ()); #elif defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) - return map_traits::make_reference ((*this) ().data (), it_); + return detail::make_reference ((*this) ().data (), it_); #endif } else { return reference ((*this) () (i_, j_)); @@ -895,7 +859,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator2 begin () const { self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -903,7 +867,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator2 end () const { self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -975,11 +939,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } class const_iterator2: @@ -1017,7 +981,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1 && functor_type::fast2 ()) ++ it_; else - *this = m.find_first2 (rank_, i_, index2 () + 1); + *this = m.find2 (rank_, i_, index2 () + 1, 1); return *this; } BOOST_UBLAS_INLINE @@ -1026,7 +990,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1 && functor_type::fast2 ()) -- it_; else - *this = m.find_last2 (rank_, i_, index2 () - 1); + *this = m.find2 (rank_, i_, index2 () - 1, -1); return *this; } @@ -1049,7 +1013,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator1 begin () const { const self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1057,7 +1021,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator1 end () const { const self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1127,11 +1091,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } class iterator2: @@ -1164,7 +1128,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1 && functor_type::fast2 ()) ++ it_; else - *this = m.find_first2 (rank_, i_, index2 () + 1); + *this = m.find2 (rank_, i_, index2 () + 1, 1); return *this; } BOOST_UBLAS_INLINE @@ -1173,7 +1137,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1 && functor_type::fast2 ()) -- it_; else - *this = m.find_last2 (rank_, i_, index2 () - 1); + *this = m.find2 (rank_, i_, index2 () - 1, -1); return *this; } @@ -1188,7 +1152,7 @@ namespace boost { namespace numeric { namespace ublas { #elif defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) return reference ((*this) (), &(*it_).second, index1 (), index2 ()); #elif defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) - return map_traits::make_reference ((*this) ().data (), it_); + return detail::make_reference ((*this) ().data (), it_); #endif } else { return reference ((*this) () (i_, j_)); @@ -1202,7 +1166,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator1 begin () const { self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1210,7 +1174,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator1 end () const { self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1282,11 +1246,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } // Reverse iterators @@ -1356,7 +1320,7 @@ namespace boost { namespace numeric { namespace ublas { #elif defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) typedef sparse_matrix_element > reference; #elif defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) - typedef typename map_traits::reference reference; + typedef typename detail::map_traits::reference reference; #endif typedef const T *const_pointer; typedef T *pointer; @@ -1628,7 +1592,7 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - const_iterator1 find1 (int rank, size_type i, size_type j, int direction) const { + const_iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) const { BOOST_UBLAS_CHECK (data ().begin () != data ().end (), internal_logic ()); for (;;) { vector_const_iterator_type itv (data ().lower_bound (functor_type::address1 (i, size1_, j, size2_))); @@ -1663,7 +1627,7 @@ namespace boost { namespace numeric { namespace ublas { } // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - iterator1 find1 (int rank, size_type i, size_type j, int direction) { + iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) { BOOST_UBLAS_CHECK (data ().begin () != data ().end (), internal_logic ()); for (;;) { vector_iterator_type itv (data ().lower_bound (functor_type::address1 (i, size1_, j, size2_))); @@ -1698,7 +1662,7 @@ namespace boost { namespace numeric { namespace ublas { } // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - const_iterator2 find2 (int rank, size_type i, size_type j, int direction) const { + const_iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) const { BOOST_UBLAS_CHECK (data ().begin () != data ().end (), internal_logic ()); for (;;) { vector_const_iterator_type itv (data ().lower_bound (functor_type::address1 (i, size1_, j, size2_))); @@ -1733,7 +1697,7 @@ namespace boost { namespace numeric { namespace ublas { } // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - iterator2 find2 (int rank, size_type i, size_type j, int direction) { + iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) { BOOST_UBLAS_CHECK (data ().begin () != data ().end (), internal_logic ()); for (;;) { vector_iterator_type itv (data ().lower_bound (functor_type::address1 (i, size1_, j, size2_))); @@ -1766,38 +1730,6 @@ namespace boost { namespace numeric { namespace ublas { } } } - BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j, -1); - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j, -1); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j, -1); - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j, -1); - } // Iterators simply are pointers. @@ -1838,11 +1770,11 @@ namespace boost { namespace numeric { namespace ublas { else { i_ = index1 () + 1; if (rank_ == 1 && ++ itv_ == m.end1 ().itv_) - *this = m.find_first1 (rank_, i_, j_); + *this = m.find1 (rank_, i_, j_, 1); else if (rank_ == 1) { it_ = (*itv_).second.begin (); if (it_ == (*itv_).second.end () || index2 () != j_) - *this = m.find_first1 (rank_, i_, j_); + *this = m.find1 (rank_, i_, j_, 1); } } return *this; @@ -1855,11 +1787,11 @@ namespace boost { namespace numeric { namespace ublas { else { i_ = index1 () - 1; if (rank_ == 1 && -- itv_ == m.end1 ().itv_) - *this = m.find_last1 (rank_, i_, j_); + *this = m.find1 (rank_, i_, j_, -1); else if (rank_ == 1) { it_ = (*itv_).second.begin (); if (it_ == (*itv_).second.end () || index2 () != j_) - *this = m.find_last1 (rank_, i_, j_); + *this = m.find1 (rank_, i_, j_, -1); } } return *this; @@ -1884,7 +1816,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator2 begin () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1892,7 +1824,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator2 end () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1962,11 +1894,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } class iterator1: @@ -2000,12 +1932,12 @@ namespace boost { namespace numeric { namespace ublas { ++ it_; else { i_ = index1 () + 1; - if (rank_ == 1 && ++ itv_ == m.end1 ().itv_) - *this = m.find_first1 (rank_, i_, j_); + if (rank_ == 1 && ++ itv_ == m.end1 ().itv_) + *this = m.find1 (rank_, i_, j_, 1); else if (rank_ == 1) { it_ = (*itv_).second.begin (); if (it_ == (*itv_).second.end () || index2 () != j_) - *this = m.find_first1 (rank_, i_, j_); + *this = m.find1 (rank_, i_, j_, 1); } } return *this; @@ -2018,11 +1950,11 @@ namespace boost { namespace numeric { namespace ublas { else { i_ = index1 () - 1; if (rank_ == 1 && -- itv_ == m.end1 ().itv_) - *this = m.find_last1 (rank_, i_, j_); + *this = m.find1 (rank_, i_, j_, -1); else if (rank_ == 1) { it_ = (*itv_).second.begin (); if (it_ == (*itv_).second.end () || index2 () != j_) - *this = m.find_last1 (rank_, i_, j_); + *this = m.find1 (rank_, i_, j_, -1); } } return *this; @@ -2039,7 +1971,7 @@ namespace boost { namespace numeric { namespace ublas { #elif defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) return reference ((*this) (), &(*it_).second, index1 (), index2 ()); #elif defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) - return map_traits::make_reference ((*itv_).second, it_); + return detail::make_reference ((*itv_).second, it_); #endif } else { return reference ((*this) () (i_, j_)); @@ -2053,7 +1985,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator2 begin () const { self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -2061,7 +1993,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator2 end () const { self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -2133,11 +2065,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } class const_iterator2: @@ -2177,11 +2109,11 @@ namespace boost { namespace numeric { namespace ublas { else { j_ = index2 () + 1; if (rank_ == 1 && ++ itv_ == m.end2 ().itv_) - *this = m.find_first2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, 1); else if (rank_ == 1) { it_ = (*itv_).second.begin (); if (it_ == (*itv_).second.end () || index1 () != i_) - *this = m.find_first2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, 1); } } return *this; @@ -2194,11 +2126,11 @@ namespace boost { namespace numeric { namespace ublas { else { j_ = index2 () - 1; if (rank_ == 1 && -- itv_ == m.end2 ().itv_) - *this = m.find_last2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, -1); else if (rank_ == 1) { it_ = (*itv_).second.begin (); if (it_ == (*itv_).second.end () || index1 () != i_) - *this = m.find_last2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, -1); } } return *this; @@ -2223,7 +2155,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator1 begin () const { const self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -2231,7 +2163,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator1 end () const { const self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -2301,11 +2233,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } class iterator2: @@ -2340,11 +2272,11 @@ namespace boost { namespace numeric { namespace ublas { else { j_ = index2 () + 1; if (rank_ == 1 && ++ itv_ == m.end2 ().itv_) - *this = m.find_first2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, 1); else if (rank_ == 1) { it_ = (*itv_).second.begin (); if (it_ == (*itv_).second.end () || index1 () != i_) - *this = m.find_first2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, 1); } } return *this; @@ -2357,11 +2289,11 @@ namespace boost { namespace numeric { namespace ublas { else { j_ = index2 () - 1; if (rank_ == 1 && -- itv_ == m.end2 ().itv_) - *this = m.find_last2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, -1); else if (rank_ == 1) { it_ = (*itv_).second.begin (); if (it_ == (*itv_).second.end () || index1 () != i_) - *this = m.find_last2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, -1); } } return *this; @@ -2378,7 +2310,7 @@ namespace boost { namespace numeric { namespace ublas { #elif defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) return reference ((*this) (), &(*it_).second, index1 (), index2 ()); #elif defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) - return map_traits::make_reference ((*itv_).second, it_); + return detail::make_reference ((*itv_).second, it_); #endif } else { return reference ((*this) () (i_, j_)); @@ -2392,7 +2324,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator1 begin () const { self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -2400,7 +2332,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator1 end () const { self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -2472,11 +2404,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } // Reverse iterators @@ -2601,7 +2533,7 @@ namespace boost { namespace numeric { namespace ublas { index1_data_ (functor_type::size1 (ae ().size1 (), ae ().size2 ()) + 1), index2_data_ (non_zeros), value_data_ (non_zeros) { index1_data_ [filled1_ - 1] = k_based (filled2_); - reserve (non_zeros_); + reserve (non_zeros_, false); matrix_assign (scalar_assign (), *this, ae); } @@ -2653,7 +2585,7 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size1, size_type size2, size_type non_zeros = 0) { + void resize (size_type size1, size_type size2, size_type non_zeros = 0, bool preserve = true) { size1_ = size1; size2_ = size2; non_zeros_ = std::max (non_zeros, std::min (size1_, size2_)); @@ -2664,23 +2596,23 @@ namespace boost { namespace numeric { namespace ublas { non_zeros_ = size1_ * size2_; filled1_ = 1; filled2_ = 0; - index1_data ().resize (functor_type::size1 (size1, size2) + 1); - index2_data ().resize (non_zeros_); - value_data ().resize (non_zeros_); + detail::resize (index1_data (), functor_type::size1 (size1_, size2_) + 1, preserve); + detail::resize (index2_data (), non_zeros_, preserve); + detail::resize (value_data (), non_zeros_, preserve); index1_data_ [filled1_ - 1] = k_based (filled2_); } // Reserving BOOST_UBLAS_INLINE - void reserve (size_type non_zeros = 0, bool preserve = false) { + void reserve (size_type non_zeros = 0, bool preserve = true) { non_zeros_ = std::max (non_zeros, std::min (size1_, size2_)); // Guarding against overflow. // Thanks to Alexei Novakov for the hint. // non_zeros_ = std::min (non_zeros_, size1_ * size2_); if (size1_ > 0 && non_zeros_ / size1_ >= size2_) non_zeros_ = size1_ * size2_; - index2_data ().resize (non_zeros_, preserve); - value_data ().resize (non_zeros_, preserve); + detail::resize (index2_data (), non_zeros_, preserve); + detail::resize (value_data (), non_zeros_, preserve); } // Proxy support @@ -2752,10 +2684,11 @@ namespace boost { namespace numeric { namespace ublas { non_zeros_ = m.non_zeros_; filled1_ = m.filled1_; filled2_ = m.filled2_; + detail::resize (index1_data (), functor_type::size1 (size1_, size2_) + 1, false); + detail::resize (index2_data (), non_zeros_, false); + detail::resize (value_data (), non_zeros_, false); index1_data () = m.index1_data (); - index2_data ().resize (non_zeros_); index2_data () = m.index2_data (); - value_data ().resize (non_zeros_); value_data () = m.value_data (); } return *this; @@ -2780,7 +2713,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE compressed_matrix &reset(const matrix_expression &ae) { self_type temporary (ae, non_zeros_); - resize (temporary.size1 (), temporary.size2 (), non_zeros_); + resize (temporary.size1 (), temporary.size2 (), non_zeros_, false); return assign_temporary (temporary); } template @@ -2868,7 +2801,7 @@ namespace boost { namespace numeric { namespace ublas { void push_back (size_type i, size_type j, const_reference t) { BOOST_UBLAS_CHECK (index1_data () [filled1_ - 1] == k_based (filled2_), internal_logic ()); if (filled2_ >= non_zeros_) - reserve (2 * non_zeros_, true); + reserve (2 * non_zeros_); size_type element1 = functor_type::element1 (i, size1_, j, size2_); size_type element2 = functor_type::element2 (i, size1_, j, size2_); while (filled1_ < element1 + 2) { @@ -2893,7 +2826,7 @@ namespace boost { namespace numeric { namespace ublas { void insert (size_type i, size_type j, const_reference t) { BOOST_UBLAS_CHECK (index1_data () [filled1_ - 1] == k_based (filled2_), internal_logic ()); if (filled2_ >= non_zeros_) - reserve (2 * non_zeros_, true); + reserve (2 * non_zeros_); size_type element1 = functor_type::element1 (i, size1_, j, size2_); size_type element2 = functor_type::element2 (i, size1_, j, size2_); while (filled1_ < element1 + 2) { @@ -2985,7 +2918,7 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - const_iterator1 find1 (int rank, size_type i, size_type j, int direction) const { + const_iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) const { for (;;) { size_type address1 (functor_type::address1 (i, size1_, j, size2_)); size_type address2 (functor_type::address2 (i, size1_, j, size2_)); @@ -3022,7 +2955,7 @@ namespace boost { namespace numeric { namespace ublas { } // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - iterator1 find1 (int rank, size_type i, size_type j, int direction) { + iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) { for (;;) { size_type address1 (functor_type::address1 (i, size1_, j, size2_)); size_type address2 (functor_type::address2 (i, size1_, j, size2_)); @@ -3059,7 +2992,7 @@ namespace boost { namespace numeric { namespace ublas { } // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - const_iterator2 find2 (int rank, size_type i, size_type j, int direction) const { + const_iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) const { for (;;) { size_type address1 (functor_type::address1 (i, size1_, j, size2_)); size_type address2 (functor_type::address2 (i, size1_, j, size2_)); @@ -3096,7 +3029,7 @@ namespace boost { namespace numeric { namespace ublas { } // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - iterator2 find2 (int rank, size_type i, size_type j, int direction) { + iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) { for (;;) { size_type address1 (functor_type::address1 (i, size1_, j, size2_)); size_type address2 (functor_type::address2 (i, size1_, j, size2_)); @@ -3131,38 +3064,6 @@ namespace boost { namespace numeric { namespace ublas { } } } - BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j, -1); - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j, -1); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j, -1); - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j, -1); - } // Iterators simply are pointers. @@ -3203,7 +3104,7 @@ namespace boost { namespace numeric { namespace ublas { else { i_ = index1 () + 1; if (rank_ == 1) - *this = m.find_first1 (rank_, i_, j_); + *this = m.find1 (rank_, i_, j_, 1); } return *this; } @@ -3215,7 +3116,7 @@ namespace boost { namespace numeric { namespace ublas { else { i_ = index1 () - 1; if (rank_ == 1) - *this = m.find_last1 (rank_, i_, j_); + *this = m.find1 (rank_, i_, j_, -1); } return *this; } @@ -3239,7 +3140,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator2 begin () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3247,7 +3148,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator2 end () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3317,11 +3218,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } class iterator1: @@ -3356,7 +3257,7 @@ namespace boost { namespace numeric { namespace ublas { else { i_ = index1 () + 1; if (rank_ == 1) - *this = m.find_first1 (rank_, i_, j_); + *this = m.find1 (rank_, i_, j_, 1); } return *this; } @@ -3368,7 +3269,7 @@ namespace boost { namespace numeric { namespace ublas { else { i_ = index1 () - 1; if (rank_ == 1) - *this = m.find_last1 (rank_, i_, j_); + *this = m.find1 (rank_, i_, j_, -1); } return *this; } @@ -3396,7 +3297,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator2 begin () const { self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3404,7 +3305,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator2 end () const { self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3476,11 +3377,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } class const_iterator2: @@ -3520,7 +3421,7 @@ namespace boost { namespace numeric { namespace ublas { else { j_ = index2 () + 1; if (rank_ == 1) - *this = m.find_first2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, 1); } return *this; } @@ -3532,7 +3433,7 @@ namespace boost { namespace numeric { namespace ublas { else { j_ = index2 () - 1; if (rank_ == 1) - *this = m.find_last2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, -1); } return *this; } @@ -3556,7 +3457,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator1 begin () const { const self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3564,7 +3465,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator1 end () const { const self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3634,11 +3535,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } class iterator2: @@ -3673,7 +3574,7 @@ namespace boost { namespace numeric { namespace ublas { else { j_ = index2 () + 1; if (rank_ == 1) - *this = m.find_first2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, 1); } return *this; } @@ -3685,7 +3586,7 @@ namespace boost { namespace numeric { namespace ublas { else { j_ = index2 (); if (rank_ == 1) - *this = m.find_last2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, -1); } return *this; } @@ -3713,7 +3614,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator1 begin () const { self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3721,7 +3622,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator1 end () const { self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -3793,11 +3694,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } // Reverse iterators @@ -3935,7 +3836,7 @@ namespace boost { namespace numeric { namespace ublas { filled_ (0), sorted_ (true), index1_data_ (non_zeros), index2_data_ (non_zeros), value_data_ (non_zeros) { - reserve (non_zeros_); + reserve (non_zeros_, false); matrix_assign (scalar_assign (), *this, ae); } @@ -3987,33 +3888,35 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size1, size_type size2, size_type non_zeros = 0) { + void resize (size_type size1, size_type size2, size_type non_zeros = 0, bool preserve = true) { size1_ = size1; size2_ = size2; non_zeros_ = std::max (non_zeros, std::min (size1_, size2_)); // Guarding against overflow. // Thanks to Alexei Novakov for the hint. // non_zeros_ = std::min (non_zeros_, size1_ * size2_); - if (size1_ > 0 && non_zeros_ / size1_ >= size2_) - non_zeros_ = size1_ * size2_; + // FIX: coordinate_vector may contain duplicate elements. + // if (size1_ > 0 && non_zeros_ / size1_ >= size2_) + // non_zeros_ = size1_ * size2_; filled_ = 0; - index1_data ().resize (non_zeros_); - index2_data ().resize (non_zeros_); - value_data ().resize (non_zeros_); + detail::resize (index1_data (), non_zeros_, preserve); + detail::resize (index2_data (), non_zeros_, preserve); + detail::resize (value_data (), non_zeros_, preserve); } // Reserving BOOST_UBLAS_INLINE - void reserve (size_type non_zeros = 0, bool preserve = false) { + void reserve (size_type non_zeros = 0, bool preserve = true) { non_zeros_ = std::max (non_zeros, std::min (size1_, size2_)); // Guarding against overflow. // Thanks to Alexei Novakov for the hint. // non_zeros_ = std::min (non_zeros_, size1_ * size2_); - if (size1_ > 0 && non_zeros_ / size1_ >= size2_) - non_zeros_ = size1_ * size2_; - index1_data ().resize (non_zeros_, preserve); - index2_data ().resize (non_zeros_, preserve); - value_data ().resize (non_zeros_, preserve); + // FIX: coordinate_vector may contain duplicate elements. + // if (size1_ > 0 && non_zeros_ / size1_ >= size2_) + // non_zeros_ = size1_ * size2_; + detail::resize (index1_data (), non_zeros_, preserve); + detail::resize (index2_data (), non_zeros_, preserve); + detail::resize (value_data (), non_zeros_, preserve); } // Proxy support @@ -4098,11 +4001,11 @@ namespace boost { namespace numeric { namespace ublas { non_zeros_ = m.non_zeros_; filled_ = m.filled_; sorted_ = m.sorted_; - index1_data ().resize (non_zeros_); + detail::resize (index1_data (), non_zeros_, false); + detail::resize (index2_data (), non_zeros_, false); + detail::resize (value_data (), non_zeros_, false); index1_data () = m.index1_data (); - index2_data ().resize (non_zeros_); index2_data () = m.index2_data (); - value_data ().resize (non_zeros_); value_data () = m.value_data (); } return *this; @@ -4127,7 +4030,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE coordinate_matrix &reset(const matrix_expression &ae) { self_type temporary (ae, non_zeros_); - resize (temporary.size1 (), temporary.size2 (), non_zeros_); + resize (temporary.size1 (), temporary.size2 (), non_zeros_, false); return assign_temporary (temporary); } template @@ -4213,21 +4116,26 @@ namespace boost { namespace numeric { namespace ublas { // Sorting BOOST_UBLAS_INLINE void sort () const { - if (! sorted_) { - typedef std::pair pair_type; - typedef std::pair triple_type; - unbounded_array a (filled_); - size_type i; - for (i = 0; i < filled_; ++ i) - a [i] = triple_type (pair_type (index1_data_ [i], index2_data_ [i]), value_data_ [i]); - std::sort (a.begin (), a.end (), detail::less_triple ()); - for (i = 0; i < filled_; ++ i) { - index1_data_ [i] = a [i].first.first; - index2_data_ [i] = a [i].first.second; - value_data_ [i] = a [i].second; + if (! sorted_ && filled_ > 0) { + index_triple_array + ita (filled_, index1_data_, index2_data_, value_data_); + std::sort (ita.begin (), ita.end ()); + // FIX: check for duplicates + size_type filled = 1; + for (size_type i = 1; i < filled_; ++ i) { + if (index1_data_ [filled - 1] != index1_data_ [i] || + index2_data_ [filled - 1] != index2_data_ [i]) { + ++ filled; + if (filled - 1 != i) { + index1_data_ [filled - 1] = index1_data_ [i]; + index2_data_ [filled - 1] = index2_data_ [i]; + value_data_ [filled - 1] = value_data_ [i]; + } + } else { + value_data_ [filled - 1] += value_data_ [i]; + } } + filled_ = filled; sorted_ = true; } } @@ -4236,7 +4144,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE void push_back (size_type i, size_type j, const_reference t) { if (filled_ >= non_zeros_) - reserve (2 * non_zeros_, true); + reserve (2 * non_zeros_); size_type element1 = functor_type::element1 (i, size1_, j, size2_); size_type element2 = functor_type::element2 (i, size1_, j, size2_); if (filled_ == 0 || @@ -4255,7 +4163,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE void insert (size_type i, size_type j, const_reference t) { if (filled_ >= non_zeros_) - reserve (2 * non_zeros_, true); + reserve (2 * non_zeros_); size_type element1 = functor_type::element1 (i, size1_, j, size2_); size_type element2 = functor_type::element2 (i, size1_, j, size2_); ++ filled_; @@ -4313,7 +4221,7 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - const_iterator1 find1 (int rank, size_type i, size_type j, int direction) const { + const_iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) const { sort (); for (;;) { size_type address1 (functor_type::address1 (i, size1_, j, size2_)); @@ -4351,7 +4259,7 @@ namespace boost { namespace numeric { namespace ublas { } // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - iterator1 find1 (int rank, size_type i, size_type j, int direction) { + iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) { sort (); for (;;) { size_type address1 (functor_type::address1 (i, size1_, j, size2_)); @@ -4389,7 +4297,7 @@ namespace boost { namespace numeric { namespace ublas { } // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - const_iterator2 find2 (int rank, size_type i, size_type j, int direction) const { + const_iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) const { sort (); for (;;) { size_type address1 (functor_type::address1 (i, size1_, j, size2_)); @@ -4427,7 +4335,7 @@ namespace boost { namespace numeric { namespace ublas { } // This function seems to be big. So we do not let the compiler inline it. // BOOST_UBLAS_INLINE - iterator2 find2 (int rank, size_type i, size_type j, int direction) { + iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) { sort (); for (;;) { size_type address1 (functor_type::address1 (i, size1_, j, size2_)); @@ -4463,38 +4371,6 @@ namespace boost { namespace numeric { namespace ublas { } } } - BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - return find1 (rank, i, j, -1); - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - return find1 (rank, i, j, -1); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j, 1); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - return find2 (rank, i, j, -1); - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { - return find2 (rank, i, j, -1); - } // Iterators simply are pointers. @@ -4535,7 +4411,7 @@ namespace boost { namespace numeric { namespace ublas { else { i_ = index1 () + 1; if (rank_ == 1) - *this = m.find_first1 (rank_, i_, j_); + *this = m.find1 (rank_, i_, j_, 1); } return *this; } @@ -4547,7 +4423,7 @@ namespace boost { namespace numeric { namespace ublas { else { i_ = index1 () - 1; if (rank_ == 1) - *this = m.find_last1 (rank_, i_, j_); + *this = m.find1 (rank_, i_, j_, -1); } return *this; } @@ -4571,7 +4447,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator2 begin () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -4579,7 +4455,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator2 end () const { const self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -4649,11 +4525,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } class iterator1: @@ -4688,7 +4564,7 @@ namespace boost { namespace numeric { namespace ublas { else { i_ = index1 () + 1; if (rank_ == 1) - *this = m.find_first1 (rank_, i_, j_); + *this = m.find1 (rank_, i_, j_, 1); } return *this; } @@ -4700,7 +4576,7 @@ namespace boost { namespace numeric { namespace ublas { else { i_ = index1 () - 1; if (rank_ == 1) - *this = m.find_last1 (rank_, i_, j_); + *this = m.find1 (rank_, i_, j_, -1); } return *this; } @@ -4728,7 +4604,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator2 begin () const { self_type &m = (*this) (); - return m.find_first2 (1, index1 (), 0); + return m.find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -4736,7 +4612,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator2 end () const { self_type &m = (*this) (); - return m.find_first2 (1, index1 (), m.size2 ()); + return m.find2 (1, index1 (), m.size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -4808,11 +4684,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } class const_iterator2: @@ -4852,7 +4728,7 @@ namespace boost { namespace numeric { namespace ublas { else { j_ = index2 () + 1; if (rank_ == 1) - *this = m.find_first2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, 1); } return *this; } @@ -4864,7 +4740,7 @@ namespace boost { namespace numeric { namespace ublas { else { j_ = index2 () - 1; if (rank_ == 1) - *this = m.find_last2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, -1); } return *this; } @@ -4888,7 +4764,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator1 begin () const { const self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -4896,7 +4772,7 @@ namespace boost { namespace numeric { namespace ublas { #endif const_iterator1 end () const { const self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -4966,11 +4842,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } class iterator2: @@ -5005,7 +4881,7 @@ namespace boost { namespace numeric { namespace ublas { else { j_ = index2 () + 1; if (rank_ == 1) - *this = m.find_first2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, 1); } return *this; } @@ -5017,7 +4893,7 @@ namespace boost { namespace numeric { namespace ublas { else { j_ = index2 (); if (rank_ == 1) - *this = m.find_last2 (rank_, i_, j_); + *this = m.find2 (rank_, i_, j_, -1); } return *this; } @@ -5045,7 +4921,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator1 begin () const { self_type &m = (*this) (); - return m.find_first1 (1, 0, index2 ()); + return m.find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -5053,7 +4929,7 @@ namespace boost { namespace numeric { namespace ublas { #endif iterator1 end () const { self_type &m = (*this) (); - return m.find_first1 (1, m.size1 (), index2 ()); + return m.find1 (1, m.size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -5125,11 +5001,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } // Reverse iterators @@ -5175,7 +5051,7 @@ namespace boost { namespace numeric { namespace ublas { size_type size1_; size_type size2_; size_type non_zeros_; - size_type filled_; + mutable size_type filled_; mutable bool sorted_; mutable index_array_type index1_data_; mutable index_array_type index2_data_; diff --git a/include/boost/numeric/ublas/new.hpp b/include/boost/numeric/ublas/new.hpp new file mode 100644 index 00000000..8448e6ea --- /dev/null +++ b/include/boost/numeric/ublas/new.hpp @@ -0,0 +1,51 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + +#ifndef BOOST_UBLAS_NEW_H +#define BOOST_UBLAS_NEW_H + +void *operator new (std::size_t size) { + size += 16; + void *p = malloc (size); + char offset = (unsigned long) p % 16; + if (offset == 0) + offset = 16; + (char *) p += offset; + *((char *) p - 1) = offset; + return p; +} +void operator delete (void *p) { + char offset = *((char *) p - 1); + (char *) p -= offset; + free (p); +} +void *operator new [] (std::size_t size) { + size += 16; + void *p = malloc (size); + char offset = (unsigned long) p % 16; + if (offset == 0) + offset = 16; + (char *) p += offset; + *((char *) p - 1) = offset; + return p; +} +void operator delete [] (void *p) { + char offset = *((char *) p - 1); + (char *) p -= offset; + free (p); +} + +#endif \ No newline at end of file diff --git a/include/boost/numeric/ublas/raw.hpp b/include/boost/numeric/ublas/raw.hpp index 4a48c34f..2b29e7a6 100755 --- a/include/boost/numeric/ublas/raw.hpp +++ b/include/boost/numeric/ublas/raw.hpp @@ -17,6 +17,407 @@ namespace boost { namespace numeric { namespace ublas { + template < typename V > + BOOST_UBLAS_INLINE + int size( const V &v ) ; + + template < typename V > + BOOST_UBLAS_INLINE + int size( const vector_reference &v ) ; + + template < typename M > + BOOST_UBLAS_INLINE + int size1( const M &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + int size2( const M &m ) ; + + template < typename M > + BOOST_UBLAS_INLINE + int size1( const matrix_reference &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + int size2( const matrix_reference &m ) ; + + template < typename M > + BOOST_UBLAS_INLINE + int leading_dimension( const M &m, row_major_tag ) ; + template < typename M > + BOOST_UBLAS_INLINE + int leading_dimension( const M &m, column_major_tag ) ; + template < typename M > + BOOST_UBLAS_INLINE + int leading_dimension( const M &m ) ; + + template < typename M > + BOOST_UBLAS_INLINE + int leading_dimension( const matrix_reference &m ) ; + + template < typename V > + BOOST_UBLAS_INLINE + int stride( const V &v ) ; + + template < typename V > + BOOST_UBLAS_INLINE + int stride( const vector_range &v ) ; + template < typename V > + BOOST_UBLAS_INLINE + int stride( const vector_slice &v ) ; + + template < typename M > + BOOST_UBLAS_INLINE + int stride( const matrix_row &v ) ; + template < typename M > + BOOST_UBLAS_INLINE + int stride( const matrix_column &v ) ; + + template < typename M > + BOOST_UBLAS_INLINE + int stride1( const M &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + int stride2( const M &m ) ; + + template < typename M > + BOOST_UBLAS_INLINE + int stride1( const matrix_reference &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + int stride2( const matrix_reference &m ) ; + + template < typename T, std::size_t M, std::size_t N > + BOOST_UBLAS_INLINE + int stride1( const c_matrix &m ) ; + template < typename T, std::size_t M, std::size_t N > + BOOST_UBLAS_INLINE + int stride2( const c_matrix &m ) ; + + template < typename M > + BOOST_UBLAS_INLINE + int stride1( const matrix_range &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + int stride1( const matrix_slice &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + int stride2( const matrix_range &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + int stride2( const matrix_slice &m ) ; + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename MV > + BOOST_UBLAS_INLINE + typename MV::const_pointer data( const MV &mv ) ; +#endif + // We need data_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename MV > + BOOST_UBLAS_INLINE + typename MV::const_pointer data_const( const MV &mv ) ; + template < typename MV > + BOOST_UBLAS_INLINE + typename MV::pointer data( MV &mv ) ; + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer data( const vector_reference &v ) ; +#endif + // We need data_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer data_const( const vector_reference &v ) ; + template < typename V > + BOOST_UBLAS_INLINE + typename V::pointer data( vector_reference &v ) ; + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename T, std::size_t N > + BOOST_UBLAS_INLINE + typename c_vector::const_pointer data( const c_vector &v ) ; +#endif +#ifndef BOOST_MSVC + // We need data_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename T, std::size_t N > + BOOST_UBLAS_INLINE + typename c_vector::const_pointer data_const( const c_vector &v ) ; + template < typename T, std::size_t N > + BOOST_UBLAS_INLINE + typename c_vector::pointer data( c_vector &v ) ; +#endif + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer data( const vector_range &v ) ; + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer data( const vector_slice &v ) ; +#endif + // We need data_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer data_const( const vector_range &v ) ; + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer data_const( const vector_slice &v ) ; + template < typename V > + BOOST_UBLAS_INLINE + typename V::pointer data( vector_range &v ) ; + template < typename V > + BOOST_UBLAS_INLINE + typename V::pointer data( vector_slice &v ) ; + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer data( const matrix_reference &m ) ; +#endif + // We need data_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer data_const( const matrix_reference &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::pointer data( matrix_reference &m ) ; + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename T, std::size_t M, std::size_t N > + BOOST_UBLAS_INLINE + typename c_matrix::const_pointer data( const c_matrix &m ) ; +#endif +#ifndef BOOST_MSVC + // We need data_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename T, std::size_t M, std::size_t N > + BOOST_UBLAS_INLINE + typename c_matrix::const_pointer data_const( const c_matrix &m ) ; + template < typename T, std::size_t M, std::size_t N > + BOOST_UBLAS_INLINE + typename c_matrix::pointer data( c_matrix &m ) ; +#endif + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer data( const matrix_row &v ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer data( const matrix_column &v ) ; +#endif + // We need data_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer data_const( const matrix_row &v ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer data_const( const matrix_column &v ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::pointer data( matrix_row &v ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::pointer data( matrix_column &v ) ; + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer data( const matrix_range &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer data( const matrix_slice &m ) ; +#endif + // We need data_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer data_const( const matrix_range &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer data_const( const matrix_slice &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::pointer data( matrix_range &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::pointer data( matrix_slice &m ) ; + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename MV > + BOOST_UBLAS_INLINE + typename MV::const_pointer base( const MV &mv ) ; +#endif + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename MV > + BOOST_UBLAS_INLINE + typename MV::const_pointer base_const( const MV &mv ) ; + template < typename MV > + BOOST_UBLAS_INLINE + typename MV::pointer base( MV &mv ) ; + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer base( const vector_reference &v ) ; +#endif + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer base_const( const vector_reference &v ) ; + template < typename V > + BOOST_UBLAS_INLINE + typename V::pointer base( vector_reference &v ) ; + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename T, std::size_t N > + BOOST_UBLAS_INLINE + typename c_vector::const_pointer base( const c_vector &v ) ; +#endif +#ifndef BOOST_MSVC + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename T, std::size_t N > + BOOST_UBLAS_INLINE + typename c_vector::const_pointer base_const( const c_vector &v ) ; + template < typename T, std::size_t N > + BOOST_UBLAS_INLINE + typename c_vector::pointer base( c_vector &v ) ; +#endif + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer base( const vector_range &v ) ; + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer base( const vector_slice &v ) ; +#endif + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer base_const( const vector_range &v ) ; + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer base_const( const vector_slice &v ) ; + template < typename V > + BOOST_UBLAS_INLINE + typename V::pointer base( vector_range &v ) ; + template < typename V > + BOOST_UBLAS_INLINE + typename V::pointer base( vector_slice &v ) ; + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base( const matrix_reference &m ) ; +#endif + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base_const( const matrix_reference &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::pointer base( matrix_reference &m ) ; + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename T, std::size_t M, std::size_t N > + BOOST_UBLAS_INLINE + typename c_matrix::const_pointer base( const c_matrix &m ) ; +#endif +#ifndef BOOST_MSVC + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename T, std::size_t M, std::size_t N > + BOOST_UBLAS_INLINE + typename c_matrix::const_pointer base_const( const c_matrix &m ) ; + template < typename T, std::size_t M, std::size_t N > + BOOST_UBLAS_INLINE + typename c_matrix::pointer base( c_matrix &m ) ; +#endif + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base( const matrix_row &v ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base( const matrix_column &v ) ; +#endif + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base_const( const matrix_row &v ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base_const( const matrix_column &v ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::pointer base( matrix_row &v ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::pointer base( matrix_column &v ) ; + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base( const matrix_range &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base( const matrix_slice &m ) ; +#endif + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base_const( const matrix_range &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base_const( const matrix_slice &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::pointer base( matrix_range &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::pointer base( matrix_slice &m ) ; + + template < typename MV > + BOOST_UBLAS_INLINE + typename MV::size_type start( const MV &mv ) ; + + template < typename V > + BOOST_UBLAS_INLINE + typename V::size_type start( const vector_range &v ) ; + template < typename V > + BOOST_UBLAS_INLINE + typename V::size_type start( const vector_slice &v ) ; + + template < typename M > + BOOST_UBLAS_INLINE + typename M::size_type start( const matrix_row &v ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::size_type start( const matrix_column &v ) ; + + template < typename M > + BOOST_UBLAS_INLINE + typename M::size_type start( const matrix_range &m ) ; + template < typename M > + BOOST_UBLAS_INLINE + typename M::size_type start( const matrix_slice &m ) ; + + + template < typename V > BOOST_UBLAS_INLINE int size( const V &v ) { @@ -128,7 +529,7 @@ namespace boost { namespace numeric { namespace ublas { template < typename T, std::size_t M, std::size_t N > BOOST_UBLAS_INLINE int stride1( const c_matrix &m ) { - return m.size2() ; + return N ; } template < typename T, std::size_t M, std::size_t N > BOOST_UBLAS_INLINE @@ -223,12 +624,12 @@ namespace boost { namespace numeric { namespace ublas { template < typename V > BOOST_UBLAS_INLINE typename V::const_pointer data( const vector_range &v ) { - return data( v.data() ) + v.start() ; + return data( v.data() ) + v.start() * stride (v.data() ) ; } template < typename V > BOOST_UBLAS_INLINE typename V::const_pointer data( const vector_slice &v ) { - return data( v.data() ) + v.start() ; + return data( v.data() ) + v.start() * stride (v.data() ) ; } #endif // We need data_const() mostly due to MSVC 6.0. @@ -236,22 +637,22 @@ namespace boost { namespace numeric { namespace ublas { template < typename V > BOOST_UBLAS_INLINE typename V::const_pointer data_const( const vector_range &v ) { - return data_const( v.data() ) + v.start() ; + return data_const( v.data() ) + v.start() * stride (v.data() ) ; } template < typename V > BOOST_UBLAS_INLINE typename V::const_pointer data_const( const vector_slice &v ) { - return data_const( v.data() ) + v.start() ; + return data_const( v.data() ) + v.start() * stride (v.data() ) ; } template < typename V > BOOST_UBLAS_INLINE typename V::pointer data( vector_range &v ) { - return data( v.data() ) + v.start() ; + return data( v.data() ) + v.start() * stride (v.data() ) ; } template < typename V > BOOST_UBLAS_INLINE typename V::pointer data( vector_slice &v ) { - return data( v.data() ) + v.start() ; + return data( v.data() ) + v.start() * stride (v.data() ) ; } #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING @@ -366,6 +767,254 @@ namespace boost { namespace numeric { namespace ublas { return data( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ; } +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename MV > + BOOST_UBLAS_INLINE + typename MV::const_pointer base( const MV &mv ) { + return &mv.data().begin()[0] ; + } +#endif + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename MV > + BOOST_UBLAS_INLINE + typename MV::const_pointer base_const( const MV &mv ) { + return &mv.data().begin()[0] ; + } + template < typename MV > + BOOST_UBLAS_INLINE + typename MV::pointer base( MV &mv ) { + return &mv.data().begin()[0] ; + } + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer base( const vector_reference &v ) { + return base( v.expression () ) ; + } +#endif + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer base_const( const vector_reference &v ) { + return base_const( v.expression () ) ; + } + template < typename V > + BOOST_UBLAS_INLINE + typename V::pointer base( vector_reference &v ) { + return base( v.expression () ) ; + } + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename T, std::size_t N > + BOOST_UBLAS_INLINE + typename c_vector::const_pointer base( const c_vector &v ) { + return v.data() ; + } +#endif +#ifndef BOOST_MSVC + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename T, std::size_t N > + BOOST_UBLAS_INLINE + typename c_vector::const_pointer base_const( const c_vector &v ) { + return v.data() ; + } + template < typename T, std::size_t N > + BOOST_UBLAS_INLINE + typename c_vector::pointer base( c_vector &v ) { + return v.data() ; + } +#endif + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer base( const vector_range &v ) { + return base( v.data() ) ; + } + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer base( const vector_slice &v ) { + return base( v.data() ) ; + } +#endif + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer base_const( const vector_range &v ) { + return base_const( v.data() ) ; + } + template < typename V > + BOOST_UBLAS_INLINE + typename V::const_pointer base_const( const vector_slice &v ) { + return base_const( v.data() ) ; + } + template < typename V > + BOOST_UBLAS_INLINE + typename V::pointer base( vector_range &v ) { + return base( v.data() ) ; + } + template < typename V > + BOOST_UBLAS_INLINE + typename V::pointer base( vector_slice &v ) { + return base( v.data() ) ; + } + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base( const matrix_reference &m ) { + return base( m.expression () ) ; + } +#endif + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base_const( const matrix_reference &m ) { + return base_const( m.expression () ) ; + } + template < typename M > + BOOST_UBLAS_INLINE + typename M::pointer base( matrix_reference &m ) { + return base( m.expression () ) ; + } + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename T, std::size_t M, std::size_t N > + BOOST_UBLAS_INLINE + typename c_matrix::const_pointer base( const c_matrix &m ) { + return m.data() ; + } +#endif +#ifndef BOOST_MSVC + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename T, std::size_t M, std::size_t N > + BOOST_UBLAS_INLINE + typename c_matrix::const_pointer base_const( const c_matrix &m ) { + return m.data() ; + } + template < typename T, std::size_t M, std::size_t N > + BOOST_UBLAS_INLINE + typename c_matrix::pointer base( c_matrix &m ) { + return m.data() ; + } +#endif + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base( const matrix_row &v ) { + return base( v.data() ) ; + } + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base( const matrix_column &v ) { + return base( v.data() ) ; + } +#endif + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base_const( const matrix_row &v ) { + return base_const( v.data() ) ; + } + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base_const( const matrix_column &v ) { + return base_const( v.data() ) ; + } + template < typename M > + BOOST_UBLAS_INLINE + typename M::pointer base( matrix_row &v ) { + return base( v.data() ) ; + } + template < typename M > + BOOST_UBLAS_INLINE + typename M::pointer base( matrix_column &v ) { + return base( v.data() ) ; + } + +#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base( const matrix_range &m ) { + return base( m.data() ) ; + } + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base( const matrix_slice &m ) { + return base( m.data() ) ; + } +#endif + // We need base_const() mostly due to MSVC 6.0. + // But how shall we write portable code otherwise? + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base_const( const matrix_range &m ) { + return base_const( m.data() ) ; + } + template < typename M > + BOOST_UBLAS_INLINE + typename M::const_pointer base_const( const matrix_slice &m ) { + return base_const( m.data() ) ; + } + template < typename M > + BOOST_UBLAS_INLINE + typename M::pointer base( matrix_range &m ) { + return base( m.data() ) ; + } + template < typename M > + BOOST_UBLAS_INLINE + typename M::pointer base( matrix_slice &m ) { + return base( m.data() ) ; + } + + template < typename MV > + BOOST_UBLAS_INLINE + typename MV::size_type start( const MV &mv ) { + return 0 ; + } + + template < typename V > + BOOST_UBLAS_INLINE + typename V::size_type start( const vector_range &v ) { + return v.start() * stride (v.data() ) ; + } + template < typename V > + BOOST_UBLAS_INLINE + typename V::size_type start( const vector_slice &v ) { + return v.start() * stride (v.data() ) ; + } + + template < typename M > + BOOST_UBLAS_INLINE + typename M::size_type start( const matrix_row &v ) { + return v.index() * stride1( v.data() ) ; + } + template < typename M > + BOOST_UBLAS_INLINE + typename M::size_type start( const matrix_column &v ) { + return v.index() * stride2( v.data() ) ; + } + + template < typename M > + BOOST_UBLAS_INLINE + typename M::size_type start( const matrix_range &m ) { + return m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ; + } + template < typename M > + BOOST_UBLAS_INLINE + typename M::size_type start( const matrix_slice &m ) { + return m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ; + } + }}} #endif diff --git a/include/boost/numeric/ublas/storage.hpp b/include/boost/numeric/ublas/storage.hpp index 7a0d33df..37959b79 100644 --- a/include/boost/numeric/ublas/storage.hpp +++ b/include/boost/numeric/ublas/storage.hpp @@ -297,13 +297,7 @@ namespace boost { namespace numeric { namespace ublas { pointer data_; }; - template - BOOST_UBLAS_INLINE - unbounded_array &assign_temporary (unbounded_array &a1, unbounded_array &a2) { - return a1.assign_temporary (a2); - } - - // Bounded array + // Bounded array template class bounded_array { public: @@ -517,15 +511,9 @@ namespace boost { namespace numeric { namespace ublas { private: size_type size_; - value_type data_ [N]; + BOOST_UBLAS_ALIGN_16 value_type data_ [N]; }; - template - BOOST_UBLAS_INLINE - bounded_array &assign_temporary (bounded_array &a1, bounded_array &a2) { - return a1.assign_temporary (a2); - } - #ifdef BOOST_UBLAS_SIMPLE_ARRAY_ADAPTOR // Array adaptor @@ -1053,28 +1041,41 @@ namespace boost { namespace numeric { namespace ublas { #endif - template - BOOST_UBLAS_INLINE - std::valarray &assign_temporary (std::valarray &a1, std::valarray &a2) { - // Too unusual semantic. - // BOOST_UBLAS_CHECK (&a1 != &a2, external_logic ()); - if (&a1 != &a2) { - BOOST_UBLAS_CHECK (a1.size () == a2.size (), bad_size ()); - a1 = a2; - } - return a1; - } + namespace detail { + using namespace boost::numeric::ublas; - template - BOOST_UBLAS_INLINE - std::vector &assign_temporary (std::vector &a1, std::vector &a2) { - // Too unusual semantic. - // BOOST_UBLAS_CHECK (&a1 != &a2, external_logic ()); - if (&a1 != &a2) { - BOOST_UBLAS_CHECK (a1.size () == a2.size (), bad_size ()); - a1.swap (a2); + // Some helpers for unbounded_array + + template + BOOST_UBLAS_INLINE + void resize (unbounded_array &a, typename unbounded_array::size_type size, bool preserve) { + a.resize (size, preserve); } - return a1; + + // Some helpers for bounded_array + + template + BOOST_UBLAS_INLINE + void resize (bounded_array &a, typename bounded_array::size_type size, bool preserve) { + a.resize (size, preserve); + } + + // Some helpers for array_adaptor + + template + BOOST_UBLAS_INLINE + void resize (array_adaptor &a, typename array_adaptor::size_type size, bool preserve) { + a.resize (size, preserve); + } + + // Some helpers for std::vector + + template + BOOST_UBLAS_INLINE + void resize (std::vector &a, typename std::vector::size_type size, bool preserve) { + a.resize (size); + } + } // Range class @@ -1727,36 +1728,286 @@ namespace boost { namespace numeric { namespace ublas { template indirect_array indirect_array::all_; + // Gunter Winkler contributed the classes index_pair, index_pair_array, + // index_triple and index_triple_array to enable inplace sort of parallel arrays. + + template + class index_pair : + private boost::noncopyable, + public container_reference { + public: + typedef index_pair self_type; + typedef typename V::size_type size_type; + + BOOST_UBLAS_INLINE + index_pair(V& v, size_type i) : + container_reference(v), i_(i), + v1_(v.data1_[i]), v2_(v.data2_[i]) {} + BOOST_UBLAS_INLINE + index_pair(const self_type& rhs) : + container_reference(), i_(-1), + v1_(rhs.v1_), v2_(rhs.v2_) {} + + BOOST_UBLAS_INLINE + self_type& operator=(const self_type& rhs) { + v1_ = rhs.v1_; + v2_ = rhs.v2_; + if (i_ != size_type(-1)) { + (*this)().data1_[i_] = v1_; + (*this)().data2_[i_] = v2_; + } + return *this; + } + + BOOST_UBLAS_INLINE + void swap(self_type rhs) { + self_type tmp(rhs); + rhs = *this; + *this = tmp; + } +#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS + BOOST_UBLAS_INLINE + friend void swap(self_type lhs, self_type rhs) { + lhs.swap(rhs); + } +#endif + + BOOST_UBLAS_INLINE + bool compare(const self_type& rhs) const { + return (v1_ < rhs.v1_); + } + BOOST_UBLAS_INLINE + friend bool operator < (const self_type& lhs, const self_type& rhs) { + return lhs.compare(rhs); + } + + private: + size_type i_; + typename V::value1_type v1_; + typename V::value2_type v2_; + }; + + template + class index_pair_array: + private boost::noncopyable { + public: + typedef index_pair_array self_type; + typedef typename V1::value_type value1_type; + typedef typename V2::value_type value2_type; + + typedef typename std::size_t size_type; + typedef typename std::ptrdiff_t difference_type; + typedef index_pair value_type; + typedef value_type reference; + typedef const value_type& const_reference; + + BOOST_UBLAS_INLINE + index_pair_array(size_type size, V1& data1, V2& data2) : + size_(size),data1_(data1),data2_(data2) {} + + BOOST_UBLAS_INLINE + const size_type size() const { + return size_; + } + + BOOST_UBLAS_INLINE + const_reference operator () (size_type i) const { + return value_type((*this), i); + } + BOOST_UBLAS_INLINE + reference operator () (size_type i) { + return value_type((*this), i); + } + + typedef indexed_iterator iterator; + typedef indexed_const_iterator const_iterator; + + BOOST_UBLAS_INLINE + iterator begin() { + return iterator( (*this), 0); + } + BOOST_UBLAS_INLINE + iterator end() { + return iterator( (*this), size()); + } + + BOOST_UBLAS_INLINE + const_iterator begin() const { + return const_iterator( (*this), 0); + } + BOOST_UBLAS_INLINE + const_iterator end() const { + return const_iterator( (*this), size()); + } + + // unnecessary function: + BOOST_UBLAS_INLINE + bool compare(size_type i1, size_type i2) const { + return data1_[i1] < data1_[i2]; + } + + // gives a large speedup + BOOST_UBLAS_INLINE + friend void iter_swap(const iterator& lhs, const iterator& rhs) { + const size_type i1 = lhs.index(); + const size_type i2 = rhs.index(); + std::swap(lhs().data1_[i1], rhs().data1_[i2]); + std::swap(lhs().data2_[i1], rhs().data2_[i2]); + } + + private: + size_type size_; + V1& data1_; + V2& data2_; + + // friend class value_type; + friend class index_pair; + }; + + template + class index_triple : + private boost::noncopyable, + public container_reference { + public: + typedef index_triple self_type; + typedef typename M::size_type size_type; + + BOOST_UBLAS_INLINE + index_triple(M& m, size_type i) : + container_reference(m), i_(i), + v1_(m.data1_[i]), v2_(m.data2_[i]), v3_(m.data3_[i]) {} + BOOST_UBLAS_INLINE + index_triple(const self_type& rhs) : + container_reference(), i_(-1), + v1_(rhs.v1_), v2_(rhs.v2_), v3_(rhs.v3_) {} + + BOOST_UBLAS_INLINE + self_type& operator=(const self_type& rhs) { + v1_ = rhs.v1_; + v2_ = rhs.v2_; + v3_ = rhs.v3_; + if (i_ != size_type(-1)) { + (*this)().data1_[i_] = v1_; + (*this)().data2_[i_] = v2_; + (*this)().data3_[i_] = v3_; + } + return *this; + } + + BOOST_UBLAS_INLINE + void swap(self_type rhs) { + self_type tmp(rhs); + rhs = *this; + *this = tmp; + } +#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS + BOOST_UBLAS_INLINE + friend void swap(self_type lhs, self_type rhs) { + lhs.swap(rhs); + } +#endif + + BOOST_UBLAS_INLINE + bool compare(const self_type& rhs) const { + return ((v1_ < rhs.v1_) || + (v1_ == rhs.v1_ && v2_ < rhs.v2_)); + } + BOOST_UBLAS_INLINE + friend bool operator < (const self_type& lhs, const self_type& rhs) { + return lhs.compare(rhs); + } + + private: + size_type i_; + typename M::value1_type v1_; + typename M::value2_type v2_; + typename M::value3_type v3_; + }; + + template + class index_triple_array: + private boost::noncopyable { + public: + typedef index_triple_array self_type; + typedef typename V1::value_type value1_type; + typedef typename V2::value_type value2_type; + typedef typename V3::value_type value3_type; + + typedef typename std::size_t size_type; + typedef typename std::ptrdiff_t difference_type; + typedef index_triple value_type; + typedef value_type reference; + typedef const value_type& const_reference; + + BOOST_UBLAS_INLINE + index_triple_array(size_type size, V1& data1, V2& data2, V3& data3) : + size_(size),data1_(data1),data2_(data2),data3_(data3) {} + + BOOST_UBLAS_INLINE + const size_type size() const { + return size_; + } + + BOOST_UBLAS_INLINE + const_reference operator () (size_type i) const { + return value_type((*this), i); + } + BOOST_UBLAS_INLINE + reference operator () (size_type i) { + return value_type((*this), i); + } + + typedef indexed_iterator iterator; + typedef indexed_const_iterator const_iterator; + + BOOST_UBLAS_INLINE + iterator begin() { + return iterator( (*this), 0); + } + BOOST_UBLAS_INLINE + iterator end() { + return iterator( (*this), size()); + } + + BOOST_UBLAS_INLINE + const_iterator begin() const { + return const_iterator( (*this), 0); + } + BOOST_UBLAS_INLINE + const_iterator end() const { + return const_iterator( (*this), size()); + } + + // unnecessary function: + BOOST_UBLAS_INLINE + bool compare(size_type i1, size_type i2) const { + return ((data1_[i1] < data1_[i2]) || + (data1_[i1] == data1_[i2] && data2_[i1] < data2_[i2])); + } + + // gives a large speedup + BOOST_UBLAS_INLINE + friend void iter_swap(const iterator& lhs, const iterator& rhs) { + const size_type i1 = lhs.index(); + const size_type i2 = rhs.index(); + std::swap(lhs().data1_[i1], rhs().data1_[i2]); + std::swap(lhs().data2_[i1], rhs().data2_[i2]); + std::swap(lhs().data3_[i1], rhs().data3_[i2]); + } + + private: + size_type size_; + V1& data1_; + V2& data2_; + V3& data3_; + + // friend class value_type; + friend class index_triple; + }; + }}} #endif - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/include/boost/numeric/ublas/storage_sparse.hpp b/include/boost/numeric/ublas/storage_sparse.hpp index 399b0cec..7c8e322f 100644 --- a/include/boost/numeric/ublas/storage_sparse.hpp +++ b/include/boost/numeric/ublas/storage_sparse.hpp @@ -285,6 +285,14 @@ namespace boost { namespace numeric { namespace ublas { // Assuming std compliant allocator as requested during review. // if (! data_) // throw std::bad_alloc (); + std::fill (data_, data_ + size_, value_type ()); + } + BOOST_UBLAS_INLINE + map_array (no_init): + capacity_ (0), data_ (new value_type [0]), size_ (0) { + // Assuming std compliant allocator as requested during review. + // if (! data_) + // throw std::bad_alloc (); } BOOST_UBLAS_EXPLICIT BOOST_UBLAS_INLINE map_array (size_type size): @@ -292,6 +300,14 @@ namespace boost { namespace numeric { namespace ublas { // Assuming std compliant allocator as requested during review. // if (! data_) // throw std::bad_alloc (); + std::fill (data_, data_ + size_, value_type ()); + } + BOOST_UBLAS_EXPLICIT BOOST_UBLAS_INLINE + map_array (size_type size, no_init): + capacity_ (size), data_ (new value_type [size]), size_ (0) { + // Assuming std compliant allocator as requested during review. + // if (! data_) + // throw std::bad_alloc (); } BOOST_UBLAS_INLINE map_array (const map_array &a): @@ -320,7 +336,8 @@ namespace boost { namespace numeric { namespace ublas { // throw std::bad_alloc (); // if (! data_) // throw std::bad_alloc (); - std::copy (data_, data_ + size_, data); + std::copy (data_, data_ + std::min (size, size_), data); + std::fill (data + std::min (size, size_), data + size, value_type ()); delete [] data_; capacity_ = size << 1; data_ = data; @@ -597,21 +614,53 @@ namespace boost { namespace numeric { namespace ublas { size_type size_; }; - template - BOOST_UBLAS_INLINE - map_array &assign_temporary (map_array &a1, map_array &a2) { - return a1.assign_temporary (a2); + namespace detail { + using namespace boost::numeric::ublas; + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template + struct map_traits {}; + + template + struct map_traits > { + typedef typename map_array::data_reference reference; + }; + + template + struct map_traits > { + typedef typename std::map::mapped_type &reference; + + }; +#endif + + // Some helpers for map_array + + template + BOOST_UBLAS_INLINE + void reserve (map_array &a, typename map_array::size_type capacity) { + a.reserve (capacity); + } + + template + BOOST_UBLAS_INLINE + typename map_array::data_reference make_reference (map_array &a, typename map_array::iterator it) { + return reference (a, it); + } + + // Some helpers for std::map + + template + BOOST_UBLAS_INLINE + void reserve (std::map &a, typename std::map::size_type capacity) {} + + template + BOOST_UBLAS_INLINE + typename std::map::mapped_type &make_reference (std::map &a, typename std::map::iterator it) { + return (*it).second; + } + } - template - BOOST_UBLAS_INLINE - std::map &assign_temporary (std::map &a1, std::map &a2) { - // Too unusual semantic. - // BOOST_UBLAS_CHECK (&a1 != &a2, external_logic ()); - if (&a1 != &a2) - a1.swap (a2); - return a1; - } // This specialization is missing in Dinkumware's STL?! template BOOST_UBLAS_INLINE @@ -622,35 +671,6 @@ namespace boost { namespace numeric { namespace ublas { a1.swap (a2); } -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - template - struct map_traits {}; - template - struct map_traits > { - typedef typename std::map::size_type size_type; - typedef typename std::map::mapped_type &reference; - - static void reserve (std::map &a, size_type capacity) {} - - static reference make_reference (std::map &a, typename std::map::iterator it) { - return (*it).second; - } - }; - template - struct map_traits > { - typedef typename map_array::size_type size_type; - typedef typename map_array::data_reference reference; - - static void reserve (map_array &a, size_type capacity) { - a.reserve (capacity); - } - - static reference make_reference (map_array &a, typename map_array::iterator it) { - return reference (a, it); - } - }; -#endif - // Set array template class set_array { @@ -671,6 +691,14 @@ namespace boost { namespace numeric { namespace ublas { // Assuming std compliant allocator as requested during review. // if (! data_) // throw std::bad_alloc (); + std::fill (data_, data_ + size_, value_type ()); + } + BOOST_UBLAS_INLINE + set_array (no_init): + capacity_ (0), data_ (new value_type [0]), size_ (0) { + // Assuming std compliant allocator as requested during review. + // if (! data_) + // throw std::bad_alloc (); } BOOST_UBLAS_EXPLICIT BOOST_UBLAS_INLINE set_array (size_type size): @@ -678,6 +706,14 @@ namespace boost { namespace numeric { namespace ublas { // Assuming std compliant allocator as requested during review. // if (! data_) // throw std::bad_alloc (); + std::fill (data_, data_ + size_, value_type ()); + } + BOOST_UBLAS_EXPLICIT BOOST_UBLAS_INLINE + set_array (size_type size, no_init): + capacity_ (size), data_ (new value_type [size]), size_ (0) { + // Assuming std compliant allocator as requested during review. + // if (! data_) + // throw std::bad_alloc (); } BOOST_UBLAS_INLINE set_array (const set_array &a): @@ -706,7 +742,8 @@ namespace boost { namespace numeric { namespace ublas { // throw std::bad_alloc (); // if (! data_) // throw std::bad_alloc (); - std::copy (data_, data_ + size_, data); + std::copy (data_, data_ + std::min (size, size_), data); + std::fill (data + std::min (size, size_), data + size, value_type ()); delete [] data_; capacity_ = size << 1; data_ = data; @@ -971,21 +1008,6 @@ namespace boost { namespace numeric { namespace ublas { size_type size_; }; - template - BOOST_UBLAS_INLINE - set_array &assign_temporary (set_array &a1, set_array &a2) { - return a1.assign_temporary (a2); - } - - template - BOOST_UBLAS_INLINE - std::set &assign_temporary (std::set &a1, std::set &a2) { - // Too unusual semantic. - // BOOST_UBLAS_CHECK (&a1 != &a2, external_logic ()); - if (&a1 != &a2) - a1.swap (a2); - return a1; - } // This specialization is missing in Dinkumware's STL?! template BOOST_UBLAS_INLINE diff --git a/include/boost/numeric/ublas/symmetric.hpp b/include/boost/numeric/ublas/symmetric.hpp index 3095fb2f..417acd1f 100644 --- a/include/boost/numeric/ublas/symmetric.hpp +++ b/include/boost/numeric/ublas/symmetric.hpp @@ -77,29 +77,32 @@ namespace boost { namespace numeric { namespace ublas { // Construction and destruction BOOST_UBLAS_INLINE symmetric_matrix (): - size_ (0), - data_ (0) {} + size_ (0), data_ (0) {} BOOST_UBLAS_INLINE symmetric_matrix (size_type size): - size_ (BOOST_UBLAS_SAME (size, size)), - data_ (functor1_type::packed_size (size, size)) {} + size_ (BOOST_UBLAS_SAME (size, size)), data_ (0) { + resize (size); + } BOOST_UBLAS_INLINE symmetric_matrix (size_type size1, size_type size2): - size_ (BOOST_UBLAS_SAME (size1, size2)), - data_ (functor1_type::packed_size (size1, size2)) {} + size_ (BOOST_UBLAS_SAME (size1, size2)), data_ (0) { + resize (size1, size2); + } BOOST_UBLAS_INLINE symmetric_matrix (size_type size, const array_type &data): - size_ (size), - data_ (data) {} + size_ (size), data_ (data) {} BOOST_UBLAS_INLINE symmetric_matrix (const symmetric_matrix &m): - size_ (m.size_), - data_ (m.data_) {} + size_ (m.size_), data_ (m.data_) {} template BOOST_UBLAS_INLINE symmetric_matrix (const matrix_expression &ae): - size_ (BOOST_UBLAS_SAME (ae ().size1 (), ae ().size2 ())), - data_ (functor1_type::packed_size (ae ().size1 (), ae ().size2 ())) { + size_ (BOOST_UBLAS_SAME (ae ().size1 (), ae ().size2 ())), data_ (0) { +#ifndef BOOST_UBLAS_TYPE_CHECK + resize (ae ().size1 (), ae ().size2 (), false); +#else + resize (ae ().size1 (), ae ().size2 (), true); +#endif matrix_assign (scalar_assign (), *this, ae); } @@ -123,14 +126,14 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size) { + void resize (size_type size, bool preserve = true) { size_ = BOOST_UBLAS_SAME (size, size); - data ().resize (functor1_type::packed_size (size, size)); + detail::resize (data (), functor1_type::packed_size (size, size), preserve); } BOOST_UBLAS_INLINE - void resize (size_type size1, size_type size2) { + void resize (size_type size1, size_type size2, bool preserve = true) { size_ = BOOST_UBLAS_SAME (size1, size2); - data ().resize (functor1_type::packed_size (size1, size2)); + detail::resize (data (), functor1_type::packed_size (size1, size2), preserve); } // Element access @@ -182,7 +185,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE symmetric_matrix &reset (const matrix_expression &ae) { self_type temporary (ae); - resize (temporary.size1 (), temporary.size2 ()); + resize (temporary.size1 (), temporary.size2 (), false); return assign_temporary (temporary); } template @@ -328,41 +331,21 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { + const_iterator1 find1 (int rank, size_type i, size_type j) const { return const_iterator1 (*this, i, j); } BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { + iterator1 find1 (int rank, size_type i, size_type j) { if (rank == 1) i = functor1_type::restrict1 (i, j); return iterator1 (*this, i, j); } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - return const_iterator1 (*this, i, j); - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - if (rank == 1) - i = functor1_type::restrict1 (i, j); - return iterator1 (*this, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { + const_iterator2 find2 (int rank, size_type i, size_type j) const { return const_iterator2 (*this, i, j); } BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { - if (rank == 1) - j = functor1_type::restrict2 (i, j); - return iterator2 (*this, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - return const_iterator2 (*this, i, j); - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { + iterator2 find2 (int rank, size_type i, size_type j) { if (rank == 1) j = functor1_type::restrict2 (i, j); return iterator2 (*this, i, j); @@ -439,14 +422,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator2 begin () const { - return (*this) ().find_first2 (1, it1_, 0); + return (*this) ().find2 (1, it1_, 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { - return (*this) ().find_first2 (1, it1_, (*this) ().size2 ()); + return (*this) ().find2 (1, it1_, (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -505,11 +488,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size_, 0); + return find1 (0, size_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -576,14 +559,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator2 begin () const { - return (*this) ().find_first2 (1, it1_, 0); + return (*this) ().find2 (1, it1_, 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator2 end () const { - return (*this) ().find_first2 (1, it1_, (*this) ().size2 ()); + return (*this) ().find2 (1, it1_, (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -644,11 +627,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size_, 0); + return find1 (0, size_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -720,14 +703,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator1 begin () const { - return (*this) ().find_first1 (1, 0, it2_); + return (*this) ().find1 (1, 0, it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), it2_); + return (*this) ().find1 (1, (*this) ().size1 (), it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -786,11 +769,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size_); + return find2 (0, 0, size_); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -857,14 +840,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator1 begin () const { - return (*this) ().find_first1 (1, 0, it2_); + return (*this) ().find1 (1, 0, it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), it2_); + return (*this) ().find1 (1, (*this) ().size1 (), it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -925,11 +908,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size_); + return find2 (0, 0, size_); } // Reverse iterators @@ -1157,7 +1140,7 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - symmetric_adaptor &minus_assign (const matrix_expression &ae) { + symmetric_adaptor &minus_assign (const matrix_expression &ae) { matrix_assign (scalar_minus_assign (), *this, ae, functor_type ()); return *this; } @@ -1174,12 +1157,17 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // Comparison + bool operator == (const symmetric_adaptor &sa) const { + return (*this).data () == sa.data (); + } + // Swapping BOOST_UBLAS_INLINE void swap (symmetric_adaptor &m) { // Too unusual semantic // BOOST_UBLAS_CHECK (this != &m, external_logic ()); - if (this != &m) + if (this != &m) matrix_swap (scalar_swap (), *this, m, functor_type ()); } #ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS @@ -1214,124 +1202,64 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { + const_iterator1 find1 (int rank, size_type i, size_type j) const { if (functor_type::other (i, j)) { if (functor_type::other (size1 (), j)) { return const_iterator1 (*this, 0, 0, - data ().find_first1 (rank, i, j), data ().find_first1 (rank, size1 (), j), - data ().find_first2 (rank, size2 (), size1 ()), data ().find_first2 (rank, size2 (), size1 ())); + data ().find1 (rank, i, j), data ().find1 (rank, size1 (), j), + data ().find2 (rank, size2 (), size1 ()), data ().find2 (rank, size2 (), size1 ())); } else { return const_iterator1 (*this, 0, 1, - data ().find_first1 (rank, i, j), data ().find_first1 (rank, j, j), - data ().find_first2 (rank, j, j), data ().find_first2 (rank, j, size1 ())); + data ().find1 (rank, i, j), data ().find1 (rank, j, j), + data ().find2 (rank, j, j), data ().find2 (rank, j, size1 ())); } } else { if (functor_type::other (size1 (), j)) { return const_iterator1 (*this, 1, 0, - data ().find_first1 (rank, j, j), data ().find_first1 (rank, size1 (), j), - data ().find_first2 (rank, j, i), data ().find_first2 (rank, j, j)); + data ().find1 (rank, j, j), data ().find1 (rank, size1 (), j), + data ().find2 (rank, j, i), data ().find2 (rank, j, j)); } else { return const_iterator1 (*this, 1, 1, - data ().find_first1 (rank, size1 (), size2 ()), data ().find_first1 (rank, size1 (), size2 ()), - data ().find_first2 (rank, j, i), data ().find_first2 (rank, j, size1 ())); + data ().find1 (rank, size1 (), size2 ()), data ().find1 (rank, size1 (), size2 ()), + data ().find2 (rank, j, i), data ().find2 (rank, j, size1 ())); } } } BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { + iterator1 find1 (int rank, size_type i, size_type j) { if (rank == 1) i = functor_type::restrict1 (i, j); - return iterator1 (*this, data ().find_first1 (rank, i, j)); + return iterator1 (*this, data ().find1 (rank, i, j)); } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - if (functor_type::other (i, j)) { - if (functor_type::other (size1 (), j)) { - return const_iterator1 (*this, 0, 0, - data ().find_last1 (rank, i, j), data ().find_last1 (rank, size1 (), j), - data ().find_last2 (rank, size2 (), size1 ()), data ().find_last2 (rank, size2 (), size1 ())); - } else { - return const_iterator1 (*this, 0, 1, - data ().find_last1 (rank, i, j), data ().find_last1 (rank, j, j), - data ().find_last2 (rank, j, j), data ().find_last2 (rank, j, size1 ())); - } - } else { - if (functor_type::other (size1 (), j)) { - return const_iterator1 (*this, 1, 0, - data ().find_last1 (rank, j, j), data ().find_last1 (rank, size1 (), j), - data ().find_last2 (rank, j, i), data ().find_last2 (rank, j, j)); - } else { - return const_iterator1 (*this, 1, 1, - data ().find_last1 (rank, size1 (), size2 ()), data ().find_last1 (rank, size1 (), size2 ()), - data ().find_last2 (rank, j, i), data ().find_last2 (rank, j, size1 ())); - } - } - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - if (rank == 1) - i = functor_type::restrict1 (i, j); - return iterator1 (*this, data ().find_last1 (rank, i, j)); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { + const_iterator2 find2 (int rank, size_type i, size_type j) const { if (functor_type::other (i, j)) { if (functor_type::other (i, size2 ())) { return const_iterator2 (*this, 1, 1, - data ().find_first1 (rank, size2 (), size1 ()), data ().find_first1 (rank, size2 (), size1 ()), - data ().find_first2 (rank, i, j), data ().find_first2 (rank, i, size2 ())); + data ().find1 (rank, size2 (), size1 ()), data ().find1 (rank, size2 (), size1 ()), + data ().find2 (rank, i, j), data ().find2 (rank, i, size2 ())); } else { return const_iterator2 (*this, 1, 0, - data ().find_first1 (rank, i, i), data ().find_first1 (rank, size2 (), i), - data ().find_first2 (rank, i, j), data ().find_first2 (rank, i, i)); + data ().find1 (rank, i, i), data ().find1 (rank, size2 (), i), + data ().find2 (rank, i, j), data ().find2 (rank, i, i)); } } else { if (functor_type::other (i, size2 ())) { return const_iterator2 (*this, 0, 1, - data ().find_first1 (rank, j, i), data ().find_first1 (rank, i, i), - data ().find_first2 (rank, i, i), data ().find_first2 (rank, i, size2 ())); + data ().find1 (rank, j, i), data ().find1 (rank, i, i), + data ().find2 (rank, i, i), data ().find2 (rank, i, size2 ())); } else { return const_iterator2 (*this, 0, 0, - data ().find_first1 (rank, j, i), data ().find_first1 (rank, size2 (), i), - data ().find_first2 (rank, size1 (), size2 ()), data ().find_first2 (rank, size2 (), size2 ())); + data ().find1 (rank, j, i), data ().find1 (rank, size2 (), i), + data ().find2 (rank, size1 (), size2 ()), data ().find2 (rank, size2 (), size2 ())); } } } BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { + iterator2 find2 (int rank, size_type i, size_type j) { if (rank == 1) j = functor_type::restrict2 (i, j); - return iterator2 (*this, data ().find_first2 (rank, i, j)); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - if (functor_type::other (i, j)) { - if (functor_type::other (i, size2 ())) { - return const_iterator2 (*this, 1, 1, - data ().find_last1 (rank, size2 (), size1 ()), data ().find_last1 (rank, size2 (), size1 ()), - data ().find_last2 (rank, i, j), data ().find_last2 (rank, i, size2 ())); - } else { - return const_iterator2 (*this, 1, 0, - data ().find_last1 (rank, i, i), data ().find_last1 (rank, size2 (), i), - data ().find_last2 (rank, i, j), data ().find_last2 (rank, i, i)); - } - } else { - if (functor_type::other (i, size2 ())) { - return const_iterator2 (*this, 0, 1, - data ().find_last1 (rank, j, i), data ().find_last1 (rank, i, i), - data ().find_last2 (rank, i, i), data ().find_last2 (rank, i, size2 ())); - } else { - return const_iterator2 (*this, 0, 0, - data ().find_last1 (rank, j, i), data ().find_last1 (rank, size2 (), i), - data ().find_last2 (rank, size1 (), size2 ()), data ().find_last2 (rank, size2 (), size2 ())); - } - } - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { - if (rank == 1) - j = functor_type::restrict2 (i, j); - return iterator2 (*this, data ().find_last2 (rank, i, j)); + return iterator2 (*this, data ().find2 (rank, i, j)); } // Iterators simply are indices. @@ -1542,14 +1470,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator2 begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1638,11 +1566,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1712,14 +1640,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator2 begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator2 end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1776,11 +1704,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1989,14 +1917,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator1 begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -2085,11 +2013,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -2159,14 +2087,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator1 begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -2223,11 +2151,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } // Reverse iterators diff --git a/include/boost/numeric/ublas/traits.hpp b/include/boost/numeric/ublas/traits.hpp index 16667110..40daa1b6 100644 --- a/include/boost/numeric/ublas/traits.hpp +++ b/include/boost/numeric/ublas/traits.hpp @@ -36,6 +36,7 @@ namespace boost { namespace numeric { namespace ublas { typedef T real_type; typedef T precision_type; +#ifdef BOOST_UBLAS_DEPRECATED BOOST_STATIC_CONSTANT (std::size_t, plus_complexity = 0); BOOST_STATIC_CONSTANT (std::size_t, multiplies_complexity = 0); @@ -94,13 +95,12 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { - // Check, that the values match at least half. - static real_type sqrt_epsilon (type_traits::sqrt (std::numeric_limits::epsilon ())); - return self_type::norm_inf (t1 - t2) < sqrt_epsilon * + return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (std::max (self_type::norm_inf (t1), self_type::norm_inf (t2)), - std::numeric_limits::min ()); + BOOST_UBLAS_TYPE_CHECK_MIN); } +#endif }; template<> @@ -173,12 +173,10 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { - // Check, that the values match at least half. - static real_type sqrt_epsilon (type_traits::sqrt (std::numeric_limits::epsilon ())); - return self_type::norm_inf (t1 - t2) < sqrt_epsilon * + return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (std::max (self_type::norm_inf (t1), self_type::norm_inf (t2)), - std::numeric_limits::min ()); + BOOST_UBLAS_TYPE_CHECK_MIN); } }; template<> @@ -255,12 +253,10 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { - // Check, that the values match at least half. - static real_type sqrt_epsilon (type_traits::sqrt (std::numeric_limits::epsilon ())); - return self_type::norm_inf (t1 - t2) < sqrt_epsilon * + return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (std::max (self_type::norm_inf (t1), self_type::norm_inf (t2)), - std::numeric_limits::min ()); + BOOST_UBLAS_TYPE_CHECK_MIN); } }; #ifdef BOOST_UBLAS_USE_LONG_DOUBLE @@ -334,12 +330,10 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { - // Check, that the values match at least half. - static real_type sqrt_epsilon (type_traits::sqrt (std::numeric_limits::epsilon ())); - return self_type::norm_inf (t1 - t2) < sqrt_epsilon * + return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (std::max (self_type::norm_inf (t1), self_type::norm_inf (t2)), - std::numeric_limits::min ()); + BOOST_UBLAS_TYPE_CHECK_MIN); } }; #endif @@ -409,12 +403,10 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { - // Check, that the values match at least half. - static real_type sqrt_epsilon (type_traits::sqrt (std::numeric_limits::epsilon ())); - return self_type::norm_inf (t1 - t2) < sqrt_epsilon * + return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (std::max (self_type::norm_inf (t1), self_type::norm_inf (t2)), - std::numeric_limits::min ()); + BOOST_UBLAS_TYPE_CHECK_MIN); } }; template<> @@ -486,12 +478,10 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { - // Check, that the values match at least half. - static real_type sqrt_epsilon (type_traits::sqrt (std::numeric_limits::epsilon ())); - return self_type::norm_inf (t1 - t2) < sqrt_epsilon * + return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (std::max (self_type::norm_inf (t1), self_type::norm_inf (t2)), - std::numeric_limits::min ()); + BOOST_UBLAS_TYPE_CHECK_MIN); } }; #ifdef BOOST_UBLAS_USE_LONG_DOUBLE @@ -560,12 +550,10 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { - // Check, that the values match at least half. - static real_type sqrt_epsilon (type_traits::sqrt (std::numeric_limits::epsilon ())); - return self_type::norm_inf (t1 - t2) < sqrt_epsilon * + return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (std::max (self_type::norm_inf (t1), self_type::norm_inf (t2)), - std::numeric_limits::min ()); + BOOST_UBLAS_TYPE_CHECK_MIN); } }; #endif @@ -784,12 +772,10 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { - // Check, that the values match at least half. - static real_type sqrt_epsilon (type_traits::sqrt (std::numeric_limits::epsilon ())); - return self_type::norm_inf (t1 - t2) < sqrt_epsilon * + return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (std::max (self_type::norm_inf (t1), self_type::norm_inf (t2)), - std::numeric_limits::min ()); + BOOST_UBLAS_TYPE_CHECK_MIN); } }; template<> @@ -854,12 +840,10 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { - // Check, that the values match at least half. - static real_type sqrt_epsilon (type_traits::sqrt (std::numeric_limits::epsilon ())); - return self_type::norm_inf (t1 - t2) < sqrt_epsilon * + return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (std::max (self_type::norm_inf (t1), self_type::norm_inf (t2)), - std::numeric_limits::min ()); + BOOST_UBLAS_TYPE_CHECK_MIN); } }; #ifdef BOOST_UBLAS_USE_LONG_DOUBLE @@ -921,12 +905,10 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { - // Check, that the values match at least half. - static real_type sqrt_epsilon (type_traits::sqrt (std::numeric_limits::epsilon ())); - return self_type::norm_inf (t1 - t2) < sqrt_epsilon * + return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (std::max (self_type::norm_inf (t1), self_type::norm_inf (t2)), - std::numeric_limits::min ()); + BOOST_UBLAS_TYPE_CHECK_MIN); } }; #endif @@ -997,12 +979,10 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { - // Check, that the values match at least half. - static real_type sqrt_epsilon (type_traits::sqrt (std::numeric_limits::epsilon ())); - return self_type::norm_inf (t1 - t2) < sqrt_epsilon * + return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (std::max (self_type::norm_inf (t1), self_type::norm_inf (t2)), - std::numeric_limits::min ()); + BOOST_UBLAS_TYPE_CHECK_MIN); } }; template<> @@ -1074,12 +1054,10 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { - // Check, that the values match at least half. - static real_type sqrt_epsilon (type_traits::sqrt (std::numeric_limits::epsilon ())); - return self_type::norm_inf (t1 - t2) < sqrt_epsilon * + return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (std::max (self_type::norm_inf (t1), self_type::norm_inf (t2)), - std::numeric_limits::min ()); + BOOST_UBLAS_TYPE_CHECK_MIN); } }; #ifdef BOOST_UBLAS_USE_LONG_DOUBLE @@ -1148,12 +1126,10 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { - // Check, that the values match at least half. - static real_type sqrt_epsilon (type_traits::sqrt (std::numeric_limits::epsilon ())); - return self_type::norm_inf (t1 - t2) < sqrt_epsilon * + return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (std::max (self_type::norm_inf (t1), self_type::norm_inf (t2)), - std::numeric_limits::min ()); + BOOST_UBLAS_TYPE_CHECK_MIN); } }; #endif diff --git a/include/boost/numeric/ublas/triangular.hpp b/include/boost/numeric/ublas/triangular.hpp index f77340e5..8fed8d22 100644 --- a/include/boost/numeric/ublas/triangular.hpp +++ b/include/boost/numeric/ublas/triangular.hpp @@ -60,25 +60,27 @@ namespace boost { namespace numeric { namespace ublas { // Construction and destruction BOOST_UBLAS_INLINE triangular_matrix (): - size1_ (0), size2_ (0), - data_ (0) {} + size1_ (0), size2_ (0), data_ (0) {} BOOST_UBLAS_INLINE triangular_matrix (size_type size1, size_type size2): - size1_ (size1), size2_ (size2), - data_ (functor1_type::packed_size (size1, size2)) {} + size1_ (size1), size2_ (size2), data_ (0) { + resize (size1, size2); + } BOOST_UBLAS_INLINE triangular_matrix (size_type size1, size_type size2, const array_type &data): - size1_ (size1), size2_ (size2), - data_ (data) {} + size1_ (size1), size2_ (size2), data_ (data) {} BOOST_UBLAS_INLINE triangular_matrix (const triangular_matrix &m): - size1_ (m.size1_), size2_ (m.size2_), - data_ (m.data_) {} + size1_ (m.size1_), size2_ (m.size2_), data_ (m.data_) {} template BOOST_UBLAS_INLINE triangular_matrix (const matrix_expression &ae): - size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), - data_ (functor1_type::packed_size (ae ().size1 (), ae ().size2 ())) { + size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ (0) { +#ifndef BOOST_UBLAS_TYPE_CHECK + resize (ae ().size1 (), ae ().size2 (), false); +#else + resize (ae ().size1 (), ae ().size2 (), true); +#endif matrix_assign (scalar_assign (), *this, ae); } @@ -102,10 +104,10 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size1, size_type size2) { + void resize (size_type size1, size_type size2, bool preserve = true) { size1_ = size1; size2_ = size2; - data ().resize (functor1_type::packed_size (size1, size2)); + detail::resize (data (), functor1_type::packed_size (size1, size2), preserve); } // Element access @@ -174,7 +176,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE triangular_matrix &reset (const matrix_expression &ae) { self_type temporary (ae); - resize (temporary.size1 (), temporary.size2 ()); + resize (temporary.size1 (), temporary.size2 (), false); return assign_temporary (temporary); } template @@ -315,50 +317,26 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { + const_iterator1 find1 (int rank, size_type i, size_type j) const { if (rank == 1) i = functor1_type::restrict1 (i, j); return const_iterator1 (*this, i, j); } BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { - if (rank == 1) - i = functor1_type::mutable_restrict1 (i, j); - return iterator1 (*this, i, j); - } - BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - if (rank == 1) - i = functor1_type::restrict1 (i, j); - return const_iterator1 (*this, i, j); - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { + iterator1 find1 (int rank, size_type i, size_type j) { if (rank == 1) i = functor1_type::mutable_restrict1 (i, j); return iterator1 (*this, i, j); } BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { - if (rank == 1) + const_iterator2 find2 (int rank, size_type i, size_type j) const { + if (rank == 1) j = functor1_type::restrict2 (i, j); return const_iterator2 (*this, i, j); } BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { - if (rank == 1) - j = functor1_type::mutable_restrict2 (i, j); - return iterator2 (*this, i, j); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - if (rank == 1) - j = functor1_type::restrict2 (i, j); - return const_iterator2 (*this, i, j); - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { - if (rank == 1) + iterator2 find2 (int rank, size_type i, size_type j) { + if (rank == 1) j = functor1_type::mutable_restrict2 (i, j); return iterator2 (*this, i, j); } @@ -434,14 +412,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator2 begin () const { - return (*this) ().find_first2 (1, it1_, 0); + return (*this) ().find2 (1, it1_, 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { - return (*this) ().find_first2 (1, it1_, (*this) ().size2 ()); + return (*this) ().find2 (1, it1_, (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -500,11 +478,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -571,14 +549,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator2 begin () const { - return (*this) ().find_first2 (1, it1_, 0); + return (*this) ().find2 (1, it1_, 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator2 end () const { - return (*this) ().find_first2 (1, it1_, (*this) ().size2 ()); + return (*this) ().find2 (1, it1_, (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -639,11 +617,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1_, 0); + return find1 (0, size1_, 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -715,14 +693,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator1 begin () const { - return (*this) ().find_first1 (1, 0, it2_); + return (*this) ().find1 (1, 0, it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), it2_); + return (*this) ().find1 (1, (*this) ().size1 (), it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -781,11 +759,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -852,14 +830,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator1 begin () const { - return (*this) ().find_first1 (1, 0, it2_); + return (*this) ().find1 (1, 0, it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), it2_); + return (*this) ().find1 (1, (*this) ().size1 (), it2_); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -920,11 +898,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2_); + return find2 (0, 0, size2_); } // Reverse iterators @@ -1151,7 +1129,7 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - triangular_adaptor &operator = (const matrix_expression &ae) { + triangular_adaptor &operator = (const matrix_expression &ae) { matrix_assign (scalar_assign (), *this, matrix (ae)); return *this; } @@ -1198,6 +1176,11 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // Comparison + bool operator == (const triangular_adaptor &ta) const { + return (*this).data () == ta.data (); + } + // Swapping BOOST_UBLAS_INLINE void swap (triangular_adaptor &m) { @@ -1238,52 +1221,28 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator1 find_first1 (int rank, size_type i, size_type j) const { + const_iterator1 find1 (int rank, size_type i, size_type j) const { if (rank == 1) i = functor_type::restrict1 (i, j); - return const_iterator1 (*this, data ().find_first1 (rank, i, j)); + return const_iterator1 (*this, data ().find1 (rank, i, j)); } BOOST_UBLAS_INLINE - iterator1 find_first1 (int rank, size_type i, size_type j) { + iterator1 find1 (int rank, size_type i, size_type j) { if (rank == 1) i = functor_type::mutable_restrict1 (i, j); - return iterator1 (*this, data ().find_first1 (rank, i, j)); + return iterator1 (*this, data ().find1 (rank, i, j)); } BOOST_UBLAS_INLINE - const_iterator1 find_last1 (int rank, size_type i, size_type j) const { - if (rank == 1) - i = functor_type::restrict1 (i, j); - return const_iterator1 (*this, data ().find_last1 (rank, i, j)); - } - BOOST_UBLAS_INLINE - iterator1 find_last1 (int rank, size_type i, size_type j) { - if (rank == 1) - i = functor_type::mutable_restrict1 (i, j); - return iterator1 (*this, data ().find_last1 (rank, i, j)); - } - BOOST_UBLAS_INLINE - const_iterator2 find_first2 (int rank, size_type i, size_type j) const { + const_iterator2 find2 (int rank, size_type i, size_type j) const { if (rank == 1) j = functor_type::restrict2 (i, j); - return const_iterator2 (*this, data ().find_first2 (rank, i, j)); + return const_iterator2 (*this, data ().find2 (rank, i, j)); } BOOST_UBLAS_INLINE - iterator2 find_first2 (int rank, size_type i, size_type j) { + iterator2 find2 (int rank, size_type i, size_type j) { if (rank == 1) j = functor_type::mutable_restrict2 (i, j); - return iterator2 (*this, data ().find_first2 (rank, i, j)); - } - BOOST_UBLAS_INLINE - const_iterator2 find_last2 (int rank, size_type i, size_type j) const { - if (rank == 1) - j = functor_type::restrict2 (i, j); - return const_iterator2 (*this, data ().find_last2 (rank, i, j)); - } - BOOST_UBLAS_INLINE - iterator2 find_last2 (int rank, size_type i, size_type j) { - if (rank == 1) - j = functor_type::mutable_restrict2 (i, j); - return iterator2 (*this, data ().find_last2 (rank, i, j)); + return iterator2 (*this, data ().find2 (rank, i, j)); } // Iterators simply are indices. @@ -1366,14 +1325,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator2 begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator2 end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1428,11 +1387,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 begin1 () const { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1509,14 +1468,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator2 begin () const { - return (*this) ().find_first2 (1, index1 (), 0); + return (*this) ().find2 (1, index1 (), 0); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator2 end () const { - return (*this) ().find_first2 (1, index1 (), (*this) ().size2 ()); + return (*this) ().find2 (1, index1 (), (*this) ().size2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1573,11 +1532,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 begin1 () { - return find_first1 (0, 0, 0); + return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { - return find_first1 (0, size1 (), 0); + return find1 (0, size1 (), 0); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1658,14 +1617,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif const_iterator1 begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif const_iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1720,11 +1679,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator2 begin2 () const { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1801,14 +1760,14 @@ namespace boost { namespace numeric { namespace ublas { typename self_type:: #endif iterator1 begin () const { - return (*this) ().find_first1 (1, 0, index2 ()); + return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type:: #endif iterator1 end () const { - return (*this) ().find_first1 (1, (*this) ().size1 (), index2 ()); + return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE #ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION @@ -1865,11 +1824,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 begin2 () { - return find_first2 (0, 0, 0); + return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { - return find_first2 (0, 0, size2 ()); + return find2 (0, 0, size2 ()); } // Reverse iterators @@ -1981,8 +1940,8 @@ namespace boost { namespace numeric { namespace ublas { #endif value_type t = e2 () (n) /= e1 () (n, n); if (t != value_type ()) { - typename E1::const_iterator1 it1e1 (e1 ().find_first1 (1, n + 1, n)); - typename E1::const_iterator1 it1e1_end (e1 ().find_first1 (1, e1 ().size1 (), n)); + typename E1::const_iterator1 it1e1 (e1 ().find1 (1, n + 1, n)); + typename E1::const_iterator1 it1e1_end (e1 ().find1 (1, e1 ().size1 (), n)); difference_type m (it1e1_end - it1e1); while (-- m >= 0) e2 () (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1; @@ -2010,8 +1969,8 @@ namespace boost { namespace numeric { namespace ublas { #endif value_type t = e2 () (n) /= e1 () (n, n); if (t != value_type ()) { - typename E1::const_iterator1 it1e1 (e1 ().find_first1 (1, n + 1, n)); - typename E1::const_iterator1 it1e1_end (e1 ().find_first1 (1, e1 ().size1 (), n)); + typename E1::const_iterator1 it1e1 (e1 ().find1 (1, n + 1, n)); + typename E1::const_iterator1 it1e1_end (e1 ().find1 (1, e1 ().size1 (), n)); while (it1e1 != it1e1_end) e2 () (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1; } @@ -2099,8 +2058,8 @@ namespace boost { namespace numeric { namespace ublas { #endif value_type t = e2 () (n) /= e1 () (n, n); if (t != value_type ()) { - typename E1::const_reverse_iterator1 it1e1 (e1 ().find_first1 (1, n, n)); - typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find_first1 (1, 0, n)); + typename E1::const_reverse_iterator1 it1e1 (e1 ().find1 (1, n, n)); + typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find1 (1, 0, n)); difference_type m (it1e1_rend - it1e1); while (-- m >= 0) e2 () (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1; @@ -2128,8 +2087,8 @@ namespace boost { namespace numeric { namespace ublas { #endif value_type t = e2 () (n) /= e1 () (n, n); if (t != value_type ()) { - typename E1::const_reverse_iterator1 it1e1 (e1 ().find_first1 (1, n, n)); - typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find_first1 (1, 0, n)); + typename E1::const_reverse_iterator1 it1e1 (e1 ().find1 (1, n, n)); + typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find1 (1, 0, n)); while (it1e1 != it1e1_rend) e2 () (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1; } @@ -2237,8 +2196,8 @@ namespace boost { namespace numeric { namespace ublas { #endif value_type t = e1 () (n) /= e2 () (n, n); if (t != value_type ()) { - typename E2::const_reverse_iterator2 it2e2 (e2 ().find_first2 (1, n, n)); - typename E2::const_reverse_iterator2 it2e2_rend (e2 ().find_first2 (1, n, 0)); + typename E2::const_reverse_iterator2 it2e2 (e2 ().find2 (1, n, n)); + typename E2::const_reverse_iterator2 it2e2_rend (e2 ().find2 (1, n, 0)); difference_type m (it2e2_rend - it2e2); while (-- m >= 0) e1 () (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2; @@ -2266,8 +2225,8 @@ namespace boost { namespace numeric { namespace ublas { #endif value_type t = e1 () (n) /= e2 () (n, n); if (t != value_type ()) { - typename E2::const_reverse_iterator2 it2e2 (e2 ().find_first2 (1, n, n)); - typename E2::const_reverse_iterator2 it2e2_rend (e2 ().find_first2 (1, n, 0)); + typename E2::const_reverse_iterator2 it2e2 (e2 ().find2 (1, n, n)); + typename E2::const_reverse_iterator2 it2e2_rend (e2 ().find2 (1, n, 0)); while (it2e2 != it2e2_rend) e1 () (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2; } @@ -2355,8 +2314,8 @@ namespace boost { namespace numeric { namespace ublas { #endif value_type t = e1 () (n) /= e2 () (n, n); if (t != value_type ()) { - typename E2::const_iterator2 it2e2 (e2 ().find_first2 (1, n, n + 1)); - typename E2::const_iterator2 it2e2_end (e2 ().find_first2 (1, n, e2 ().size2 ())); + typename E2::const_iterator2 it2e2 (e2 ().find2 (1, n, n + 1)); + typename E2::const_iterator2 it2e2_end (e2 ().find2 (1, n, e2 ().size2 ())); difference_type m (it2e2_end - it2e2); while (-- m >= 0) e1 () (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2; @@ -2384,8 +2343,8 @@ namespace boost { namespace numeric { namespace ublas { #endif value_type t = e1 () (n) /= e2 () (n, n); if (t != value_type ()) { - typename E2::const_iterator2 it2e2 (e2 ().find_first2 (1, n, n + 1)); - typename E2::const_iterator2 it2e2_end (e2 ().find_first2 (1, n, e2 ().size2 ())); + typename E2::const_iterator2 it2e2 (e2 ().find2 (1, n, n + 1)); + typename E2::const_iterator2 it2e2_end (e2 ().find2 (1, n, e2 ().size2 ())); while (it2e2 != it2e2_end) e1 () (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2; } @@ -2508,8 +2467,8 @@ namespace boost { namespace numeric { namespace ublas { for (size_type l = 0; l < size2; ++ l) { value_type t = e2 () (n, l) /= e1 () (n, n); if (t != value_type ()) { - typename E1::const_iterator1 it1e1 (e1 ().find_first1 (1, n + 1, n)); - typename E1::const_iterator1 it1e1_end (e1 ().find_first1 (1, e1 ().size1 (), n)); + typename E1::const_iterator1 it1e1 (e1 ().find1 (1, n + 1, n)); + typename E1::const_iterator1 it1e1_end (e1 ().find1 (1, e1 ().size1 (), n)); difference_type m (it1e1_end - it1e1); while (-- m >= 0) e2 () (it1e1.index1 (), l) -= *it1e1 * t, ++ it1e1; @@ -2540,8 +2499,8 @@ namespace boost { namespace numeric { namespace ublas { for (size_type l = 0; l < size2; ++ l) { value_type t = e2 () (n, l) /= e1 () (n, n); if (t != value_type ()) { - typename E1::const_iterator1 it1e1 (e1 ().find_first1 (1, n + 1, n)); - typename E1::const_iterator1 it1e1_end (e1 ().find_first1 (1, e1 ().size1 (), n)); + typename E1::const_iterator1 it1e1 (e1 ().find1 (1, n + 1, n)); + typename E1::const_iterator1 it1e1_end (e1 ().find1 (1, e1 ().size1 (), n)); while (it1e1 != it1e1_end) e2 () (it1e1.index1 (), l) -= *it1e1 * t, ++ it1e1; } @@ -2618,8 +2577,8 @@ namespace boost { namespace numeric { namespace ublas { for (difference_type l = size2 - 1; l >= 0; -- l) { value_type t = e2 () (n, l) /= e1 () (n, n); if (t != value_type ()) { - typename E1::const_reverse_iterator1 it1e1 (e1 ().find_first1 (1, n, n)); - typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find_first1 (1, 0, n)); + typename E1::const_reverse_iterator1 it1e1 (e1 ().find1 (1, n, n)); + typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find1 (1, 0, n)); difference_type m (it1e1_rend - it1e1); while (-- m >= 0) e2 () (it1e1.index1 (), l) -= *it1e1 * t, ++ it1e1; @@ -2650,8 +2609,8 @@ namespace boost { namespace numeric { namespace ublas { for (difference_type l = size2 - 1; l >= 0; -- l) { value_type t = e2 () (n, l) /= e1 () (n, n); if (t != value_type ()) { - typename E1::const_reverse_iterator1 it1e1 (e1 ().find_first1 (1, n, n)); - typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find_first1 (1, 0, n)); + typename E1::const_reverse_iterator1 it1e1 (e1 ().find1 (1, n, n)); + typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find1 (1, 0, n)); while (it1e1 != it1e1_rend) e2 () (it1e1.index1 (), l) -= *it1e1 * t, ++ it1e1; } diff --git a/include/boost/numeric/ublas/vector.hpp b/include/boost/numeric/ublas/vector.hpp index d8a08444..a212141a 100644 --- a/include/boost/numeric/ublas/vector.hpp +++ b/include/boost/numeric/ublas/vector.hpp @@ -64,7 +64,9 @@ namespace boost { namespace numeric { namespace ublas { size_ (0), data_ (0) {} BOOST_UBLAS_EXPLICIT BOOST_UBLAS_INLINE vector (size_type size): - size_ (size), data_ (size) {} + size_ (size), data_ (0) { + resize (size); + } BOOST_UBLAS_INLINE vector (size_type size, const array_type &data): size_ (size), data_ (data) {} @@ -74,7 +76,12 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE vector (const vector_expression &ae): - size_ (ae ().size ()), data_ (ae ().size ()) { + size_ (ae ().size ()), data_ (0) { +#ifndef BOOST_UBLAS_TYPE_CHECK + resize (ae ().size (), false); +#else + resize (ae ().size (), true); +#endif vector_assign (scalar_assign (), *this, ae); } @@ -94,9 +101,9 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size) { + void resize (size_type size, bool preserve = true) { size_ = size; - data ().resize (size); + detail::resize (data (), size, preserve); } // Element access @@ -147,7 +154,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE vector &reset (const vector_expression &ae) { self_type temporary (ae); - resize (temporary.size ()); + resize (temporary.size (), false); return assign_temporary (temporary); } template @@ -267,22 +274,6 @@ namespace boost { namespace numeric { namespace ublas { return iterator (*this, i); #endif } - BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { - return find (i); - } - BOOST_UBLAS_INLINE - iterator find_first (size_type i) { - return find (i); - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { - return find (i); - } - BOOST_UBLAS_INLINE - iterator find_last (size_type i) { - return find (i); - } // Iterators simply are pointers. @@ -386,11 +377,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size_); + return find (size_); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -484,11 +475,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator begin () { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE iterator end () { - return find_first (size_); + return find (size_); } // Reverse iterator @@ -606,7 +597,7 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size) { + void resize (size_type size, bool preserve = true) { size_ = size; } @@ -664,12 +655,10 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { - return const_iterator (*this, std::max (i, index_)); - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { - return const_iterator (*this, std::min (i, index_ + 1)); + const_iterator find (size_type i) const { + i = std::max (i, index_); + i = std::min (i, index_ + 1); + return const_iterator (*this, i); } // Iterators simply are pointers. @@ -767,11 +756,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size_); + return find (size_); } // Reverse iterator @@ -849,7 +838,7 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size) { + void resize (size_type size, bool preserve = true) { size_ = size; } @@ -900,11 +889,7 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { - return const_iterator (*this, 0); - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { + const_iterator find (size_type i) const { return const_iterator (*this, 0); } @@ -981,11 +966,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size_); + return find (size_); } // Reverse iterator @@ -1058,7 +1043,7 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size) { + void resize (size_type size, bool preserve = true) { size_ = size; } @@ -1119,14 +1104,6 @@ namespace boost { namespace numeric { namespace ublas { const_iterator find (size_type i) const { return const_iterator (*this, i); } - BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { - return find (i); - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { - return find (i); - } // Iterators simply are pointers. @@ -1223,11 +1200,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size_); + return find (size_); } // Reverse iterator @@ -1324,12 +1301,12 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE pointer data () { - return data_; + return reinterpret_cast (data_); } // Resizing BOOST_UBLAS_INLINE - void resize (size_type size) { + void resize (size_type size, bool preserve = true) { if (size > N) // Raising exceptions abstracted as requested during review. // throw std::bad_alloc (); @@ -1388,7 +1365,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE c_vector &reset (const vector_expression &ae) { self_type temporary (ae); - resize (temporary.size ()); + resize (temporary.size (), false); return assign_temporary (temporary); } template @@ -1504,22 +1481,6 @@ namespace boost { namespace numeric { namespace ublas { return iterator (*this, i); #endif } - BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { - return find (i); - } - BOOST_UBLAS_INLINE - iterator find_first (size_type i) { - return find (i); - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { - return find (i); - } - BOOST_UBLAS_INLINE - iterator find_last (size_type i) { - return find (i); - } // Iterators simply are pointers. @@ -1624,11 +1585,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size_); + return find (size_); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1723,11 +1684,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator begin () { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE iterator end () { - return find_first (size_); + return find (size_); } // Reverse iterator diff --git a/include/boost/numeric/ublas/vector_assign.hpp b/include/boost/numeric/ublas/vector_assign.hpp index 1bc53d2b..941c7e9e 100644 --- a/include/boost/numeric/ublas/vector_assign.hpp +++ b/include/boost/numeric/ublas/vector_assign.hpp @@ -29,18 +29,16 @@ namespace boost { namespace numeric { namespace ublas { bool equals (const vector_expression &e1, const vector_expression &e2) { typedef BOOST_UBLAS_TYPENAME type_traits::promote_type>::real_type real_type; - // Check, that the values match at least half. - static real_type sqrt_epsilon (type_traits::sqrt (std::numeric_limits::epsilon ())); #ifndef __GNUC__ - return norm_inf (e1 - e2) < sqrt_epsilon * + return norm_inf (e1 - e2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (std::max (norm_inf (e1), norm_inf (e2)), - std::numeric_limits::min ()); + BOOST_UBLAS_TYPE_CHECK_MIN); #else // GCC 3.1, oops?! - return norm_inf (e1 - e2) < sqrt_epsilon * + return norm_inf (e1 - e2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * std::max (real_type (std::max (real_type (norm_inf (e1)), real_type (norm_inf (e2)))), - real_type (std::numeric_limits::min ())); + real_type (BOOST_UBLAS_TYPE_CHECK_MIN)); #endif } @@ -49,8 +47,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE void restart (const vector_expression &e, typename E::size_type index, typename E::const_iterator &ite, typename E::const_iterator &ite_end) { - ite = e ().find_first (index); - ite_end = e ().find_first (e ().size ()); + ite = e ().find (index); + ite_end = e ().find (e ().size ()); if (ite != ite_end && ite.index () == index) ++ ite; } @@ -58,8 +56,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE void restart (vector_expression &e, typename E::size_type index, typename E::iterator &ite, typename E::iterator &ite_end) { - ite = e ().find_first (index); - ite_end = e ().find_first (e ().size ()); + ite = e ().find (index); + ite_end = e ().find (e ().size ()); if (ite != ite_end && ite.index () == index) ++ ite; } diff --git a/include/boost/numeric/ublas/vector_expression.hpp b/include/boost/numeric/ublas/vector_expression.hpp index e2879884..d28da6c4 100644 --- a/include/boost/numeric/ublas/vector_expression.hpp +++ b/include/boost/numeric/ublas/vector_expression.hpp @@ -221,17 +221,19 @@ namespace boost { namespace numeric { namespace ublas { return expression () [i]; } + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const vector_const_reference &vr) const { + return &(*this).expression () == &vr.expression (); + } + typedef const_iterator_type const_iterator; typedef const_iterator iterator; // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { - return expression ().find_first (i); - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { - return expression ().find_last (i); + const_iterator find (size_type i) const { + return expression ().find (i); } // Iterator is the iterator of the referenced expression. @@ -294,8 +296,6 @@ namespace boost { namespace numeric { namespace ublas { typedef typename E::reference reference; typedef typename E::const_pointer const_pointer; typedef typename E::pointer pointer; - typedef typename E::const_iterator const_iterator_type; - typedef typename E::iterator iterator_type; #else typedef typename E::const_reference const_reference; typedef typename boost::mpl::if_c::value, @@ -305,6 +305,15 @@ namespace boost { namespace numeric { namespace ublas { typedef typename boost::mpl::if_c::value, typename E::const_pointer, typename E::pointer>::type pointer; +#endif + typedef const vector_reference const_self_type; + typedef vector_reference self_type; + typedef const_self_type const_closure_type; + typedef const_closure_type closure_type; +#ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS + typedef typename E::const_iterator const_iterator_type; + typedef typename E::iterator iterator_type; +#else typedef typename E::const_iterator const_iterator_type; typedef typename boost::mpl::if_c::value, typename E::const_iterator, @@ -334,6 +343,12 @@ namespace boost { namespace numeric { namespace ublas { return e_; } + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const vector_reference &vr) const { + return &(*this).expression () == &vr.expression (); + } + // Resizing #ifndef BOOST_UBLAS_REFERENCE_CONST_MEMBER BOOST_UBLAS_INLINE @@ -378,25 +393,73 @@ namespace boost { namespace numeric { namespace ublas { } #endif + // Assignment + template + BOOST_UBLAS_INLINE + vector_reference &operator = (const vector_expression &ae) { + expression ().operator = (ae); + return *this; + } + template + BOOST_UBLAS_INLINE + vector_reference &reset (const vector_expression &ae) { + expression ().reset (ae); + return *this; + } + template + BOOST_UBLAS_INLINE + vector_reference &assign (const vector_expression &ae) { + expression ().assign (ae); + return *this; + } + template + BOOST_UBLAS_INLINE + vector_reference &operator += (const vector_expression &ae) { + expression ().operator += (ae); + return *this; + } + template + BOOST_UBLAS_INLINE + vector_reference &plus_assign (const vector_expression &ae) { + expression ().plus_assign (ae); + return *this; + } + template + BOOST_UBLAS_INLINE + vector_reference &operator -= (const vector_expression &ae) { + expression ().operator -= (ae); + return *this; + } + template + BOOST_UBLAS_INLINE + vector_reference &minus_assign (const vector_expression &ae) { + expression ().minus_assign (ae); + return *this; + } + template + BOOST_UBLAS_INLINE + vector_reference &operator *= (const AT &at) { + expression ().operator *= (at); + return *this; + } + template + BOOST_UBLAS_INLINE + vector_reference &operator /= (const AT &at) { + expression ().operator /= (at); + return *this; + } + typedef const_iterator_type const_iterator; typedef iterator_type iterator; // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { - return expression ().find_first (i); + const_iterator find (size_type i) const { + return expression ().find (i); } BOOST_UBLAS_INLINE - iterator find_first (size_type i) { - return expression ().find_first (i); - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { - return expression ().find_last (i); - } - BOOST_UBLAS_INLINE - iterator find_last (size_type i) { - return expression ().find_last (i); + iterator find (size_type i) { + return expression ().find (i); } // Iterator is the iterator of the referenced expression. @@ -522,21 +585,12 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { + const_iterator find (size_type i) const { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - const_iterator_type it (e_.find_first (i)); + const_iterator_type it (e_.find (i)); return const_iterator (*this, it.index ()); #else - return const_iterator (*this, e_.find_first (i)); -#endif - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - const_iterator_type it (e_.find_last (i)); - return const_iterator (*this, it.index ()); -#else - return const_iterator (*this, e_.find_last (i)); + return const_iterator (*this, e_.find (i)); #endif } @@ -638,11 +692,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size ()); + return find (size ()); } // Reverse iterator @@ -802,11 +856,11 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { - const_iterator1_type it1 (e1_.find_first (i)); - const_iterator1_type it1_end (e1_.find_first (size ())); - const_iterator2_type it2 (e2_.find_first (i)); - const_iterator2_type it2_end (e2_.find_first (size ())); + const_iterator find (size_type i) const { + const_iterator1_type it1 (e1_.find (i)); + const_iterator1_type it1_end (e1_.find (size ())); + const_iterator2_type it2 (e2_.find (i)); + const_iterator2_type it2_end (e2_.find (size ())); i = std::min (it1 != it1_end ? it1.index () : size (), it2 != it2_end ? it2.index () : size ()); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -815,20 +869,6 @@ namespace boost { namespace numeric { namespace ublas { return const_iterator (*this, i, it1, it1_end, it2, it2_end); #endif } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { - const_iterator1_type it1 (e1_.find_last (i)); - const_iterator1_type it1_end (e1_.find_last (size ())); - const_iterator2_type it2 (e2_.find_last (i)); - const_iterator2_type it2_end (e2_.find_last (size ())); - i = std::max (it1 != it1_end ? it1.index () : size (), - it2 != it2_end ? it2.index () : size ()); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator (*this, i); -#else - return const_iterator (*this, i, it1, it1_end, it2, it2_end); -#endif - } // Iterator merges the iterators of the referenced expressions and // enhances them with the binary functor. @@ -1039,11 +1079,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size ()); + return find (size ()); } // Reverse iterator @@ -1196,21 +1236,12 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { + const_iterator find (size_type i) const { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - const_iterator2_type it (e2_.find_first (i)); + const_iterator2_type it (e2_.find (i)); return const_iterator (*this, it.index ()); #else - return const_iterator (*this, e1_, e2_.find_first (i)); -#endif - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - const_iterator2_type it (e2_.find_last (i)); - return const_iterator (*this, it.index ()); -#else - return const_iterator (*this, e1_, e2_.find_last (i)); + return const_iterator (*this, e1_, e2_.find (i)); #endif } @@ -1320,11 +1351,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size ()); + return find (size ()); } // Reverse iterator @@ -1439,21 +1470,12 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { + const_iterator find (size_type i) const { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - const_iterator1_type it (e1_.find_first (i)); + const_iterator1_type it (e1_.find (i)); return const_iterator (*this, it.index ()); #else - return const_iterator (*this, e1_.find_first (i), e2_); -#endif - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - const_iterator1_type it (e1_.find_last (i)); - return const_iterator (*this, it.index ()); -#else - return const_iterator (*this, e1_.find_last (i), e2_); + return const_iterator (*this, e1_.find (i), e2_); #endif } @@ -1563,11 +1585,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size ()); + return find (size ()); } // Reverse iterator diff --git a/include/boost/numeric/ublas/vector_proxy.hpp b/include/boost/numeric/ublas/vector_proxy.hpp index 1d358836..d5dba580 100644 --- a/include/boost/numeric/ublas/vector_proxy.hpp +++ b/include/boost/numeric/ublas/vector_proxy.hpp @@ -228,6 +228,12 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const vector_range &vr) const { + return (*this).data () == vr.data () && r_ == vr.r_; + } + // Swapping BOOST_UBLAS_INLINE void swap (vector_range vr) { @@ -259,8 +265,8 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { - const_iterator_type it (data ().find_first (start () + i)); + const_iterator find (size_type i) const { + const_iterator_type it (data ().find (start () + i)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator (*this, it.index ()); #else @@ -268,26 +274,8 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - iterator find_first (size_type i) { - iterator_type it (data ().find_first (start () + i)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return iterator (*this, it.index ()); -#else - return iterator (*this, it); -#endif - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { - const_iterator_type it (data ().find_last (start () + i)); -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator (*this, it.index ()); -#else - return const_iterator (*this, it); -#endif - } - BOOST_UBLAS_INLINE - iterator find_last (size_type i) { - iterator_type it (data ().find_last (start () + i)); + iterator find (size_type i) { + iterator_type it (data ().find (start () + i)); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator (*this, it.index ()); #else @@ -359,7 +347,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ - it.it_; } @@ -387,12 +375,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ == it.it_; } BOOST_UBLAS_INLINE bool operator < (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ < it.it_; } @@ -403,11 +391,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size ()); + return find (size ()); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -463,7 +451,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ - it.it_; } @@ -491,12 +479,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ == it.it_; } BOOST_UBLAS_INLINE bool operator < (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ < it.it_; } @@ -509,11 +497,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator begin () { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE iterator end () { - return find_first (size ()); + return find (size ()); } // Reverse iterator @@ -576,6 +564,11 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE + vector_range project (vector_range &data, const range &r) { + return data.project (r); + } + template + BOOST_UBLAS_INLINE vector_range project (const vector_range &data, const range &r) { return data.project (r); } @@ -786,6 +779,12 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const vector_slice &vs) const { + return (*this).data () == vs.data () && s_ == vs.s_; + } + // Swapping BOOST_UBLAS_INLINE void swap (vector_slice vs) { @@ -817,7 +816,7 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { + const_iterator find (size_type i) const { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator (*this, i); #else @@ -825,23 +824,7 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - iterator find_first (size_type i) { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return iterator (*this, i); -#else - return iterator (*this, s_.begin () + i); -#endif - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator (*this, i); -#else - return const_iterator (*this, s_.begin () + i); -#endif - } - BOOST_UBLAS_INLINE - iterator find_last (size_type i) { + iterator find (size_type i) { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator (*this, i); #else @@ -908,7 +891,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ - it.it_; } @@ -936,12 +919,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ == it.it_; } BOOST_UBLAS_INLINE bool operator < (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ < it.it_; } @@ -952,11 +935,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size ()); + return find (size ()); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1007,7 +990,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ - it.it_; } @@ -1035,12 +1018,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ == it.it_; } BOOST_UBLAS_INLINE bool operator < (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ < it.it_; } @@ -1053,11 +1036,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator begin () { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE iterator end () { - return find_first (size ()); + return find (size ()); } // Reverse iterator @@ -1103,6 +1086,11 @@ namespace boost { namespace numeric { namespace ublas { // Projections #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template + BOOST_UBLAS_INLINE + vector_slice project (vector_slice &data, const range &r) { + return data.project (r); + } template BOOST_UBLAS_INLINE vector_slice project (const vector_slice &data, const range &r) { @@ -1127,6 +1115,11 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE + vector_slice project (vector_slice &data, const slice &s) { + return data.project (s); + } + template + BOOST_UBLAS_INLINE vector_slice project (const vector_slice &data, const slice &s) { return data.project (s); } @@ -1339,6 +1332,12 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // Comparison + BOOST_UBLAS_INLINE + bool operator == (const vector_indirect &vi) const { + return (*this).data () == vi.data () && ia_ == vi.ia_; + } + // Swapping BOOST_UBLAS_INLINE void swap (vector_indirect vi) { @@ -1370,7 +1369,7 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { + const_iterator find (size_type i) const { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator (*this, i); #else @@ -1378,23 +1377,7 @@ namespace boost { namespace numeric { namespace ublas { #endif } BOOST_UBLAS_INLINE - iterator find_first (size_type i) { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return iterator (*this, i); -#else - return iterator (*this, ia_.begin () + i); -#endif - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { -#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR - return const_iterator (*this, i); -#else - return const_iterator (*this, ia_.begin () + i); -#endif - } - BOOST_UBLAS_INLINE - iterator find_last (size_type i) { + iterator find (size_type i) { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator (*this, i); #else @@ -1461,7 +1444,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ - it.it_; } @@ -1489,12 +1472,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ == it.it_; } BOOST_UBLAS_INLINE bool operator < (const const_iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ < it.it_; } @@ -1505,11 +1488,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size ()); + return find (size ()); } #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -1560,7 +1543,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE difference_type operator - (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ - it.it_; } @@ -1588,12 +1571,12 @@ namespace boost { namespace numeric { namespace ublas { // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ == it.it_; } BOOST_UBLAS_INLINE bool operator < (const iterator &it) const { - BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ()); return it_ < it.it_; } @@ -1606,11 +1589,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator begin () { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE iterator end () { - return find_first (size ()); + return find (size ()); } // Reverse iterator @@ -1656,6 +1639,11 @@ namespace boost { namespace numeric { namespace ublas { // Projections #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING + template + BOOST_UBLAS_INLINE + vector_indirect project (vector_indirect &data, const range &r) { + return data.project (r); + } template BOOST_UBLAS_INLINE vector_indirect project (const vector_indirect &data, const range &r) { @@ -1663,6 +1651,11 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE + vector_indirect project (vector_indirect &data, const slice &s) { + return data.project (s); + } + template + BOOST_UBLAS_INLINE vector_indirect project (const vector_indirect &data, const slice &s) { return data.project (s); } @@ -1686,6 +1679,11 @@ namespace boost { namespace numeric { namespace ublas { // } // template // BOOST_UBLAS_INLINE + // vector_indirect project (vector_indirect &data, const IA &ia) { + // return data.project (ia); + // } + // template + // BOOST_UBLAS_INLINE // vector_indirect project (const vector_indirect &data, const IA &ia) { // return data.project (ia); // } @@ -1708,6 +1706,11 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE + vector_indirect > project (vector_indirect > &data, const indirect_array &ia) { + return data.project (ia); + } + template + BOOST_UBLAS_INLINE vector_indirect > project (const vector_indirect > &data, const indirect_array &ia) { return data.project (ia); } diff --git a/include/boost/numeric/ublas/vector_sparse.hpp b/include/boost/numeric/ublas/vector_sparse.hpp index a9b2b62a..a11394b1 100644 --- a/include/boost/numeric/ublas/vector_sparse.hpp +++ b/include/boost/numeric/ublas/vector_sparse.hpp @@ -273,9 +273,7 @@ namespace boost { namespace numeric { namespace ublas { size_ = size; non_zeros_ = std::max (non_zeros, size_type (1)); non_zeros_ = std::min (non_zeros_, size_); -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - map_traits::reserve (data (), non_zeros_); -#endif + detail::reserve (data (), non_zeros_); data ().clear (); } @@ -284,9 +282,7 @@ namespace boost { namespace numeric { namespace ublas { void reserve (size_type non_zeros = 0) { non_zeros_ = std::max (non_zeros, size_type (1)); non_zeros_ = std::min (non_zeros_, size_); -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - map_traits::reserve (data (), non_zeros_); -#endif + detail::reserve (data (), non_zeros_); } // Proxy support @@ -471,22 +467,6 @@ namespace boost { namespace numeric { namespace ublas { iterator find (size_type i) { return iterator (*this, data ().lower_bound (i)); } - BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { - return find (i); - } - BOOST_UBLAS_INLINE - iterator find_first (size_type i) { - return find (i); - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { - return find (i); - } - BOOST_UBLAS_INLINE - iterator find_last (size_type i) { - return find (i); - } // Iterators simply are pointers. @@ -567,11 +547,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size_); + return find (size_); } class iterator: @@ -616,7 +596,7 @@ namespace boost { namespace numeric { namespace ublas { #elif defined (BOOST_UBLAS_STRICT_VECTOR_SPARSE) return reference ((*this) (), &(*it_).second, index ()); #elif defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) - return map_traits::make_reference ((*this) ().data (), it_); + return detail::make_reference ((*this) ().data (), it_); #endif } @@ -649,11 +629,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator begin () { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE iterator end () { - return find_first (size_); + return find (size_); } // Reverse iterator @@ -753,7 +733,7 @@ namespace boost { namespace numeric { namespace ublas { compressed_vector (const vector_expression &ae, size_type non_zeros = 0): size_ (ae ().size ()), non_zeros_ (non_zeros), filled_ (0), index_data_ (non_zeros), value_data_ (non_zeros) { - reserve (non_zeros_); + reserve (non_zeros_, false); vector_assign (scalar_assign (), *this, ae); } @@ -793,22 +773,22 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size, size_type non_zeros = 0) { + void resize (size_type size, size_type non_zeros = 0, bool preserve = true) { size_ = size; non_zeros_ = std::max (non_zeros, size_type (1)); non_zeros_ = std::min (non_zeros_, size_); filled_ = 0; - index_data ().resize (non_zeros_); - value_data ().resize (non_zeros_); + detail::resize (index_data (), non_zeros_, preserve); + detail::resize (value_data (), non_zeros_, preserve); } // Reserving BOOST_UBLAS_INLINE - void reserve (size_type non_zeros = 0, bool preserve = false) { + void reserve (size_type non_zeros = 0, bool preserve = true) { non_zeros_ = std::max (non_zeros, size_type (1)); non_zeros_ = std::min (non_zeros_, size_); - index_data ().resize (non_zeros_, preserve); - value_data ().resize (non_zeros_, preserve); + detail::resize (index_data (), non_zeros_, preserve); + detail::resize (value_data (), non_zeros_, preserve); } // Proxy support @@ -865,8 +845,9 @@ namespace boost { namespace numeric { namespace ublas { size_ = v.size_; non_zeros_ = v.non_zeros_; filled_ = v.filled_; + detail::resize (index_data (), non_zeros_, false); + detail::resize (value_data (), non_zeros_, false); index_data () = v.index_data (); - value_data ().resize (non_zeros_); value_data () = v.value_data (); } return *this; @@ -891,7 +872,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE compressed_vector &reset (const vector_expression &ae) { self_type temporary (ae, non_zeros_); - resize (temporary.size (), non_zeros_); + resize (temporary.size (), non_zeros_, false); return assign_temporary (temporary); } template @@ -974,7 +955,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE void push_back (size_type i, const_reference t) { if (filled_ >= non_zeros_) - reserve (2 * non_zeros_, true); + reserve (2 * non_zeros_); if (filled_ == 0 || index_data () [filled_ - 1] < k_based (i)) { ++ filled_; index_data () [filled_ - 1] = k_based (i); @@ -988,7 +969,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE void insert (size_type i, const_reference t) { if (filled_ >= non_zeros_) - reserve (2 * non_zeros_, true); + reserve (2 * non_zeros_); iterator_type it (detail::lower_bound (index_data ().begin (), index_data ().begin () + filled_, k_based (i), std::less ())); difference_type n = it - index_data ().begin (); BOOST_UBLAS_CHECK (filled_ == 0 || filled_ == size_type (n) || *it != k_based (i), external_logic ()); @@ -1035,22 +1016,6 @@ namespace boost { namespace numeric { namespace ublas { iterator find (size_type i) { return iterator (*this, detail::lower_bound (index_data ().begin (), index_data ().begin () + filled_, k_based (i), std::less ())); } - BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { - return find (i); - } - BOOST_UBLAS_INLINE - iterator find_first (size_type i) { - return find (i); - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { - return find (i); - } - BOOST_UBLAS_INLINE - iterator find_last (size_type i) { - return find (i); - } // Iterators simply are pointers. @@ -1131,11 +1096,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size_); + return find (size_); } class iterator: @@ -1211,11 +1176,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator begin () { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE iterator end () { - return find_first (size_); + return find (size_); } // Reverse iterator @@ -1330,7 +1295,7 @@ namespace boost { namespace numeric { namespace ublas { coordinate_vector (const vector_expression &ae, size_type non_zeros = 0): size_ (ae ().size ()), non_zeros_ (non_zeros), filled_ (0), sorted_ (true), index_data_ (non_zeros), value_data_ (non_zeros) { - reserve (non_zeros_); + reserve (non_zeros_, false); vector_assign (scalar_assign (), *this, ae); } @@ -1370,22 +1335,24 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE - void resize (size_type size, size_type non_zeros = 0) { + void resize (size_type size, size_type non_zeros = 0, bool preserve = true) { size_ = size; non_zeros_ = std::max (non_zeros, size_type (1)); - non_zeros_ = std::min (non_zeros_, size_); + // FIX: coordinate_vector may contain duplicate elements. + // non_zeros_ = std::min (non_zeros_, size_); filled_ = 0; - index_data ().resize (non_zeros_); - value_data ().resize (non_zeros_); + detail::resize (index_data (), non_zeros_, preserve); + detail::resize (value_data (), non_zeros_, preserve); } // Reserving BOOST_UBLAS_INLINE - void reserve (size_type non_zeros = 0, bool preserve = false) { + void reserve (size_type non_zeros = 0, bool preserve = true) { non_zeros_ = std::max (non_zeros, size_type (1)); - non_zeros_ = std::min (non_zeros_, size_); - index_data ().resize (non_zeros_, preserve); - value_data ().resize (non_zeros_, preserve); + // FIX: coordinate_vector may contain duplicate elements. + // non_zeros_ = std::min (non_zeros_, size_); + detail::resize (index_data (), non_zeros_, preserve); + detail::resize (value_data (), non_zeros_, preserve); } // Proxy support @@ -1447,8 +1414,9 @@ namespace boost { namespace numeric { namespace ublas { non_zeros_ = v.non_zeros_; filled_ = v.filled_; sorted_ = v.sorted_; + detail::resize (index_data (), non_zeros_, false); + detail::resize (value_data (), non_zeros_, false); index_data () = v.index_data (); - value_data ().resize (non_zeros_); value_data () = v.value_data (); } return *this; @@ -1473,7 +1441,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE coordinate_vector &reset (const vector_expression &ae) { self_type temporary (ae, non_zeros_); - resize (temporary.size (), non_zeros_); + resize (temporary.size (), non_zeros_, false); return assign_temporary (temporary); } template @@ -1556,18 +1524,24 @@ namespace boost { namespace numeric { namespace ublas { // Sorting BOOST_UBLAS_INLINE void sort () const { - if (! sorted_) { - typedef std::pair pair_type; - unbounded_array a (filled_); - size_type i; - for (i = 0; i < filled_; ++ i) - a [i] = pair_type (index_data_ [i], value_data_ [i]); - std::sort (a.begin (), a.end (), detail::less_pair ()); - for (i = 0; i < filled_; ++ i) { - index_data_ [i] = a [i].first; - value_data_ [i] = a [i].second; + if (! sorted_ && filled_ > 0) { + index_pair_array + ipa (filled_, index_data_, value_data_); + std::sort (ipa.begin (), ipa.end ()); + // FIX: check for duplicates + size_type filled = 1; + for (size_type i = 1; i < filled_; ++ i) { + if (index_data_ [filled - 1] != index_data_ [i]) { + ++ filled; + if (filled - 1 != i) { + index_data_ [filled - 1] = index_data_ [i]; + value_data_ [filled - 1] = value_data_ [i]; + } + } else { + value_data_ [filled - 1] += value_data_ [i]; + } } + filled_ = filled; sorted_ = true; } } @@ -1576,7 +1550,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE void push_back (size_type i, const_reference t) { if (filled_ >= non_zeros_) - reserve (2 * non_zeros_, true); + reserve (2 * non_zeros_); if (filled_ == 0 || index_data () [filled_ - 1] < k_based (i)) { ++ filled_; index_data () [filled_ - 1] = k_based (i); @@ -1590,7 +1564,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE void insert (size_type i, const_reference t) { if (filled_ >= non_zeros_) - reserve (2 * non_zeros_, true); + reserve (2 * non_zeros_); ++ filled_; index_data () [filled_ - 1] = k_based (i); value_data () [filled_ - 1] = t; @@ -1634,22 +1608,6 @@ namespace boost { namespace numeric { namespace ublas { sort (); return iterator (*this, detail::lower_bound (index_data ().begin (), index_data ().begin () + filled_, k_based (i), std::less ())); } - BOOST_UBLAS_INLINE - const_iterator find_first (size_type i) const { - return find (i); - } - BOOST_UBLAS_INLINE - iterator find_first (size_type i) { - return find (i); - } - BOOST_UBLAS_INLINE - const_iterator find_last (size_type i) const { - return find (i); - } - BOOST_UBLAS_INLINE - iterator find_last (size_type i) { - return find (i); - } // Iterators simply are pointers. @@ -1730,11 +1688,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator begin () const { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE const_iterator end () const { - return find_first (size_); + return find (size_); } class iterator: @@ -1810,11 +1768,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator begin () { - return find_first (0); + return find (0); } BOOST_UBLAS_INLINE iterator end () { - return find_first (size_); + return find (size_); } // Reverse iterator @@ -1853,7 +1811,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_STATIC_CONSTANT (size_type, index_base_ = IB); size_type size_; size_type non_zeros_; - size_type filled_; + mutable size_type filled_; mutable bool sorted_; mutable index_array_type index_data_; mutable value_array_type value_data_; diff --git a/test1/Jamfile b/test1/Jamfile index fbfb9aa5..5735938f 100644 --- a/test1/Jamfile +++ b/test1/Jamfile @@ -26,6 +26,7 @@ exe test1 # USE_BOUNDED_VECTOR # USE_BOUNDED_MATRIX USE_RANGE +# <*>"-fabi-version=0" <*>"-Xc" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" diff --git a/test2/Jamfile b/test2/Jamfile index e131a303..2e3a8e8e 100644 --- a/test2/Jamfile +++ b/test2/Jamfile @@ -23,6 +23,7 @@ exe test2 : $(BOOST_ROOT) $(BOOST_ROOT) BOOST_UBLAS_SAFE +# <*>"-fabi-version=0" <*>"-Xc" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" diff --git a/test3/Jamfile b/test3/Jamfile index 8f56d464..0744ba67 100644 --- a/test3/Jamfile +++ b/test3/Jamfile @@ -25,6 +25,7 @@ exe test3 BOOST_UBLAS_SAFE USE_RANGE <*>"-Xc" +# <*>"-fabi-version=0" <*>"-w-8026 -w-8027 -w-8030 -w-8057 -w-8084 -w-8092" <*>"-w-8026 -w-8027 -w-8030 -w-8057 -w-8084 -w-8092" ; diff --git a/test4/Jamfile b/test4/Jamfile index fbf717ae..f225e103 100644 --- a/test4/Jamfile +++ b/test4/Jamfile @@ -25,6 +25,7 @@ exe test4 BOOST_UBLAS_SAFE USE_RANGE USE_ADAPTOR +# <*>"-fabi-version=0" <*>"-Xc" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" diff --git a/test4/test43.cpp b/test4/test43.cpp index 623c4c9e..3c2adc96 100644 --- a/test4/test43.cpp +++ b/test4/test43.cpp @@ -264,6 +264,8 @@ void test_matrix () { test_my_matrix, ublas::row_major, ublas::unbounded_array > >, 3 > () (); test_my_matrix, ublas::row_major, ublas::unbounded_array > >, 3 > () (0); #endif +#endif +#endif #ifdef USE_STD_VECTOR #ifdef USE_FLOAT @@ -277,8 +279,6 @@ void test_matrix () { test_my_matrix >, 3 > () (); test_my_matrix >, 3 > () (0); #endif -#endif -#endif #ifdef USE_STD_COMPLEX #ifdef USE_FLOAT @@ -350,6 +350,8 @@ void test_matrix () { test_my_matrix, ublas::row_major, ublas::unbounded_array > >, 3 > () (); test_my_matrix, ublas::row_major, ublas::unbounded_array > >, 3 > () (0); #endif +#endif +#endif #ifdef USE_STD_VECTOR #ifdef USE_FLOAT @@ -363,8 +365,6 @@ void test_matrix () { test_my_matrix >, 3 > () (); test_my_matrix >, 3 > () (0); #endif -#endif -#endif #ifdef USE_STD_COMPLEX #ifdef USE_FLOAT diff --git a/test5/Jamfile b/test5/Jamfile index 005c48be..206f65bc 100644 --- a/test5/Jamfile +++ b/test5/Jamfile @@ -25,6 +25,7 @@ exe test5 BOOST_UBLAS_SAFE USE_RANGE USE_ADAPTOR +# <*>"-fabi-version=0" <*>"-Xc" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" diff --git a/test6/Jamfile b/test6/Jamfile index f471762a..51b28c4a 100644 --- a/test6/Jamfile +++ b/test6/Jamfile @@ -25,6 +25,7 @@ exe test6 BOOST_UBLAS_SAFE USE_RANGE USE_ADAPTOR +# <*>"-fabi-version=0" <*>"-Xc" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" diff --git a/test7/Jamfile b/test7/Jamfile index 0c3365ab..a555d8b9 100644 --- a/test7/Jamfile +++ b/test7/Jamfile @@ -25,6 +25,7 @@ exe test7 BOOST_UBLAS_USE_INTERVAL BOOST_UBLAS_SAFE USE_RANGE +# <*>"-fabi-version=0" <*>"-Xc" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092"