From 2532aff0baca1b99400942efa0621e87f9bc01b3 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 23 Jun 2004 04:49:48 +0000 Subject: [PATCH] remove std_min and std_max, update minmax coding guidelines svn path=/trunk/boost/boost/numeric/ublas/; revision=23162 --- doc/samples/banded_adaptor.cpp | 3 +- doc/samples/banded_matrix.cpp | 3 +- doc/samples/matrix_binary.cpp | 5 +- doc/samples/matrix_matrix_binary.cpp | 5 +- doc/samples/matrix_matrix_solve.cpp | 3 +- doc/samples/matrix_vector_binary.cpp | 3 +- doc/samples/matrix_vector_solve.cpp | 3 +- doc/samples/vector_binary.cpp | 3 +- doc/samples/vector_binary_outer.cpp | 3 +- doc/samples/vector_binary_redux.cpp | 3 +- include/boost/numeric/ublas/banded.hpp | 148 +++++++++++------- include/boost/numeric/ublas/functional.hpp | 124 +++++++++------ include/boost/numeric/ublas/hermitian.hpp | 36 +++-- include/boost/numeric/ublas/lu.hpp | 9 +- include/boost/numeric/ublas/matrix.hpp | 12 +- include/boost/numeric/ublas/matrix_assign.hpp | 29 ++-- .../boost/numeric/ublas/matrix_expression.hpp | 18 ++- include/boost/numeric/ublas/matrix_proxy.hpp | 12 +- include/boost/numeric/ublas/matrix_sparse.hpp | 48 ++++-- .../boost/numeric/ublas/operation_blocked.hpp | 24 +-- .../boost/numeric/ublas/operation_sparse.hpp | 12 +- include/boost/numeric/ublas/storage.hpp | 39 +++-- .../boost/numeric/ublas/storage_sparse.hpp | 10 +- include/boost/numeric/ublas/symmetric.hpp | 36 +++-- include/boost/numeric/ublas/traits.hpp | 60 ++++--- include/boost/numeric/ublas/vector.hpp | 6 +- include/boost/numeric/ublas/vector_assign.hpp | 17 +- .../boost/numeric/ublas/vector_expression.hpp | 9 +- include/boost/numeric/ublas/vector_sparse.hpp | 36 +++-- test4/test4.hpp | 6 +- 30 files changed, 440 insertions(+), 285 deletions(-) diff --git a/doc/samples/banded_adaptor.cpp b/doc/samples/banded_adaptor.cpp index 0f7dcec7..08f8f7f5 100644 --- a/doc/samples/banded_adaptor.cpp +++ b/doc/samples/banded_adaptor.cpp @@ -16,14 +16,13 @@ #include #include -#include int main () { using namespace boost::numeric::ublas; matrix m (3, 3); banded_adaptor > ba (m, 1, 1); for (signed i = 0; i < signed (ba.size1 ()); ++ i) - for (signed j = std_max (i - 1, 0); j < std_min (i + 2, signed (ba.size2 ())); ++ j) + for (signed j = (std::max)(i - 1, 0); j < (std::min)(i + 2, signed (ba.size2 ())); ++ j) ba (i, j) = 3 * i + j; std::cout << ba << std::endl; } diff --git a/doc/samples/banded_matrix.cpp b/doc/samples/banded_matrix.cpp index eb31d874..7289a99c 100644 --- a/doc/samples/banded_matrix.cpp +++ b/doc/samples/banded_matrix.cpp @@ -16,13 +16,12 @@ #include #include -#include int main () { using namespace boost::numeric::ublas; banded_matrix m (3, 3, 1, 1); for (signed i = 0; i < signed (m.size1 ()); ++ i) - for (signed j = std_max (i - 1, 0); j < std_min (i + 2, signed (m.size2 ())); ++ j) + for (signed j = (std::max)(i - 1, 0); j < (std::min)(i + 2, signed (m.size2 ())); ++ j) m (i, j) = 3 * i + j; std::cout << m << std::endl; } diff --git a/doc/samples/matrix_binary.cpp b/doc/samples/matrix_binary.cpp index 3148d3ab..9ec41455 100644 --- a/doc/samples/matrix_binary.cpp +++ b/doc/samples/matrix_binary.cpp @@ -16,13 +16,12 @@ #include #include -#include int main () { using namespace boost::numeric::ublas; matrix m1 (3, 3), m2 (3, 3); - for (unsigned i = 0; i < std_min (m1.size1 (), m2.size1 ()); ++ i) - for (unsigned j = 0; j < std_min (m1.size2 (), m2.size2 ()); ++ j) + for (unsigned i = 0; i < (std::min)(m1.size1 (), m2.size1 ()); ++ i) + for (unsigned j = 0; j < (std::min)(m1.size2 (), m2.size2 ()); ++ j) m1 (i, j) = m2 (i, j) = 3 * i + j; std::cout << m1 + m2 << std::endl; diff --git a/doc/samples/matrix_matrix_binary.cpp b/doc/samples/matrix_matrix_binary.cpp index 7b3bc9ad..6a8957d4 100644 --- a/doc/samples/matrix_matrix_binary.cpp +++ b/doc/samples/matrix_matrix_binary.cpp @@ -16,13 +16,12 @@ #include #include -#include int main () { using namespace boost::numeric::ublas; matrix m1 (3, 3), m2 (3, 3); - for (unsigned i = 0; i < std_min (m1.size1 (), m2.size1 ()); ++ i) - for (unsigned j = 0; j < std_min (m1.size2 (), m2.size2 ()); ++ j) + for (unsigned i = 0; i < (std::min)(m1.size1 (), m2.size1 ()); ++ i) + for (unsigned j = 0; j < (std::min)(m1.size2 (), m2.size2 ()); ++ j) m1 (i, j) = m2 (i, j) = 3 * i + j; std::cout << prod (m1, m2) << std::endl; diff --git a/doc/samples/matrix_matrix_solve.cpp b/doc/samples/matrix_matrix_solve.cpp index 12558937..3bb89fce 100644 --- a/doc/samples/matrix_matrix_solve.cpp +++ b/doc/samples/matrix_matrix_solve.cpp @@ -16,12 +16,11 @@ #include #include -#include int main () { using namespace boost::numeric::ublas; matrix m1 (3, 3), m2 (3, 3); - for (unsigned i = 0; i < std_min (m1.size1 (), m2.size1 ()); ++ i) + for (unsigned i = 0; i < (std::min)(m1.size1 (), m2.size1 ()); ++ i) for (unsigned j = 0; j <= i; ++ j) m1 (i, j) = m2 (i, j) = 3 * i + j + 1; diff --git a/doc/samples/matrix_vector_binary.cpp b/doc/samples/matrix_vector_binary.cpp index 74197c8e..d1028042 100644 --- a/doc/samples/matrix_vector_binary.cpp +++ b/doc/samples/matrix_vector_binary.cpp @@ -16,13 +16,12 @@ #include #include -#include int main () { using namespace boost::numeric::ublas; matrix m (3, 3); vector v (3); - for (unsigned i = 0; i < std_min (m.size1 (), v.size ()); ++ i) { + for (unsigned i = 0; i < (std::min)(m.size1 (), v.size ()); ++ i) { for (unsigned j = 0; j < m.size2 (); ++ j) m (i, j) = 3 * i + j; v (i) = i; diff --git a/doc/samples/matrix_vector_solve.cpp b/doc/samples/matrix_vector_solve.cpp index 1ed0496d..b5487329 100644 --- a/doc/samples/matrix_vector_solve.cpp +++ b/doc/samples/matrix_vector_solve.cpp @@ -16,13 +16,12 @@ #include #include -#include int main () { using namespace boost::numeric::ublas; matrix m (3, 3); vector v (3); - for (unsigned i = 0; i < std_min (m.size1 (), v.size ()); ++ i) { + for (unsigned i = 0; i < (std::min)(m.size1 (), v.size ()); ++ i) { for (unsigned j = 0; j <= i; ++ j) m (i, j) = 3 * i + j + 1; v (i) = i; diff --git a/doc/samples/vector_binary.cpp b/doc/samples/vector_binary.cpp index f069c54c..5ab27b19 100644 --- a/doc/samples/vector_binary.cpp +++ b/doc/samples/vector_binary.cpp @@ -16,12 +16,11 @@ #include #include -#include int main () { using namespace boost::numeric::ublas; vector v1 (3), v2 (3); - for (unsigned i = 0; i < std_min (v1.size (), v2.size ()); ++ i) + for (unsigned i = 0; i < (std::min)(v1.size (), v2.size ()); ++ i) v1 (i) = v2 (i) = i; std::cout << v1 + v2 << std::endl; diff --git a/doc/samples/vector_binary_outer.cpp b/doc/samples/vector_binary_outer.cpp index 72ba9dcc..95482fb2 100644 --- a/doc/samples/vector_binary_outer.cpp +++ b/doc/samples/vector_binary_outer.cpp @@ -16,12 +16,11 @@ #include #include -#include int main () { using namespace boost::numeric::ublas; vector v1 (3), v2 (3); - for (unsigned i = 0; i < std_min (v1.size (), v2.size ()); ++ i) + for (unsigned i = 0; i < (std::min)(v1.size (), v2.size ()); ++ i) v1 (i) = v2 (i) = i; std::cout << outer_prod (v1, v2) << std::endl; diff --git a/doc/samples/vector_binary_redux.cpp b/doc/samples/vector_binary_redux.cpp index 7ad0728a..a481aae3 100644 --- a/doc/samples/vector_binary_redux.cpp +++ b/doc/samples/vector_binary_redux.cpp @@ -15,12 +15,11 @@ // #include -#include int main () { using namespace boost::numeric::ublas; vector v1 (3), v2 (3); - for (unsigned i = 0; i < std_min (v1.size (), v2.size ()); ++ i) + for (unsigned i = 0; i < (std::min)(v1.size (), v2.size ()); ++ i) v1 (i) = v2 (i) = i; std::cout << inner_prod (v1, v2) << std::endl; diff --git a/include/boost/numeric/ublas/banded.hpp b/include/boost/numeric/ublas/banded.hpp index 61a35a1e..94f2026e 100644 --- a/include/boost/numeric/ublas/banded.hpp +++ b/include/boost/numeric/ublas/banded.hpp @@ -122,24 +122,26 @@ 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, bool preserve = true) { + BOOST_USING_STD_MAX(); size1_ = size1; size2_ = size2; lower_ = lower; upper_ = upper; - detail::resize (data (), std_max (size1, size2) * (lower + 1 + upper), preserve); + detail::resize (data (), max BOOST_PREVENT_MACRO_SUBSTITUTION (size1, size2) * (lower + 1 + upper), preserve); } // Element access BOOST_UBLAS_INLINE const_reference operator () (size_type i, size_type j) const { + BOOST_USING_STD_MAX(); BOOST_UBLAS_CHECK (i < size1_, bad_index ()); BOOST_UBLAS_CHECK (j < size2_, bad_index ()); #ifdef BOOST_UBLAS_OWN_BANDED - size_type k = std_max (i, j); + size_type k = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); size_type l = lower_ + j - i; - if (k < std_max (size1_, size2_) && + if (k < max BOOST_PREVENT_MACRO_SUBSTITUTION (size1_, size2_) && l < lower_ + 1 + upper_) - return data () [functor_type::element (k, std_max (size1_, size2_), + return data () [functor_type::element (k, max BOOST_PREVENT_MACRO_SUBSTITUTION (size1_, size2_), l, lower_ + 1 + upper_)]; #else size_type k = j; @@ -153,14 +155,15 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE reference operator () (size_type i, size_type j) { + BOOST_USING_STD_MAX(); BOOST_UBLAS_CHECK (i < size1_, bad_index ()); BOOST_UBLAS_CHECK (j < size2_, bad_index ()); #ifdef BOOST_UBLAS_OWN_BANDED - size_type k = std_max (i, j); + size_type k = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); size_type l = lower_ + j - i; - if (k < std_max (size1_, size2_) && + if (k < max BOOST_PREVENT_MACRO_SUBSTITUTION (size1_, size2_) && l < lower_ + 1 + upper_) - return data () [functor_type::element (k, std_max (size1_, size2_), + return data () [functor_type::element (k, max BOOST_PREVENT_MACRO_SUBSTITUTION (size1_, size2_), l, lower_ + 1 + upper_)]; #else size_type k = j; @@ -299,6 +302,7 @@ namespace boost { namespace numeric { namespace ublas { // Thanks to Kresimir Fresl for spotting this. BOOST_UBLAS_INLINE void insert (size_type i, size_type j, const_reference t) { + BOOST_USING_STD_MAX(); BOOST_UBLAS_CHECK (i < size1_, bad_index ()); BOOST_UBLAS_CHECK (j < size2_, bad_index ()); // FIXME: is this ugly check still needed?! @@ -307,13 +311,13 @@ namespace boost { namespace numeric { namespace ublas { // return; // #endif #ifdef BOOST_UBLAS_OWN_BANDED - size_type k = std_max (i, j); + size_type k = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); size_type l = lower_ + j - i; - BOOST_UBLAS_CHECK (type_traits::equals (data () [functor_type::element (k, std_max (size1_, size2_), + BOOST_UBLAS_CHECK (type_traits::equals (data () [functor_type::element (k, max BOOST_PREVENT_MACRO_SUBSTITUTION (size1_, size2_), l, lower_ + 1 + upper_)], value_type ()), bad_index ()); - // data ().insert (data ().begin () + functor_type::element (k, std_max (size1_, size2_), + // data ().insert (data ().begin () + functor_type::element (k, max BOOST_PREVENT_MACRO_SUBSTITUTION (size1_, size2_), // l, lower_ + 1 + upper_), t); - data () [functor_type::element (k, std_max (size1_, size2_), + data () [functor_type::element (k, max BOOST_PREVENT_MACRO_SUBSTITUTION (size1_, size2_), l, lower_ + 1 + upper_)] = t; #else size_type k = j; @@ -328,14 +332,15 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE void erase (size_type i, size_type j) { + BOOST_USING_STD_MAX(); BOOST_UBLAS_CHECK (i < size1_, bad_index ()); BOOST_UBLAS_CHECK (j < size2_, bad_index ()); #ifdef BOOST_UBLAS_OWN_BANDED - size_type k = std_max (i, j); + size_type k = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); size_type l = lower_ + j - i; - // data ().erase (data ().begin () + functor_type::element (k, std_max (size1_, size2_), + // data ().erase (data ().begin () + functor_type::element (k, max BOOST_PREVENT_MACRO_SUBSTITUTION (size1_, size2_), // l, lower_ + 1 + upper_)); - data () [functor_type::element (k, std_max (size1_, size2_), + data () [functor_type::element (k, max BOOST_PREVENT_MACRO_SUBSTITUTION (size1_, size2_), l, lower_ + 1 + upper_)] = value_type (); #else size_type k = j; @@ -378,41 +383,49 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE const_iterator1 find1 (int rank, size_type i, size_type j) const { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); 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); + size_type lower_i = max BOOST_PREVENT_MACRO_SUBSTITUTION (difference_type (j - upper_), difference_type (0)); + i = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, lower_i); + size_type upper_i = min BOOST_PREVENT_MACRO_SUBSTITUTION (j + 1 + lower_, size1_); + i = min BOOST_PREVENT_MACRO_SUBSTITUTION (i, upper_i); } return const_iterator1 (*this, i, j); } BOOST_UBLAS_INLINE iterator1 find1 (int rank, size_type i, size_type j) { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); 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); + size_type lower_i = max BOOST_PREVENT_MACRO_SUBSTITUTION (difference_type (j - upper_), difference_type (0)); + i = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, lower_i); + size_type upper_i = min BOOST_PREVENT_MACRO_SUBSTITUTION (j + 1 + lower_, size1_); + i = min BOOST_PREVENT_MACRO_SUBSTITUTION (i, upper_i); } return iterator1 (*this, i, j); } BOOST_UBLAS_INLINE const_iterator2 find2 (int rank, size_type i, size_type j) const { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); 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); + size_type lower_j = max BOOST_PREVENT_MACRO_SUBSTITUTION (difference_type (i - lower_), difference_type (0)); + j = max BOOST_PREVENT_MACRO_SUBSTITUTION (j, lower_j); + size_type upper_j = min BOOST_PREVENT_MACRO_SUBSTITUTION (i + 1 + upper_, size2_); + j = min BOOST_PREVENT_MACRO_SUBSTITUTION (j, upper_j); } return const_iterator2 (*this, i, j); } BOOST_UBLAS_INLINE iterator2 find2 (int rank, size_type i, size_type j) { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); 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); + size_type lower_j = max BOOST_PREVENT_MACRO_SUBSTITUTION (difference_type (i - lower_), difference_type (0)); + j = max BOOST_PREVENT_MACRO_SUBSTITUTION (j, lower_j); + size_type upper_j = min BOOST_PREVENT_MACRO_SUBSTITUTION (i + 1 + upper_, size2_); + j = min BOOST_PREVENT_MACRO_SUBSTITUTION (j, upper_j); } return iterator2 (*this, i, j); } @@ -1182,12 +1195,13 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_PROXY_CONST_MEMBER BOOST_UBLAS_INLINE const_reference operator () (size_type i, size_type j) const { + BOOST_USING_STD_MAX(); BOOST_UBLAS_CHECK (i < size1 (), bad_index ()); BOOST_UBLAS_CHECK (j < size2 (), bad_index ()); #ifdef BOOST_UBLAS_OWN_BANDED - size_type k = std_max (i, j); + size_type k = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); size_type l = lower_ + j - i; - if (k < std_max (size1 (), size2 ()) && + if (k < max BOOST_PREVENT_MACRO_SUBSTITUTION (size1 (), size2 ()) && l < lower_ + 1 + upper_) return data () (i, j); #else @@ -1201,12 +1215,13 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE reference operator () (size_type i, size_type j) { + BOOST_USING_STD_MAX(); BOOST_UBLAS_CHECK (i < size1 (), bad_index ()); BOOST_UBLAS_CHECK (j < size2 (), bad_index ()); #ifdef BOOST_UBLAS_OWN_BANDED - size_type k = std_max (i, j); + size_type k = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); size_type l = lower_ + j - i; - if (k < std_max (size1 (), size2 ()) && + if (k < max BOOST_PREVENT_MACRO_SUBSTITUTION (size1 (), size2 ()) && l < lower_ + 1 + upper_) return data () (i, j); #else @@ -1226,12 +1241,13 @@ namespace boost { namespace numeric { namespace ublas { #else BOOST_UBLAS_INLINE reference operator () (size_type i, size_type j) const { + BOOST_USING_STD_MAX(); BOOST_UBLAS_CHECK (i < size1 (), bad_index ()); BOOST_UBLAS_CHECK (j < size2 (), bad_index ()); #ifdef BOOST_UBLAS_OWN_BANDED - size_type k = std_max (i, j); + size_type k = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); size_type l = lower_ + j - i; - if (k < std_max (size1 (), size2 ()) && + if (k < max BOOST_PREVENT_MACRO_SUBSTITUTION (size1 (), size2 ()) && l < lower_ + 1 + upper_) return data () (i, j); #else @@ -1359,41 +1375,49 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE const_iterator1 find1 (int rank, size_type i, size_type j) const { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); 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); + size_type lower_i = max BOOST_PREVENT_MACRO_SUBSTITUTION (difference_type (j - upper_), difference_type (0)); + i = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, lower_i); + size_type upper_i = min BOOST_PREVENT_MACRO_SUBSTITUTION (j + 1 + lower_, size1 ()); + i = min BOOST_PREVENT_MACRO_SUBSTITUTION (i, upper_i); } return const_iterator1 (*this, data ().find1 (rank, i, j)); } BOOST_UBLAS_INLINE iterator1 find1 (int rank, size_type i, size_type j) { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); 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); + size_type lower_i = max BOOST_PREVENT_MACRO_SUBSTITUTION (difference_type (j - upper_), difference_type (0)); + i = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, lower_i); + size_type upper_i = min BOOST_PREVENT_MACRO_SUBSTITUTION (j + 1 + lower_, size1 ()); + i = min BOOST_PREVENT_MACRO_SUBSTITUTION (i, upper_i); } return iterator1 (*this, data ().find1 (rank, i, j)); } BOOST_UBLAS_INLINE const_iterator2 find2 (int rank, size_type i, size_type j) const { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); 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); + size_type lower_j = max BOOST_PREVENT_MACRO_SUBSTITUTION (difference_type (i - lower_), difference_type (0)); + j = max BOOST_PREVENT_MACRO_SUBSTITUTION (j, lower_j); + size_type upper_j = min BOOST_PREVENT_MACRO_SUBSTITUTION (i + 1 + upper_, size2 ()); + j = min BOOST_PREVENT_MACRO_SUBSTITUTION (j, upper_j); } return const_iterator2 (*this, data ().find2 (rank, i, j)); } BOOST_UBLAS_INLINE iterator2 find2 (int rank, size_type i, size_type j) { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); 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); + size_type lower_j = max BOOST_PREVENT_MACRO_SUBSTITUTION (difference_type (i - lower_), difference_type (0)); + j = max BOOST_PREVENT_MACRO_SUBSTITUTION (j, lower_j); + size_type upper_j = min BOOST_PREVENT_MACRO_SUBSTITUTION (i + 1 + upper_, size2 ()); + j = min BOOST_PREVENT_MACRO_SUBSTITUTION (j, upper_j); } return iterator2 (*this, data ().find2 (rank, i, j)); } @@ -1462,14 +1486,15 @@ namespace boost { namespace numeric { namespace ublas { // Dereference BOOST_UBLAS_INLINE reference operator * () const { + BOOST_USING_STD_MAX(); size_type i = index1 (); size_type j = index2 (); BOOST_UBLAS_CHECK (i < (*this) ().size1 (), bad_index ()); BOOST_UBLAS_CHECK (j < (*this) ().size2 (), bad_index ()); #ifdef BOOST_UBLAS_OWN_BANDED - size_type k = std_max (i, j); + size_type k = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); size_type l = (*this) ().lower () + j - i; - if (k < std_max ((*this) ().size1 (), (*this) ().size2 ()) && + if (k < max BOOST_PREVENT_MACRO_SUBSTITUTION ((*this) ().size1 (), (*this) ().size2 ()) && l < (*this) ().lower () + 1 + (*this) ().upper ()) return *it1_; #else @@ -1615,14 +1640,15 @@ namespace boost { namespace numeric { namespace ublas { // Dereference BOOST_UBLAS_INLINE reference operator * () const { + BOOST_USING_STD_MAX(); size_type i = index1 (); size_type j = index2 (); BOOST_UBLAS_CHECK (i < (*this) ().size1 (), bad_index ()); BOOST_UBLAS_CHECK (j < (*this) ().size2 (), bad_index ()); #ifdef BOOST_UBLAS_OWN_BANDED - size_type k = std_max (i, j); + size_type k = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); size_type l = (*this) ().lower () + j - i; - if (k < std_max ((*this) ().size1 (), (*this) ().size2 ()) && + if (k < max BOOST_PREVENT_MACRO_SUBSTITUTION ((*this) ().size1 (), (*this) ().size2 ()) && l < (*this) ().lower () + 1 + (*this) ().upper ()) return *it1_; #else @@ -1774,14 +1800,15 @@ namespace boost { namespace numeric { namespace ublas { // Dereference BOOST_UBLAS_INLINE reference operator * () const { + BOOST_USING_STD_MAX(); size_type i = index1 (); size_type j = index2 (); BOOST_UBLAS_CHECK (i < (*this) ().size1 (), bad_index ()); BOOST_UBLAS_CHECK (j < (*this) ().size2 (), bad_index ()); #ifdef BOOST_UBLAS_OWN_BANDED - size_type k = std_max (i, j); + size_type k = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); size_type l = (*this) ().lower () + j - i; - if (k < std_max ((*this) ().size1 (), (*this) ().size2 ()) && + if (k < max BOOST_PREVENT_MACRO_SUBSTITUTION ((*this) ().size1 (), (*this) ().size2 ()) && l < (*this) ().lower () + 1 + (*this) ().upper ()) return *it2_; #else @@ -1927,14 +1954,15 @@ namespace boost { namespace numeric { namespace ublas { // Dereference BOOST_UBLAS_INLINE reference operator * () const { + BOOST_USING_STD_MAX(); size_type i = index1 (); size_type j = index2 (); BOOST_UBLAS_CHECK (i < (*this) ().size1 (), bad_index ()); BOOST_UBLAS_CHECK (j < (*this) ().size2 (), bad_index ()); #ifdef BOOST_UBLAS_OWN_BANDED - size_type k = std_max (i, j); + size_type k = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); size_type l = (*this) ().lower () + j - i; - if (k < std_max ((*this) ().size1 (), (*this) ().size2 ()) && + if (k < max BOOST_PREVENT_MACRO_SUBSTITUTION ((*this) ().size1 (), (*this) ().size2 ()) && l < (*this) ().lower () + 1 + (*this) ().upper ()) return *it2_; #else diff --git a/include/boost/numeric/ublas/functional.hpp b/include/boost/numeric/ublas/functional.hpp index 956bcd91..03419db4 100644 --- a/include/boost/numeric/ublas/functional.hpp +++ b/include/boost/numeric/ublas/functional.hpp @@ -721,6 +721,7 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE result_type operator () (I1 it1, const I1 &it1_end, I2 it2, const I2 &it2_end) const { + BOOST_USING_STD_MIN(); result_type t = result_type (); difference_type it1_size (it1_end - it1); difference_type it2_size (it2_end - it2); @@ -728,20 +729,20 @@ namespace boost { namespace numeric { namespace ublas { if (it1_size > 0 && it2_size > 0) diff = it2.index () - it1.index (); if (diff != 0) { - difference_type size = std_min (diff, it1_size); + difference_type size = min BOOST_PREVENT_MACRO_SUBSTITUTION (diff, it1_size); if (size > 0) { it1 += size; it1_size -= size; diff -= size; } - size = std_min (- diff, it2_size); + size = min BOOST_PREVENT_MACRO_SUBSTITUTION (- diff, it2_size); if (size > 0) { it2 += size; it2_size -= size; diff += size; } } - difference_type size (std_min (it1_size, it2_size)); + difference_type size (min BOOST_PREVENT_MACRO_SUBSTITUTION (it1_size, it2_size)); while (-- size >= 0) t += *it1 * *it2, ++ it1, ++ it2; return t; @@ -862,6 +863,7 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE result_type operator () (I1 it1, const I1 &it1_end, I2 it2, const I2 &it2_end) const { + BOOST_USING_STD_MIN(); result_type t = result_type (); difference_type it1_size (it1_end - it1); difference_type it2_size (it2_end - it2); @@ -869,20 +871,20 @@ namespace boost { namespace numeric { namespace ublas { if (it1_size > 0 && it2_size > 0) diff = it2.index () - it1.index2 (); if (diff != 0) { - difference_type size = std_min (diff, it1_size); + difference_type size = min BOOST_PREVENT_MACRO_SUBSTITUTION (diff, it1_size); if (size > 0) { it1 += size; it1_size -= size; diff -= size; } - size = std_min (- diff, it2_size); + size = min BOOST_PREVENT_MACRO_SUBSTITUTION (- diff, it2_size); if (size > 0) { it2 += size; it2_size -= size; diff += size; } } - difference_type size (std_min (it1_size, it2_size)); + difference_type size (min BOOST_PREVENT_MACRO_SUBSTITUTION (it1_size, it2_size)); while (-- size >= 0) t += *it1 * *it2, ++ it1, ++ it2; return t; @@ -1026,6 +1028,7 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE result_type operator () (I1 it1, const I1 &it1_end, I2 it2, const I2 &it2_end) const { + BOOST_USING_STD_MIN(); result_type t = result_type (); difference_type it1_size (it1_end - it1); difference_type it2_size (it2_end - it2); @@ -1033,20 +1036,20 @@ namespace boost { namespace numeric { namespace ublas { if (it1_size > 0 && it2_size > 0) diff = it2.index1 () - it1.index (); if (diff != 0) { - difference_type size = std_min (diff, it1_size); + difference_type size = min BOOST_PREVENT_MACRO_SUBSTITUTION (diff, it1_size); if (size > 0) { it1 += size; it1_size -= size; diff -= size; } - size = std_min (- diff, it2_size); + size = min BOOST_PREVENT_MACRO_SUBSTITUTION (- diff, it2_size); if (size > 0) { it2 += size; it2_size -= size; diff += size; } } - difference_type size (std_min (it1_size, it2_size)); + difference_type size (min BOOST_PREVENT_MACRO_SUBSTITUTION (it1_size, it2_size)); while (-- size >= 0) t += *it1 * *it2, ++ it1, ++ it2; return t; @@ -1199,6 +1202,7 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE result_type operator () (I1 it1, const I1 &it1_end, I2 it2, const I2 &it2_end, packed_random_access_iterator_tag) const { + BOOST_USING_STD_MIN(); result_type t = result_type (); difference_type it1_size (it1_end - it1); difference_type it2_size (it2_end - it2); @@ -1206,20 +1210,20 @@ namespace boost { namespace numeric { namespace ublas { if (it1_size > 0 && it2_size > 0) diff = it2.index1 () - it1.index2 (); if (diff != 0) { - difference_type size = std_min (diff, it1_size); + difference_type size = min BOOST_PREVENT_MACRO_SUBSTITUTION (diff, it1_size); if (size > 0) { it1 += size; it1_size -= size; diff -= size; } - size = std_min (- diff, it2_size); + size = min BOOST_PREVENT_MACRO_SUBSTITUTION (- diff, it2_size); if (size > 0) { it2 += size; it2_size -= size; diff += size; } } - difference_type size (std_min (it1_size, it2_size)); + difference_type size (min BOOST_PREVENT_MACRO_SUBSTITUTION (it1_size, it2_size)); while (-- size >= 0) t += *it1 * *it2, ++ it1, ++ it2; return t; @@ -1411,12 +1415,13 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type upper_element (size_type i, size_type size1, size_type j, size_type size2) { + BOOST_USING_STD_MAX(); BOOST_UBLAS_CHECK (i < size1, bad_index ()); BOOST_UBLAS_CHECK (j < size2, bad_index ()); BOOST_UBLAS_CHECK (i <= j, bad_index ()); // sigma_i (size - i) = size * i - i * (i - 1) / 2 // i = 0 1 2 3, sigma = 0 4 7 9 - return (i * (2 * std_max (size1, size2) - i + 1)) / 2 + j - i; + return (i * (2 * max BOOST_PREVENT_MACRO_SUBSTITUTION (size1, size2) - i + 1)) / 2 + j - i; } static @@ -1561,12 +1566,13 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type lower_element (size_type i, size_type size1, size_type j, size_type size2) { + BOOST_USING_STD_MAX(); BOOST_UBLAS_CHECK (i < size1, bad_index ()); BOOST_UBLAS_CHECK (j < size2, bad_index ()); BOOST_UBLAS_CHECK (i >= j, bad_index ()); // sigma_j (size - j) = size * j - j * (j - 1) / 2 // j = 0 1 2 3, sigma = 0 4 7 9 - return i - j + (j * (2 * std_max (size1, size2) - j + 1)) / 2; + return i - j + (j * (2 * max BOOST_PREVENT_MACRO_SUBSTITUTION (size1, size2) - j + 1)) / 2; } static BOOST_UBLAS_INLINE @@ -1684,7 +1690,8 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type packed_size (size_type size1, size_type size2) { - size_type size = std_max (size1, size2); + BOOST_USING_STD_MAX(); + size_type size = max BOOST_PREVENT_MACRO_SUBSTITUTION (size1, size2); return ((size + 1) * size) / 2; } @@ -1713,22 +1720,26 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type restrict1 (size_type i, size_type j) { - return std_max (i, j); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } static BOOST_UBLAS_INLINE size_type restrict2 (size_type i, size_type j) { - return std_min (i + 1, j); + BOOST_USING_STD_MIN(); + return min BOOST_PREVENT_MACRO_SUBSTITUTION (i + 1, j); } static BOOST_UBLAS_INLINE size_type mutable_restrict1 (size_type i, size_type j) { - return std_max (i, j); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } static BOOST_UBLAS_INLINE size_type mutable_restrict2 (size_type i, size_type j) { - return std_min (i + 1, j); + BOOST_USING_STD_MIN(); + return min BOOST_PREVENT_MACRO_SUBSTITUTION (i + 1, j); } }; struct upper { @@ -1738,7 +1749,8 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type packed_size (size_type size1, size_type size2) { - size_type size = std_max (size1, size2); + BOOST_USING_STD_MAX(); + size_type size = max BOOST_PREVENT_MACRO_SUBSTITUTION (size1, size2); return ((size + 1) * size) / 2; } @@ -1767,22 +1779,26 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type restrict1 (size_type i, size_type j) { - return std_min (i, j + 1); + BOOST_USING_STD_MIN(); + return min BOOST_PREVENT_MACRO_SUBSTITUTION (i, j + 1); } static BOOST_UBLAS_INLINE size_type restrict2 (size_type i, size_type j) { - return std_max (i, j); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } static BOOST_UBLAS_INLINE size_type mutable_restrict1 (size_type i, size_type j) { - return std_min (i, j + 1); + BOOST_USING_STD_MIN(); + return min BOOST_PREVENT_MACRO_SUBSTITUTION (i, j + 1); } static BOOST_UBLAS_INLINE size_type mutable_restrict2 (size_type i, size_type j) { - return std_max (i, j); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } }; struct unit_lower { @@ -1792,7 +1808,8 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type packed_size (size_type size1, size_type size2) { - size_type size = std_max (size1, size2); + BOOST_USING_STD_MAX(); + size_type size = max BOOST_PREVENT_MACRO_SUBSTITUTION (size1, size2); return ((size + 1) * size) / 2; } @@ -1821,22 +1838,26 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type restrict1 (size_type i, size_type j) { - return std_max (i, j); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } static BOOST_UBLAS_INLINE size_type restrict2 (size_type i, size_type j) { - return std_min (i + 1, j); + BOOST_USING_STD_MIN(); + return min BOOST_PREVENT_MACRO_SUBSTITUTION (i + 1, j); } static BOOST_UBLAS_INLINE size_type mutable_restrict1 (size_type i, size_type j) { - return std_max (i, j); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } static BOOST_UBLAS_INLINE size_type mutable_restrict2 (size_type i, size_type j) { - return std_min (i, j); + BOOST_USING_STD_MIN(); + return min BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } }; struct unit_upper { @@ -1846,7 +1867,8 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type packed_size (size_type size1, size_type size2) { - size_type size = std_max (size1, size2); + BOOST_USING_STD_MAX(); + size_type size = max BOOST_PREVENT_MACRO_SUBSTITUTION (size1, size2); return ((size + 1) * size) / 2; } @@ -1875,22 +1897,26 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type restrict1 (size_type i, size_type j) { - return std_min (i, j + 1); + BOOST_USING_STD_MIN(); + return min BOOST_PREVENT_MACRO_SUBSTITUTION (i, j + 1); } static BOOST_UBLAS_INLINE size_type restrict2 (size_type i, size_type j) { - return std_max (i, j); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } static BOOST_UBLAS_INLINE size_type mutable_restrict1 (size_type i, size_type j) { - return std_min (i, j); + BOOST_USING_STD_MIN(); + return min BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } static BOOST_UBLAS_INLINE size_type mutable_restrict2 (size_type i, size_type j) { - return std_max (i, j); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } }; struct strict_lower { @@ -1900,7 +1926,8 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type packed_size (size_type size1, size_type size2) { - size_type size = std_max (size1, size2); + BOOST_USING_STD_MAX(); + size_type size = max BOOST_PREVENT_MACRO_SUBSTITUTION (size1, size2); return ((size + 1) * size) / 2; } @@ -1929,22 +1956,26 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type restrict1 (size_type i, size_type j) { - return std_max (i, j); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } static BOOST_UBLAS_INLINE size_type restrict2 (size_type i, size_type j) { - return std_min (i, j); + BOOST_USING_STD_MIN(); + return min BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } static BOOST_UBLAS_INLINE size_type mutable_restrict1 (size_type i, size_type j) { - return std_max (i, j); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } static BOOST_UBLAS_INLINE size_type mutable_restrict2 (size_type i, size_type j) { - return std_min (i, j); + BOOST_USING_STD_MIN(); + return min BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } }; struct strict_upper { @@ -1954,7 +1985,8 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type packed_size (size_type size1, size_type size2) { - size_type size = std_max (size1, size2); + BOOST_USING_STD_MAX(); + size_type size = max BOOST_PREVENT_MACRO_SUBSTITUTION (size1, size2); return ((size + 1) * size) / 2; } @@ -1983,22 +2015,26 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type restrict1 (size_type i, size_type j) { - return std_min (i, j); + BOOST_USING_STD_MIN(); + return min BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } static BOOST_UBLAS_INLINE size_type restrict2 (size_type i, size_type j) { - return std_max (i, j); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } static BOOST_UBLAS_INLINE size_type mutable_restrict1 (size_type i, size_type j) { - return std_min (i, j); + BOOST_USING_STD_MIN(); + return min BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } static BOOST_UBLAS_INLINE size_type mutable_restrict2 (size_type i, size_type j) { - return std_max (i, j); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); } }; diff --git a/include/boost/numeric/ublas/hermitian.hpp b/include/boost/numeric/ublas/hermitian.hpp index c33c86f4..3c4c714a 100644 --- a/include/boost/numeric/ublas/hermitian.hpp +++ b/include/boost/numeric/ublas/hermitian.hpp @@ -1744,25 +1744,26 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator1 &operator += (difference_type n) { + BOOST_USING_STD_MIN(); BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ()); if (current_ == 0) { - size_type d = std_min (n, it1_end_ - it1_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_end_ - it1_); it1_ += d; n -= d; if (n > 0 || (end_ == 1 && it1_ == it1_end_)) { BOOST_UBLAS_CHECK (end_ == 1, external_logic ()); - d = std_min (n, it2_end_ - it2_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_end_ - it2_begin_); it2_ = it2_begin_ + d; n -= d; current_ = 1; } } else /* if (current_ == 1) */ { - size_type d = std_min (n, it2_end_ - it2_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_end_ - it2_); it2_ += d; n -= d; if (n > 0 || (end_ == 0 && it2_ == it2_end_)) { BOOST_UBLAS_CHECK (end_ == 0, external_logic ()); - d = std_min (n, it1_end_ - it1_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_end_ - it1_begin_); it1_ = it1_begin_ + d; n -= d; current_ = 0; @@ -1773,25 +1774,26 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator1 &operator -= (difference_type n) { + BOOST_USING_STD_MIN(); BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ()); if (current_ == 0) { - size_type d = std_min (n, it1_ - it1_begin_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_ - it1_begin_); it1_ -= d; n -= d; if (n > 0) { BOOST_UBLAS_CHECK (end_ == 1, external_logic ()); - d = std_min (n, it2_end_ - it2_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_end_ - it2_begin_); it2_ = it2_end_ - d; n -= d; current_ = 1; } } else /* if (current_ == 1) */ { - size_type d = std_min (n, it2_ - it2_begin_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_ - it2_begin_); it2_ -= d; n -= d; if (n > 0) { BOOST_UBLAS_CHECK (end_ == 0, external_logic ()); - d = std_min (n, it1_end_ - it1_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_end_ - it1_begin_); it1_ = it1_end_ - d; n -= d; current_ = 0; @@ -2201,25 +2203,26 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator2 &operator += (difference_type n) { + BOOST_USING_STD_MIN(); BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ()); if (current_ == 0) { - size_type d = std_min (n, it1_end_ - it1_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_end_ - it1_); it1_ += d; n -= d; if (n > 0 || (end_ == 1 && it1_ == it1_end_)) { BOOST_UBLAS_CHECK (end_ == 1, external_logic ()); - d = std_min (n, it2_end_ - it2_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_end_ - it2_begin_); it2_ = it2_begin_ + d; n -= d; current_ = 1; } } else /* if (current_ == 1) */ { - size_type d = std_min (n, it2_end_ - it2_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_end_ - it2_); it2_ += d; n -= d; if (n > 0 || (end_ == 0 && it2_ == it2_end_)) { BOOST_UBLAS_CHECK (end_ == 0, external_logic ()); - d = std_min (n, it1_end_ - it1_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_end_ - it1_begin_); it1_ = it1_begin_ + d; n -= d; current_ = 0; @@ -2230,25 +2233,26 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator2 &operator -= (difference_type n) { + BOOST_USING_STD_MIN(); BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ()); if (current_ == 0) { - size_type d = std_min (n, it1_ - it1_begin_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_ - it1_begin_); it1_ -= d; n -= d; if (n > 0) { BOOST_UBLAS_CHECK (end_ == 1, external_logic ()); - d = std_min (n, it2_end_ - it2_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_end_ - it2_begin_); it2_ = it2_end_ - d; n -= d; current_ = 1; } } else /* if (current_ == 1) */ { - size_type d = std_min (n, it2_ - it2_begin_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_ - it2_begin_); it2_ -= d; n -= d; if (n > 0) { BOOST_UBLAS_CHECK (end_ == 0, external_logic ()); - d = std_min (n, it1_end_ - it1_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_end_ - it1_begin_); it1_ = it1_end_ - d; n -= d; current_ = 0; diff --git a/include/boost/numeric/ublas/lu.hpp b/include/boost/numeric/ublas/lu.hpp index 07069d54..931136c5 100644 --- a/include/boost/numeric/ublas/lu.hpp +++ b/include/boost/numeric/ublas/lu.hpp @@ -92,7 +92,8 @@ namespace boost { namespace numeric { namespace ublas { int singular = 0; size_type size1 = m.size1 (); size_type size2 = m.size2 (); - size_type size = std_min (size1, size2); + BOOST_USING_STD_MIN(); + size_type size = min BOOST_PREVENT_MACRO_SUBSTITUTION (size1, size2); for (size_type i = 0; i < size; ++ i) { matrix_column mci (column (m, i)); matrix_row mri (row (m, i)); @@ -126,7 +127,8 @@ namespace boost { namespace numeric { namespace ublas { int singular = 0; size_type size1 = m.size1 (); size_type size2 = m.size2 (); - size_type size = std_min (size1, size2); + BOOST_USING_STD_MIN(); + size_type size = min BOOST_PREVENT_MACRO_SUBSTITUTION (size1, size2); for (size_type i = 0; i < size; ++ i) { matrix_column mci (column (m, i)); matrix_row mri (row (m, i)); @@ -169,7 +171,8 @@ namespace boost { namespace numeric { namespace ublas { int singular = 0; size_type size1 = m.size1 (); size_type size2 = m.size2 (); - size_type size = std_min (size1, size2); + BOOST_USING_STD_MIN(); + size_type size = min BOOST_PREVENT_MACRO_SUBSTITUTION (size1, size2); #ifndef BOOST_UBLAS_LU_WITH_INPLACE_SOLVE matrix_type mr (m); mr.assign (zero_matrix (size1, size2)); diff --git a/include/boost/numeric/ublas/matrix.hpp b/include/boost/numeric/ublas/matrix.hpp index e90d00e1..3e764238 100644 --- a/include/boost/numeric/ublas/matrix.hpp +++ b/include/boost/numeric/ublas/matrix.hpp @@ -2066,17 +2066,21 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE const_iterator1 find1 (int rank, size_type i, size_type j) const { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); if (rank == 1) { - i = std_max (i, j); - i = std_min (i, j + 1); + i = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, j); + i = min BOOST_PREVENT_MACRO_SUBSTITUTION (i, j + 1); } return const_iterator1 (*this, i, j); } BOOST_UBLAS_INLINE const_iterator2 find2 (int rank, size_type i, size_type j) const { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); if (rank == 1) { - j = std_max (j, i); - j = std_min (j, i + 1); + j = max BOOST_PREVENT_MACRO_SUBSTITUTION (j, i); + j = min BOOST_PREVENT_MACRO_SUBSTITUTION (j, i + 1); } return const_iterator2 (*this, i, j); } diff --git a/include/boost/numeric/ublas/matrix_assign.hpp b/include/boost/numeric/ublas/matrix_assign.hpp index ee286dbc..cdf02e5d 100644 --- a/include/boost/numeric/ublas/matrix_assign.hpp +++ b/include/boost/numeric/ublas/matrix_assign.hpp @@ -37,8 +37,9 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_TYPE_CHECK_MIN); #else // GCC 3.1, oops?! + BOOST_USING_STD_MAX(); 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)))), + max BOOST_PREVENT_MACRO_SUBSTITUTION (real_type (max BOOST_PREVENT_MACRO_SUBSTITUTION (real_type (norm_inf (e1)), real_type (norm_inf (e2)))), real_type (BOOST_UBLAS_TYPE_CHECK_MIN)); #endif } @@ -509,6 +510,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 void matrix_assign (F1, M &m, const matrix_expression &e, F2, packed_proxy_tag, row_major_tag) { + BOOST_USING_STD_MIN(); BOOST_UBLAS_CHECK (m.size1 () == e ().size1 (), bad_size ()); BOOST_UBLAS_CHECK (m.size2 () == e ().size2 (), bad_size ()); typedef F1 functor1_type; @@ -535,13 +537,13 @@ namespace boost { namespace numeric { namespace ublas { if (it1_size > 0 && it1e_size > 0) diff1 = it1.index1 () - it1e.index1 (); if (diff1 != 0) { - difference_type size1 = std_min (diff1, it1e_size); + difference_type size1 = min BOOST_PREVENT_MACRO_SUBSTITUTION (diff1, it1e_size); if (size1 > 0) { it1e += size1; it1e_size -= size1; diff1 -= size1; } - size1 = std_min (- diff1, it1_size); + size1 = min BOOST_PREVENT_MACRO_SUBSTITUTION (- diff1, it1_size); if (size1 > 0) { it1_size -= size1; if (boost::is_same::value) { @@ -564,7 +566,7 @@ namespace boost { namespace numeric { namespace ublas { diff1 += size1; } } - difference_type size1 (std_min (it1_size, it1e_size)); + difference_type size1 (min BOOST_PREVENT_MACRO_SUBSTITUTION (it1_size, it1e_size)); it1_size -= size1; it1e_size -= size1; while (-- size1 >= 0) { @@ -584,13 +586,13 @@ namespace boost { namespace numeric { namespace ublas { difference_type diff2 (0); if (it2_size > 0 && it2e_size > 0) { diff2 = it2.index2 () - it2e.index2 (); - difference_type size2 = std_min (diff2, it2e_size); + difference_type size2 = min BOOST_PREVENT_MACRO_SUBSTITUTION (diff2, it2e_size); if (size2 > 0) { it2e += size2; it2e_size -= size2; diff2 -= size2; } - size2 = std_min (- diff2, it2_size); + size2 = min BOOST_PREVENT_MACRO_SUBSTITUTION (- diff2, it2_size); if (size2 > 0) { it2_size -= size2; if (boost::is_same::value) { @@ -602,7 +604,7 @@ namespace boost { namespace numeric { namespace ublas { diff2 += size2; } } - difference_type size2 (std_min (it2_size, it2e_size)); + difference_type size2 (min BOOST_PREVENT_MACRO_SUBSTITUTION (it2_size, it2e_size)); it2_size -= size2; it2e_size -= size2; while (-- size2 >= 0) @@ -644,6 +646,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 void matrix_assign (F1, M &m, const matrix_expression &e, F2, packed_proxy_tag, column_major_tag) { + BOOST_USING_STD_MIN(); BOOST_UBLAS_CHECK (m.size2 () == e ().size2 (), bad_size ()); BOOST_UBLAS_CHECK (m.size1 () == e ().size1 (), bad_size ()); typedef F1 functor1_type; @@ -670,13 +673,13 @@ namespace boost { namespace numeric { namespace ublas { if (it2_size > 0 && it2e_size > 0) diff2 = it2.index2 () - it2e.index2 (); if (diff2 != 0) { - difference_type size2 = std_min (diff2, it2e_size); + difference_type size2 = min BOOST_PREVENT_MACRO_SUBSTITUTION (diff2, it2e_size); if (size2 > 0) { it2e += size2; it2e_size -= size2; diff2 -= size2; } - size2 = std_min (- diff2, it2_size); + size2 = min BOOST_PREVENT_MACRO_SUBSTITUTION (- diff2, it2_size); if (size2 > 0) { it2_size -= size2; if (boost::is_same::value) { @@ -699,7 +702,7 @@ namespace boost { namespace numeric { namespace ublas { diff2 += size2; } } - difference_type size2 (std_min (it2_size, it2e_size)); + difference_type size2 (min BOOST_PREVENT_MACRO_SUBSTITUTION (it2_size, it2e_size)); it2_size -= size2; it2e_size -= size2; while (-- size2 >= 0) { @@ -719,13 +722,13 @@ namespace boost { namespace numeric { namespace ublas { difference_type diff1 (0); if (it1_size > 0 && it1e_size > 0) { diff1 = it1.index1 () - it1e.index1 (); - difference_type size1 = std_min (diff1, it1e_size); + difference_type size1 = min BOOST_PREVENT_MACRO_SUBSTITUTION (diff1, it1e_size); if (size1 > 0) { it1e += size1; it1e_size -= size1; diff1 -= size1; } - size1 = std_min (- diff1, it1_size); + size1 = min BOOST_PREVENT_MACRO_SUBSTITUTION (- diff1, it1_size); if (size1 > 0) { it1_size -= size1; if (boost::is_same::value) { @@ -737,7 +740,7 @@ namespace boost { namespace numeric { namespace ublas { diff1 += size1; } } - difference_type size1 (std_min (it1_size, it1e_size)); + difference_type size1 (min BOOST_PREVENT_MACRO_SUBSTITUTION (it1_size, it1e_size)); it1_size -= size1; it1e_size -= size1; while (-- size1 >= 0) diff --git a/include/boost/numeric/ublas/matrix_expression.hpp b/include/boost/numeric/ublas/matrix_expression.hpp index 8e5d2b5f..d768ea1f 100644 --- a/include/boost/numeric/ublas/matrix_expression.hpp +++ b/include/boost/numeric/ublas/matrix_expression.hpp @@ -2115,7 +2115,8 @@ namespace boost { namespace numeric { namespace ublas { 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 (), + BOOST_USING_STD_MIN(); + i = min BOOST_PREVENT_MACRO_SUBSTITUTION (it11 != it11_end ? it11.index1 () : size1 (), it21 != it21_end ? it21.index1 () : size1 ()); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator1 (*this, i, j); @@ -2131,7 +2132,8 @@ namespace boost { namespace numeric { namespace ublas { 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 (), + BOOST_USING_STD_MIN(); + j = min BOOST_PREVENT_MACRO_SUBSTITUTION (it12 != it12_end ? it12.index2 () : size2 (), it22 != it22_end ? it22.index2 () : size2 ()); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator2 (*this, i, j); @@ -2248,7 +2250,8 @@ namespace boost { namespace numeric { namespace ublas { if (it2_ != it2_end_) { index2 = it2_.index1 (); } - i_ = std_min (index1, index2); + BOOST_USING_STD_MIN(); + i_ = min BOOST_PREVENT_MACRO_SUBSTITUTION (index1, index2); } BOOST_UBLAS_INLINE void decrement (sparse_bidirectional_iterator_tag) { @@ -2266,7 +2269,8 @@ namespace boost { namespace numeric { namespace ublas { if (it2_ != it2_end_) index2 = it2_.index1 (); } - i_ = std_max (index1, index2); + BOOST_USING_STD_MAX(); + i_ = max BOOST_PREVENT_MACRO_SUBSTITUTION (index1, index2); } BOOST_UBLAS_INLINE value_type dereference (sparse_bidirectional_iterator_tag) const { @@ -2514,7 +2518,8 @@ namespace boost { namespace numeric { namespace ublas { if (it2_ != it2_end_) index2 = it2_.index2 (); } - j_ = std_min (index1, index2); + BOOST_USING_STD_MIN(); + j_ = min BOOST_PREVENT_MACRO_SUBSTITUTION (index1, index2); } BOOST_UBLAS_INLINE void decrement (sparse_bidirectional_iterator_tag) { @@ -2532,7 +2537,8 @@ namespace boost { namespace numeric { namespace ublas { if (it2_ != it2_end_) index2 = it2_.index2 (); } - j_ = std_max (index1, index2); + BOOST_USING_STD_MAX(); + j_ = max BOOST_PREVENT_MACRO_SUBSTITUTION (index1, index2); } BOOST_UBLAS_INLINE value_type dereference (sparse_bidirectional_iterator_tag) const { diff --git a/include/boost/numeric/ublas/matrix_proxy.hpp b/include/boost/numeric/ublas/matrix_proxy.hpp index 78c90611..85ca5972 100644 --- a/include/boost/numeric/ublas/matrix_proxy.hpp +++ b/include/boost/numeric/ublas/matrix_proxy.hpp @@ -1881,7 +1881,8 @@ namespace boost { namespace numeric { namespace ublas { // One of the slices may be stationary. // Thanks to Michael Stevens for this extension. // return BOOST_UBLAS_SAME (it1_ - it.it1_, it2_ - it.it2_); - return std_max (it1_ - it.it1_, it2_ - it.it2_); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (it1_ - it.it1_, it2_ - it.it2_); } // Dereference @@ -1896,7 +1897,8 @@ namespace boost { namespace numeric { namespace ublas { // One of the slices may be stationary. // Thanks to Michael Stevens for this extension. // return BOOST_UBLAS_SAME (it1_.index (), it2_.index ()); - return std_max (it1_.index (), it2_.index ()); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (it1_.index (), it2_.index ()); } // Assignment @@ -1994,7 +1996,8 @@ namespace boost { namespace numeric { namespace ublas { // One of the slices may be stationary. // Thanks to Michael Stevens for this extension. // return BOOST_UBLAS_SAME (it1_ - it.it1_, it2_ - it.it2_); - return std_max (it1_ - it.it1_, it2_ - it.it2_); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (it1_ - it.it1_, it2_ - it.it2_); } // Dereference @@ -2009,7 +2012,8 @@ namespace boost { namespace numeric { namespace ublas { // One of the slices may be stationary. // Thanks to Michael Stevens for this extension. // return BOOST_UBLAS_SAME (it1_.index (), it2_.index ()); - return std_max (it1_.index (), it2_.index ()); + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (it1_.index (), it2_.index ()); } // Assignment diff --git a/include/boost/numeric/ublas/matrix_sparse.hpp b/include/boost/numeric/ublas/matrix_sparse.hpp index 547f3018..c294885b 100644 --- a/include/boost/numeric/ublas/matrix_sparse.hpp +++ b/include/boost/numeric/ublas/matrix_sparse.hpp @@ -379,12 +379,14 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE void resize (size_type size1, size_type size2, size_type non_zeros = 0) { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); size1_ = size1; size2_ = size2; - non_zeros_ = std_max (non_zeros, std_min (size1_, size2_)); + non_zeros_ = max BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros, min BOOST_PREVENT_MACRO_SUBSTITUTION (size1_, size2_)); // Guarding against overflow. // Thanks to Alexei Novakov for the hint. - // non_zeros_ = std_min (non_zeros_, size1_ * size2_); + // non_zeros_ = min BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros_, size1_ * size2_); if (size1_ > 0 && non_zeros_ / size1_ >= size2_) non_zeros_ = size1_ * size2_; detail::reserve (data (), non_zeros_); @@ -394,10 +396,12 @@ namespace boost { namespace numeric { namespace ublas { // Reserving BOOST_UBLAS_INLINE void reserve (size_type non_zeros = 0) { - non_zeros_ = std_max (non_zeros, std_min (size1_, size2_)); + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); + non_zeros_ = max BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros, min BOOST_PREVENT_MACRO_SUBSTITUTION (size1_, size2_)); // Guarding against overflow. // Thanks to Alexei Novakov for the hint. - // non_zeros_ = std_min (non_zeros_, size1_ * size2_); + // non_zeros_ = min BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros_, size1_ * size2_); if (size1_ > 0 && non_zeros_ / size1_ >= size2_) non_zeros_ = size1_ * size2_; detail::reserve (data (), non_zeros_); @@ -2697,12 +2701,14 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE void resize (size_type size1, size_type size2, size_type non_zeros = 0, bool preserve = true) { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); size1_ = size1; size2_ = size2; - non_zeros_ = std_max (non_zeros, std_min (size1_, size2_)); + non_zeros_ = max BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros, min BOOST_PREVENT_MACRO_SUBSTITUTION (size1_, size2_)); // Guarding against overflow. // Thanks to Alexei Novakov for the hint. - // non_zeros_ = std_min (non_zeros_, size1_ * size2_); + // non_zeros_ = min BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros_, size1_ * size2_); if (size1_ > 0 && non_zeros_ / size1_ >= size2_) non_zeros_ = size1_ * size2_; filled1_ = 1; @@ -2716,10 +2722,12 @@ namespace boost { namespace numeric { namespace ublas { // Reserving BOOST_UBLAS_INLINE void reserve (size_type non_zeros = 0, bool preserve = true) { - non_zeros_ = std_max (non_zeros, std_min (size1_, size2_)); + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); + non_zeros_ = max BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros, min BOOST_PREVENT_MACRO_SUBSTITUTION (size1_, size2_)); // Guarding against overflow. // Thanks to Alexei Novakov for the hint. - // non_zeros_ = std_min (non_zeros_, size1_ * size2_); + // non_zeros_ = min BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros_, size1_ * size2_); if (size1_ > 0 && non_zeros_ / size1_ >= size2_) non_zeros_ = size1_ * size2_; detail::resize (index2_data (), non_zeros_, preserve); @@ -3031,9 +3039,10 @@ namespace boost { namespace numeric { namespace ublas { // BOOST_UBLAS_INLINE const_iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) const { for (;;) { + BOOST_USING_STD_MIN(); size_type address1 (functor_type::address1 (i, size1_, j, size2_)); size_type address2 (functor_type::address2 (i, size1_, j, size2_)); - vector_const_iterator_type itv (index1_data ().begin () + std_min (filled1_ - 1, address1)); + vector_const_iterator_type itv (index1_data ().begin () + min BOOST_PREVENT_MACRO_SUBSTITUTION (filled1_ - 1, address1)); if (filled1_ <= address1 + 1) return const_iterator1 (*this, rank, i, j, itv, index2_data ().begin () + filled2_); @@ -3068,9 +3077,10 @@ namespace boost { namespace numeric { namespace ublas { // BOOST_UBLAS_INLINE iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) { for (;;) { + BOOST_USING_STD_MIN(); size_type address1 (functor_type::address1 (i, size1_, j, size2_)); size_type address2 (functor_type::address2 (i, size1_, j, size2_)); - vector_iterator_type itv (index1_data ().begin () + std_min (filled1_ - 1, address1)); + vector_iterator_type itv (index1_data ().begin () + min BOOST_PREVENT_MACRO_SUBSTITUTION (filled1_ - 1, address1)); if (filled1_ <= address1 + 1) return iterator1 (*this, rank, i, j, itv, index2_data ().begin () + filled2_); @@ -3105,9 +3115,10 @@ namespace boost { namespace numeric { namespace ublas { // BOOST_UBLAS_INLINE const_iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) const { for (;;) { + BOOST_USING_STD_MIN(); size_type address1 (functor_type::address1 (i, size1_, j, size2_)); size_type address2 (functor_type::address2 (i, size1_, j, size2_)); - vector_const_iterator_type itv (index1_data ().begin () + std_min (filled1_ - 1, address1)); + vector_const_iterator_type itv (index1_data ().begin () + min BOOST_PREVENT_MACRO_SUBSTITUTION (filled1_ - 1, address1)); if (filled1_ <= address1 + 1) return const_iterator2 (*this, rank, i, j, itv, index2_data ().begin () + filled2_); @@ -3142,9 +3153,10 @@ namespace boost { namespace numeric { namespace ublas { // BOOST_UBLAS_INLINE iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) { for (;;) { + BOOST_USING_STD_MIN(); size_type address1 (functor_type::address1 (i, size1_, j, size2_)); size_type address2 (functor_type::address2 (i, size1_, j, size2_)); - vector_iterator_type itv (index1_data ().begin () + std_min (filled1_ - 1, address1)); + vector_iterator_type itv (index1_data ().begin () + min BOOST_PREVENT_MACRO_SUBSTITUTION (filled1_ - 1, address1)); if (filled1_ <= address1 + 1) return iterator2 (*this, rank, i, j, itv, index2_data ().begin () + filled2_); @@ -4005,12 +4017,14 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE void resize (size_type size1, size_type size2, size_type non_zeros = 0, bool preserve = true) { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); size1_ = size1; size2_ = size2; - non_zeros_ = std_max (non_zeros, std_min (size1_, size2_)); + non_zeros_ = max BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros, min BOOST_PREVENT_MACRO_SUBSTITUTION (size1_, size2_)); // Guarding against overflow. // Thanks to Alexei Novakov for the hint. - // non_zeros_ = std_min (non_zeros_, size1_ * size2_); + // non_zeros_ = min BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros_, size1_ * size2_); // FIX: coordinate_vector may contain duplicate elements. // if (size1_ > 0 && non_zeros_ / size1_ >= size2_) // non_zeros_ = size1_ * size2_; @@ -4023,10 +4037,12 @@ namespace boost { namespace numeric { namespace ublas { // Reserving BOOST_UBLAS_INLINE void reserve (size_type non_zeros = 0, bool preserve = true) { - non_zeros_ = std_max (non_zeros, std_min (size1_, size2_)); + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); + non_zeros_ = max BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros, min BOOST_PREVENT_MACRO_SUBSTITUTION (size1_, size2_)); // Guarding against overflow. // Thanks to Alexei Novakov for the hint. - // non_zeros_ = std_min (non_zeros_, size1_ * size2_); + // non_zeros_ = min BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros_, size1_ * size2_); // FIX: coordinate_vector may contain duplicate elements. // if (size1_ > 0 && non_zeros_ / size1_ >= size2_) // non_zeros_ = size1_ * size2_; diff --git a/include/boost/numeric/ublas/operation_blocked.hpp b/include/boost/numeric/ublas/operation_blocked.hpp index 9acc0007..8efd06a2 100644 --- a/include/boost/numeric/ublas/operation_blocked.hpp +++ b/include/boost/numeric/ublas/operation_blocked.hpp @@ -26,6 +26,7 @@ namespace boost { namespace numeric { namespace ublas { V block_prod (const matrix_expression &e1, const vector_expression &e2) { + BOOST_USING_STD_MIN(); typedef V vector_type; const std::size_t block_size = BS; typedef const E1 expression1_type; @@ -41,7 +42,7 @@ namespace boost { namespace numeric { namespace ublas { size_type i_size = e1 ().size1 (); size_type j_size = BOOST_UBLAS_SAME (e1 ().size2 (), e2 ().size ()); for (size_type i_begin = 0; i_begin < i_size; i_begin += block_size) { - size_type i_end = i_begin + std_min (i_size - i_begin, block_size); + size_type i_end = i_begin + min BOOST_PREVENT_MACRO_SUBSTITUTION (i_size - i_begin, block_size); // FIX: never ignore Martin Weiser's advice ;-( #ifdef BOOST_UBLAS_NO_CACHE vector_range v_range (v, range (i_begin, i_end)); @@ -51,7 +52,7 @@ namespace boost { namespace numeric { namespace ublas { #endif v_range.assign (zero_vector (i_end - i_begin)); for (size_type j_begin = 0; j_begin < j_size; j_begin += block_size) { - size_type j_end = j_begin + std_min (j_size - j_begin, block_size); + size_type j_end = j_begin + min BOOST_PREVENT_MACRO_SUBSTITUTION (j_size - j_begin, block_size); #ifdef BOOST_UBLAS_NO_CACHE const matrix_range e1_range (e1 (), range (i_begin, i_end), range (j_begin, j_end)); const vector_range e2_range (e2 (), range (j_begin, j_end)); @@ -79,6 +80,7 @@ namespace boost { namespace numeric { namespace ublas { V block_prod (const vector_expression &e1, const matrix_expression &e2) { + BOOST_USING_STD_MIN(); typedef V vector_type; const std::size_t block_size = BS; typedef const E1 expression1_type; @@ -94,7 +96,7 @@ namespace boost { namespace numeric { namespace ublas { size_type i_size = BOOST_UBLAS_SAME (e1 ().size (), e2 ().size1 ()); size_type j_size = e2 ().size2 (); for (size_type j_begin = 0; j_begin < j_size; j_begin += block_size) { - size_type j_end = j_begin + std_min (j_size - j_begin, block_size); + size_type j_end = j_begin + min BOOST_PREVENT_MACRO_SUBSTITUTION (j_size - j_begin, block_size); // FIX: never ignore Martin Weiser's advice ;-( #ifdef BOOST_UBLAS_NO_CACHE vector_range v_range (v, range (j_begin, j_end)); @@ -104,7 +106,7 @@ namespace boost { namespace numeric { namespace ublas { #endif v_range.assign (zero_vector (j_end - j_begin)); for (size_type i_begin = 0; i_begin < i_size; i_begin += block_size) { - size_type i_end = i_begin + std_min (i_size - i_begin, block_size); + size_type i_end = i_begin + min BOOST_PREVENT_MACRO_SUBSTITUTION (i_size - i_begin, block_size); #ifdef BOOST_UBLAS_NO_CACHE const vector_range e1_range (e1 (), range (i_begin, i_end)); const matrix_range e2_range (e2 (), range (i_begin, i_end), range (j_begin, j_end)); @@ -132,6 +134,7 @@ namespace boost { namespace numeric { namespace ublas { block_prod (const matrix_expression &e1, const matrix_expression &e2, row_major_tag) { + BOOST_USING_STD_MIN(); typedef M matrix_type; const std::size_t block_size = BS; typedef const E1 expression1_type; @@ -149,9 +152,9 @@ namespace boost { namespace numeric { namespace ublas { size_type j_size = e2 ().size2 (); size_type k_size = BOOST_UBLAS_SAME (e1 ().size2 (), e2 ().size1 ()); for (size_type i_begin = 0; i_begin < i_size; i_begin += block_size) { - size_type i_end = i_begin + std_min (i_size - i_begin, block_size); + size_type i_end = i_begin + min BOOST_PREVENT_MACRO_SUBSTITUTION (i_size - i_begin, block_size); for (size_type j_begin = 0; j_begin < j_size; j_begin += block_size) { - size_type j_end = j_begin + std_min (j_size - j_begin, block_size); + size_type j_end = j_begin + min BOOST_PREVENT_MACRO_SUBSTITUTION (j_size - j_begin, block_size); // FIX: never ignore Martin Weiser's advice ;-( #ifdef BOOST_UBLAS_NO_CACHE matrix_range m_range (m, range (i_begin, i_end), range (j_begin, j_end)); @@ -161,7 +164,7 @@ namespace boost { namespace numeric { namespace ublas { #endif m_range.assign (zero_matrix (i_end - i_begin, j_end - j_begin)); for (size_type k_begin = 0; k_begin < k_size; k_begin += block_size) { - size_type k_end = k_begin + std_min (k_size - k_begin, block_size); + size_type k_end = k_begin + min BOOST_PREVENT_MACRO_SUBSTITUTION (k_size - k_begin, block_size); #ifdef BOOST_UBLAS_NO_CACHE const matrix_range e1_range (e1 (), range (i_begin, i_end), range (k_begin, k_end)); const matrix_range e2_range (e2 (), range (k_begin, k_end), range (j_begin, j_end)); @@ -191,6 +194,7 @@ namespace boost { namespace numeric { namespace ublas { block_prod (const matrix_expression &e1, const matrix_expression &e2, column_major_tag) { + BOOST_USING_STD_MIN(); typedef M matrix_type; const std::size_t block_size = BS; typedef const E1 expression1_type; @@ -208,9 +212,9 @@ namespace boost { namespace numeric { namespace ublas { size_type j_size = e2 ().size2 (); size_type k_size = BOOST_UBLAS_SAME (e1 ().size2 (), e2 ().size1 ()); for (size_type j_begin = 0; j_begin < j_size; j_begin += block_size) { - size_type j_end = j_begin + std_min (j_size - j_begin, block_size); + size_type j_end = j_begin + min BOOST_PREVENT_MACRO_SUBSTITUTION (j_size - j_begin, block_size); for (size_type i_begin = 0; i_begin < i_size; i_begin += block_size) { - size_type i_end = i_begin + std_min (i_size - i_begin, block_size); + size_type i_end = i_begin + min BOOST_PREVENT_MACRO_SUBSTITUTION (i_size - i_begin, block_size); // FIX: never ignore Martin Weiser's advice ;-( #ifdef BOOST_UBLAS_NO_CACHE matrix_range m_range (m, range (i_begin, i_end), range (j_begin, j_end)); @@ -220,7 +224,7 @@ namespace boost { namespace numeric { namespace ublas { #endif m_range.assign (zero_matrix (i_end - i_begin, j_end - j_begin)); for (size_type k_begin = 0; k_begin < k_size; k_begin += block_size) { - size_type k_end = k_begin + std_min (k_size - k_begin, block_size); + size_type k_end = k_begin + min BOOST_PREVENT_MACRO_SUBSTITUTION (k_size - k_begin, block_size); #ifdef BOOST_UBLAS_NO_CACHE const matrix_range e1_range (e1 (), range (i_begin, i_end), range (k_begin, k_end)); const matrix_range e2_range (e2 (), range (k_begin, k_end), range (j_begin, j_end)); diff --git a/include/boost/numeric/ublas/operation_sparse.hpp b/include/boost/numeric/ublas/operation_sparse.hpp index 5aa624df..4df11d85 100644 --- a/include/boost/numeric/ublas/operation_sparse.hpp +++ b/include/boost/numeric/ublas/operation_sparse.hpp @@ -31,6 +31,8 @@ namespace boost { namespace numeric { namespace ublas { const matrix_expression &e2, M &m, const F &f, row_major_tag) { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); typedef M matrix_type; typedef const E1 expression1_type; typedef const E2 expression2_type; @@ -62,8 +64,8 @@ namespace boost { namespace numeric { namespace ublas { while (itr != itr_end) { size_type j (itr.index ()); temporary (j) += *it2 * *itr; - jb = std_min (jb, j); - je = std_max (je, j); + jb = min BOOST_PREVENT_MACRO_SUBSTITUTION (jb, j); + je = max BOOST_PREVENT_MACRO_SUBSTITUTION (je, j); ++ itr; } ++ it2; @@ -94,6 +96,8 @@ namespace boost { namespace numeric { namespace ublas { const matrix_expression &e2, M &m, const F &f, column_major_tag) { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); typedef M matrix_type; typedef const E1 expression1_type; typedef const E2 expression2_type; @@ -125,8 +129,8 @@ namespace boost { namespace numeric { namespace ublas { while (itc != itc_end) { size_type i (itc.index ()); temporary (i) += *it1 * *itc; - ib = std_min (ib, i); - ie = std_max (ie, i); + ib = min BOOST_PREVENT_MACRO_SUBSTITUTION (ib, i); + ie = max BOOST_PREVENT_MACRO_SUBSTITUTION (ie, i); ++ itc; } ++ it1; diff --git a/include/boost/numeric/ublas/storage.hpp b/include/boost/numeric/ublas/storage.hpp index aacd0334..d0028d43 100644 --- a/include/boost/numeric/ublas/storage.hpp +++ b/include/boost/numeric/ublas/storage.hpp @@ -40,7 +40,8 @@ namespace boost { namespace numeric { namespace ublas { // BOOST_UBLAS_INLINE // const T &same_impl (const T &size1, const T &size2) { // BOOST_UBLAS_CHECK (size1 == size2, bad_argument ()); -// return std_min (size1, size2); +// BOOST_USING_STD_MIN(); +// return min BOOST_PREVENT_MACRO_SUBSTITUTION (size1, size2); // } // #define BOOST_UBLAS_SAME(size1, size2) same_impl ((size1), (size2)) template @@ -50,7 +51,8 @@ namespace boost { namespace numeric { namespace ublas { // const T &same_impl_ex (const T &size1, const T &size2, const char *file, int line) { T same_impl_ex (const T &size1, const T &size2, const char *file, int line) { BOOST_UBLAS_CHECK_EX (size1 == size2, file, line, bad_argument ()); - return std_min (size1, size2); + BOOST_USING_STD_MIN(); + return min BOOST_PREVENT_MACRO_SUBSTITUTION (size1, size2); } #define BOOST_UBLAS_SAME(size1, size2) same_impl_ex ((size1), (size2), __FILE__, __LINE__) #else @@ -129,6 +131,7 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE void resize (size_type size, bool preserve = true) { + BOOST_USING_STD_MIN(); if (size != size_) { pointer data = new value_type [size]; // Assuming std compliant allocator as requested during review. @@ -137,8 +140,8 @@ namespace boost { namespace numeric { namespace ublas { // if (! data_) // throw std::bad_alloc (); if (preserve) { - std::copy (data_, data_ + std_min (size, size_), data); - std::fill (data + std_min (size, size_), data + size, value_type ()); + std::copy (data_, data_ + min BOOST_PREVENT_MACRO_SUBSTITUTION (size, size_), data); + std::fill (data + min BOOST_PREVENT_MACRO_SUBSTITUTION (size, size_), data + size, value_type ()); } delete [] data_; size_ = size; @@ -354,12 +357,13 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE void resize (size_type size, bool preserve = true) { + BOOST_USING_STD_MIN(); if (size > N) // Raising exceptions abstracted as requested during review. // throw std::bad_alloc (); bad_size ().raise (); if (preserve) - std::fill (data_ + std_min (size, size_), data_ + size, value_type ()); + std::fill (data_ + min BOOST_PREVENT_MACRO_SUBSTITUTION (size, size_), data_ + size, value_type ()); size_ = size; } @@ -409,7 +413,8 @@ namespace boost { namespace numeric { namespace ublas { // Precondition for container relaxed as requested during review. // BOOST_UBLAS_CHECK (size_ == a.size_, bad_size ()); std::swap (size_, a.size_); - std::swap_ranges (data_, data_ + std_max (size_, a.size_), a.data_); + BOOST_USING_STD_MAX(); + std::swap_ranges (data_, data_ + max BOOST_PREVENT_MACRO_SUBSTITUTION (size_, a.size_), a.data_); } } #ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS @@ -589,7 +594,8 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE void resize (size_type size, bool preserve = true) { - if (size != size_) { + BOOST_USING_STD_MIN(); + if (size != size_) { pointer data = new value_type [size]; // Assuming std compliant allocator as requested during review. // if (! data) @@ -597,8 +603,8 @@ namespace boost { namespace numeric { namespace ublas { // if (! data_) // throw std::bad_alloc (); if (preserve) { - std::copy (data_, data_ + std_min (size, size_), data); - std::fill (data + std_min (size, size_), data + size, value_type ()); + std::copy (data_, data_ + min BOOST_PREVENT_MACRO_SUBSTITUTION (size, size_), data); + std::fill (data + min BOOST_PREVENT_MACRO_SUBSTITUTION (size, size_), data + size, value_type ()); } if (own_) delete [] data_; @@ -609,12 +615,13 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE void resize (size_type size, pointer data, bool preserve = true) { + BOOST_USING_STD_MIN(); // Assuming std compliant allocator as requested during review. // if (! data_) // throw std::bad_alloc (); if (preserve) { - std::copy (data_, data_ + std_min (size, size_), data); - std::fill (data + std_min (size, size_), data + size, value_type ()); + std::copy (data_, data_ + min BOOST_PREVENT_MACRO_SUBSTITUTION (size, size_), data); + std::fill (data + min BOOST_PREVENT_MACRO_SUBSTITUTION (size, size_), data + size, value_type ()); } if (own_) delete [] data_; @@ -855,6 +862,7 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE void resize (size_type size, bool preserve = true) { + BOOST_USING_STD_MIN(); if (size != size_) { shared_array data (new value_type [size]); // Assuming std compliant allocator as requested during review. @@ -863,8 +871,8 @@ namespace boost { namespace numeric { namespace ublas { // if (! data_.get ()) // throw std::bad_alloc (); if (preserve) { - std::copy (data_.get (), data_.get () + std_min (size, size_), data.get ()); - std::fill (data.get () + std_min (size, size_), data.get () + size, value_type ()); + std::copy (data_.get (), data_.get () + min BOOST_PREVENT_MACRO_SUBSTITUTION (size, size_), data.get ()); + std::fill (data.get () + min BOOST_PREVENT_MACRO_SUBSTITUTION (size, size_), data.get () + size, value_type ()); } size_ = size; data_ = data; @@ -872,12 +880,13 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE void resize (size_type size, pointer data, bool preserve = true) { + BOOST_USING_STD_MIN(); // Assuming std compliant allocator as requested during review. // if (! data_.get ()) // throw std::bad_alloc (); if (preserve) { - std::copy (data_.get (), data_.get () + std_min (size, size_), data); - std::fill (data + std_min (size, size_), data + size, value_type ()); + std::copy (data_.get (), data_.get () + min BOOST_PREVENT_MACRO_SUBSTITUTION (size, size_), data); + std::fill (data + min BOOST_PREVENT_MACRO_SUBSTITUTION (size, size_), data + size, value_type ()); } size_ = size; data_ = data; diff --git a/include/boost/numeric/ublas/storage_sparse.hpp b/include/boost/numeric/ublas/storage_sparse.hpp index 5e468bc9..b1252489 100644 --- a/include/boost/numeric/ublas/storage_sparse.hpp +++ b/include/boost/numeric/ublas/storage_sparse.hpp @@ -343,6 +343,7 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE void resize (size_type size) { + BOOST_USING_STD_MIN(); BOOST_UBLAS_CHECK (size_ <= capacity_, internal_logic ()); if (size > capacity_) { pointer data = new value_type [size << 1]; @@ -351,8 +352,8 @@ namespace boost { namespace numeric { namespace ublas { // throw std::bad_alloc (); // if (! data_) // throw std::bad_alloc (); - std::copy (data_, data_ + std_min (size, size_), data); - std::fill (data + std_min (size, size_), data + size, value_type ()); + std::copy (data_, data_ + min BOOST_PREVENT_MACRO_SUBSTITUTION (size, size_), data); + std::fill (data + min BOOST_PREVENT_MACRO_SUBSTITUTION (size, size_), data + size, value_type ()); delete [] data_; capacity_ = size << 1; data_ = data; @@ -753,6 +754,7 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE void resize (size_type size) { + BOOST_USING_STD_MIN(); BOOST_UBLAS_CHECK (size_ <= capacity_, internal_logic ()); if (size > capacity_) { pointer data = new value_type [size << 1]; @@ -761,8 +763,8 @@ namespace boost { namespace numeric { namespace ublas { // throw std::bad_alloc (); // if (! data_) // throw std::bad_alloc (); - std::copy (data_, data_ + std_min (size, size_), data); - std::fill (data + std_min (size, size_), data + size, value_type ()); + std::copy (data_, data_ + min BOOST_PREVENT_MACRO_SUBSTITUTION (size, size_), data); + std::fill (data + min BOOST_PREVENT_MACRO_SUBSTITUTION (size, size_), data + size, value_type ()); delete [] data_; capacity_ = size << 1; data_ = data; diff --git a/include/boost/numeric/ublas/symmetric.hpp b/include/boost/numeric/ublas/symmetric.hpp index 59c19d28..71cebe75 100644 --- a/include/boost/numeric/ublas/symmetric.hpp +++ b/include/boost/numeric/ublas/symmetric.hpp @@ -1379,25 +1379,26 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator1 &operator += (difference_type n) { + BOOST_USING_STD_MIN(); BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ()); if (current_ == 0) { - size_type d = std_min (n, it1_end_ - it1_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_end_ - it1_); it1_ += d; n -= d; if (n > 0 || (end_ == 1 && it1_ == it1_end_)) { BOOST_UBLAS_CHECK (end_ == 1, external_logic ()); - d = std_min (n, it2_end_ - it2_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_end_ - it2_begin_); it2_ = it2_begin_ + d; n -= d; current_ = 1; } } else /* if (current_ == 1) */ { - size_type d = std_min (n, it2_end_ - it2_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_end_ - it2_); it2_ += d; n -= d; if (n > 0 || (end_ == 0 && it2_ == it2_end_)) { BOOST_UBLAS_CHECK (end_ == 0, external_logic ()); - d = std_min (n, it1_end_ - it1_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_end_ - it1_begin_); it1_ = it1_begin_ + d; n -= d; current_ = 0; @@ -1408,25 +1409,26 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator1 &operator -= (difference_type n) { + BOOST_USING_STD_MIN(); BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ()); if (current_ == 0) { - size_type d = std_min (n, it1_ - it1_begin_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_ - it1_begin_); it1_ -= d; n -= d; if (n > 0) { BOOST_UBLAS_CHECK (end_ == 1, external_logic ()); - d = std_min (n, it2_end_ - it2_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_end_ - it2_begin_); it2_ = it2_end_ - d; n -= d; current_ = 1; } } else /* if (current_ == 1) */ { - size_type d = std_min (n, it2_ - it2_begin_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_ - it2_begin_); it2_ -= d; n -= d; if (n > 0) { BOOST_UBLAS_CHECK (end_ == 0, external_logic ()); - d = std_min (n, it1_end_ - it1_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_end_ - it1_begin_); it1_ = it1_end_ - d; n -= d; current_ = 0; @@ -1826,25 +1828,26 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator2 &operator += (difference_type n) { + BOOST_USING_STD_MIN(); BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ()); if (current_ == 0) { - size_type d = std_min (n, it1_end_ - it1_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_end_ - it1_); it1_ += d; n -= d; if (n > 0 || (end_ == 1 && it1_ == it1_end_)) { BOOST_UBLAS_CHECK (end_ == 1, external_logic ()); - d = std_min (n, it2_end_ - it2_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_end_ - it2_begin_); it2_ = it2_begin_ + d; n -= d; current_ = 1; } } else /* if (current_ == 1) */ { - size_type d = std_min (n, it2_end_ - it2_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_end_ - it2_); it2_ += d; n -= d; if (n > 0 || (end_ == 0 && it2_ == it2_end_)) { BOOST_UBLAS_CHECK (end_ == 0, external_logic ()); - d = std_min (n, it1_end_ - it1_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_end_ - it1_begin_); it1_ = it1_begin_ + d; n -= d; current_ = 0; @@ -1855,25 +1858,26 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator2 &operator -= (difference_type n) { + BOOST_USING_STD_MIN(); BOOST_UBLAS_CHECK (current_ == 0 || current_ == 1, internal_logic ()); if (current_ == 0) { - size_type d = std_min (n, it1_ - it1_begin_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_ - it1_begin_); it1_ -= d; n -= d; if (n > 0) { BOOST_UBLAS_CHECK (end_ == 1, external_logic ()); - d = std_min (n, it2_end_ - it2_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_end_ - it2_begin_); it2_ = it2_end_ - d; n -= d; current_ = 1; } } else /* if (current_ == 1) */ { - size_type d = std_min (n, it2_ - it2_begin_); + size_type d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it2_ - it2_begin_); it2_ -= d; n -= d; if (n > 0) { BOOST_UBLAS_CHECK (end_ == 0, external_logic ()); - d = std_min (n, it1_end_ - it1_begin_); + d = min BOOST_PREVENT_MACRO_SUBSTITUTION (n, it1_end_ - it1_begin_); it1_ = it1_end_ - d; n -= d; current_ = 0; diff --git a/include/boost/numeric/ublas/traits.hpp b/include/boost/numeric/ublas/traits.hpp index f5dc0ce0..3927c72c 100644 --- a/include/boost/numeric/ublas/traits.hpp +++ b/include/boost/numeric/ublas/traits.hpp @@ -88,15 +88,17 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE real_type norm_inf (const_reference t) { // Oops, should have known that! - return std_max (type_traits::abs (self_type::real (t)), + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (type_traits::abs (self_type::real (t)), type_traits::abs (self_type::imag (t))); } static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { + BOOST_USING_STD_MAX(); return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * - std_max (std_max (self_type::norm_inf (t1), + max BOOST_PREVENT_MACRO_SUBSTITUTION (max BOOST_PREVENT_MACRO_SUBSTITUTION (self_type::norm_inf (t1), self_type::norm_inf (t2)), BOOST_UBLAS_TYPE_CHECK_MIN); } @@ -172,8 +174,9 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { + BOOST_USING_STD_MAX(); return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * - std_max (std_max (self_type::norm_inf (t1), + max BOOST_PREVENT_MACRO_SUBSTITUTION (max BOOST_PREVENT_MACRO_SUBSTITUTION (self_type::norm_inf (t1), self_type::norm_inf (t2)), BOOST_UBLAS_TYPE_CHECK_MIN); } @@ -252,8 +255,9 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { + BOOST_USING_STD_MAX(); return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * - std_max (std_max (self_type::norm_inf (t1), + max BOOST_PREVENT_MACRO_SUBSTITUTION (max BOOST_PREVENT_MACRO_SUBSTITUTION (self_type::norm_inf (t1), self_type::norm_inf (t2)), BOOST_UBLAS_TYPE_CHECK_MIN); } @@ -329,8 +333,9 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { + BOOST_USING_STD_MAX(); return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * - std_max (std_max (self_type::norm_inf (t1), + max BOOST_PREVENT_MACRO_SUBSTITUTION (max BOOST_PREVENT_MACRO_SUBSTITUTION (self_type::norm_inf (t1), self_type::norm_inf (t2)), BOOST_UBLAS_TYPE_CHECK_MIN); } @@ -395,15 +400,17 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE real_type norm_inf (const_reference t) { // Oops, should have known that! - return std_max (type_traits::abs (self_type::real (t)), + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (type_traits::abs (self_type::real (t)), type_traits::abs (self_type::imag (t))); } static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { + BOOST_USING_STD_MAX(); return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * - std_max (std_max (self_type::norm_inf (t1), + max BOOST_PREVENT_MACRO_SUBSTITUTION (max BOOST_PREVENT_MACRO_SUBSTITUTION (self_type::norm_inf (t1), self_type::norm_inf (t2)), BOOST_UBLAS_TYPE_CHECK_MIN); } @@ -470,15 +477,17 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE real_type norm_inf (const_reference t) { // Oops, should have known that! - return std_max (type_traits::abs (self_type::real (t)), + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (type_traits::abs (self_type::real (t)), type_traits::abs (self_type::imag (t))); } static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { + BOOST_USING_STD_MAX(); return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * - std_max (std_max (self_type::norm_inf (t1), + max BOOST_PREVENT_MACRO_SUBSTITUTION (max BOOST_PREVENT_MACRO_SUBSTITUTION (self_type::norm_inf (t1), self_type::norm_inf (t2)), BOOST_UBLAS_TYPE_CHECK_MIN); } @@ -542,15 +551,17 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE real_type norm_inf (const_reference t) { // Oops, should have known that! - return std_max (type_traits::abs (self_type::real (t)), + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (type_traits::abs (self_type::real (t)), type_traits::abs (self_type::imag (t))); } static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { + BOOST_USING_STD_MAX(); return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * - std_max (std_max (self_type::norm_inf (t1), + max BOOST_PREVENT_MACRO_SUBSTITUTION (max BOOST_PREVENT_MACRO_SUBSTITUTION (self_type::norm_inf (t1), self_type::norm_inf (t2)), BOOST_UBLAS_TYPE_CHECK_MIN); } @@ -616,8 +627,9 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { + BOOST_USING_STD_MAX(); return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * - std_max (std_max (self_type::norm_inf (t1), + max BOOST_PREVENT_MACRO_SUBSTITUTION (max BOOST_PREVENT_MACRO_SUBSTITUTION (self_type::norm_inf (t1), self_type::norm_inf (t2)), BOOST_UBLAS_TYPE_CHECK_MIN); } @@ -684,8 +696,9 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { + BOOST_USING_STD_MAX(); return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * - std_max (std_max (self_type::norm_inf (t1), + max BOOST_PREVENT_MACRO_SUBSTITUTION (max BOOST_PREVENT_MACRO_SUBSTITUTION (self_type::norm_inf (t1), self_type::norm_inf (t2)), BOOST_UBLAS_TYPE_CHECK_MIN); } @@ -749,8 +762,9 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { + BOOST_USING_STD_MAX(); return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * - std_max (std_max (self_type::norm_inf (t1), + max BOOST_PREVENT_MACRO_SUBSTITUTION (max BOOST_PREVENT_MACRO_SUBSTITUTION (self_type::norm_inf (t1), self_type::norm_inf (t2)), BOOST_UBLAS_TYPE_CHECK_MIN); } @@ -816,15 +830,17 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE real_type norm_inf (const_reference t) { // Oops, should have known that! - return std_max (type_traits::abs (self_type::real (t)), + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (type_traits::abs (self_type::real (t)), type_traits::abs (self_type::imag (t))); } static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { + BOOST_USING_STD_MAX(); return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * - std_max (std_max (self_type::norm_inf (t1), + max BOOST_PREVENT_MACRO_SUBSTITUTION (max BOOST_PREVENT_MACRO_SUBSTITUTION (self_type::norm_inf (t1), self_type::norm_inf (t2)), BOOST_UBLAS_TYPE_CHECK_MIN); } @@ -891,15 +907,17 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE real_type norm_inf (const_reference t) { // Oops, should have known that! - return std_max (type_traits::abs (self_type::real (t)), + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (type_traits::abs (self_type::real (t)), type_traits::abs (self_type::imag (t))); } static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { + BOOST_USING_STD_MAX(); return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * - std_max (std_max (self_type::norm_inf (t1), + max BOOST_PREVENT_MACRO_SUBSTITUTION (max BOOST_PREVENT_MACRO_SUBSTITUTION (self_type::norm_inf (t1), self_type::norm_inf (t2)), BOOST_UBLAS_TYPE_CHECK_MIN); } @@ -963,15 +981,17 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE real_type norm_inf (const_reference t) { // Oops, should have known that! - return std_max (type_traits::abs (self_type::real (t)), + BOOST_USING_STD_MAX(); + return max BOOST_PREVENT_MACRO_SUBSTITUTION (type_traits::abs (self_type::real (t)), type_traits::abs (self_type::imag (t))); } static BOOST_UBLAS_INLINE bool equals (const_reference t1, const_reference t2) { + BOOST_USING_STD_MAX(); return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * - std_max (std_max (self_type::norm_inf (t1), + max BOOST_PREVENT_MACRO_SUBSTITUTION (max BOOST_PREVENT_MACRO_SUBSTITUTION (self_type::norm_inf (t1), self_type::norm_inf (t2)), BOOST_UBLAS_TYPE_CHECK_MIN); } diff --git a/include/boost/numeric/ublas/vector.hpp b/include/boost/numeric/ublas/vector.hpp index 0eaa1bf8..36215de0 100644 --- a/include/boost/numeric/ublas/vector.hpp +++ b/include/boost/numeric/ublas/vector.hpp @@ -671,8 +671,10 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE const_iterator find (size_type i) const { - i = std_max (i, index_); - i = std_min (i, index_ + 1); + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); + i = max BOOST_PREVENT_MACRO_SUBSTITUTION (i, index_); + i = min BOOST_PREVENT_MACRO_SUBSTITUTION (i, index_ + 1); return const_iterator (*this, i); } diff --git a/include/boost/numeric/ublas/vector_assign.hpp b/include/boost/numeric/ublas/vector_assign.hpp index 36471f15..c385f692 100644 --- a/include/boost/numeric/ublas/vector_assign.hpp +++ b/include/boost/numeric/ublas/vector_assign.hpp @@ -37,8 +37,9 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_TYPE_CHECK_MIN); #else // GCC 3.1, oops?! + BOOST_USING_STD_MAX(); 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)))), + max BOOST_PREVENT_MACRO_SUBSTITUTION (real_type (max BOOST_PREVENT_MACRO_SUBSTITUTION (real_type (norm_inf (e1)), real_type (norm_inf (e2)))), real_type (BOOST_UBLAS_TYPE_CHECK_MIN)); #endif } @@ -279,6 +280,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 void vector_assign (F, V &v, const vector_expression &e, packed_proxy_tag) { + BOOST_USING_STD_MIN(); BOOST_UBLAS_CHECK (v.size () == e ().size (), bad_size ()); typedef F functor_type; typedef typename V::difference_type difference_type; @@ -300,14 +302,14 @@ namespace boost { namespace numeric { namespace ublas { difference_type it_size (it_end - it); difference_type ite_size (ite_end - ite); if (it_size > 0 && ite_size > 0) { - difference_type size (std_min (difference_type (it.index () - ite.index ()), ite_size)); + difference_type size (min BOOST_PREVENT_MACRO_SUBSTITUTION (difference_type (it.index () - ite.index ()), ite_size)); if (size > 0) { ite += size; ite_size -= size; } } if (it_size > 0 && ite_size > 0) { - difference_type size (std_min (difference_type (ite.index () - it.index ()), it_size)); + difference_type size (min BOOST_PREVENT_MACRO_SUBSTITUTION (difference_type (ite.index () - it.index ()), it_size)); if (size > 0) { it_size -= size; if (boost::is_same::value) { @@ -318,7 +320,7 @@ namespace boost { namespace numeric { namespace ublas { } } } - difference_type size (std_min (it_size, ite_size)); + difference_type size (min BOOST_PREVENT_MACRO_SUBSTITUTION (it_size, ite_size)); it_size -= size; ite_size -= size; while (-- size >= 0) @@ -496,6 +498,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 void vector_swap (F, V &v, vector_expression &e, packed_proxy_tag) { + BOOST_USING_STD_MIN(); typedef F functor_type; typedef typename V::difference_type difference_type; typename V::iterator it (v.begin ()); @@ -505,18 +508,18 @@ namespace boost { namespace numeric { namespace ublas { difference_type it_size (it_end - it); difference_type ite_size (ite_end - ite); if (it_size > 0 && ite_size > 0) { - difference_type size (std_min (difference_type (it.index () - ite.index ()), ite_size)); + difference_type size (min BOOST_PREVENT_MACRO_SUBSTITUTION (difference_type (it.index () - ite.index ()), ite_size)); if (size > 0) { ite += size; ite_size -= size; } } if (it_size > 0 && ite_size > 0) { - difference_type size (std_min (difference_type (ite.index () - it.index ()), it_size)); + difference_type size (min BOOST_PREVENT_MACRO_SUBSTITUTION (difference_type (ite.index () - it.index ()), it_size)); if (size > 0) it_size -= size; } - difference_type size (std_min (it_size, ite_size)); + difference_type size (min BOOST_PREVENT_MACRO_SUBSTITUTION (it_size, ite_size)); it_size -= size; ite_size -= size; while (-- size >= 0) diff --git a/include/boost/numeric/ublas/vector_expression.hpp b/include/boost/numeric/ublas/vector_expression.hpp index 3b5028a7..5007693d 100644 --- a/include/boost/numeric/ublas/vector_expression.hpp +++ b/include/boost/numeric/ublas/vector_expression.hpp @@ -860,11 +860,12 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE const_iterator find (size_type i) const { + BOOST_USING_STD_MIN(); 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 (), + i = min BOOST_PREVENT_MACRO_SUBSTITUTION (it1 != it1_end ? it1.index () : size (), it2 != it2_end ? it2.index () : size ()); #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator (*this, i); @@ -975,7 +976,8 @@ namespace boost { namespace numeric { namespace ublas { if (it2_ != it2_end_) index2 = it2_.index (); } - i_ = std_min (index1, index2); + BOOST_USING_STD_MIN(); + i_ = min BOOST_PREVENT_MACRO_SUBSTITUTION (index1, index2); } BOOST_UBLAS_INLINE void decrement (sparse_bidirectional_iterator_tag) { @@ -993,7 +995,8 @@ namespace boost { namespace numeric { namespace ublas { if (it2_ != it2_end_) index2 = it2_.index (); } - i_ = std_max (index1, index2); + BOOST_USING_STD_MAX(); + i_ = max BOOST_PREVENT_MACRO_SUBSTITUTION (index1, index2); } BOOST_UBLAS_INLINE value_type dereference (sparse_bidirectional_iterator_tag) const { diff --git a/include/boost/numeric/ublas/vector_sparse.hpp b/include/boost/numeric/ublas/vector_sparse.hpp index 47844762..76d8e60d 100644 --- a/include/boost/numeric/ublas/vector_sparse.hpp +++ b/include/boost/numeric/ublas/vector_sparse.hpp @@ -371,9 +371,11 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE void resize (size_type size, size_type non_zeros = 0) { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); size_ = size; - non_zeros_ = std_max (non_zeros, size_type (1)); - non_zeros_ = std_min (non_zeros_, size_); + non_zeros_ = max BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros, size_type (1)); + non_zeros_ = min BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros_, size_); detail::reserve (data (), non_zeros_); data ().clear (); } @@ -381,8 +383,10 @@ namespace boost { namespace numeric { namespace ublas { // Reserving BOOST_UBLAS_INLINE void reserve (size_type non_zeros = 0) { - non_zeros_ = std_max (non_zeros, size_type (1)); - non_zeros_ = std_min (non_zeros_, size_); + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); + non_zeros_ = max BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros, size_type (1)); + non_zeros_ = min BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros_, size_); detail::reserve (data (), non_zeros_); } @@ -882,9 +886,11 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE void resize (size_type size, size_type non_zeros = 0, bool preserve = true) { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); size_ = size; - non_zeros_ = std_max (non_zeros, size_type (1)); - non_zeros_ = std_min (non_zeros_, size_); + non_zeros_ = max BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros, size_type (1)); + non_zeros_ = min BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros_, size_); filled_ = 0; detail::resize (index_data (), non_zeros_, preserve); detail::resize (value_data (), non_zeros_, preserve); @@ -893,8 +899,10 @@ namespace boost { namespace numeric { namespace ublas { // Reserving BOOST_UBLAS_INLINE 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_); + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); + non_zeros_ = max BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros, size_type (1)); + non_zeros_ = min BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros_, size_); detail::resize (index_data (), non_zeros_, preserve); detail::resize (value_data (), non_zeros_, preserve); } @@ -1451,10 +1459,12 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE void resize (size_type size, size_type non_zeros = 0, bool preserve = true) { + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); size_ = size; - non_zeros_ = std_max (non_zeros, size_type (1)); + non_zeros_ = max BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros, size_type (1)); // FIX: coordinate_vector may contain duplicate elements. - // non_zeros_ = std_min (non_zeros_, size_); + // non_zeros_ = min BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros_, size_); filled_ = 0; detail::resize (index_data (), non_zeros_, preserve); detail::resize (value_data (), non_zeros_, preserve); @@ -1463,9 +1473,11 @@ namespace boost { namespace numeric { namespace ublas { // Reserving BOOST_UBLAS_INLINE void reserve (size_type non_zeros = 0, bool preserve = true) { - non_zeros_ = std_max (non_zeros, size_type (1)); + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); + non_zeros_ = max BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros, size_type (1)); // FIX: coordinate_vector may contain duplicate elements. - // non_zeros_ = std_min (non_zeros_, size_); + // non_zeros_ = min BOOST_PREVENT_MACRO_SUBSTITUTION (non_zeros_, size_); detail::resize (index_data (), non_zeros_, preserve); detail::resize (value_data (), non_zeros_, preserve); } diff --git a/test4/test4.hpp b/test4/test4.hpp index 1337ef32..e097197d 100644 --- a/test4/test4.hpp +++ b/test4/test4.hpp @@ -17,8 +17,6 @@ #ifndef TEST4_H #define TEST4_H -#include - #define USE_BANDED // #define USE_DIAGONAL @@ -37,10 +35,10 @@ void initialize_matrix (M &m) { int size2 = m.size2 (); for (int i = 0; i < size1; ++ i) #ifdef USE_BANDED - for (int j = boost::std_max (i - 1, 0); j < boost::std_min (i + 2, size2); ++ j) + for (int j = (std::max)(i - 1, 0); j < (std::min)(i + 2, size2); ++ j) #endif #ifdef USE_DIAGONAL - for (int j = boost::std_max (i, 0); j < boost::std_min (i + 1, size2); ++ j) + for (int j = (std::max)(i, 0); j < (std::min)(i + 1, size2); ++ j) #endif m (i, j) = i * size1 + j + 1.f; }