From a01d2a9899c8b522fda5d44e81ed10ed46de861d Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Tue, 13 Jul 2004 15:42:31 +0000 Subject: [PATCH] Patch for norm_1 return type for complex Thanks to Karl! svn path=/trunk/boost/boost/numeric/ublas/; revision=23503 --- include/boost/numeric/ublas/operation.hpp | 50 +++++++++++-------- .../boost/numeric/ublas/operation_blocked.hpp | 20 +++++--- .../boost/numeric/ublas/operation_sparse.hpp | 10 ++-- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/include/boost/numeric/ublas/operation.hpp b/include/boost/numeric/ublas/operation.hpp index 7c64eb26..ced4bced 100644 --- a/include/boost/numeric/ublas/operation.hpp +++ b/include/boost/numeric/ublas/operation.hpp @@ -78,12 +78,13 @@ namespace boost { namespace numeric { namespace ublas { v.assign (zero_vector (e1.size1 ())); #if BOOST_UBLAS_TYPE_CHECK vector cv (v); - value_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2)); indexing_vector_assign (scalar_plus_assign::reference, value_type> (), cv, prod (e1, e2)); #endif axpy_prod (e1, e2, v, orientation_category ()); #if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits::epsilon () * verrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits::epsilon () * verrorbound, internal_logic ()); #endif return v; } @@ -229,12 +230,13 @@ namespace boost { namespace numeric { namespace ublas { v.assign (zero_vector (e1 ().size1 ())); #if BOOST_UBLAS_TYPE_CHECK vector cv (v); - value_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2)); indexing_vector_assign (scalar_plus_assign::reference, value_type> (), cv, prod (e1, e2)); #endif axpy_prod (e1, e2, v, iterator_category ()); #if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits::epsilon () * verrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits::epsilon () * verrorbound, internal_logic ()); #endif return v; } @@ -302,12 +304,13 @@ namespace boost { namespace numeric { namespace ublas { v.assign (zero_vector (e2 ().size2 ())); #if BOOST_UBLAS_TYPE_CHECK vector cv (v); - value_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2)); indexing_vector_assign (scalar_plus_assign::reference, value_type> (), cv, prod (e1, e2)); #endif axpy_prod (e1, e2, v, orientation_category ()); #if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits::epsilon () * verrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits::epsilon () * verrorbound, internal_logic ()); #endif return v; } @@ -453,12 +456,13 @@ namespace boost { namespace numeric { namespace ublas { v.assign (zero_vector (e2 ().size2 ())); #if BOOST_UBLAS_TYPE_CHECK vector cv (v); - value_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2)); indexing_vector_assign (scalar_plus_assign::reference, value_type> (), cv, prod (e1, e2)); #endif axpy_prod (e1, e2, v, iterator_category ()); #if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits::epsilon () * verrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits::epsilon () * verrorbound, internal_logic ()); #endif return v; } @@ -490,7 +494,8 @@ namespace boost { namespace numeric { namespace ublas { #if BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); - value_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, prod (e1, e2), row_major_tag ()); #endif size_type size1 (e1 ().size1 ()); @@ -499,7 +504,7 @@ namespace boost { namespace numeric { namespace ublas { for (size_type j = 0; j < size2; ++ j) row (m, i).plus_assign (e1 () (i, j) * row (e2 (), j)); #if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); #endif return m; } @@ -519,7 +524,8 @@ namespace boost { namespace numeric { namespace ublas { #if BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); - value_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, prod (e1, e2), row_major_tag ()); #endif typename expression1_type::const_iterator1 it1 (e1 ().begin1 ()); @@ -547,7 +553,7 @@ namespace boost { namespace numeric { namespace ublas { ++ it1; } #if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); #endif return m; } @@ -567,7 +573,8 @@ namespace boost { namespace numeric { namespace ublas { #if BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); - value_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, prod (e1, e2), column_major_tag ()); #endif size_type size1 (e2 ().size1 ()); @@ -576,7 +583,7 @@ namespace boost { namespace numeric { namespace ublas { for (size_type i = 0; i < size1; ++ i) column (m, j).plus_assign (e2 () (i, j) * column (e1 (), i)); #if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); #endif return m; } @@ -596,7 +603,8 @@ namespace boost { namespace numeric { namespace ublas { #if BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); - value_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, prod (e1, e2), column_major_tag ()); #endif typename expression2_type::const_iterator2 it2 (e2 ().begin2 ()); @@ -624,7 +632,7 @@ namespace boost { namespace numeric { namespace ublas { ++ it2; } #if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); #endif return m; } @@ -726,7 +734,8 @@ namespace boost { namespace numeric { namespace ublas { #if BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); - value_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, prod (e1, e2), row_major_tag ()); #endif size_type size (BOOST_UBLAS_SAME (e1 ().size2 (), e2 ().size1 ())); @@ -736,7 +745,7 @@ namespace boost { namespace numeric { namespace ublas { m.plus_assign (outer_prod (ce1, re2)); } #if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); #endif return m; } @@ -756,7 +765,8 @@ namespace boost { namespace numeric { namespace ublas { #if BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); - value_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, prod (e1, e2), column_major_tag ()); #endif size_type size (BOOST_UBLAS_SAME (e1 ().size2 (), e2 ().size1 ())); @@ -766,7 +776,7 @@ namespace boost { namespace numeric { namespace ublas { m.plus_assign (outer_prod (ce1, re2)); } #if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); #endif return m; } diff --git a/include/boost/numeric/ublas/operation_blocked.hpp b/include/boost/numeric/ublas/operation_blocked.hpp index feca510a..8c0a1074 100644 --- a/include/boost/numeric/ublas/operation_blocked.hpp +++ b/include/boost/numeric/ublas/operation_blocked.hpp @@ -34,7 +34,8 @@ namespace boost { namespace numeric { namespace ublas { V v (e1 ().size1 ()); #if BOOST_UBLAS_TYPE_CHECK vector cv (v.size ()); - value_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2)); indexing_vector_assign (scalar_assign::reference, value_type> (), cv, prod (e1, e2)); #endif size_type i_size = e1 ().size1 (); @@ -68,7 +69,7 @@ namespace boost { namespace numeric { namespace ublas { #endif } #if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (v - cv) <= BOOST_UBLAS_TYPE_CHECK_EPSILON * verrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits::epsilon () * verrorbound, internal_logic ()); #endif return v; } @@ -88,7 +89,8 @@ namespace boost { namespace numeric { namespace ublas { V v (e2 ().size2 ()); #if BOOST_UBLAS_TYPE_CHECK vector cv (v.size ()); - value_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type verrorbound (norm_1 (v) + norm_1 (e1) * norm_1 (e2)); indexing_vector_assign (scalar_assign::reference, value_type> (), cv, prod (e1, e2)); #endif size_type i_size = BOOST_UBLAS_SAME (e1 ().size (), e2 ().size1 ()); @@ -121,7 +123,7 @@ namespace boost { namespace numeric { namespace ublas { #endif } #if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (v - cv) <= BOOST_UBLAS_TYPE_CHECK_EPSILON * verrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (v - cv) <= 2 * std::numeric_limits::epsilon () * verrorbound, internal_logic ()); #endif return v; } @@ -142,7 +144,8 @@ namespace boost { namespace numeric { namespace ublas { M m (e1 ().size1 (), e2 ().size2 ()); #if BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); - value_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, prod (e1, e2), row_major_tag ()); disable_type_check::value = true; #endif @@ -181,7 +184,7 @@ namespace boost { namespace numeric { namespace ublas { } #if BOOST_UBLAS_TYPE_CHECK disable_type_check::value = false; - BOOST_UBLAS_CHECK (norm_1 (m - cm) <= BOOST_UBLAS_TYPE_CHECK_EPSILON * merrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); #endif return m; } @@ -202,7 +205,8 @@ namespace boost { namespace numeric { namespace ublas { M m (e1 ().size1 (), e2 ().size2 ()); #if BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); - value_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, prod (e1, e2), column_major_tag ()); disable_type_check::value = true; #endif @@ -241,7 +245,7 @@ namespace boost { namespace numeric { namespace ublas { } #if BOOST_UBLAS_TYPE_CHECK disable_type_check::value = false; - BOOST_UBLAS_CHECK (norm_1 (m - cm) <= BOOST_UBLAS_TYPE_CHECK_EPSILON * merrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); #endif return m; } diff --git a/include/boost/numeric/ublas/operation_sparse.hpp b/include/boost/numeric/ublas/operation_sparse.hpp index c17c8468..a02a1d07 100644 --- a/include/boost/numeric/ublas/operation_sparse.hpp +++ b/include/boost/numeric/ublas/operation_sparse.hpp @@ -38,7 +38,8 @@ namespace boost { namespace numeric { namespace ublas { vector temporary (e2 ().size2 ()); #if BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); - value_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, prod (e1, e2), row_major_tag ()); #endif typename expression1_type::const_iterator1 it1 (e1 ().begin1 ()); @@ -81,7 +82,7 @@ namespace boost { namespace numeric { namespace ublas { ++ it1; } #if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); #endif return m; } @@ -102,7 +103,8 @@ namespace boost { namespace numeric { namespace ublas { vector temporary (e1 ().size1 ()); #if BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); - value_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); + typedef type_traits::real_type real_type; + real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, prod (e1, e2), column_major_tag ()); #endif typename expression2_type::const_iterator2 it2 (e2 ().begin2 ()); @@ -145,7 +147,7 @@ namespace boost { namespace numeric { namespace ublas { ++ it2; } #if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); + BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); #endif return m; }