Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52145 - in branches/release/boost/numeric/ublas: . detail
From: guwi17_at_[hidden]
Date: 2009-04-02 18:15:11


Author: guwi17
Date: 2009-04-02 18:15:10 EDT (Thu, 02 Apr 2009)
New Revision: 52145
URL: http://svn.boost.org/trac/boost/changeset/52145

Log:
ublas/expression_types.hpp: added typedef ublas_expression::self_type
ublas/fwd.hpp: added default template arguments to declaration of generalized_vector_of_vector
ublas/lu.hpp: added constructor from vector to permutation_matrix
ublas/storage.hpp: fix #2891
ublas/detail/concepts.hpp: added documentation and some missing concept checks

ublas/traits.hpp:
  added new traits classes: container_traits, matrix_traits, vector_traits
  they work for all ublas classes and c-arrays (T[M][N] and T[M])

ublas/functional.hpp:
  added triangular type tags
  fix #2800
  added my name to copyright message

Text files modified:
   branches/release/boost/numeric/ublas/detail/concepts.hpp | 27 +++++++++++++
   branches/release/boost/numeric/ublas/expression_types.hpp | 2
   branches/release/boost/numeric/ublas/functional.hpp | 26 +++++++++--
   branches/release/boost/numeric/ublas/fwd.hpp | 3 +
   branches/release/boost/numeric/ublas/lu.hpp | 6 ++
   branches/release/boost/numeric/ublas/storage.hpp | 4
   branches/release/boost/numeric/ublas/traits.hpp | 83 ++++++++++++++++++++++++++++++++++++++++
   7 files changed, 143 insertions(+), 8 deletions(-)

Modified: branches/release/boost/numeric/ublas/detail/concepts.hpp
==============================================================================
--- branches/release/boost/numeric/ublas/detail/concepts.hpp (original)
+++ branches/release/boost/numeric/ublas/detail/concepts.hpp 2009-04-02 18:15:10 EDT (Thu, 02 Apr 2009)
@@ -237,11 +237,22 @@
         }
     };
 
+ /** \brief Scalar expression concept.
+ *
+ * requirements
+ * \li \c SE::value_type is the type of the scalar expression
+ * \li \c SE must be convertable to \c SE::value_type
+ * \li the constant \c SE::complexity must exist
+ *
+ * \param SE the type of the scalar expression
+ */
     template<class SE>
     struct ScalarExpressionConcept {
         typedef SE scalar_expression_type;
         typedef typename SE::value_type value_type;
 
+ static const unsigned complexity = SE::complexity;
+
         void constraints () {
             scalar_expression_type *sp;
             scalar_expression_type s = *sp;
@@ -252,12 +263,28 @@
         }
     };
 
+ /** \brief Vector expression concept.
+ *
+ * requirements
+ * \li \c VE::value_type is the type of the elements
+ * \li \c VE::const_reference The return type when accessing an element of a constant vector
+ * expression. Must be convertable to a \c value_type.
+ * \li \c VE::size_type is the (unsigned) type of the indices
+ * \li \c VE::difference_type is the (signed) type of distances between indices
+ * \li \c VE::category
+ *
+ * \li the constant \c SE::complexity must exist
+ *
+ * \param SE the type of the scalar expression
+ */
     template<class VE>
     struct VectorExpressionConcept {
         typedef VE vector_expression_type;
         typedef typename VE::type_category type_category;
         typedef typename VE::size_type size_type;
+ typedef typename VE::difference_type difference_type;
         typedef typename VE::value_type value_type;
+ typedef typename VE::const_reference const_reference;
         typedef typename VE::const_iterator const_iterator_type;
         typedef typename VE::const_reverse_iterator const_reverse_iterator_type;
 

Modified: branches/release/boost/numeric/ublas/expression_types.hpp
==============================================================================
--- branches/release/boost/numeric/ublas/expression_types.hpp (original)
+++ branches/release/boost/numeric/ublas/expression_types.hpp 2009-04-02 18:15:10 EDT (Thu, 02 Apr 2009)
@@ -291,6 +291,8 @@
     template<class E>
     class matrix_expression:
         public ublas_expression<E> {
+ private:
+ typedef matrix_expression<E> self_type;
     public:
         static const unsigned complexity = 0;
         typedef E expression_type;

Modified: branches/release/boost/numeric/ublas/functional.hpp
==============================================================================
--- branches/release/boost/numeric/ublas/functional.hpp (original)
+++ branches/release/boost/numeric/ublas/functional.hpp 2009-04-02 18:15:10 EDT (Thu, 02 Apr 2009)
@@ -1,6 +1,6 @@
 //
-// Copyright (c) 2000-2002
-// Joerg Walter, Mathias Koch
+// Copyright (c) 2000-2009
+// Joerg Walter, Mathias Koch, Gunter Winkler
 //
 // Distributed under the Boost Software License, Version 1.0. (See
 // accompanying file LICENSE_1_0.txt or copy at
@@ -1343,6 +1343,9 @@
         }
     };
 
+ // forward declaration
+ template <class Z, class D> struct basic_column_major;
+
     // This functor defines storage layout and it's properties
     // matrix (i,j) -> storage [i * size_i + j]
     template <class Z, class D>
@@ -1350,6 +1353,7 @@
         typedef Z size_type;
         typedef D difference_type;
         typedef row_major_tag orientation_category;
+ typedef basic_column_major<Z,D> transposed_layout;
 
         static
         BOOST_UBLAS_INLINE
@@ -1527,6 +1531,7 @@
         typedef Z size_type;
         typedef D difference_type;
         typedef column_major_tag orientation_category;
+ typedef basic_row_major<Z,D> transposed_layout;
 
         static
         BOOST_UBLAS_INLINE
@@ -1776,7 +1781,7 @@
             static
             BOOST_UBLAS_INLINE
             size_type element (LAYOUT l, size_type i, size_type size_i, size_type j, size_type size_j) {
- return L::element(l, j, size_j, i, size_i);
+ return L::element(typename LAYOUT::transposed_layout(), j, size_j, i, size_i);
             }
 
             static
@@ -1826,6 +1831,7 @@
     template <class Z>
     struct basic_lower {
         typedef Z size_type;
+ typedef lower_tag triangular_type;
 
         template<class L>
         static
@@ -1912,6 +1918,7 @@
     template <class Z>
     struct basic_unit_lower : public basic_lower<Z> {
         typedef Z size_type;
+ typedef unit_lower_tag triangular_type;
 
         template<class L>
         static
@@ -1971,6 +1978,7 @@
     template <class Z>
     struct basic_strict_lower : public basic_unit_lower<Z> {
         typedef Z size_type;
+ typedef strict_lower_tag triangular_type;
 
         template<class L>
         static
@@ -2033,15 +2041,21 @@
 
     template <class Z>
     struct basic_upper : public detail::transposed_structure<basic_lower<Z> >
- { };
+ {
+ typedef upper_tag triangular_type;
+ };
 
     template <class Z>
     struct basic_unit_upper : public detail::transposed_structure<basic_unit_lower<Z> >
- { };
+ {
+ typedef unit_upper_tag triangular_type;
+ };
 
     template <class Z>
     struct basic_strict_upper : public detail::transposed_structure<basic_strict_lower<Z> >
- { };
+ {
+ typedef strict_upper_tag triangular_type;
+ };
 
 
 }}}

Modified: branches/release/boost/numeric/ublas/fwd.hpp
==============================================================================
--- branches/release/boost/numeric/ublas/fwd.hpp (original)
+++ branches/release/boost/numeric/ublas/fwd.hpp 2009-04-02 18:15:10 EDT (Thu, 02 Apr 2009)
@@ -139,6 +139,9 @@
     template<class T, class L = row_major, class A = unbounded_array<unbounded_array<T> > >
     class vector_of_vector;
 
+ template<class T, class L = row_major, class A = vector<compressed_vector<T> > >
+ class generalized_vector_of_vector;
+
     // Triangular matrix type
     struct lower_tag {};
     struct upper_tag {};

Modified: branches/release/boost/numeric/ublas/lu.hpp
==============================================================================
--- branches/release/boost/numeric/ublas/lu.hpp (original)
+++ branches/release/boost/numeric/ublas/lu.hpp 2009-04-02 18:15:10 EDT (Thu, 02 Apr 2009)
@@ -32,12 +32,18 @@
 
         // Construction and destruction
         BOOST_UBLAS_INLINE
+ explicit
         permutation_matrix (size_type size):
             vector<T, A> (size) {
             for (size_type i = 0; i < size; ++ i)
                 (*this) (i) = i;
         }
         BOOST_UBLAS_INLINE
+ explicit
+ permutation_matrix (const vector_type & init)
+ : vector_type(init)
+ { }
+ BOOST_UBLAS_INLINE
         ~permutation_matrix () {}
 
         // Assignment

Modified: branches/release/boost/numeric/ublas/storage.hpp
==============================================================================
--- branches/release/boost/numeric/ublas/storage.hpp (original)
+++ branches/release/boost/numeric/ublas/storage.hpp 2009-04-02 18:15:10 EDT (Thu, 02 Apr 2009)
@@ -340,12 +340,12 @@
         // Resizing
         BOOST_UBLAS_INLINE
         void resize (size_type size) {
- BOOST_UBLAS_CHECK (size_ <= N, bad_size ());
+ BOOST_UBLAS_CHECK (size <= N, bad_size ());
             size_ = size;
         }
         BOOST_UBLAS_INLINE
         void resize (size_type size, value_type init) {
- BOOST_UBLAS_CHECK (size_ <= N, bad_size ());
+ BOOST_UBLAS_CHECK (size <= N, bad_size ());
             if (size > size_)
                 std::fill (data_ + size_, data_ + size, init);
             size_ = size;

Modified: branches/release/boost/numeric/ublas/traits.hpp
==============================================================================
--- branches/release/boost/numeric/ublas/traits.hpp (original)
+++ branches/release/boost/numeric/ublas/traits.hpp 2009-04-02 18:15:10 EDT (Thu, 02 Apr 2009)
@@ -511,6 +511,89 @@
 
     }
 
+
+ /** \brief Traits class to extract type information from a matrix or vector CONTAINER.
+ *
+ */
+ template < class E >
+ struct container_traits {
+ /// type of indices
+ typedef typename E::size_type size_type;
+ /// type of differences of indices
+ typedef typename E::difference_type difference_type;
+
+ /// storage category: \c unknown_storage_tag, \c dense_tag, \c packed_tag, ...
+ typedef typename E::storage_category storage_category;
+
+ /// type of elements
+ typedef typename E::value_type value_type;
+ /// reference to an element
+ typedef typename E::reference reference;
+ /// const reference to an element
+ typedef typename E::const_reference const_reference;
+
+ /// type used in expressions to mark a reference to this class (usually a container_reference<E> or the class itself)
+ typedef typename E::closure_type closure_type;
+ /// type used in expressions to mark a reference to this class (usually a const container_reference<const E> or the class itself)
+ typedef typename E::const_closure_type const_closure_type;
+ };
+
+ /** \brief Traits class to extract type information from a MATRIX.
+ *
+ */
+ template < class MATRIX >
+ struct matrix_traits : container_traits <MATRIX> {
+
+ /// orientation of the matrix, either \c row_major_tag, \c column_major_tag or \c unknown_orientation_tag
+ typedef typename MATRIX::orientation_category orientation_category;
+
+ };
+
+ /** \brief Traits class to extract type information from a VECTOR.
+ *
+ */
+ template < class VECTOR >
+ struct vector_traits : container_traits <VECTOR> {
+
+ };
+
+ template < class T, int M, int N >
+ struct matrix_traits < T[M][N] > {
+ typedef T matrix_type[M][N];
+
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+
+ typedef row_major_tag orientation_category;
+ typedef dense_tag storage_category;
+
+ typedef T value_type;
+ typedef T *reference;
+ typedef const T *const_reference;
+
+ // \todo { define correct wrapper }
+ typedef matrix_reference<matrix_type> closure_type;
+ typedef const matrix_reference<const matrix_type> const_closure_type;
+ };
+
+ template < class T, int N >
+ struct vector_traits < T[N] > {
+ typedef T vector_type[N];
+
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+
+ typedef dense_tag storage_category;
+
+ typedef T value_type;
+ typedef T *reference;
+ typedef const T *const_reference;
+
+ // \todo { define correct wrapper }
+ typedef vector_reference<vector_type> closure_type;
+ typedef const vector_reference<const vector_type> const_closure_type;
+ };
+
 }}}
 
 #endif


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