From e3e78929849d5e1dc5a65c01a445789c22a1efce Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Mon, 5 Oct 2009 20:57:40 +0000 Subject: [PATCH] see #3449: introduce new free functions to access matrix/vector properties (Incomplete) * added patch from Marco Guazzone implementing all requested new functions svn path=/trunk/libs/numeric/ublas/; revision=56602 --- .../boost/numeric/ublas/operation/begin.hpp | 318 ++++++++++++++++++ .../boost/numeric/ublas/operation/c_array.hpp | 41 +++ include/boost/numeric/ublas/operation/end.hpp | 318 ++++++++++++++++++ .../numeric/ublas/operation/num_columns.hpp | 43 +++ .../numeric/ublas/operation/num_rows.hpp | 42 +++ .../boost/numeric/ublas/operation/size.hpp | 273 +++++++++++++++ include/boost/numeric/ublas/operations.hpp | 26 ++ include/boost/numeric/ublas/tags.hpp | 37 ++ .../ublas/traits/const_iterator_type.hpp | 127 +++++++ .../numeric/ublas/traits/iterator_type.hpp | 126 +++++++ test/Jamfile.v2 | 12 +- test/begin_end.cpp | 174 ++++++++++ test/num_columns.cpp | 106 ++++++ test/num_rows.cpp | 106 ++++++ test/size.cpp | 271 +++++++++++++++ test/utils.hpp | 33 ++ 16 files changed, 2052 insertions(+), 1 deletion(-) create mode 100644 include/boost/numeric/ublas/operation/begin.hpp create mode 100644 include/boost/numeric/ublas/operation/c_array.hpp create mode 100644 include/boost/numeric/ublas/operation/end.hpp create mode 100644 include/boost/numeric/ublas/operation/num_columns.hpp create mode 100644 include/boost/numeric/ublas/operation/num_rows.hpp create mode 100644 include/boost/numeric/ublas/operation/size.hpp create mode 100644 include/boost/numeric/ublas/operations.hpp create mode 100644 include/boost/numeric/ublas/tags.hpp create mode 100644 include/boost/numeric/ublas/traits/const_iterator_type.hpp create mode 100644 include/boost/numeric/ublas/traits/iterator_type.hpp create mode 100644 test/begin_end.cpp create mode 100644 test/num_columns.cpp create mode 100644 test/num_rows.cpp create mode 100644 test/size.cpp create mode 100644 test/utils.hpp diff --git a/include/boost/numeric/ublas/operation/begin.hpp b/include/boost/numeric/ublas/operation/begin.hpp new file mode 100644 index 00000000..d14bb35c --- /dev/null +++ b/include/boost/numeric/ublas/operation/begin.hpp @@ -0,0 +1,318 @@ +/** + * -*- c++ -*- + * + * \file begin.hpp + * + * \brief The \c begin operation. + * + * Copyright (c) 2009, 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@gmail.com + */ + +#ifndef BOOST_NUMERIC_UBLAS_OPERATION_BEGIN_HPP +#define BOOST_NUMERIC_UBLAS_OPERATION_BEGIN_HPP + + +#include +#include +#include +#include + + +namespace boost { namespace numeric { namespace ublas { + + namespace detail { + + /** + * \brief Auxiliary class for implementing the \c begin operation. + * \tparam CategoryT The expression category type (e.g., vector_tag). + * \tparam TagT The dimension type tag (e.g., tag::major). + * \tparam OrientationT The orientation category type (e.g., row_major_tag). + */ + template + struct begin_impl; + + + /// \brief Specialization of \c begin_impl for iterating vector expressions. + template <> + struct begin_impl + { + /** + * \brief Return an iterator to the first element of the given vector + * expression. + * \tparam ExprT A model of VectorExpression type. + * \param e A vector expression. + * \return An iterator over the given vector expression. + */ + template + static typename ExprT::iterator apply(ExprT& e) + { + return e.begin(); + } + + + /** + * \brief Return a const iterator to the first element of the given vector + * expression. + * \tparam ExprT A model of VectorExpression type. + * \param e A vector expression. + * \return A const iterator to the first element of the given vector + * expression. + */ + template + static typename ExprT::const_iterator apply(ExprT const& e) + { + return e.begin(); + } + }; + + + /// \brief Specialization of \c begin_impl for iterating matrix expressions with + /// a row-major orientation over the major dimension. + template <> + struct begin_impl + { + /** + * \brief Return an iterator to the first element of the given row-major + * matrix expression over the major dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return An iterator over the major dimension of the given matrix + * expression. + */ + template + static typename ExprT::iterator1 apply(ExprT& e) + { + return e.begin1(); + } + + + /** + * \brief Return a const iterator to the first element of the given + * row-major matrix expression over the major dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return A const iterator over the major dimension of the given matrix + * expression. + */ + template + static typename ExprT::const_iterator1 apply(ExprT const& e) + { + return e.begin1(); + } + }; + + + /// \brief Specialization of \c begin_impl for iterating matrix expressions with + /// a column-major orientation over the major dimension. + template <> + struct begin_impl + { + /** + * \brief Return an iterator to the first element of the given column-major + * matrix expression over the major dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return An iterator over the major dimension of the given matrix + * expression. + */ + template + static typename ExprT::iterator2 apply(ExprT& e) + { + return e.begin2(); + } + + + /** + * \brief Return a const iterator to the first element of the given + * column-major matrix expression over the major dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return A const iterator over the major dimension of the given matrix + * expression. + */ + template + static typename ExprT::const_iterator2 apply(ExprT const& e) + { + return e.begin2(); + } + }; + + + /// \brief Specialization of \c begin_impl for iterating matrix expressions with + /// a row-major orientation over the minor dimension. + template <> + struct begin_impl + { + /** + * \brief Return an iterator to the first element of the given row-major + * matrix expression over the minor dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return An iterator over the minor dimension of the given matrix + * expression. + */ + template + static typename ExprT::iterator2 apply(ExprT& e) + { + return e.begin2(); + } + + + /** + * \brief Return a const iterator to the first element of the given + * row-major matrix expression over the minor dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return A const iterator over the minor dimension of the given matrix + * expression. + */ + template + static typename ExprT::const_iterator2 apply(ExprT const& e) + { + return e.begin2(); + } + }; + + + + /// \brief Specialization of \c begin_impl for iterating matrix expressions with + /// a column-major orientation over the minor dimension. + template <> + struct begin_impl + { + /** + * \brief Return an iterator to the first element of the given column-major + * matrix expression over the minor dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return An iterator over the minor dimension of the given matrix + * expression. + */ + template + static typename ExprT::iterator1 apply(ExprT& e) + { + return e.begin1(); + } + + + /** + * \brief Return a const iterator to the first element of the given + * column-major matrix expression over the minor dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return A const iterator over the minor dimension of the given matrix + * expression. + */ + template + static typename ExprT::const_iterator1 apply(ExprT const& e) + { + return e.begin1(); + } + }; + + } // Namespace detail + + + /** + * \brief An iterator to the first element of the given vector expression. + * \tparam ExprT A model of VectorExpression type. + * \param e A vector expression. + * \return An iterator to the first element of the given vector expression. + */ + template + BOOST_UBLAS_INLINE + typename ExprT::iterator begin(vector_expression& e) + { + return detail::begin_impl::apply(e()); + } + + + /** + * \brief A const iterator to the first element of the given vector expression. + * \tparam ExprT A model of VectorExpression type. + * \param e A vector expression. + * \return A const iterator to the first element of the given vector expression. + */ + template + BOOST_UBLAS_INLINE + typename ExprT::const_iterator begin(vector_expression const& e) + { + return detail::begin_impl::apply(e()); + } + + + /** + * \brief An iterator to the first element of the given matrix expression + * according to its orientation. + * \tparam DimTagT A dimension tag type (e.g., tag::major). + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return An iterator to the first element of the given matrix expression + * according to its orientation. + */ + template + BOOST_UBLAS_INLINE + typename iterator_type::type begin(matrix_expression& e) + { + return detail::begin_impl::apply(e()); + } + + + /** + * \brief A const iterator to the first element of the given matrix expression + * according to its orientation. + * \tparam TagT A dimension tag type (e.g., tag::major). + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return A const iterator to the first element of the given matrix expression + * according to its orientation. + */ + template + BOOST_UBLAS_INLINE + typename const_iterator_type::type begin(matrix_expression const& e) + { + return detail::begin_impl::apply(e()); + } + + + /** + * \brief An iterator to the first element over the dual dimension of the given + * iterator. + * \tparam IteratorT A model of Iterator type. + * \param it An iterator. + * \return An iterator to the first element over the dual dimension of the given + * iterator. + */ + template + BOOST_UBLAS_INLINE + typename IteratorT::dual_iterator_type begin(IteratorT& it) + { + return it.begin(); + } + + + /** + * \brief A const iterator to the first element over the dual dimension of the + * given iterator. + * \tparam IteratorT A model of Iterator type. + * \param it An iterator. + * \return A const iterator to the first element over the dual dimension of the + * given iterator. + */ + template + BOOST_UBLAS_INLINE + typename IteratorT::dual_iterator_type begin(IteratorT const& it) + { + return it.begin(); + } + +}}} // Namespace boost::numeric::ublas + + +#endif // BOOST_NUMERIC_UBLAS_OPERATION_BEGIN_HPP diff --git a/include/boost/numeric/ublas/operation/c_array.hpp b/include/boost/numeric/ublas/operation/c_array.hpp new file mode 100644 index 00000000..7b3aee0c --- /dev/null +++ b/include/boost/numeric/ublas/operation/c_array.hpp @@ -0,0 +1,41 @@ +/** + * -*- c++ -*- + * + * \file c_array.hpp + * + * \brief provides specializations of matrix and vector operations for c arrays and c matrices. + * + * Copyright (c) 2009, Gunter Winkler + * + * 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 Gunter Winkler (guwi17 at gmx dot de) + */ + +#ifndef BOOST_NUMERIC_UBLAS_OPERATION_C_ARRAY_HPP +#define BOOST_NUMERIC_UBLAS_OPERATION_C_ARRAY_HPP + +#include + +namespace boost { namespace numeric { namespace ublas { + + namespace detail { + + + + } // namespace boost::numeric::ublas::detail + + + template + BOOST_UBLAS_INLINE + typename ExprT::const_iterator begin(vector_expression const& e) + { + return detail::begin_impl::apply(e()); + } + + +}}} // Namespace boost::numeric::ublas + +#endif diff --git a/include/boost/numeric/ublas/operation/end.hpp b/include/boost/numeric/ublas/operation/end.hpp new file mode 100644 index 00000000..2e3b3e5c --- /dev/null +++ b/include/boost/numeric/ublas/operation/end.hpp @@ -0,0 +1,318 @@ +/** + * -*- c++ -*- + * + * \file end.hpp + * + * \brief The \c end operation. + * + * Copyright (c) 2009, 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@gmail.com + */ + + +#ifndef BOOST_NUMERIC_UBLAS_OPERATION_END_HPP +#define BOOST_NUMERIC_UBLAS_OPERATION_END_HPP + + +#include +#include +#include +#include + + +namespace boost { namespace numeric { namespace ublas { + + namespace detail { + + /** + * \brief Auxiliary class for implementing the \c end operation. + * \tparam CategoryT The expression category type (e.g., vector_tag). + * \tparam TagT The dimension type tag (e.g., tag::major). + * \tparam OrientationT The orientation category type (e.g., row_major_tag). + */ + template + struct end_impl; + + + /// \brief Specialization of \c end_impl for iterating vector expressions. + template <> + struct end_impl + { + /** + * \brief Return an iterator to the last element of the given vector + * expression. + * \tparam ExprT A model of VectorExpression type. + * \param e A vector expression. + * \return An iterator over the given vector expression. + */ + template + static typename ExprT::iterator apply(ExprT& e) + { + return e.end(); + } + + + /** + * \brief Return a const iterator to the last element of the given vector + * expression. + * \tparam ExprT A model of VectorExpression type. + * \param e A vector expression. + * \return A const iterator to the first element of the given vector + * expression. + */ + template + static typename ExprT::const_iterator apply(ExprT const& e) + { + return e.end(); + } + }; + + + /// \brief Specialization of \c end_impl for iterating matrix expressions with a + /// row-major orientation over the major dimension. + template <> + struct end_impl + { + /** + * \brief Return an iterator to the last element of the given row-major + * matrix expression over the major dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return An iterator over the major dimension of the given matrix + * expression. + */ + template + static typename ExprT::iterator1 apply(ExprT& e) + { + return e.end1(); + } + + + /** + * \brief Return a const iterator to the last element of the given row-major + * matrix expression over the major dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return A const iterator over the major dimension of the given matrix + * expression. + */ + template + static typename ExprT::const_iterator1 apply(ExprT const& e) + { + return e.end1(); + } + }; + + + /// \brief Specialization of \c end_impl for iterating matrix expressions with a + /// column-major orientation over the major dimension. + template <> + struct end_impl + { + /** + * \brief Return an iterator to the last element of the given column-major + * matrix expression over the major dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return An iterator over the major dimension of the given matrix + * expression. + */ + template + static typename ExprT::iterator2 apply(ExprT& e) + { + return e.end2(); + } + + + /** + * \brief Return a const iterator to the last element of the given + * column-major matrix expression over the major dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return A const iterator over the major dimension of the given matrix + * expression. + */ + template + static typename ExprT::const_iterator2 apply(ExprT const& e) + { + return e.end2(); + } + }; + + + /// \brief Specialization of \c end_impl for iterating matrix expressions with a + /// row-major orientation over the minor dimension. + template <> + struct end_impl + { + /** + * \brief Return an iterator to the last element of the given row-major + * matrix expression over the minor dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return An iterator over the minor dimension of the given matrix + * expression. + */ + template + static typename ExprT::iterator2 apply(ExprT& e) + { + return e.end2(); + } + + + /** + * \brief Return a const iterator to the last element of the given + * row-minor matrix expression over the major dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return A const iterator over the minor dimension of the given matrix + * expression. + */ + template + static typename ExprT::const_iterator2 apply(ExprT const& e) + { + return e.end2(); + } + }; + + + /// \brief Specialization of \c end_impl for iterating matrix expressions with a + /// column-major orientation over the minor dimension. + template <> + struct end_impl + { + /** + * \brief Return an iterator to the last element of the given column-major + * matrix expression over the minor dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return An iterator over the minor dimension of the given matrix + * expression. + */ + template + static typename ExprT::iterator1 apply(ExprT& e) + { + return e.end1(); + } + + + /** + * \brief Return a const iterator to the last element of the given + * column-minor matrix expression over the major dimension. + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return A const iterator over the minor dimension of the given matrix + * expression. + */ + template + static typename ExprT::const_iterator1 apply(ExprT const& e) + { + return e.end1(); + } + }; + + } // Namespace detail + + + /** + * \brief An iterator to the last element of the given vector expression. + * \tparam ExprT A model of VectorExpression type. + * \param e A vector expression. + * \return An iterator to the last element of the given vector expression. + */ + template + BOOST_UBLAS_INLINE + typename ExprT::iterator end(vector_expression& e) + { + return detail::end_impl::apply(e()); + } + + + /** + * \brief A const iterator to the last element of the given vector expression. + * \tparam ExprT A model of VectorExpression type. + * \param e A vector expression. + * \return A const iterator to the last element of the given vector expression. + */ + template + BOOST_UBLAS_INLINE + typename ExprT::const_iterator end(vector_expression const& e) + { + return detail::end_impl::apply(e()); + } + + + /** + * \brief An iterator to the last element of the given matrix expression + * according to its orientation. + * \tparam DimTagT A dimension tag type (e.g., tag::major). + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return An iterator to the last element of the given matrix expression + * according to its orientation. + */ + template + BOOST_UBLAS_INLINE + typename iterator_type::type end(matrix_expression& e) + { + return detail::end_impl::apply(e()); + } + + + /** + * \brief A const iterator to the last element of the given matrix expression + * according to its orientation. + * \tparam TagT A dimension tag type (e.g., tag::major). + * \tparam ExprT A model of MatrixExpression type. + * \param e A matrix expression. + * \return A const iterator to the last element of the given matrix expression + * according to its orientation. + */ + template + BOOST_UBLAS_INLINE + typename const_iterator_type::type end(matrix_expression const& e) + { + return detail::end_impl::apply(e()); + } + + + /** + * \brief An iterator to the last element over the dual dimension of the given + * iterator. + * \tparam IteratorT A model of Iterator type. + * \param it An iterator. + * \return An iterator to the last element over the dual dimension of the given + * iterator. + */ + template + BOOST_UBLAS_INLINE + typename IteratorT::dual_iterator_type end(IteratorT& it) + { + return it.end(); + } + + + /** + * \brief A const iterator to the last element over the dual dimension of the + * given iterator. + * \tparam IteratorT A model of Iterator type. + * \param it An iterator. + * \return A const iterator to the last element over the dual dimension of the + * given iterator. + */ + template + BOOST_UBLAS_INLINE + typename IteratorT::dual_iterator_type end(IteratorT const& it) + { + return it.end(); + } + +}}} // Namespace boost::numeric::ublas + + +#endif // BOOST_NUMERIC_UBLAS_OPERATION_END_HPP diff --git a/include/boost/numeric/ublas/operation/num_columns.hpp b/include/boost/numeric/ublas/operation/num_columns.hpp new file mode 100644 index 00000000..30fcc7b6 --- /dev/null +++ b/include/boost/numeric/ublas/operation/num_columns.hpp @@ -0,0 +1,43 @@ +/** + * -*- c++ -*- + * + * \file num_columns.hpp + * + * \brief The \c num_columns operation. + * + * Copyright (c) 2009, 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@gmail.com + */ + + +#ifndef BOOST_NUMERIC_UBLAS_OPERATION_NUM_COLUMNS_HPP +#define BOOST_NUMERIC_UBLAS_OPERATION_NUM_COLUMNS_HPP + + +#include + + +namespace boost { namespace numeric { namespace ublas { + + /** + * \brief Return the number of columns. + * \tparam MatrixExprT A type which models the matrix expression concept. + * \param m A matrix expression. + * \return The number of columns. + */ + template + BOOST_UBLAS_INLINE + typename MatrixExprT::size_type num_columns(MatrixExprT const& m) + { + return m.size2(); + } + +}}} // Namespace boost::numeric::ublas + + +#endif // BOOST_NUMERIC_UBLAS_OPERATION_NUM_COLUMNS_HPP diff --git a/include/boost/numeric/ublas/operation/num_rows.hpp b/include/boost/numeric/ublas/operation/num_rows.hpp new file mode 100644 index 00000000..856256ff --- /dev/null +++ b/include/boost/numeric/ublas/operation/num_rows.hpp @@ -0,0 +1,42 @@ +/** + * -*- c++ -*- + * + * \file num_rows.hpp + * + * \brief The \c num_rows operation. + * + * Copyright (c) 2009, 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@gmail.com + */ + +#ifndef BOOST_NUMERIC_UBLAS_OPERATION_NUM_ROWS_HPP +#define BOOST_NUMERIC_UBLAS_OPERATION_NUM_ROWS_HPP + + +#include + + +namespace boost { namespace numeric { namespace ublas { + + /** + * \brief Return the number of rows. + * \tparam MatrixExprT A type which models the matrix expression concept. + * \param m A matrix expression. + * \return The number of rows. + */ + template + BOOST_UBLAS_INLINE + typename MatrixExprT::size_type num_rows(MatrixExprT const& m) + { + return m.size1(); + } + +}}} // Namespace boost::numeric::ublas + + +#endif // BOOST_NUMERIC_UBLAS_OPERATION_NUM_ROWS_HPP diff --git a/include/boost/numeric/ublas/operation/size.hpp b/include/boost/numeric/ublas/operation/size.hpp new file mode 100644 index 00000000..fbbe2520 --- /dev/null +++ b/include/boost/numeric/ublas/operation/size.hpp @@ -0,0 +1,273 @@ +/** + * -*- c++ -*- + * + * \file size.hpp + * + * \brief The \c size operation. + * + * Copyright (c) 2009, 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@gmail.com + */ + +#ifndef BOOST_NUMERIC_UBLAS_OPERATION_SIZE_HPP +#define BOOST_NUMERIC_UBLAS_OPERATION_SIZE_HPP + + +#include +#include +#include +#include +#include + + +namespace boost { namespace numeric { namespace ublas { + + namespace detail { + + /** + * \brief Auxiliary class for computing the size of the given dimension for + * a container of the given category.. + * \tparam Dim The dimension number (starting from 1). + * \tparam CategoryT The category type (e.g., vector_tag). + */ + template + struct size_by_dim_impl; + + + /// \brief Specialization of \c size_by_dim_impl for computing the size of a + /// vector + template <> + struct size_by_dim_impl<1, vector_tag> + { + /** + * \brief Compute the size of the given vector. + * \tparam ExprT A vector expression type. + * \pre ExprT must be a model of VectorExpression. + */ + template + BOOST_UBLAS_INLINE + static typename ExprT::size_type apply(ExprT const& e) + { + return e.size(); + } + }; + + + /// \brief Specialization of \c size_by_dim_impl for computing the number of + /// rows of a matrix + template <> + struct size_by_dim_impl<1, matrix_tag> + { + /** + * \brief Compute the number of rows of the given matrix. + * \tparam ExprT A matrix expression type. + * \pre ExprT must be a model of MatrixExpression. + */ + template + BOOST_UBLAS_INLINE + static typename ExprT::size_type apply(ExprT const& e) + { + return e.size1(); + } + }; + + + /// \brief Specialization of \c size_by_dim_impl for computing the number of + /// columns of a matrix + template <> + struct size_by_dim_impl<2, matrix_tag> + { + /** + * \brief Compute the number of columns of the given matrix. + * \tparam ExprT A matrix expression type. + * \pre ExprT must be a model of MatrixExpression. + */ + template + BOOST_UBLAS_INLINE + static typename ExprT::size_type apply(ExprT const& e) + { + return e.size2(); + } + }; + + + /** + * \brief Auxiliary class for computing the size of the given dimension for + * a container of the given category and with the given orientation.. + * \tparam Dim The dimension number (starting from 1). + * \tparam CategoryT The category type (e.g., vector_tag). + * \tparam OrientationT The orientation category type (e.g., row_major_tag). + */ + template + struct size_by_tag_impl; + + + /// \brief Specialization of \c size_by_tag_impl for computing the size of the + /// major dimension of a row-major oriented matrix. + template <> + struct size_by_tag_impl + { + /** + * \brief Compute the number of rows of the given matrix. + * \tparam ExprT A matrix expression type. + * \pre ExprT must be a model of MatrixExpression. + */ + template + BOOST_UBLAS_INLINE + static typename ExprT::size_type apply(ExprT const& e) + { + return e.size1(); + } + }; + + + /// \brief Specialization of \c size_by_tag_impl for computing the size of the + /// minor dimension of a row-major oriented matrix. + template <> + struct size_by_tag_impl + { + /** + * \brief Compute the number of columns of the given matrix. + * \tparam ExprT A matrix expression type. + * \pre ExprT must be a model of MatrixExpression. + */ + template + BOOST_UBLAS_INLINE + static typename ExprT::size_type apply(ExprT const& e) + { + return e.size2(); + } + }; + + + /// \brief Specialization of \c size_by_tag_impl for computing the size of the + /// leading dimension of a row-major oriented matrix. + template <> + struct size_by_tag_impl + { + /** + * \brief Compute the number of columns of the given matrix. + * \tparam ExprT A matrix expression type. + * \pre ExprT must be a model of MatrixExpression. + */ + template + BOOST_UBLAS_INLINE + static typename ExprT::size_type apply(ExprT const& e) + { + return e.size2(); + } + }; + + + /// \brief Specialization of \c size_by_tag_impl for computing the size of the + /// major dimension of a column-major oriented matrix. + template <> + struct size_by_tag_impl + { + /** + * \brief Compute the number of columns of the given matrix. + * \tparam ExprT A matrix expression type. + * \pre ExprT must be a model of MatrixExpression. + */ + template + BOOST_UBLAS_INLINE + static typename ExprT::size_type apply(ExprT const& e) + { + return e.size2(); + } + }; + + + /// \brief Specialization of \c size_by_tag_impl for computing the size of the + /// minor dimension of a column-major oriented matrix. + template <> + struct size_by_tag_impl + { + /** + * \brief Compute the number of rows of the given matrix. + * \tparam ExprT A matrix expression type. + * \pre ExprT must be a model of MatrixExpression. + */ + template + BOOST_UBLAS_INLINE + static typename ExprT::size_type apply(ExprT const& e) + { + return e.size1(); + } + }; + + + /// \brief Specialization of \c size_by_tag_impl for computing the size of the + /// leading dimension of a column-major oriented matrix. + template <> + struct size_by_tag_impl + { + /** + * \brief Compute the number of rows of the given matrix. + * \tparam ExprT A matrix expression type. + * \pre ExprT must be a model of MatrixExpression. + */ + template + BOOST_UBLAS_INLINE + static typename ExprT::size_type apply(ExprT const& e) + { + return e.size1(); + } + }; + + } // Namespace detail + + + /** + * \brief Return the number of columns. + * \tparam MatrixExprT A type which models the matrix expression concept. + * \param m A matrix expression. + * \return The number of columns. + */ + template + BOOST_UBLAS_INLINE + typename VectorExprT::size_type size(VectorExprT const& v) + { + return v.size(); + } + + + /** + * \brief Return the size of the given dimension for the given expression. + * \tparam Dim The dimension number (starting from 1). + * \tparam ExprT An expression type. + * \param e An expression. + * \return The number of columns. + * \return The size associated to the dimension \a Dim. + */ + template + BOOST_UBLAS_INLINE + typename ExprT::size_type size(ExprT const& e) + { + return detail::size_by_dim_impl::apply(e); + } + + + /** + * \brief Return the size of the given dimension tag for the given expression. + * \tparam TagT The dimension tag type (e.g., tag::major). + * \tparam ExprT An expression type. + * \param e An expression. + * \return The size associated to the dimension tag \a TagT. + */ + template + BOOST_UBLAS_INLINE + typename ExprT::size_type size(ExprT const& e) + { + return detail::size_by_tag_impl::apply(e); + } + +}}} // Namespace boost::numeric::ublas + + +#endif // BOOST_NUMERIC_UBLAS_OPERATION_SIZE_HPP diff --git a/include/boost/numeric/ublas/operations.hpp b/include/boost/numeric/ublas/operations.hpp new file mode 100644 index 00000000..23c4fab3 --- /dev/null +++ b/include/boost/numeric/ublas/operations.hpp @@ -0,0 +1,26 @@ +/** + * -*- c++ -*- + * + * \file operations.hpp + * + * \brief This header includes several headers from the operation directory. + * + * Copyright (c) 2009, Gunter Winkler + * + * 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 Gunter Winkler (guwi17 at gmx dot de) + */ + +#ifndef BOOST_NUMERIC_UBLAS_OPERATIONS_HPP +#define BOOST_NUMERIC_UBLAS_OPERATIONS_HPP + +#include +#include +#include +#include +#include + +#endif diff --git a/include/boost/numeric/ublas/tags.hpp b/include/boost/numeric/ublas/tags.hpp new file mode 100644 index 00000000..27351bb1 --- /dev/null +++ b/include/boost/numeric/ublas/tags.hpp @@ -0,0 +1,37 @@ +/** + * -*- c++ -*- + * + * \file tags.hpp + * + * \brief Tags. + * + * Copyright (c) 2009, 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@gmail.com + */ + +#ifndef BOOST_NUMERIC_UBLAS_TAG_HPP +#define BOOST_NUMERIC_UBLAS_TAG_HPP + + +namespace boost { namespace numeric { namespace ublas { namespace tag { + +/// \brief Tag for the major dimension. +struct major {}; + + +/// \brief Tag for the minor dimension. +struct minor {}; + + +/// \brief Tag for the leading dimension. +struct leading {}; + +}}}} // Namespace boost::numeric::ublas::tag + + +#endif // BOOST_NUMERIC_UBLAS_TAG_HPP diff --git a/include/boost/numeric/ublas/traits/const_iterator_type.hpp b/include/boost/numeric/ublas/traits/const_iterator_type.hpp new file mode 100644 index 00000000..1beeccc6 --- /dev/null +++ b/include/boost/numeric/ublas/traits/const_iterator_type.hpp @@ -0,0 +1,127 @@ +/** + * -*- c++ -*- + * + * \file const_iterator_type.hpp + * + * \brief Const iterator to a given container type. + * + * Copyright (c) 2009, 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@gmail.com + */ + + +#ifndef BOOST_NUMERIC_UBLAS_TRAITS_CONST_ITERATOR_TYPE_HPP +#define BOOST_NUMERIC_UBLAS_TRAITS_CONST_ITERATOR_TYPE_HPP + + +#include +#include +#include + + +namespace boost { namespace numeric { namespace ublas { + + namespace detail { + + /** + * \brief Auxiliary class for retrieving the const iterator to the given + * matrix expression according its orientation and to the given dimension tag. + * \tparam MatrixT A model of MatrixExpression. + * \tparam TagT A dimension tag type (e.g., tag::major). + * \tparam OrientationT An orientation category type (e.g., row_major_tag). + */ + template + struct const_iterator_type_impl; + + + /// \brief Specialization of \c const_iterator_type_impl for row-major oriented + /// matrices and over the major dimension. + template + struct const_iterator_type_impl + { + typedef typename matrix_view_traits::const_iterator1 type; + }; + + + /// \brief Specialization of \c const_iterator_type_impl for column-major + /// oriented matrices and over the major dimension. + template + struct const_iterator_type_impl + { + typedef typename matrix_view_traits::const_iterator2 type; + }; + + + /// \brief Specialization of \c const_iterator_type_impl for row-major oriented + /// matrices and over the minor dimension. + template + struct const_iterator_type_impl + { + typedef typename matrix_view_traits::const_iterator2 type; + }; + + + /// \brief Specialization of \c const_iterator_type_impl for column-major + /// oriented matrices and over the minor dimension. + template + struct const_iterator_type_impl + { + typedef typename matrix_view_traits::const_iterator1 type; + }; + + } // Namespace detail + + + /** + * \brief A const iterator for the given container type over the given + * dimension. + * \tparam ContainerT A container expression type. + * \tparam TagT A dimension tag type (e.g., tag::major). + */ + template + struct const_iterator_type; + + + /** + * \brief Specialization of \c const_iterator_type for vector expressions. + * \tparam VectorT A model of VectorExpression type. + */ + template + struct const_iterator_type + { + typedef typename vector_view_traits::const_iterator type; + }; + + + /** + * \brief Specialization of \c const_iterator_type for matrix expressions and + * over the major dimension. + * \tparam MatrixT A model of MatrixExpression type. + */ + template + struct const_iterator_type + { + typedef typename detail::const_iterator_type_impl::orientation_category>::type type; + }; + + + /** + * \brief Specialization of \c const_iterator_type for matrix expressions and + * over the minor dimension. + * \tparam MatrixT A model of MatrixExpression type. + */ + template + struct const_iterator_type + { + typedef typename detail::const_iterator_type_impl::orientation_category>::type type; + }; + +}}} // Namespace boost::numeric::ublas + + +#endif // BOOST_NUMERIC_UBLAS_TRAITS_CONST_ITERATOR_TYPE_HPP diff --git a/include/boost/numeric/ublas/traits/iterator_type.hpp b/include/boost/numeric/ublas/traits/iterator_type.hpp new file mode 100644 index 00000000..c706b4dd --- /dev/null +++ b/include/boost/numeric/ublas/traits/iterator_type.hpp @@ -0,0 +1,126 @@ +/** + * -*- c++ -*- + * + * \file iterator_type.hpp + * + * \brief Iterator to a given container type. + * + * Copyright (c) 2009, 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@gmail.com + */ + + +#ifndef BOOST_NUMERIC_UBLAS_TRAITS_ITERATOR_TYPE_HPP +#define BOOST_NUMERIC_UBLAS_TRAITS_ITERATOR_TYPE_HPP + + +#include +#include +#include + + +namespace boost { namespace numeric { namespace ublas { + + namespace detail { + + /** + * \brief Auxiliary class for retrieving the iterator to the given + * matrix expression according its orientation and to the given dimension tag. + * \tparam MatrixT A model of MatrixExpression. + * \tparam TagT A dimension tag type (e.g., tag::major). + * \tparam OrientationT An orientation category type (e.g., row_major_tag). + */ + template + struct iterator_type_impl; + + + /// \brief Specialization of \c iterator_type_impl for row-major oriented + /// matrices and over the major dimension. + template + struct iterator_type_impl + { + typedef typename matrix_traits::iterator1 type; + }; + + + /// \brief Specialization of \c iterator_type_impl for column-major oriented + /// matrices and over the major dimension. + template + struct iterator_type_impl + { + typedef typename matrix_traits::iterator2 type; + }; + + + /// \brief Specialization of \c iterator_type_impl for row-major oriented + /// matrices and over the minor dimension. + template + struct iterator_type_impl + { + typedef typename matrix_traits::iterator2 type; + }; + + + /// \brief Specialization of \c iterator_type_impl for column-major oriented + /// matrices and over the minor dimension. + template + struct iterator_type_impl + { + typedef typename matrix_traits::iterator1 type; + }; + + } // Namespace detail + + + /** + * \brief A iterator for the given container type over the given dimension. + * \tparam ContainerT A container expression type. + * \tparam TagT A dimension tag type (e.g., tag::major). + */ + template + struct iterator_type; + + + /** + * \brief Specialization of \c iterator_type for vector expressions. + * \tparam VectorT A model of VectorExpression type. + */ + template + struct iterator_type + { + typedef typename vector_traits::iterator type; + }; + + + /** + * \brief Specialization of \c iterator_type for matrix expressions and + * over the major dimension. + * \tparam MatrixT A model of MatrixExpression type. + */ + template + struct iterator_type + { + typedef typename detail::iterator_type_impl::orientation_category>::type type; + }; + + + /** + * \brief Specialization of \c iterator_type for matrix expressions and + * over the minor dimension. + * \tparam MatrixT A model of MatrixExpression type. + */ + template + struct iterator_type + { + typedef typename detail::iterator_type_impl::orientation_category>::type type; + }; + +}}} // Namespace boost::numeric::ublas + + +#endif // BOOST_NUMERIC_UBLAS_TRAITS_ITERATOR_TYPE_HPP diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 10ba1fe6..a1ac7dc9 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -103,8 +103,10 @@ test-suite numeric/uBLAS [ compile concepts.cpp : # requirements EXTERNAL +# INTERAL +# SKIP_BAD intel-linux:"-Xc" - darwin:"-fabi-version=0" + darwin:"-fabi-version=0" ] [ run test_lu.cpp ] @@ -118,4 +120,12 @@ test-suite numeric/uBLAS ] [ run sparse_view_test.cpp ] + [ run begin_end.cpp + ] + [ run num_columns.cpp + ] + [ run num_rows.cpp + ] + [ run size.cpp + ] ; diff --git a/test/begin_end.cpp b/test/begin_end.cpp new file mode 100644 index 00000000..d29d24d7 --- /dev/null +++ b/test/begin_end.cpp @@ -0,0 +1,174 @@ +/** -*- c++ -*- \file begin_end.hpp \brief Test the \c begin and \c end operations. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "libs/numeric/ublas/test/utils.hpp" + + +static const double TOL(1.0e-5); ///< Used for comparing two real numbers. + + +BOOST_UBLAS_TEST_DEF( test_vector_iteration ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Vector Iteration" ); + + typedef double value_type; + typedef boost::numeric::ublas::vector vector_type; + + vector_type v(5); + + v(0) = 0.555950; + v(1) = 0.108929; + v(2) = 0.948014; + v(3) = 0.023787; + v(4) = 1.023787; + + + vector_type::size_type ix = 0; + for ( + boost::numeric::ublas::iterator_type::type it = boost::numeric::ublas::begin(v); + it != boost::numeric::ublas::end(v); + ++it + ) { + BOOST_UBLAS_DEBUG_TRACE( "*it = " << *it << " ==> " << v(ix) ); + BOOST_UBLAS_TEST_CHECK( std::fabs(*it - v(ix)) <= TOL ); + ++ix; + } +} + + +BOOST_UBLAS_TEST_DEF( test_vector_const_iteration ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Vector Const Iteration" ); + + typedef double value_type; + typedef boost::numeric::ublas::vector vector_type; + + vector_type v(5); + + v(0) = 0.555950; + v(1) = 0.108929; + v(2) = 0.948014; + v(3) = 0.023787; + v(4) = 1.023787; + + + vector_type::size_type ix = 0; + for ( + boost::numeric::ublas::const_iterator_type::type it = boost::numeric::ublas::begin(v); + it != boost::numeric::ublas::end(v); + ++it + ) { + BOOST_UBLAS_DEBUG_TRACE( "*it = " << *it << " ==> " << v(ix) ); + BOOST_UBLAS_TEST_CHECK( std::fabs(*it - v(ix)) <= TOL ); + ++ix; + } +} + + +BOOST_UBLAS_TEST_DEF( test_row_major_matrix_iteration ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Row-major Matrix Iteration" ); + + typedef double value_type; + typedef boost::numeric::ublas::matrix matrix_type; + typedef boost::numeric::ublas::iterator_type::type outer_iterator_type; + typedef boost::numeric::ublas::iterator_type::type inner_iterator_type; + + matrix_type A(5,4); + + A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938; + A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283; + A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152; + A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332; + A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332; + + + matrix_type::size_type row(0); + for ( + outer_iterator_type outer_it = boost::numeric::ublas::begin(A); + outer_it != boost::numeric::ublas::end(A); + ++outer_it + ) { + matrix_type::size_type col(0); + + for ( + inner_iterator_type inner_it = boost::numeric::ublas::begin(outer_it); + inner_it != boost::numeric::ublas::end(outer_it); + ++inner_it + ) { + BOOST_UBLAS_DEBUG_TRACE( "*it = " << *inner_it << " ==> " << A(row,col) ); + BOOST_UBLAS_TEST_CHECK( std::fabs(*inner_it - A(row,col)) <= TOL ); + + ++col; + } + + ++row; + } +} + + +BOOST_UBLAS_TEST_DEF( test_col_major_matrix_iteration ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Column-major Matrix Iteration" ); + + typedef double value_type; + typedef boost::numeric::ublas::matrix matrix_type; + typedef boost::numeric::ublas::iterator_type::type outer_iterator_type; + typedef boost::numeric::ublas::iterator_type::type inner_iterator_type; + + matrix_type A(5,4); + + A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938; + A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283; + A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152; + A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332; + A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332; + + + matrix_type::size_type col(0); + for ( + outer_iterator_type outer_it = boost::numeric::ublas::begin(A); + outer_it != boost::numeric::ublas::end(A); + ++outer_it + ) { + matrix_type::size_type row(0); + + for ( + inner_iterator_type inner_it = boost::numeric::ublas::begin(outer_it); + inner_it != boost::numeric::ublas::end(outer_it); + ++inner_it + ) { + BOOST_UBLAS_DEBUG_TRACE( "*it = " << *inner_it << " ==> " << A(row,col) ); + BOOST_UBLAS_TEST_CHECK( std::fabs(*inner_it - A(row,col)) <= TOL ); + + ++row; + } + + ++col; + } +} + + +int main() +{ + BOOST_UBLAS_TEST_BEGIN(); + + BOOST_UBLAS_TEST_DO( test_vector_iteration ); + BOOST_UBLAS_TEST_DO( test_vector_const_iteration ); + BOOST_UBLAS_TEST_DO( test_row_major_matrix_iteration ); + BOOST_UBLAS_TEST_DO( test_col_major_matrix_iteration ); + + BOOST_UBLAS_TEST_END(); +} diff --git a/test/num_columns.cpp b/test/num_columns.cpp new file mode 100644 index 00000000..91a9e04a --- /dev/null +++ b/test/num_columns.cpp @@ -0,0 +1,106 @@ +/** -*- c++ -*- \file num_columns.cpp \breif Test for the \c num_columns operation. */ + +#include +#include +#include +#include +#include +#include "libs/numeric/ublas/test/utils.hpp" + + +BOOST_UBLAS_TEST_DEF( test_row_major_matrix_container ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Row-major Matrix Container" ); + + typedef double value_type; + typedef boost::numeric::ublas::matrix matrix_type; + + matrix_type A(5,4); + + A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938; + A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283; + A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152; + A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332; + A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332; + + + BOOST_UBLAS_DEBUG_TRACE( "num_columns(A) = " << boost::numeric::ublas::num_columns(A) << " ==> " << A.size2() ); + BOOST_UBLAS_TEST_CHECK( boost::numeric::ublas::num_columns(A) == A.size2() ); +} + + +BOOST_UBLAS_TEST_DEF( test_col_major_matrix_container ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Column-major Matrix Container" ); + + typedef double value_type; + typedef boost::numeric::ublas::matrix matrix_type; + + matrix_type A(5,4); + + A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938; + A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283; + A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152; + A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332; + A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332; + + + BOOST_UBLAS_DEBUG_TRACE( "num_columns(A) = " << boost::numeric::ublas::num_columns(A) << " ==> " << A.size2() ); + BOOST_UBLAS_TEST_CHECK( boost::numeric::ublas::num_columns(A) == A.size2() ); +} + + +BOOST_UBLAS_TEST_DEF( test_matrix_expression ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Matrix Expression" ); + + typedef double value_type; + typedef boost::numeric::ublas::matrix matrix_type; + + matrix_type A(5,4); + + A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938; + A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283; + A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152; + A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332; + A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332; + + + BOOST_UBLAS_DEBUG_TRACE( "num_columns(A') = " << boost::numeric::ublas::num_columns(boost::numeric::ublas::trans(A)) << " ==> " << boost::numeric::ublas::trans(A).size2() ); + BOOST_UBLAS_TEST_CHECK( boost::numeric::ublas::num_columns(boost::numeric::ublas::trans(A)) == boost::numeric::ublas::trans(A).size2() ); +} + + +BOOST_UBLAS_TEST_DEF( test_matrix_reference ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Matrix Reference" ); + + typedef double value_type; + typedef boost::numeric::ublas::matrix matrix_type; + typedef boost::numeric::ublas::matrix_reference matrix_reference_type; + + matrix_type A(5,4); + + A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938; + A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283; + A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152; + A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332; + A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332; + + + BOOST_UBLAS_DEBUG_TRACE( "num_columns(reference(A)) = " << boost::numeric::ublas::num_columns(matrix_reference_type(A)) << " ==> " << matrix_reference_type(A).size2() ); + BOOST_UBLAS_TEST_CHECK( boost::numeric::ublas::num_columns(matrix_reference_type(A)) == matrix_reference_type(A).size2() ); +} + + +int main() +{ + BOOST_UBLAS_TEST_BEGIN(); + + BOOST_UBLAS_TEST_DO( test_row_major_matrix_container ); + BOOST_UBLAS_TEST_DO( test_col_major_matrix_container ); + BOOST_UBLAS_TEST_DO( test_matrix_expression ); + BOOST_UBLAS_TEST_DO( test_matrix_reference ); + + BOOST_UBLAS_TEST_END(); +} diff --git a/test/num_rows.cpp b/test/num_rows.cpp new file mode 100644 index 00000000..f0146608 --- /dev/null +++ b/test/num_rows.cpp @@ -0,0 +1,106 @@ +/** -*- c++ -*- \file num_rows.hpp \file Test the \c num_rows operation. */ + +#include +#include +#include +#include +#include +#include "libs/numeric/ublas/test/utils.hpp" + + +BOOST_UBLAS_TEST_DEF( test_row_major_matrix_container ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Row-major Matrix Container" ); + + typedef double value_type; + typedef boost::numeric::ublas::matrix matrix_type; + + matrix_type A(5,4); + + A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938; + A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283; + A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152; + A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332; + A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332; + + + BOOST_UBLAS_DEBUG_TRACE( "num_rows(A) = " << boost::numeric::ublas::num_rows(A) << " ==> " << A.size1() ); + BOOST_UBLAS_TEST_CHECK( boost::numeric::ublas::num_rows(A) == A.size1() ); +} + + +BOOST_UBLAS_TEST_DEF( test_col_major_matrix_container ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Column-major Matrix Container" ); + + typedef double value_type; + typedef boost::numeric::ublas::matrix matrix_type; + + matrix_type A(5,4); + + A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938; + A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283; + A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152; + A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332; + A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332; + + + BOOST_UBLAS_DEBUG_TRACE( "num_rows(A) = " << boost::numeric::ublas::num_rows(A) << " ==> " << A.size1() ); + BOOST_UBLAS_TEST_CHECK( boost::numeric::ublas::num_rows(A) == A.size1() ); +} + + +BOOST_UBLAS_TEST_DEF( test_matrix_expression ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Matrix Expression" ); + + typedef double value_type; + typedef boost::numeric::ublas::matrix matrix_type; + + matrix_type A(5,4); + + A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938; + A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283; + A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152; + A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332; + A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332; + + + BOOST_UBLAS_DEBUG_TRACE( "num_rows(A') = " << boost::numeric::ublas::num_rows(boost::numeric::ublas::trans(A)) << " ==> " << boost::numeric::ublas::trans(A).size1() ); + BOOST_UBLAS_TEST_CHECK( boost::numeric::ublas::num_rows(boost::numeric::ublas::trans(A)) == boost::numeric::ublas::trans(A).size1() ); +} + + +BOOST_UBLAS_TEST_DEF( test_matrix_reference ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Matrix Reference" ); + + typedef double value_type; + typedef boost::numeric::ublas::matrix matrix_type; + typedef boost::numeric::ublas::matrix_reference matrix_reference_type; + + matrix_type A(5,4); + + A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938; + A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283; + A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152; + A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332; + A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332; + + + BOOST_UBLAS_DEBUG_TRACE( "num_rows(reference(A)) = " << boost::numeric::ublas::num_rows(matrix_reference_type(A)) << " ==> " << matrix_reference_type(A).size1() ); + BOOST_UBLAS_TEST_CHECK( boost::numeric::ublas::num_rows(matrix_reference_type(A)) == matrix_reference_type(A).size1() ); +} + + +int main() +{ + BOOST_UBLAS_TEST_BEGIN(); + + BOOST_UBLAS_TEST_DO( test_row_major_matrix_container ); + BOOST_UBLAS_TEST_DO( test_col_major_matrix_container ); + BOOST_UBLAS_TEST_DO( test_matrix_expression ); + BOOST_UBLAS_TEST_DO( test_matrix_reference ); + + BOOST_UBLAS_TEST_END(); +} diff --git a/test/size.cpp b/test/size.cpp new file mode 100644 index 00000000..327081dd --- /dev/null +++ b/test/size.cpp @@ -0,0 +1,271 @@ +/** -*- c++ -*- \file size.hpp \brief Test the \c size operation. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "libs/numeric/ublas/test/utils.hpp" + + +BOOST_UBLAS_TEST_DEF( test_vector_container ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Vector Container" ); + + typedef double value_type; + typedef boost::numeric::ublas::vector vector_type; + + vector_type v(5); + + v(0) = 0.555950; + v(1) = 0.108929; + v(2) = 0.948014; + v(3) = 0.023787; + v(4) = 1.023787; + + + // size(v) + BOOST_UBLAS_DEBUG_TRACE( "size(v) = " << boost::numeric::ublas::size(v) << " ==> " << v.size() ); + BOOST_UBLAS_TEST_CHECK( boost::numeric::ublas::size(v) == v.size() ); + + // size<1>(v) + BOOST_UBLAS_DEBUG_TRACE( "size<1>(v) = " << (boost::numeric::ublas::size<1>(v)) << " ==> " << v.size() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size<1>(v) == v.size()) ); + + // [NOT_COMPILE]: this should *correctly* cause a compilation error + // size<2>(v) + //BOOST_UBLAS_DEBUG_TRACE( "size<2>(v) = " << (boost::numeric::ublas::size(v)) << " ==> " << v.size() ); + //BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size<2>(v) == v.size()) ); + // [/NOT_COMPILE] +} + + +BOOST_UBLAS_TEST_DEF( test_vector_expression ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Vector Expression" ); + + typedef double value_type; + typedef boost::numeric::ublas::vector vector_type; + + vector_type v(5); + + v(0) = 0.555950; + v(1) = 0.108929; + v(2) = 0.948014; + v(3) = 0.023787; + v(4) = 1.023787; + + + // size(-v) + BOOST_UBLAS_DEBUG_TRACE( "size(-v) = " << boost::numeric::ublas::size(-v) << " ==> " << (-v).size() ); + BOOST_UBLAS_TEST_CHECK( boost::numeric::ublas::size(-v) == (-v).size() ); + + // size<1>(-v) + BOOST_UBLAS_DEBUG_TRACE( "size<1>(-v) = " << (boost::numeric::ublas::size<1>(-v)) << " ==> " << (-v).size() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size<1>(-v) == (-v).size()) ); +} + + +BOOST_UBLAS_TEST_DEF( test_vector_reference ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Vector Reference" ); + + typedef double value_type; + typedef boost::numeric::ublas::vector vector_type; + typedef boost::numeric::ublas::vector_reference vector_reference_type; + + vector_type v(5); + + v(0) = 0.555950; + v(1) = 0.108929; + v(2) = 0.948014; + v(3) = 0.023787; + v(4) = 1.023787; + + + // size(reference(v) + BOOST_UBLAS_DEBUG_TRACE( "size(reference(v)) = " << boost::numeric::ublas::size(vector_reference_type(v)) << " ==> " << vector_reference_type(v).size() ); + BOOST_UBLAS_TEST_CHECK( boost::numeric::ublas::size(vector_reference_type(v)) == vector_reference_type(v).size() ); + + // size<1>(reference(v)) + BOOST_UBLAS_DEBUG_TRACE( "size<1>(reference(v)) = " << (boost::numeric::ublas::size<1>(vector_reference_type(v))) << " ==> " << vector_reference_type(v).size() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size<1>(vector_reference_type(v)) == vector_reference_type(v).size()) ); +} + + +BOOST_UBLAS_TEST_DEF( test_row_major_matrix_container ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Row-major Matrix Container" ); + + typedef double value_type; + typedef boost::numeric::ublas::matrix matrix_type; + + matrix_type A(5,4); + + A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938; + A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283; + A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152; + A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332; + A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332; + + + // [NOT_COMPILE] + // size(A) + //BOOST_UBLAS_DEBUG_TRACE( "size(A) = " << boost::numeric::ublas::size(A) << " ==> " << A.size1() ); + //BOOST_UBLAS_TEST_CHECK( boost::numeric::ublas::size(A) == A.size1() ); + // [/NOT_COMPILE] + + // size<1>(A) + BOOST_UBLAS_DEBUG_TRACE( "size<1>(A) = " << (boost::numeric::ublas::size<1>(A)) << " ==> " << A.size1() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size<1>(A) == A.size1()) ); + + // size<2>(A) + BOOST_UBLAS_DEBUG_TRACE( "size<2>(A) = " << (boost::numeric::ublas::size<2>(A)) << " ==> " << A.size2() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size<2>(A) == A.size2()) ); + + // size(A) + BOOST_UBLAS_DEBUG_TRACE( "size(A) = " << (boost::numeric::ublas::size(A)) << " ==> " << A.size1() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size(A) == A.size1()) ); + + // size(A) + BOOST_UBLAS_DEBUG_TRACE( "size(A) = " << (boost::numeric::ublas::size(A)) << " ==> " << A.size2() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size(A) == A.size2()) ); + + // size(A) + BOOST_UBLAS_DEBUG_TRACE( "size(A) = " << (boost::numeric::ublas::size(A)) << " ==> " << A.size2() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size(A) == A.size2()) ); +} + + +BOOST_UBLAS_TEST_DEF( test_col_major_matrix_container ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Column-major Matrix Container" ); + + typedef double value_type; + typedef boost::numeric::ublas::matrix matrix_type; + + matrix_type A(5,4); + + A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938; + A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283; + A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152; + A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332; + A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332; + + + // size<1>(A) + BOOST_UBLAS_DEBUG_TRACE( "size<1>(A) = " << (boost::numeric::ublas::size<1>(A)) << " ==> " << A.size1() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size<1>(A) == A.size1()) ); + + // size<2>(A) + BOOST_UBLAS_DEBUG_TRACE( "size<2>(A) = " << (boost::numeric::ublas::size<2>(A)) << " ==> " << A.size2() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size<2>(A) == A.size2()) ); + + // size(A) + BOOST_UBLAS_DEBUG_TRACE( "size(A) = " << (boost::numeric::ublas::size(A)) << " ==> " << A.size2() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size(A) == A.size2()) ); + + // size(A) + BOOST_UBLAS_DEBUG_TRACE( "size(A) = " << (boost::numeric::ublas::size(A)) << " ==> " << A.size1() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size(A) == A.size1()) ); + + // size(A) + BOOST_UBLAS_DEBUG_TRACE( "size(A) = " << (boost::numeric::ublas::size(A)) << " ==> " << A.size1() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size(A) == A.size1()) ); +} + + +BOOST_UBLAS_TEST_DEF( test_matrix_expression ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Matrix Expression" ); + + typedef double value_type; + typedef boost::numeric::ublas::matrix matrix_type; + + matrix_type A(5,4); + + A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938; + A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283; + A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152; + A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332; + A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332; + + + // size<1>(A') + BOOST_UBLAS_DEBUG_TRACE( "size<1>(A') = " << (boost::numeric::ublas::size<1>(boost::numeric::ublas::trans(A))) << " ==> " << A.size2() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size<1>(boost::numeric::ublas::trans(A)) == A.size2()) ); + + // size<2>(A') + BOOST_UBLAS_DEBUG_TRACE( "size<2>(A') = " << (boost::numeric::ublas::size<2>(boost::numeric::ublas::trans(A))) << " ==> " << A.size1() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size<2>(boost::numeric::ublas::trans(A)) == A.size1()) ); + + // size(A') [A is row-major => A' column-major, and viceversa] + BOOST_UBLAS_DEBUG_TRACE( "size(A') = " << (boost::numeric::ublas::size(boost::numeric::ublas::trans(A))) << " ==> " << A.size1() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size(boost::numeric::ublas::trans(A)) == A.size1()) ); + + // size(A') [A is row-major => A' column-major, and viceversa] + BOOST_UBLAS_DEBUG_TRACE( "size(A') = " << (boost::numeric::ublas::size(boost::numeric::ublas::trans(A))) << " ==> " << A.size2() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size(boost::numeric::ublas::trans(A)) == A.size2()) ); + + // size(A') [A row-major => A' column-major, and viceversa] + BOOST_UBLAS_DEBUG_TRACE( "size(A') = " << (boost::numeric::ublas::size(boost::numeric::ublas::trans(A))) << " ==> " << A.size2() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size(boost::numeric::ublas::trans(A)) == A.size2()) ); +} + + +BOOST_UBLAS_TEST_DEF( test_matrix_reference ) +{ + BOOST_UBLAS_DEBUG_TRACE( "TEST Matrix Reference" ); + + typedef double value_type; + typedef boost::numeric::ublas::matrix matrix_type; + typedef boost::numeric::ublas::matrix_reference matrix_reference_type; + + matrix_type A(5,4); + + A(0,0) = 0.555950; A(0,1) = 0.274690; A(0,2) = 0.540605; A(0,3) = 0.798938; + A(1,0) = 0.108929; A(1,1) = 0.830123; A(1,2) = 0.891726; A(1,3) = 0.895283; + A(2,0) = 0.948014; A(2,1) = 0.973234; A(2,2) = 0.216504; A(2,3) = 0.883152; + A(3,0) = 0.023787; A(3,1) = 0.675382; A(3,2) = 0.231751; A(3,3) = 0.450332; + A(4,0) = 1.023787; A(4,1) = 1.675382; A(4,2) = 1.231751; A(4,3) = 1.450332; + + + // size<1>(reference(A)) + BOOST_UBLAS_DEBUG_TRACE( "size<1>(reference(A)) = " << (boost::numeric::ublas::size<1>(matrix_reference_type(A))) << " ==> " << matrix_reference_type(A).size1() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size<1>(matrix_reference_type(A)) == matrix_reference_type(A).size1()) ); + + // size<2>(reference(A)) + BOOST_UBLAS_DEBUG_TRACE( "size<2>(reference(A)) = " << (boost::numeric::ublas::size<2>(matrix_reference_type(A))) << " ==> " << matrix_reference_type(A).size2() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size<2>(matrix_reference_type(A)) == matrix_reference_type(A).size2()) ); + + // size(reference(A)) + BOOST_UBLAS_DEBUG_TRACE( "size(reference(A) = " << (boost::numeric::ublas::size(matrix_reference_type(A))) << " ==> " << matrix_reference_type(A).size1() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size(matrix_reference_type(A)) == matrix_reference_type(A).size1()) ); + + // size(reference(A)) + BOOST_UBLAS_DEBUG_TRACE( "size(reference(A)) = " << (boost::numeric::ublas::size(matrix_reference_type(A))) << " ==> " << matrix_reference_type(A).size2() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size(matrix_reference_type(A)) == matrix_reference_type(A).size2()) ); + + // size(reference(A)) + BOOST_UBLAS_DEBUG_TRACE( "size(reference(A)) = " << (boost::numeric::ublas::size(matrix_reference_type(A))) << " ==> " << matrix_reference_type(A).size2() ); + BOOST_UBLAS_TEST_CHECK( (boost::numeric::ublas::size(matrix_reference_type(A)) == matrix_reference_type(A).size2()) ); +} + + +int main() +{ + BOOST_UBLAS_TEST_BEGIN(); + + BOOST_UBLAS_TEST_DO( test_vector_container ); + BOOST_UBLAS_TEST_DO( test_vector_expression ); + BOOST_UBLAS_TEST_DO( test_vector_reference ); + BOOST_UBLAS_TEST_DO( test_row_major_matrix_container ); + BOOST_UBLAS_TEST_DO( test_col_major_matrix_container ); + BOOST_UBLAS_TEST_DO( test_matrix_expression ); + BOOST_UBLAS_TEST_DO( test_matrix_reference ); + + BOOST_UBLAS_TEST_END(); +} diff --git a/test/utils.hpp b/test/utils.hpp new file mode 100644 index 00000000..5f67e116 --- /dev/null +++ b/test/utils.hpp @@ -0,0 +1,33 @@ +/** -*- c++ -*- \file utils.hpp \brief Test utilities. */ + +#ifndef TEST_UTILS_HPP +#define TEST_UTILS_HPP + + +#include + + +#define EXPAND_(x) x + +#define STRINGIFY_(x) #x + +#define JOIN_(x,y) x ## y + +#ifndef NDEBUG +# define BOOST_UBLAS_DEBUG_TRACE(x) std::cerr << "[Debug>> " << EXPAND_(x) << std::endl +#else +# 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 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; } + +#define BOOST_UBLAS_TEST_CHECK(x) if (!(x)) { std::cerr << "Failed assertion: " << STRINGIFY_(x) << std::endl; ++test_fails_; } + + +#endif // TEST_UTILS_HPP