Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80588 - in branches/release: boost/numeric/ublas boost/numeric/ublas/operation libs/numeric/ublas libs/numeric/ublas/doc libs/numeric/ublas/test
From: guwi17_at_[hidden]
Date: 2012-09-18 17:07:11


Author: guwi17
Date: 2012-09-18 17:07:07 EDT (Tue, 18 Sep 2012)
New Revision: 80588
URL: http://svn.boost.org/trac/boost/changeset/80588

Log:
merge [61880],[75560],[80267],[80268],[80269],[80270],[80399],[80403],[80483],[80485],[80507],[80563] into release branch

* fix #6511, fix #6514, fix #7296, fix #7297,

* see #4024

Added:
   branches/release/libs/numeric/ublas/test/test_ticket7296.cpp
      - copied unchanged from r80563, /trunk/libs/numeric/ublas/test/test_ticket7296.cpp
   branches/release/libs/numeric/ublas/test/test_triangular.cpp
      - copied unchanged from r75560, /trunk/libs/numeric/ublas/test/test_triangular.cpp
Properties modified:
   branches/release/boost/numeric/ublas/ (props changed)
   branches/release/boost/numeric/ublas/functional.hpp (props changed)
   branches/release/libs/numeric/ublas/ (props changed)
   branches/release/libs/numeric/ublas/doc/ (props changed)
Text files modified:
   branches/release/boost/numeric/ublas/matrix_sparse.hpp | 4
   branches/release/boost/numeric/ublas/operation/num_columns.hpp | 6
   branches/release/boost/numeric/ublas/operation/num_rows.hpp | 8
   branches/release/boost/numeric/ublas/traits.hpp | 12 +
   branches/release/boost/numeric/ublas/triangular.hpp | 377 +++++++++++++++++++------------------
   branches/release/boost/numeric/ublas/vector_expression.hpp | 2
   branches/release/libs/numeric/ublas/test/Jamfile.v2 | 57 +++++
   branches/release/libs/numeric/ublas/test/README | 2
   branches/release/libs/numeric/ublas/test/begin_end.cpp | 8
   branches/release/libs/numeric/ublas/test/test32.cpp | 30 +++
   branches/release/libs/numeric/ublas/test/test33.cpp | 24 ++
   branches/release/libs/numeric/ublas/test/test_assignment.cpp | 4
   branches/release/libs/numeric/ublas/test/utils.hpp | 395 +++++++++++++++++++++++++++++++++++++--
   13 files changed, 702 insertions(+), 227 deletions(-)

Modified: branches/release/boost/numeric/ublas/matrix_sparse.hpp
==============================================================================
--- branches/release/boost/numeric/ublas/matrix_sparse.hpp (original)
+++ branches/release/boost/numeric/ublas/matrix_sparse.hpp 2012-09-18 17:07:07 EDT (Tue, 18 Sep 2012)
@@ -1359,7 +1359,7 @@
 #endif
         typedef const matrix_reference<const self_type> const_closure_type;
         typedef matrix_reference<self_type> closure_type;
- typedef mapped_vector<T, typename A::value_type> vector_temporary_type;
+ typedef mapped_vector<T> vector_temporary_type;
         typedef self_type matrix_temporary_type;
         typedef typename A::value_type::second_type vector_data_value_type;
         typedef sparse_tag storage_category;
@@ -1530,7 +1530,7 @@
         template<class C> // Container assignment without temporary
         BOOST_UBLAS_INLINE
         mapped_vector_of_mapped_vector &operator = (const matrix_container<C> &m) {
- resize (m ().size1 (), m ().size2 ());
+ resize (m ().size1 (), m ().size2 (), false);
             assign (m);
             return *this;
         }

Modified: branches/release/boost/numeric/ublas/operation/num_columns.hpp
==============================================================================
--- branches/release/boost/numeric/ublas/operation/num_columns.hpp (original)
+++ branches/release/boost/numeric/ublas/operation/num_columns.hpp 2012-09-18 17:07:07 EDT (Tue, 18 Sep 2012)
@@ -20,6 +20,8 @@
 
 
 #include <boost/numeric/ublas/detail/config.hpp>
+#include <boost/numeric/ublas/expression_types.hpp>
+#include <boost/numeric/ublas/traits.hpp>
 
 
 namespace boost { namespace numeric { namespace ublas {
@@ -32,9 +34,9 @@
      */
     template <typename MatrixExprT>
     BOOST_UBLAS_INLINE
- typename MatrixExprT::size_type num_columns(MatrixExprT const& m)
+ typename matrix_traits<MatrixExprT>::size_type num_columns(matrix_expression<MatrixExprT> const& me)
     {
- return m.size2();
+ return me().size2();
     }
 
 }}} // Namespace boost::numeric::ublas

Modified: branches/release/boost/numeric/ublas/operation/num_rows.hpp
==============================================================================
--- branches/release/boost/numeric/ublas/operation/num_rows.hpp (original)
+++ branches/release/boost/numeric/ublas/operation/num_rows.hpp 2012-09-18 17:07:07 EDT (Tue, 18 Sep 2012)
@@ -5,7 +5,7 @@
  *
  * \brief The \c num_rows operation.
  *
- * Copyright (c) 2009, Marco Guazzone
+ * Copyright (c) 2009-2012, Marco Guazzone
  *
  * Distributed under the Boost Software License, Version 1.0. (See
  * accompanying file LICENSE_1_0.txt or copy at
@@ -19,6 +19,8 @@
 
 
 #include <boost/numeric/ublas/detail/config.hpp>
+#include <boost/numeric/ublas/expression_types.hpp>
+#include <boost/numeric/ublas/traits.hpp>
 
 
 namespace boost { namespace numeric { namespace ublas {
@@ -31,9 +33,9 @@
      */
     template <typename MatrixExprT>
     BOOST_UBLAS_INLINE
- typename MatrixExprT::size_type num_rows(MatrixExprT const& m)
+ typename matrix_traits<MatrixExprT>::size_type num_rows(matrix_expression<MatrixExprT> const& me)
     {
- return m.size1();
+ return me().size1();
     }
 
 }}} // Namespace boost::numeric::ublas

Modified: branches/release/boost/numeric/ublas/traits.hpp
==============================================================================
--- branches/release/boost/numeric/ublas/traits.hpp (original)
+++ branches/release/boost/numeric/ublas/traits.hpp 2012-09-18 17:07:07 EDT (Tue, 18 Sep 2012)
@@ -41,6 +41,14 @@
     // we'll find either std::abs or else another version via ADL:
     return abs (t);
   }
+ // unsigned types are always non-negative
+ template<> unsigned int boost_numeric_ublas_abs (const unsigned int& t) {
+ return t;
+ }
+ // unsigned types are always non-negative
+ template<> unsigned long boost_numeric_ublas_abs (const unsigned long& t) {
+ return t;
+ }
 }
 
 namespace boost { namespace numeric { namespace ublas {
@@ -594,10 +602,10 @@
         struct has_trivial_destructor : public boost::has_trivial_destructor<T> {};
 
         template<typename FLT>
- struct has_trivial_constructor<std::complex<FLT> > : public boost::true_type {};
+ struct has_trivial_constructor<std::complex<FLT> > : public has_trivial_constructor<FLT> {};
         
         template<typename FLT>
- struct has_trivial_destructor<std::complex<FLT> > : public boost::true_type {};
+ struct has_trivial_destructor<std::complex<FLT> > : public has_trivial_destructor<FLT> {};
 
     }
 

Modified: branches/release/boost/numeric/ublas/triangular.hpp
==============================================================================
--- branches/release/boost/numeric/ublas/triangular.hpp (original)
+++ branches/release/boost/numeric/ublas/triangular.hpp 2012-09-18 17:07:07 EDT (Tue, 18 Sep 2012)
@@ -1936,6 +1936,92 @@
             }
         }
     }
+
+ // Dense (proxy) case
+ template<class E1, class E2>
+ BOOST_UBLAS_INLINE
+ void inplace_solve (const matrix_expression<E1> &e1, vector_expression<E2> &e2,
+ lower_tag, row_major_tag, dense_proxy_tag) {
+ typedef typename E2::size_type size_type;
+ typedef typename E2::difference_type difference_type;
+ typedef typename E2::value_type value_type;
+
+ BOOST_UBLAS_CHECK (e1 ().size1 () == e1 ().size2 (), bad_size ());
+ BOOST_UBLAS_CHECK (e1 ().size2 () == e2 ().size (), bad_size ());
+ size_type size = e2 ().size ();
+ for (size_type n = 0; n < size; ++ n) {
+#ifndef BOOST_UBLAS_SINGULAR_CHECK
+ BOOST_UBLAS_CHECK (e1 () (n, n) != value_type/*zero*/(), singular ());
+#else
+ if (e1 () (n, n) == value_type/*zero*/())
+ singular ().raise ();
+#endif
+ value_type t = e2 () (n) /= e1 () (n, n);
+ if (t != value_type/*zero*/()) {
+ for (size_type m = n + 1; m < size; ++ m)
+ e2 () (m) -= e1 () (m, n) * t;
+ }
+ }
+ }
+ // Packed (proxy) case
+ template<class E1, class E2>
+ BOOST_UBLAS_INLINE
+ void inplace_solve (const matrix_expression<E1> &e1, vector_expression<E2> &e2,
+ lower_tag, row_major_tag, packed_proxy_tag) {
+ typedef typename E2::size_type size_type;
+ typedef typename E2::difference_type difference_type;
+ typedef typename E2::value_type value_type;
+
+ BOOST_UBLAS_CHECK (e1 ().size1 () == e1 ().size2 (), bad_size ());
+ BOOST_UBLAS_CHECK (e1 ().size2 () == e2 ().size (), bad_size ());
+ size_type size = e2 ().size ();
+ for (size_type n = 0; n < size; ++ n) {
+#ifndef BOOST_UBLAS_SINGULAR_CHECK
+ BOOST_UBLAS_CHECK (e1 () (n, n) != value_type/*zero*/(), singular ());
+#else
+ if (e1 () (n, n) == value_type/*zero*/())
+ singular ().raise ();
+#endif
+ value_type t = e2 () (n);
+ typename E1::const_iterator2 it2e1 (e1 ().find2 (1, n, 0));
+ typename E1::const_iterator2 it2e1_end (e1 ().find2 (1, n, n));
+ while (it2e1 != it2e1_end) {
+ t -= *it2e1 * e2 () (it2e1.index2());
+ ++ it2e1;
+ }
+ e2() (n) = t / e1 () (n, n);
+ }
+ }
+ // Sparse (proxy) case
+ template<class E1, class E2>
+ BOOST_UBLAS_INLINE
+ void inplace_solve (const matrix_expression<E1> &e1, vector_expression<E2> &e2,
+ lower_tag, row_major_tag, unknown_storage_tag) {
+ typedef typename E2::size_type size_type;
+ typedef typename E2::difference_type difference_type;
+ typedef typename E2::value_type value_type;
+
+ BOOST_UBLAS_CHECK (e1 ().size1 () == e1 ().size2 (), bad_size ());
+ BOOST_UBLAS_CHECK (e1 ().size2 () == e2 ().size (), bad_size ());
+ size_type size = e2 ().size ();
+ for (size_type n = 0; n < size; ++ n) {
+#ifndef BOOST_UBLAS_SINGULAR_CHECK
+ BOOST_UBLAS_CHECK (e1 () (n, n) != value_type/*zero*/(), singular ());
+#else
+ if (e1 () (n, n) == value_type/*zero*/())
+ singular ().raise ();
+#endif
+ value_type t = e2 () (n);
+ typename E1::const_iterator2 it2e1 (e1 ().find2 (1, n, 0));
+ typename E1::const_iterator2 it2e1_end (e1 ().find2 (1, n, n));
+ while (it2e1 != it2e1_end) {
+ t -= *it2e1 * e2 () (it2e1.index2());
+ ++ it2e1;
+ }
+ e2() (n) = t / e1 () (n, n);
+ }
+ }
+
     // Redirectors :-)
     template<class E1, class E2>
     BOOST_UBLAS_INLINE
@@ -1950,8 +2036,8 @@
     void inplace_solve (const matrix_expression<E1> &e1, vector_expression<E2> &e2,
                         lower_tag, row_major_tag) {
         typedef typename E1::storage_category storage_category;
- inplace_solve (e2, trans (e1),
- upper_tag (), row_major_tag (), storage_category ());
+ inplace_solve (e1, e2,
+ lower_tag (), row_major_tag (), storage_category ());
     }
     // Dispatcher
     template<class E1, class E2>
@@ -2020,9 +2106,9 @@
             if (t != value_type/*zero*/()) {
                 typename E1::const_reverse_iterator1 it1e1 (e1 ().find1 (1, n, n));
                 typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find1 (1, 0, n));
- difference_type m (it1e1_rend - it1e1);
- while (-- m >= 0)
- e2 () (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1;
+ while (it1e1 != it1e1_rend) {
+ e2 () (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1;
+ }
             }
         }
     }
@@ -2049,11 +2135,100 @@
             if (t != value_type/*zero*/()) {
                 typename E1::const_reverse_iterator1 it1e1 (e1 ().find1 (1, n, n));
                 typename E1::const_reverse_iterator1 it1e1_rend (e1 ().find1 (1, 0, n));
- while (it1e1 != it1e1_rend)
- e2 () (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1;
+ while (it1e1 != it1e1_rend) {
+ e2 () (it1e1.index1 ()) -= *it1e1 * t, ++ it1e1;
+ }
+ }
+ }
+ }
+
+ // Dense (proxy) case
+ template<class E1, class E2>
+ BOOST_UBLAS_INLINE
+ void inplace_solve (const matrix_expression<E1> &e1, vector_expression<E2> &e2,
+ upper_tag, row_major_tag, dense_proxy_tag) {
+ typedef typename E2::size_type size_type;
+ typedef typename E2::difference_type difference_type;
+ typedef typename E2::value_type value_type;
+
+ BOOST_UBLAS_CHECK (e1 ().size1 () == e1 ().size2 (), bad_size ());
+ BOOST_UBLAS_CHECK (e1 ().size2 () == e2 ().size (), bad_size ());
+ size_type size = e1 ().size1 ();
+ for (difference_type n = size-1; n >=0; -- n) {
+#ifndef BOOST_UBLAS_SINGULAR_CHECK
+ BOOST_UBLAS_CHECK (e1 () (n, n) != value_type/*zero*/(), singular ());
+#else
+ if (e1 () (n, n) == value_type/*zero*/())
+ singular ().raise ();
+#endif
+ value_type t = e2 () (n);
+ for (difference_type m = n + 1; m < e1 ().size2(); ++ m) {
+ t -= e1 () (n, m) * e2 () (m);
+ }
+ e2() (n) = t / e1 () (n, n);
+ }
+ }
+ // Packed (proxy) case
+ template<class E1, class E2>
+ BOOST_UBLAS_INLINE
+ void inplace_solve (const matrix_expression<E1> &e1, vector_expression<E2> &e2,
+ upper_tag, row_major_tag, packed_proxy_tag) {
+ typedef typename E2::size_type size_type;
+ typedef typename E2::difference_type difference_type;
+ typedef typename E2::value_type value_type;
+
+ BOOST_UBLAS_CHECK (e1 ().size1 () == e1 ().size2 (), bad_size ());
+ BOOST_UBLAS_CHECK (e1 ().size2 () == e2 ().size (), bad_size ());
+ size_type size = e1 ().size1 ();
+ for (difference_type n = size-1; n >=0; -- n) {
+#ifndef BOOST_UBLAS_SINGULAR_CHECK
+ BOOST_UBLAS_CHECK (e1 () (n, n) != value_type/*zero*/(), singular ());
+#else
+ if (e1 () (n, n) == value_type/*zero*/())
+ singular ().raise ();
+#endif
+ value_type t = e2 () (n);
+ typename E1::const_iterator2 it2e1 (e1 ().find2 (1, n, n+1));
+ typename E1::const_iterator2 it2e1_end (e1 ().find2 (1, n, e1 ().size2 ()));
+ while (it2e1 != it2e1_end) {
+ t -= *it2e1 * e2 () (it2e1.index2());
+ ++ it2e1;
+ }
+ e2() (n) = t / e1 () (n, n);
+
+ }
+ }
+ // Sparse (proxy) case
+ template<class E1, class E2>
+ BOOST_UBLAS_INLINE
+ void inplace_solve (const matrix_expression<E1> &e1, vector_expression<E2> &e2,
+ upper_tag, row_major_tag, unknown_storage_tag) {
+ typedef typename E2::size_type size_type;
+ typedef typename E2::difference_type difference_type;
+ typedef typename E2::value_type value_type;
+
+ BOOST_UBLAS_CHECK (e1 ().size1 () == e1 ().size2 (), bad_size ());
+ BOOST_UBLAS_CHECK (e1 ().size2 () == e2 ().size (), bad_size ());
+ size_type size = e1 ().size1 ();
+ for (difference_type n = size-1; n >=0; -- n) {
+#ifndef BOOST_UBLAS_SINGULAR_CHECK
+ BOOST_UBLAS_CHECK (e1 () (n, n) != value_type/*zero*/(), singular ());
+#else
+ if (e1 () (n, n) == value_type/*zero*/())
+ singular ().raise ();
+#endif
+ value_type t = e2 () (n);
+ typename E1::const_iterator2 it2e1 (e1 ().find2 (1, n, n+1));
+ typename E1::const_iterator2 it2e1_end (e1 ().find2 (1, n, e1 ().size2 ()));
+ while (it2e1 != it2e1_end) {
+ t -= *it2e1 * e2 () (it2e1.index2());
+ ++ it2e1;
             }
+ e2() (n) = t / e1 () (n, n);
+
         }
     }
+
     // Redirectors :-)
     template<class E1, class E2>
     BOOST_UBLAS_INLINE
@@ -2068,8 +2243,8 @@
     void inplace_solve (const matrix_expression<E1> &e1, vector_expression<E2> &e2,
                         upper_tag, row_major_tag) {
         typedef typename E1::storage_category storage_category;
- inplace_solve (e2, trans (e1),
- lower_tag (), row_major_tag (), storage_category ());
+ inplace_solve (e1, e2,
+ upper_tag (), row_major_tag (), storage_category ());
     }
     // Dispatcher
     template<class E1, class E2>
@@ -2100,103 +2275,21 @@
         return r;
     }
 
- // Dense (proxy) case
- template<class E1, class E2>
- BOOST_UBLAS_INLINE
- void inplace_solve (vector_expression<E1> &e1, const matrix_expression<E2> &e2,
- lower_tag, row_major_tag, dense_proxy_tag) {
- typedef typename E1::size_type size_type;
- typedef typename E1::difference_type difference_type;
- typedef typename E1::value_type value_type;
-
- BOOST_UBLAS_CHECK (e1 ().size () == e2 ().size1 (), bad_size ());
- BOOST_UBLAS_CHECK (e2 ().size1 () == e2 ().size2 (), bad_size ());
- size_type size = e1 ().size ();
- for (difference_type n = size - 1; n >= 0; -- n) {
-#ifndef BOOST_UBLAS_SINGULAR_CHECK
- BOOST_UBLAS_CHECK (e2 () (n, n) != value_type/*zero*/(), singular ());
-#else
- if (e2 () (n, n) == value_type/*zero*/())
- singular ().raise ();
-#endif
- value_type t = e1 () (n) /= e2 () (n, n);
- if (t != value_type/*zero*/()) {
- for (difference_type m = n - 1; m >= 0; -- m)
- e1 () (m) -= t * e2 () (n, m);
- }
- }
- }
- // Packed (proxy) case
- template<class E1, class E2>
- BOOST_UBLAS_INLINE
- void inplace_solve (vector_expression<E1> &e1, const matrix_expression<E2> &e2,
- lower_tag, row_major_tag, packed_proxy_tag) {
- typedef typename E1::size_type size_type;
- typedef typename E1::difference_type difference_type;
- typedef typename E1::value_type value_type;
-
- BOOST_UBLAS_CHECK (e1 ().size () == e2 ().size1 (), bad_size ());
- BOOST_UBLAS_CHECK (e2 ().size1 () == e2 ().size2 (), bad_size ());
- size_type size = e1 ().size ();
- for (difference_type n = size - 1; n >= 0; -- n) {
-#ifndef BOOST_UBLAS_SINGULAR_CHECK
- BOOST_UBLAS_CHECK (e2 () (n, n) != value_type/*zero*/(), singular ());
-#else
- if (e2 () (n, n) == value_type/*zero*/())
- singular ().raise ();
-#endif
- value_type t = e1 () (n) /= e2 () (n, n);
- if (t != value_type/*zero*/()) {
- typename E2::const_reverse_iterator2 it2e2 (e2 ().find2 (1, n, n));
- typename E2::const_reverse_iterator2 it2e2_rend (e2 ().find2 (1, n, 0));
- difference_type m (it2e2_rend - it2e2);
- while (-- m >= 0)
- e1 () (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2;
- }
- }
- }
- // Sparse (proxy) case
- template<class E1, class E2>
- BOOST_UBLAS_INLINE
- void inplace_solve (vector_expression<E1> &e1, const matrix_expression<E2> &e2,
- lower_tag, row_major_tag, unknown_storage_tag) {
- typedef typename E1::size_type size_type;
- typedef typename E1::difference_type difference_type;
- typedef typename E1::value_type value_type;
-
- BOOST_UBLAS_CHECK (e1 ().size () == e2 ().size1 (), bad_size ());
- BOOST_UBLAS_CHECK (e2 ().size1 () == e2 ().size2 (), bad_size ());
- size_type size = e1 ().size ();
- for (difference_type n = size - 1; n >= 0; -- n) {
-#ifndef BOOST_UBLAS_SINGULAR_CHECK
- BOOST_UBLAS_CHECK (e2 () (n, n) != value_type/*zero*/(), singular ());
-#else
- if (e2 () (n, n) == value_type/*zero*/())
- singular ().raise ();
-#endif
- value_type t = e1 () (n) /= e2 () (n, n);
- if (t != value_type/*zero*/()) {
- typename E2::const_reverse_iterator2 it2e2 (e2 ().find2 (1, n, n));
- typename E2::const_reverse_iterator2 it2e2_rend (e2 ().find2 (1, n, 0));
- while (it2e2 != it2e2_rend)
- e1 () (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2;
- }
- }
- }
+
     // Redirectors :-)
     template<class E1, class E2>
     BOOST_UBLAS_INLINE
     void inplace_solve (vector_expression<E1> &e1, const matrix_expression<E2> &e2,
                         lower_tag, row_major_tag) {
- typedef typename E1::storage_category storage_category;
- inplace_solve (e1, e2,
- lower_tag (), row_major_tag (), storage_category ());
+ typedef typename E2::storage_category storage_category;
+ inplace_solve (trans(e2), e1,
+ upper_tag (), column_major_tag (), storage_category ());
     }
     template<class E1, class E2>
     BOOST_UBLAS_INLINE
     void inplace_solve (vector_expression<E1> &e1, const matrix_expression<E2> &e2,
                         lower_tag, column_major_tag) {
- typedef typename E1::storage_category storage_category;
+ typedef typename E2::storage_category storage_category;
         inplace_solve (trans (e2), e1,
                        upper_tag (), row_major_tag (), storage_category ());
     }
@@ -2218,103 +2311,21 @@
                        unit_lower_tag (), orientation_category ());
     }
 
- // Dense (proxy) case
- template<class E1, class E2>
- BOOST_UBLAS_INLINE
- void inplace_solve (vector_expression<E1> &e1, const matrix_expression<E2> &e2,
- upper_tag, row_major_tag, dense_proxy_tag) {
- typedef typename E1::size_type size_type;
- typedef typename E1::difference_type difference_type;
- typedef typename E1::value_type value_type;
-
- BOOST_UBLAS_CHECK (e1 ().size () == e2 ().size1 (), bad_size ());
- BOOST_UBLAS_CHECK (e2 ().size1 () == e2 ().size2 (), bad_size ());
- size_type size = e1 ().size ();
- for (size_type n = 0; n < size; ++ n) {
-#ifndef BOOST_UBLAS_SINGULAR_CHECK
- BOOST_UBLAS_CHECK (e2 () (n, n) != value_type/*zero*/(), singular ());
-#else
- if (e2 () (n, n) == value_type/*zero*/())
- singular ().raise ();
-#endif
- value_type t = e1 () (n) /= e2 () (n, n);
- if (t != value_type/*zero*/()) {
- for (size_type m = n + 1; m < size; ++ m)
- e1 () (m) -= t * e2 () (n, m);
- }
- }
- }
- // Packed (proxy) case
- template<class E1, class E2>
- BOOST_UBLAS_INLINE
- void inplace_solve (vector_expression<E1> &e1, const matrix_expression<E2> &e2,
- upper_tag, row_major_tag, packed_proxy_tag) {
- typedef typename E1::size_type size_type;
- typedef typename E1::difference_type difference_type;
- typedef typename E1::value_type value_type;
-
- BOOST_UBLAS_CHECK (e1 ().size () == e2 ().size1 (), bad_size ());
- BOOST_UBLAS_CHECK (e2 ().size1 () == e2 ().size2 (), bad_size ());
- size_type size = e1 ().size ();
- for (size_type n = 0; n < size; ++ n) {
-#ifndef BOOST_UBLAS_SINGULAR_CHECK
- BOOST_UBLAS_CHECK (e2 () (n, n) != value_type/*zero*/(), singular ());
-#else
- if (e2 () (n, n) == value_type/*zero*/())
- singular ().raise ();
-#endif
- value_type t = e1 () (n) /= e2 () (n, n);
- if (t != value_type/*zero*/()) {
- typename E2::const_iterator2 it2e2 (e2 ().find2 (1, n, n + 1));
- typename E2::const_iterator2 it2e2_end (e2 ().find2 (1, n, e2 ().size2 ()));
- difference_type m (it2e2_end - it2e2);
- while (-- m >= 0)
- e1 () (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2;
- }
- }
- }
- // Sparse (proxy) case
- template<class E1, class E2>
- BOOST_UBLAS_INLINE
- void inplace_solve (vector_expression<E1> &e1, const matrix_expression<E2> &e2,
- upper_tag, row_major_tag, unknown_storage_tag) {
- typedef typename E1::size_type size_type;
- typedef typename E1::difference_type difference_type;
- typedef typename E1::value_type value_type;
-
- BOOST_UBLAS_CHECK (e1 ().size () == e2 ().size1 (), bad_size ());
- BOOST_UBLAS_CHECK (e2 ().size1 () == e2 ().size2 (), bad_size ());
- size_type size = e1 ().size ();
- for (size_type n = 0; n < size; ++ n) {
-#ifndef BOOST_UBLAS_SINGULAR_CHECK
- BOOST_UBLAS_CHECK (e2 () (n, n) != value_type/*zero*/(), singular ());
-#else
- if (e2 () (n, n) == value_type/*zero*/())
- singular ().raise ();
-#endif
- value_type t = e1 () (n) /= e2 () (n, n);
- if (t != value_type/*zero*/()) {
- typename E2::const_iterator2 it2e2 (e2 ().find2 (1, n, n + 1));
- typename E2::const_iterator2 it2e2_end (e2 ().find2 (1, n, e2 ().size2 ()));
- while (it2e2 != it2e2_end)
- e1 () (it2e2.index2 ()) -= *it2e2 * t, ++ it2e2;
- }
- }
- }
+
     // Redirectors :-)
     template<class E1, class E2>
     BOOST_UBLAS_INLINE
     void inplace_solve (vector_expression<E1> &e1, const matrix_expression<E2> &e2,
                         upper_tag, row_major_tag) {
- typedef typename E1::storage_category storage_category;
- inplace_solve (e1, e2,
- upper_tag (), row_major_tag (), storage_category ());
+ typedef typename E2::storage_category storage_category;
+ inplace_solve (trans(e2), e1,
+ lower_tag (), column_major_tag (), storage_category ());
     }
     template<class E1, class E2>
     BOOST_UBLAS_INLINE
     void inplace_solve (vector_expression<E1> &e1, const matrix_expression<E2> &e2,
                         upper_tag, column_major_tag) {
- typedef typename E1::storage_category storage_category;
+ typedef typename E2::storage_category storage_category;
         inplace_solve (trans (e2), e1,
                        lower_tag (), row_major_tag (), storage_category ());
     }

Modified: branches/release/boost/numeric/ublas/vector_expression.hpp
==============================================================================
--- branches/release/boost/numeric/ublas/vector_expression.hpp (original)
+++ branches/release/boost/numeric/ublas/vector_expression.hpp 2012-09-18 17:07:07 EDT (Tue, 18 Sep 2012)
@@ -1409,7 +1409,9 @@
     // (v / t) [i] = v [i] / t
     template<class E1, class T2>
     BOOST_UBLAS_INLINE
+ typename enable_if< is_convertible<T2, typename E1::value_type >,
     typename vector_binary_scalar2_traits<E1, const T2, scalar_divides<typename E1::value_type, T2> >::result_type
+ >::type
     operator / (const vector_expression<E1> &e1,
                 const T2 &e2) {
         typedef typename vector_binary_scalar2_traits<E1, const T2, scalar_divides<typename E1::value_type, T2> >::expression_type expression_type;

Modified: branches/release/libs/numeric/ublas/test/Jamfile.v2
==============================================================================
--- branches/release/libs/numeric/ublas/test/Jamfile.v2 (original)
+++ branches/release/libs/numeric/ublas/test/Jamfile.v2 2012-09-18 17:07:07 EDT (Tue, 18 Sep 2012)
@@ -1,4 +1,4 @@
-# Copyright (c) 2004 Michael Stevens
+# Copyright (c) 2004-2011 Michael Stevens, David Bellot
 # Use, modification and distribution are subject to the
 # Boost Software License, Version 1.0. (See accompanying file
 # LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -31,12 +31,20 @@
             # USE_RANGE USE_SLICE # Too complex for regression testing
             USE_UNBOUNDED_ARRAY
                         USE_MAP_ARRAY USE_STD_MAP
- USE_MAPPED_VECTOR USE_COMPRESSED_VECTOR USE_COORDINATE_VECTOR
- USE_MAPPED_MATRIX USE_COMPRESSED_MATRIX USE_COORDINATE_MATRIX
+ USE_MAPPED_VECTOR USE_COMPRESSED_VECTOR
+ USE_MAPPED_MATRIX USE_COMPRESSED_MATRIX
                         ;
 # Generalize VofV still failing
 # USE_GENERALIZED_VECTOR_OF_VECTOR
 
+UBLAS_TESTSET_SPARSE_COO = [ modules.peek : UBLAS_TESTSET_SPARSE_COO ] ;
+UBLAS_TESTSET_SPARSE_COO ?=
+ USE_DOUBLE USE_STD_COMPLEX
+ USE_UNBOUNDED_ARRAY
+ USE_COORDINATE_VECTOR
+ USE_COORDINATE_MATRIX
+ ;
+
 
 # Project settings
 project
@@ -69,6 +77,20 @@
             test33.cpp
         : : :
             <define>$(UBLAS_TESTSET_SPARSE)
+ <define>$(UBLAS_TESTSET_SPARSE_COO)
+ ]
+ [ run test3.cpp
+ test31.cpp
+ test32.cpp
+ test33.cpp
+ : : :
+ <define>USE_FLOAT
+ <define>USE_DOUBLE
+ <define>USE_STD_COMPLEX
+ <define>USE_STD_MAP
+ <define>USE_MAPPED_VECTOR_OF_MAPPED_VECTOR
+ : test3_mvov
+ :
       ]
       [ run test4.cpp
             test42.cpp
@@ -132,6 +154,31 @@
       ]
       [ run test_complex_norms.cpp
       ]
- [ run test_assignment.cpp
- ]
+ [ run test_assignment.cpp
+ ]
+ [ run test_triangular.cpp
+ ]
+ [ run test_ticket7296.cpp
+ ]
+ [ run test_inplace_solve.cpp
+ :
+ :
+ : <define>$(UBLAS_TESTSET)
+ : test_inplace_solve_basic
+ :
+ ]
+ [ run test_inplace_solve.cpp
+ :
+ :
+ : <define>$(UBLAS_TESTSET_SPARSE) <define>$(UBLAS_TESTSET_SPARSE_COO)
+ : test_inplace_solve_sparse
+ :
+ ]
+ [ run test_inplace_solve.cpp
+ :
+ :
+ : <define>USE_MAPPED_VECTOR_OF_MAPPED_VECTOR
+ : test_inplace_solve_mvov
+ :
+ ]
     ;

Modified: branches/release/libs/numeric/ublas/test/README
==============================================================================
--- branches/release/libs/numeric/ublas/test/README (original)
+++ branches/release/libs/numeric/ublas/test/README 2012-09-18 17:07:07 EDT (Tue, 18 Sep 2012)
@@ -1,4 +1,4 @@
-Copyright (c) 2000-2004 Joerg Walter, Mathias Koch
+Copyright (c) 2000-2011 Joerg Walter, Mathias Koch, David Bellot
 
 Distributed under the Boost Software License, Version 1.0. (See
 accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/libs/numeric/ublas/test/begin_end.cpp
==============================================================================
--- branches/release/libs/numeric/ublas/test/begin_end.cpp (original)
+++ branches/release/libs/numeric/ublas/test/begin_end.cpp 2012-09-18 17:07:07 EDT (Tue, 18 Sep 2012)
@@ -45,7 +45,7 @@
             ++it
     ) {
         BOOST_UBLAS_DEBUG_TRACE( "*it = " << *it << " ==> " << v(ix) );
- BOOST_UBLAS_TEST_CHECK( std::fabs(*it - v(ix)) <= TOL );
+ BOOST_UBLAS_TEST_CHECK( std::abs(*it - v(ix)) <= TOL );
         ++ix;
     }
 }
@@ -74,7 +74,7 @@
             ++it
     ) {
         BOOST_UBLAS_DEBUG_TRACE( "*it = " << *it << " ==> " << v(ix) );
- BOOST_UBLAS_TEST_CHECK( std::fabs(*it - v(ix)) <= TOL );
+ BOOST_UBLAS_TEST_CHECK( std::abs(*it - v(ix)) <= TOL );
         ++ix;
     }
 }
@@ -112,7 +112,7 @@
                 ++inner_it
         ) {
             BOOST_UBLAS_DEBUG_TRACE( "*it = " << *inner_it << " ==> " << A(row,col) );
- BOOST_UBLAS_TEST_CHECK( std::fabs(*inner_it - A(row,col)) <= TOL );
+ BOOST_UBLAS_TEST_CHECK( std::abs(*inner_it - A(row,col)) <= TOL );
 
             ++col;
         }
@@ -154,7 +154,7 @@
                 ++inner_it
         ) {
             BOOST_UBLAS_DEBUG_TRACE( "*it = " << *inner_it << " ==> " << A(row,col) );
- BOOST_UBLAS_TEST_CHECK( std::fabs(*inner_it - A(row,col)) <= TOL );
+ BOOST_UBLAS_TEST_CHECK( std::abs(*inner_it - A(row,col)) <= TOL );
 
             ++row;
         }

Modified: branches/release/libs/numeric/ublas/test/test32.cpp
==============================================================================
--- branches/release/libs/numeric/ublas/test/test32.cpp (original)
+++ branches/release/libs/numeric/ublas/test/test32.cpp 2012-09-18 17:07:07 EDT (Tue, 18 Sep 2012)
@@ -321,4 +321,34 @@
 #endif
 #endif
 #endif
+
+#ifdef USE_MAPPED_VECTOR_OF_MAPPED_VECTOR
+#ifdef USE_STD_MAP
+#ifdef USE_FLOAT
+ std::cout << "float mapped_vector_of_mapped_vector" << std::endl;
+ test_my_matrix_vector<ublas::mapped_vector<float, std::map<std::size_t, float> >,
+ ublas::mapped_vector_of_mapped_vector<float>, 3 > () ();
+#endif
+
+#ifdef USE_DOUBLE
+ std::cout << "double mapped_vector_of_mapped_vector" << std::endl;
+ test_my_matrix_vector<ublas::mapped_vector<double, std::map<std::size_t, double> >,
+ ublas::mapped_vector_of_mapped_vector<double>, 3 > () ();
+#endif
+
+#ifdef USE_STD_COMPLEX
+#ifdef USE_FLOAT
+ std::cout << "std::complex<float> mapped_vector_of_mapped_vector" << std::endl;
+ test_my_matrix_vector<ublas::mapped_vector<std::complex<float>, std::map<std::size_t, std::complex<float> > >,
+ ublas::mapped_vector_of_mapped_vector<std::complex<float> >, 3 > () ();
+#endif
+
+#ifdef USE_DOUBLE
+ std::cout << "std::complex<double> mapped_vector_of_mapped_vector" << std::endl;
+ test_my_matrix_vector<ublas::mapped_vector<std::complex<double>, std::map<std::size_t, std::complex<double> > >,
+ ublas::mapped_vector_of_mapped_vector<std::complex<double> >, 3 > () ();
+#endif
+#endif
+#endif
+#endif
 }

Modified: branches/release/libs/numeric/ublas/test/test33.cpp
==============================================================================
--- branches/release/libs/numeric/ublas/test/test33.cpp (original)
+++ branches/release/libs/numeric/ublas/test/test33.cpp 2012-09-18 17:07:07 EDT (Tue, 18 Sep 2012)
@@ -344,4 +344,28 @@
 #endif
 #endif
 #endif
+
+#ifdef USE_MAPPED_VECTOR_OF_MAPPED_VECTOR
+#ifdef USE_FLOAT
+ std::cout << "float mapped_vector_of_mapped_vector" << std::endl;
+ test_my_matrix<ublas::mapped_vector_of_mapped_vector<float>, 3 > () ();
+#endif
+
+#ifdef USE_DOUBLE
+ std::cout << "double mapped_vector_of_mapped_vector" << std::endl;
+ test_my_matrix<ublas::mapped_vector_of_mapped_vector<double>, 3 > () ();
+#endif
+
+#ifdef USE_STD_COMPLEX
+#ifdef USE_FLOAT
+ std::cout << "std::complex<float> mapped_vector_of_mapped_vector" << std::endl;
+ test_my_matrix<ublas::mapped_vector_of_mapped_vector<std::complex<float> >, 3 > () ();
+#endif
+
+#ifdef USE_DOUBLE
+ std::cout << "std::complex<double> mapped_vector_of_mapped_vector" << std::endl;
+ test_my_matrix<ublas::mapped_vector_of_mapped_vector<std::complex<double> >, 3 > () ();
+#endif
+#endif
+#endif
 }

Modified: branches/release/libs/numeric/ublas/test/test_assignment.cpp
==============================================================================
--- branches/release/libs/numeric/ublas/test/test_assignment.cpp (original)
+++ branches/release/libs/numeric/ublas/test/test_assignment.cpp 2012-09-18 17:07:07 EDT (Tue, 18 Sep 2012)
@@ -26,7 +26,7 @@
     typename AE::size_type i, j;
     for (i=0; i!= me().size1(); i++) {
         for (j=0; j!= me().size2(); j++) {
- s+=std::fabs(me()(i,j));
+ s+= scalar_traits<typename AE::value_type>::type_abs(me()(i,j));
         }
     }
     return s/me().size1()*me().size2();
@@ -39,7 +39,7 @@
     typename AE::value_type s(0);
     typename AE::size_type i;
     for (i=0; i!= ve().size(); i++) {
- s+=std::fabs(ve()(i));
+ s+=scalar_traits<typename AE::value_type>::type_abs(ve()(i));
         }
     return s/ve().size();
 }

Modified: branches/release/libs/numeric/ublas/test/utils.hpp
==============================================================================
--- branches/release/libs/numeric/ublas/test/utils.hpp (original)
+++ branches/release/libs/numeric/ublas/test/utils.hpp 2012-09-18 17:07:07 EDT (Tue, 18 Sep 2012)
@@ -1,34 +1,383 @@
-/** -*- c++ -*- \file utils.hpp \brief Test utilities. */
-
-#ifndef TEST_UTILS_HPP
-#define TEST_UTILS_HPP
-
-
+/**
+ * \file util.hpp
+ *
+ * \brief Utility macros/functions for testing and debugging purpose.
+ *
+ * Basic usage:
+ * <pre>
+ * BOOST_UBLAS_TEST_DEF( test_case_1 )
+ * {
+ * // do your test stuff
+ * }
+ *
+ * BOOST_UBLAS_TEST_DEF( test_case_2 )
+ * {
+ * // do your test stuff
+ * }
+ *
+ * // ...
+ *
+ * BOOST_UBLAS_TEST_DEF( test_case_n )
+ * {
+ * // do your test stuff
+ * }
+ *
+ * int main()
+ * {
+ * BOOST_UBLAS_TEST_SUITE( "My Test Suite" ); // optional
+ *
+ * BOOST_UBLAS_TEST_BEGIN();
+ * BOOST_UBLAS_TEST_DO( test_case_1 );
+ * BOOST_UBLAS_TEST_DO( test_case_2 );
+ * // ...
+ * BOOST_UBLAS_TEST_DO( test_case_n );
+ * BOOST_UBLAS_TEST_END();
+ * }
+ * </pre>
+ * Inside each <em>test_case_<code>k</code></em> you can use the various
+ * \c BOOST_UBLAS_TEST_CHECK* macros.
+ *
+ * <hr/>
+ *
+ * Copyright (c) 2009-2012, Marco Guazzone
+ *
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * \author Marco Guazzone, marco.guazzone_at_[hidden]
+ */
+
+#ifndef BOOST_NUMERIC_UBLAS_TEST_UTILS_HPP
+#define BOOST_NUMERIC_UBLAS_TEST_UTILS_HPP
+
+
+#include <boost/numeric/ublas/detail/config.hpp>
+#include <boost/numeric/ublas/traits.hpp>
+#include <cmath>
+#include <complex>
+#include <cstddef>
 #include <iostream>
+#include <limits>
+#include <stdexcept>
 
+namespace boost { namespace numeric { namespace ublas { namespace test { namespace detail { namespace /*<unnamed>*/ {
 
-#define EXPAND_(x) x
-
-#define STRINGIFY_(x) #x
-
-#define JOIN_(x,y) x ## y
-
+/// Check if the given complex number is a NaN.
+template <typename T>
+BOOST_UBLAS_INLINE
+bool isnan(::std::complex<T> const& z)
+{
+ // According to IEEE, NaN is different even by itself
+ return (z != z) || ::std::isnan(z.real()) || ::std::isnan(z.imag());
+}
+
+/// Check if two (real) numbers are close each other (wrt a given tolerance).
+template <typename T1, typename T2, typename T3>
+BOOST_UBLAS_INLINE
+bool close_to(T1 x, T2 y, T3 tol)
+{
+ typedef typename promote_traits<typename promote_traits<T1,T2>::promote_type,
+ T3>::promote_type real_type;
+
+ if (::std::isnan(x) || ::std::isnan(y))
+ {
+ // According to IEEE, NaN is different even by itself
+ return false;
+ }
+ return ::std::abs(x-y) <= (::std::max(static_cast<real_type>(::std::abs(x)), static_cast<real_type>(::std::abs(y)))*tol);
+}
+
+/// Check if two complex numbers are close each other (wrt a given tolerance).
+template <typename T1, typename T2, typename T3>
+BOOST_UBLAS_INLINE
+bool close_to(::std::complex<T1> const& x, ::std::complex<T2> const& y, T3 tol)
+{
+ typedef typename promote_traits<typename promote_traits<T1,T2>::promote_type,
+ T3>::promote_type real_type;
+
+ if (isnan(x) || isnan(y))
+ {
+ // According to IEEE, NaN is different even by itself
+ return false;
+ }
+ ::std::complex<real_type> xx(x);
+ ::std::complex<real_type> yy(y);
+ return ::std::abs(xx-yy) <= (::std::max(::std::abs(xx), ::std::abs(yy))*tol);
+}
+
+/// Check if two (real) numbers are close each other (wrt a given tolerance).
+template <typename T1, typename T2, typename T3>
+BOOST_UBLAS_INLINE
+bool rel_close_to(T1 x, T2 y, T3 tol)
+{
+ typedef typename promote_traits<typename promote_traits<T1,T2>::promote_type,
+ T3>::promote_type real_type;
+
+ if (::std::isnan(x) || ::std::isnan(y))
+ {
+ // According to IEEE, NaN is different even by itself
+ return false;
+ }
+ return ::std::abs(x-y)/::std::abs(y) <= tol;
+}
+
+/// Check if two complex numbers are close each other (wrt a given tolerance).
+template <typename T1, typename T2, typename T3>
+BOOST_UBLAS_INLINE
+bool rel_close_to(::std::complex<T1> const& x, ::std::complex<T2> const& y, T3 tol)
+{
+ typedef typename promote_traits<typename promote_traits<T1,T2>::promote_type,
+ T3>::promote_type real_type;
+
+ if (isnan(x) || isnan(y))
+ {
+ // According to IEEE, NaN is different even by itself
+ return false;
+ }
+ ::std::complex<real_type> xx(x);
+ ::std::complex<real_type> yy(y);
+ return ::std::abs(xx-yy)/::std::abs(yy) <= tol;
+}
+
+}}}}}} // Namespace boost::numeric::ublas::test::detail::<unnamed>
+
+
+/// Expand its argument \a x.
+#define BOOST_UBLAS_TEST_EXPAND_(x) x
+
+
+/// Expand its argument \a x inside parenthesis.
+#define BOOST_UBLAS_TEST_EXPANDP_(x) (x)
+
+
+/// Transform its argument \a x into a string.
+#define BOOST_UBLAS_TEST_STRINGIFY_(x) #x
+
+
+/// Concatenate its two \e string arguments \a x and \a y.
+#define BOOST_UBLAS_TEST_JOIN_(x,y) x ## y
+
+
+/// Output the message \a x if in debug-mode; otherwise output nothing.
+/// Note: we don't use macro expansion inside parenthesis to let \a m be an
+/// expression of the form <code>a &lt;&lt; b</code>.
 #ifndef NDEBUG
-# define BOOST_UBLAS_DEBUG_TRACE(x) std::cerr << "[Debug>> " << EXPAND_(x) << std::endl
+# define BOOST_UBLAS_DEBUG_TRACE(x) ::std::cerr << "[Debug>> " << BOOST_UBLAS_TEST_EXPAND_(x) << ::std::endl
 #else
-# define BOOST_UBLAS_DEBUG_TRACE(x) /**/
+# define BOOST_UBLAS_DEBUG_TRACE(x) /**/
 #endif // NDEBUG
 
-#define BOOST_UBLAS_TEST_BEGIN() unsigned int test_fails_(0)
-
-#define BOOST_UBLAS_TEST_DEF(x) void EXPAND_(x)(unsigned int& test_fails_)
 
-#define BOOST_UBLAS_TEST_DO(x) EXPAND_(x)(test_fails_)
+/// Define the name \a m of the entire test suite.
+#define BOOST_UBLAS_TEST_SUITE(m) ::std::cerr << "--- Test Suite: " << BOOST_UBLAS_TEST_EXPAND_(m) << " ---" << ::std::endl;
 
-#define BOOST_UBLAS_TEST_END() if (test_fails_ > 0) { std::cerr << "Number of failed tests: " << test_fails_ << std::endl; return -1; \
-} else { std::cerr << "No failed test" << std::endl; return 0; }
-
-#define BOOST_UBLAS_TEST_CHECK(x) if (!(x)) { std::cerr << "Failed assertion: " << STRINGIFY_(x) << std::endl; ++test_fails_; }
 
+/// Define the beginning of a test suite.
+#define BOOST_UBLAS_TEST_BEGIN() /* [BOOST_UBLAS_TEST_BEGIN] */ \
+ { \
+ /* Begin of Test Suite */ \
+ ::std::size_t test_fails__(0) \
+ /* [/BOOST_UBLAS_TEST_BEGIN] */
+
+
+/// Define a test case \a x inside the current test suite.
+#define BOOST_UBLAS_TEST_DEF(x) static void BOOST_UBLAS_TEST_EXPAND_(x)(::std::size_t& test_fails__)
+
+
+/// Call the test case \a x.
+#define BOOST_UBLAS_TEST_DO(x) /* [BOOST_UBLAS_TEST_DO] */ \
+ try \
+ { \
+ BOOST_UBLAS_TEST_EXPAND_(x)(test_fails__); \
+ } \
+ catch (::std::exception& e) \
+ { \
+ ++test_fails__; \
+ BOOST_UBLAS_TEST_ERROR( e.what() ); \
+ } \
+ catch (...) \
+ { \
+ ++test_fails__; \
+ } \
+ /* [/BOOST_UBLAS_TEST_DO] */
+
+
+/// Define the end of a test suite.
+#define BOOST_UBLAS_TEST_END() /* [BOOST_UBLAS_TEST_END] */ \
+ if (test_fails__ > 0) \
+ { \
+ ::std::cerr << "Number of failed tests: " << test_fails__ << ::std::endl; \
+ } \
+ else \
+ { \
+ ::std::cerr << "No failed test" << ::std::endl; \
+ } \
+ } /* End of test suite */ \
+ /* [/BOOST_UBLAS_TEST_END] */
+
+
+/// Output the message \a m.
+/// Note: we don't use macro expansion inside parenthesis to let \a m be an
+/// expression of the form <code>a &lt;&lt; b</code>.
+#define BOOST_UBLAS_TEST_TRACE(m) ::std::cerr << "[Info>> " << BOOST_UBLAS_TEST_EXPAND_(m) << ::std::endl
+
+
+/// Check the truth of assertion \a x.
+#define BOOST_UBLAS_TEST_CHECK(x) /* [BOOST_UBLAS_TEST_CHECK] */ \
+ if (!BOOST_UBLAS_TEST_EXPANDP_(x)) \
+ { \
+ BOOST_UBLAS_TEST_ERROR( "Failed assertion: " << BOOST_UBLAS_TEST_STRINGIFY_(x) ); \
+ ++test_fails__; \
+ } \
+ /* [/BOOST_UBLAS_TEST_CHECK] */
+
+
+/// Check for the equality of \a x against \a y.
+#define BOOST_UBLAS_TEST_CHECK_EQ(x,y) /* [BOOST_UBLAS_TEST_CHECK_EQUAL] */ \
+ if (!(BOOST_UBLAS_TEST_EXPANDP_(x) == BOOST_UBLAS_TEST_EXPANDP_(y))) \
+ { \
+ BOOST_UBLAS_TEST_ERROR( "Failed assertion: (" << BOOST_UBLAS_TEST_STRINGIFY_(x) << " == " << BOOST_UBLAS_TEST_STRINGIFY_(y) << ")" ); \
+ ++test_fails__; \
+ } \
+ /* [/BOOST_UBLAS_TEST_CHECK_EQUAL] */
+
+
+/// Alias for macro \c BOOST_UBLAS_TEST_CHECK_EQ (for backward compatibility).
+#define BOOST_UBLAS_TEST_CHECK_EQUAL(x,y) BOOST_UBLAS_TEST_CHECK_EQ(x,y)
+
+
+/// Check that \a x and \a y are close with respect to a given precision \a e.
+#define BOOST_UBLAS_TEST_CHECK_CLOSE(x,y,e) /* [BOOST_UBLAS_TEST_CHECK_CLOSE] */ \
+ if (!::boost::numeric::ublas::test::detail::close_to(BOOST_UBLAS_TEST_EXPAND_(x), BOOST_UBLAS_TEST_EXPAND_(y), BOOST_UBLAS_TEST_EXPAND_(e))) \
+ { \
+ BOOST_UBLAS_TEST_ERROR( "Failed assertion: abs(" << BOOST_UBLAS_TEST_STRINGIFY_(x) << "-" << BOOST_UBLAS_TEST_STRINGIFY_(y) << ") <= " << BOOST_UBLAS_TEST_STRINGIFY_(e) << " [with " << BOOST_UBLAS_TEST_STRINGIFY_(x) << " == " << BOOST_UBLAS_TEST_EXPANDP_(x) << ", " << BOOST_UBLAS_TEST_STRINGIFY_(y) << " == " << BOOST_UBLAS_TEST_EXPANDP_(y) << " and " << BOOST_UBLAS_TEST_STRINGIFY_(e) << " == " << BOOST_UBLAS_TEST_EXPANDP_(e) << "]" ); \
+ ++test_fails__; \
+ } \
+ /* [/BOOST_UBLAS_TEST_CHECK_CLOSE] */
+
+
+/// Alias for macro \c BOOST_UBLAS_TEST_CHECK_CLOSE (for backward compatibility),
+#define BOOST_UBLAS_TEST_CHECK_PRECISION(x,y,e) BOOST_UBLAS_TEST_CHECK_CLOSE(x,y,e)
+
+
+/// Check that \a x is close to \a y with respect to a given relative precision \a e.
+#define BOOST_UBLAS_TEST_CHECK_REL_CLOSE(x,y,e) /* [BOOST_UBLAS_TEST_CHECK_REL_CLOSE] */ \
+ if (!::boost::numeric::ublas::test::detail::rel_close_to(BOOST_UBLAS_TEST_EXPAND_(x), BOOST_UBLAS_TEST_EXPAND_(y), BOOST_UBLAS_TEST_EXPAND_(e))) \
+ { \
+ BOOST_UBLAS_TEST_ERROR( "Failed assertion: abs((" << BOOST_UBLAS_TEST_STRINGIFY_(x) << "-" << BOOST_UBLAS_TEST_STRINGIFY_(y) << ")/" << BOOST_UBLAS_TEST_STRINGIFY_(y) << ") <= " << BOOST_UBLAS_TEST_STRINGIFY_(e) << " [with " << BOOST_UBLAS_TEST_STRINGIFY_(x) << " == " << BOOST_UBLAS_TEST_EXPANDP_(x) << ", " << BOOST_UBLAS_TEST_STRINGIFY_(y) << " == " << BOOST_UBLAS_TEST_EXPANDP_(y) << " and " << BOOST_UBLAS_TEST_STRINGIFY_(e) << " == " << BOOST_UBLAS_TEST_EXPANDP_(e) << "]" ); \
+ ++test_fails__; \
+ } \
+ /* [/BOOST_UBLAS_TEST_CHECK_REL_CLOSE] */
+
+
+/// Alias for macro \c BOOST_UBLAS_TEST_CHECK_REL_CLOSE (for backward compatibility),
+#define BOOST_UBLAS_TEST_CHECK_REL_PRECISION(x,y,e) BOOST_UBLAS_TEST_CHECK_REL_CLOSE(x,y,e)
+
+
+/// Check that elements of \a x and \a y are equal.
+#define BOOST_UBLAS_TEST_CHECK_VECTOR_EQ(x,y,n) /* [BOOST_UBLAS_TEST_CHECK_VECTOR_EQ] */ \
+ if (BOOST_UBLAS_TEST_EXPANDP_(n) > 0) \
+ { \
+ ::std::size_t n__ = BOOST_UBLAS_TEST_EXPAND_(n); \
+ for (::std::size_t i__ = n__; i__ > 0; --i__) \
+ { \
+ if (!(BOOST_UBLAS_TEST_EXPANDP_(x)[n__-i__]==BOOST_UBLAS_TEST_EXPANDP_(y)[n__-i__])) \
+ { \
+ BOOST_UBLAS_TEST_ERROR( "Failed assertion: (" << BOOST_UBLAS_TEST_STRINGIFY_(x[i__]) << "==" << BOOST_UBLAS_TEST_STRINGIFY_(y[i__]) << ")" << " [with " << BOOST_UBLAS_TEST_STRINGIFY_(x[i__]) << " == " << BOOST_UBLAS_TEST_EXPANDP_(x)[n__-i__] << ", " << BOOST_UBLAS_TEST_STRINGIFY_(y[i__]) << " == " << BOOST_UBLAS_TEST_EXPANDP_(y)[n__-i__] << ", " << BOOST_UBLAS_TEST_STRINGIFY_(i__) << " == " << i__ << " and " << BOOST_UBLAS_TEST_STRINGIFY_(n) << " == " << n__ << "]" ); \
+ ++test_fails__; \
+ } \
+ } \
+ } \
+ /* [/BOOST_UBLAS_TEST_CHECK_VECTOR_EQ] */
+
+
+/// Check that elements of \a x and \a y are close with respect to a given precision \a e.
+#define BOOST_UBLAS_TEST_CHECK_VECTOR_CLOSE(x,y,n,e) /* [BOOST_UBLAS_TEST_CHECK_VECTOR_CLOSE] */ \
+ if (BOOST_UBLAS_TEST_EXPANDP_(n) > 0) \
+ { \
+ ::std::size_t n__ = BOOST_UBLAS_TEST_EXPAND_(n); \
+ for (::std::size_t i__ = n__; i__ > 0; --i__) \
+ { \
+ if (!::boost::numeric::ublas::test::detail::close_to(BOOST_UBLAS_TEST_EXPANDP_(x)[n__-i__], BOOST_UBLAS_TEST_EXPANDP_(y)[n__-i__], BOOST_UBLAS_TEST_EXPANDP_(e))) \
+ { \
+ BOOST_UBLAS_TEST_ERROR( "Failed assertion: abs((" << BOOST_UBLAS_TEST_STRINGIFY_(x[i__]) << "-" << BOOST_UBLAS_TEST_STRINGIFY_(y[i__]) << ") <= " << BOOST_UBLAS_TEST_STRINGIFY_(e) << " [with " << BOOST_UBLAS_TEST_STRINGIFY_(x[i__]) << " == " << BOOST_UBLAS_TEST_EXPANDP_(x)[n__-i__] << ", " << BOOST_UBLAS_TEST_STRINGIFY_(y[i__]) << " == " << BOOST_UBLAS_TEST_EXPANDP_(y)[n__-i__] << ", " << BOOST_UBLAS_TEST_STRINGIFY_(i__) << " == " << i__ << " and " << BOOST_UBLAS_TEST_STRINGIFY_(n) << " == " << n__ << "]" ); \
+ ++test_fails__; \
+ } \
+ } \
+ } \
+ /* [/BOOST_UBLAS_TEST_CHECK_VECTOR_CLOSE] */
+
+
+/// Check that elements of \a x and \a y are close with respect to a given relative precision \a e.
+#define BOOST_UBLAS_TEST_CHECK_VECTOR_REL_CLOSE(x,y,n,e) /* [BOOST_UBLAS_TEST_CHECK_VECTOR_REL_CLOSE] */ \
+ if (BOOST_UBLAS_TEST_EXPANDP_(n) > 0) \
+ { \
+ ::std::size_t n__ = BOOST_UBLAS_TEST_EXPAND_(n); \
+ for (::std::size_t i__ = n__; i__ > 0; --i__) \
+ { \
+ if (!::boost::numeric::ublas::test::detail::rel_close_to(BOOST_UBLAS_TEST_EXPANDP_(x)[n__-i__], BOOST_UBLAS_TEST_EXPANDP_(y)[n__-i__], BOOST_UBLAS_TEST_EXPANDP_(e))) \
+ { \
+ BOOST_UBLAS_TEST_ERROR( "Failed assertion: abs((" << BOOST_UBLAS_TEST_STRINGIFY_(x[i__]) << "-" << BOOST_UBLAS_TEST_STRINGIFY_(y[i__]) << ") <= " << BOOST_UBLAS_TEST_STRINGIFY_(e) << " [with " << BOOST_UBLAS_TEST_STRINGIFY_(x[i__]) << " == " << BOOST_UBLAS_TEST_EXPANDP_(x)[n__-i__] << ", " << BOOST_UBLAS_TEST_STRINGIFY_(y[i__]) << " == " << BOOST_UBLAS_TEST_EXPANDP_(y)[n__-i__] << ", " << BOOST_UBLAS_TEST_STRINGIFY_(i__) << " == " << i__ << " and " << BOOST_UBLAS_TEST_STRINGIFY_(n) << " == " << n__ << "]" ); \
+ ++test_fails__; \
+ } \
+ } \
+ } \
+ /* [/BOOST_UBLAS_TEST_CHECK_VECTOR_REL_CLOSE] */
+
+
+/// Check that elements of matrices \a x and \a y are equal.
+#define BOOST_UBLAS_TEST_CHECK_MATRIX_EQ(x,y,nr,nc) /* [BOOST_UBLAS_TEST_CHECK_MATRIX_EQ] */ \
+ for (::std::size_t i__ = 0; i__ < BOOST_UBLAS_TEST_EXPANDP_(nr); ++i__) \
+ { \
+ for (::std::size_t j__ = 0; j__ < BOOST_UBLAS_TEST_EXPANDP_(nc); ++j__) \
+ { \
+ if (!(BOOST_UBLAS_TEST_EXPANDP_(x)(i__,j__)==BOOST_UBLAS_TEST_EXPANDP_(y)(i__,j__))) \
+ { \
+ BOOST_UBLAS_TEST_ERROR( "Failed assertion: (" << BOOST_UBLAS_TEST_STRINGIFY_(x(i__,j__)) << " == " << BOOST_UBLAS_TEST_STRINGIFY_(y(i__,j__)) << ") [with " << BOOST_UBLAS_TEST_STRINGIFY_(x(i__,j__)) << " == " << BOOST_UBLAS_TEST_EXPANDP_(x)(i__,j__) << ", " << BOOST_UBLAS_TEST_STRINGIFY_(y(i__,j__)) << " == " << BOOST_UBLAS_TEST_EXPANDP_(y)(i__,j__) << ", " << BOOST_UBLAS_TEST_STRINGIFY_(i__) << " == " << i__ << ", " << BOOST_UBLAS_TEST_STRINGIFY_(j__) << " == " << BOOST_UBLAS_TEST_EXPANDP_(j__) << ", " << BOOST_UBLAS_TEST_STRINGIFY_(nr) << " == " << BOOST_UBLAS_TEST_EXPANDP_(nr) << " and " << BOOST_UBLAS_TEST_STRINGIFY_(nc) << " == " << BOOST_UBLAS_TEST_EXPANDP_(nc) << "]" ); \
+ ++test_fails__; \
+ } \
+ } \
+ } \
+ /* [/BOOST_UBLAS_TEST_CHECK_MATRIX_EQ] */
+
+
+/// Check that elements of matrices \a x and \a y are close with respect to a given precision \a e.
+#define BOOST_UBLAS_TEST_CHECK_MATRIX_CLOSE(x,y,nr,nc,e) /* [BOOST_UBLAS_TEST_CHECK_MATRIX_CLOSE] */ \
+ for (::std::size_t i__ = 0; i__ < BOOST_UBLAS_TEST_EXPANDP_(nr); ++i__) \
+ { \
+ for (::std::size_t j__ = 0; j__ < BOOST_UBLAS_TEST_EXPANDP_(nc); ++j__) \
+ { \
+ if (!::boost::numeric::ublas::test::detail::close_to(BOOST_UBLAS_TEST_EXPANDP_(x)(i__,j__), BOOST_UBLAS_TEST_EXPANDP_(y)(i__,j__), BOOST_UBLAS_TEST_EXPANDP_(e))) \
+ { \
+ BOOST_UBLAS_TEST_ERROR( "Failed assertion: abs((" << BOOST_UBLAS_TEST_STRINGIFY_(x(i__,j__)) << "-" << BOOST_UBLAS_TEST_STRINGIFY_(y(i__,j__)) << ") <= " << BOOST_UBLAS_TEST_STRINGIFY_(e) << " [with " << BOOST_UBLAS_TEST_STRINGIFY_(x(i__,j__)) << " == " << BOOST_UBLAS_TEST_EXPANDP_(x)(i__,j__) << ", " << BOOST_UBLAS_TEST_STRINGIFY_(y(i__,j__)) << " == " << BOOST_UBLAS_TEST_EXPANDP_(y)(i__,j__) << ", " << BOOST_UBLAS_TEST_STRINGIFY_(i__) << " == " << i__ << ", " << BOOST_UBLAS_TEST_STRINGIFY_(j__) << " == " << BOOST_UBLAS_TEST_EXPANDP_(j__) << ", " << BOOST_UBLAS_TEST_STRINGIFY_(nr) << " == " << BOOST_UBLAS_TEST_EXPANDP_(nr) << " and " << BOOST_UBLAS_TEST_STRINGIFY_(nc) << " == " << BOOST_UBLAS_TEST_EXPANDP_(nc) << "]" ); \
+ ++test_fails__; \
+ } \
+ } \
+ } \
+ /* [/BOOST_UBLAS_TEST_CHECK_MATRIX_CLOSE] */
+
+
+/// Check that elements of matrices \a x and \a y are close with respect to a given relative precision \a e.
+#define BOOST_UBLAS_TEST_CHECK_MATRIX_REL_CLOSE(x,y,nr,nc,e) /* [BOOST_UBLAS_TEST_CHECK_MATRIX_REL_CLOSE] */ \
+ for (::std::size_t i__ = 0; i__ < BOOST_UBLAS_TEST_EXPANDP_(nr); ++i__) \
+ { \
+ for (::std::size_t j__ = 0; j__ < BOOST_UBLAS_TEST_EXPANDP_(nc); ++j__) \
+ { \
+ if (!::boost::numeric::ublas::test::detail::rel_close_to(BOOST_UBLAS_TEST_EXPANDP_(x)(i__,j__), BOOST_UBLAS_TEST_EXPANDP_(y)(i__,j__), BOOST_UBLAS_TEST_EXPANDP_(e))) \
+ { \
+ BOOST_UBLAS_TEST_ERROR( "Failed assertion: abs((" << BOOST_UBLAS_TEST_STRINGIFY_(x(i__,j__)) << "-" << BOOST_UBLAS_TEST_STRINGIFY_(y(i__,j__)) << ") <= " << BOOST_UBLAS_TEST_STRINGIFY_(e) << " [with " << BOOST_UBLAS_TEST_STRINGIFY_(x(i__,j__)) << " == " << BOOST_UBLAS_TEST_EXPANDP_(x)(i__,j__) << ", " << BOOST_UBLAS_TEST_STRINGIFY_(y(i__,j__)) << " == " << BOOST_UBLAS_TEST_EXPANDP_(y)(i__,j__) << ", " << BOOST_UBLAS_TEST_STRINGIFY_(i__) << " == " << i__ << ", " << BOOST_UBLAS_TEST_STRINGIFY_(j__) << " == " << BOOST_UBLAS_TEST_EXPANDP_(j__) << ", " << BOOST_UBLAS_TEST_STRINGIFY_(nr) << " == " << BOOST_UBLAS_TEST_EXPANDP_(nr) << " and " << BOOST_UBLAS_TEST_STRINGIFY_(nc) << " == " << BOOST_UBLAS_TEST_EXPANDP_(nc) << "]" ); \
+ ++test_fails__; \
+ } \
+ } \
+ } \
+ /* [/BOOST_UBLAS_TEST_CHECK_MATRIX_REL_CLOSE] */
+
+///< Output the error message \a x.
+#ifdef _MSC_VER
+# define BOOST_UBLAS_TEST_ERROR(x) ::std::cerr << "[Error (" << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ")>> " << BOOST_UBLAS_TEST_EXPAND_(x) << ::std::endl
+#else
+# define BOOST_UBLAS_TEST_ERROR(x) ::std::cerr << "[Error (" << __FILE__ << ":" << __func__ << ":" << __LINE__ << ")>> " << BOOST_UBLAS_TEST_EXPAND_(x) << ::std::endl
+#endif
 
-#endif // TEST_UTILS_HPP
+#endif // BOOST_NUMERIC_UBLAS_TEST_UTILS_HPP


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk