diff --git a/include/boost/numeric/ublas/banded.hpp b/include/boost/numeric/ublas/banded.hpp index 2ca572d2..a42c8617 100644 --- a/include/boost/numeric/ublas/banded.hpp +++ b/include/boost/numeric/ublas/banded.hpp @@ -38,13 +38,12 @@ namespace boost { namespace numeric { namespace ublas { typedef T value_type; typedef const T &const_reference; typedef T &reference; - typedef const T *const_pointer; - typedef T *pointer; - typedef F functor_type; typedef A array_type; - typedef const A const_array_type; + private: + typedef F functor_type; typedef const banded_matrix const_self_type; typedef banded_matrix self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const matrix_const_reference const_closure_type; #else @@ -104,7 +103,7 @@ namespace boost { namespace numeric { namespace ublas { return upper_; } BOOST_UBLAS_INLINE - const_array_type &data () const { + const array_type &data () const { return data_; } BOOST_UBLAS_INLINE @@ -197,13 +196,6 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - banded_matrix &reset (const matrix_expression &ae) { - self_type temporary (ae, lower_, upper_); - resize (temporary.size1 (), temporary.size2 (), lower_, upper_, false); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE banded_matrix &assign (const matrix_expression &ae) { matrix_assign (scalar_assign (), *this, ae); return *this; @@ -326,6 +318,7 @@ namespace boost { namespace numeric { namespace ublas { std::fill (data ().begin (), data ().end (), value_type (0)); } + // Iterator types #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_iterator1 iterator1; typedef indexed_iterator2 iterator2; @@ -403,10 +396,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename banded_matrix::difference_type difference_type; typedef typename banded_matrix::value_type value_type; + typedef typename banded_matrix::difference_type difference_type; typedef typename banded_matrix::const_reference reference; - typedef typename banded_matrix::const_pointer pointer; + typedef const typename banded_matrix::value_type *pointer; #endif typedef const_iterator2 dual_iterator_type; typedef const_reverse_iterator2 dual_reverse_iterator_type; @@ -543,10 +536,10 @@ namespace boost { namespace numeric { namespace ublas { public: typedef packed_random_access_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename banded_matrix::difference_type difference_type; typedef typename banded_matrix::value_type value_type; + typedef typename banded_matrix::difference_type difference_type; typedef typename banded_matrix::reference reference; - typedef typename banded_matrix::pointer pointer; + typedef typename banded_matrix::value_type *pointer; #endif typedef iterator2 dual_iterator_type; typedef reverse_iterator2 dual_reverse_iterator_type; @@ -684,10 +677,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename banded_matrix::difference_type difference_type; typedef typename banded_matrix::value_type value_type; + typedef typename banded_matrix::difference_type difference_type; typedef typename banded_matrix::const_reference reference; - typedef typename banded_matrix::const_pointer pointer; + typedef const typename banded_matrix::value_type *pointer; #endif typedef const_iterator1 dual_iterator_type; typedef const_reverse_iterator1 dual_reverse_iterator_type; @@ -824,10 +817,10 @@ namespace boost { namespace numeric { namespace ublas { public: typedef packed_random_access_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename banded_matrix::difference_type difference_type; typedef typename banded_matrix::value_type value_type; + typedef typename banded_matrix::difference_type difference_type; typedef typename banded_matrix::reference reference; - typedef typename banded_matrix::pointer pointer; + typedef typename banded_matrix::value_type *pointer; #endif typedef iterator1 dual_iterator_type; typedef reverse_iterator1 dual_reverse_iterator_type; @@ -1065,17 +1058,11 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS typedef typename M::const_reference const_reference; typedef typename M::reference reference; - typedef typename M::const_pointer const_pointer; - typedef typename M::pointer pointer; #else typedef typename M::const_reference const_reference; typedef typename boost::mpl::if_, typename M::const_reference, typename M::reference>::type reference; - typedef typename M::const_pointer const_pointer; - typedef typename boost::mpl::if_, - typename M::const_pointer, - typename M::pointer>::type pointer; #endif #ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS typedef typename M::closure_type matrix_closure_type; @@ -1084,25 +1071,12 @@ namespace boost { namespace numeric { namespace ublas { typename M::const_closure_type, typename M::closure_type>::type matrix_closure_type; #endif + private: typedef const banded_adaptor const_self_type; typedef banded_adaptor self_type; + public: typedef const_self_type const_closure_type; typedef self_type closure_type; -#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS - typedef typename M::const_iterator1 const_iterator1_type; - typedef typename M::iterator1 iterator1_type; - typedef typename M::const_iterator2 const_iterator2_type; - typedef typename M::iterator2 iterator2_type; -#else - typedef typename M::const_iterator1 const_iterator1_type; - typedef typename boost::mpl::if_, - typename M::const_iterator1, - typename M::iterator1>::type iterator1_type; - typedef typename M::const_iterator2 const_iterator2_type; - typedef typename boost::mpl::if_, - typename M::const_iterator2, - typename M::iterator2>::type iterator2_type; -#endif typedef typename storage_restrict_traits::storage_category storage_category; typedef typename M::orientation_category orientation_category; @@ -1297,6 +1271,26 @@ namespace boost { namespace numeric { namespace ublas { } #endif + // Iterator types + private: + // Use the matrix iterator +#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS + typedef typename M::const_iterator1 const_iterator1_type; + typedef typename M::iterator1 iterator1_type; + typedef typename M::const_iterator2 const_iterator2_type; + typedef typename M::iterator2 iterator2_type; +#else + typedef typename M::const_iterator1 const_iterator1_type; + typedef typename boost::mpl::if_, + typename M::const_iterator1, + typename M::iterator1>::type iterator1_type; + typedef typename M::const_iterator2 const_iterator2_type; + typedef typename boost::mpl::if_, + typename M::const_iterator2, + typename M::iterator2>::type iterator2_type; +#endif + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_iterator1 iterator1; typedef indexed_iterator2 iterator2; @@ -1373,8 +1367,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename const_iterator1_type::difference_type difference_type; typedef typename const_iterator1_type::value_type value_type; + typedef typename const_iterator1_type::difference_type difference_type; typedef typename const_iterator1_type::reference reference; typedef typename const_iterator1_type::pointer pointer; #else @@ -1530,8 +1524,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename iterator1_type::difference_type difference_type; typedef typename iterator1_type::value_type value_type; + typedef typename iterator1_type::difference_type difference_type; typedef typename iterator1_type::reference reference; typedef typename iterator1_type::pointer pointer; #else @@ -1685,8 +1679,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename const_iterator2_type::difference_type difference_type; typedef typename const_iterator2_type::value_type value_type; + typedef typename const_iterator2_type::difference_type difference_type; typedef typename const_iterator2_type::reference reference; typedef typename const_iterator2_type::pointer pointer; #else @@ -1842,8 +1836,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename iterator2_type::difference_type difference_type; typedef typename iterator2_type::value_type value_type; + typedef typename iterator2_type::difference_type difference_type; typedef typename iterator2_type::reference reference; typedef typename iterator2_type::pointer pointer; #else diff --git a/include/boost/numeric/ublas/config.hpp b/include/boost/numeric/ublas/config.hpp index d681edd1..af39835f 100644 --- a/include/boost/numeric/ublas/config.hpp +++ b/include/boost/numeric/ublas/config.hpp @@ -318,16 +318,16 @@ bool disable_type_check::value = false; #define BOOST_UBLAS_NON_CONFORMANT_PROXIES // Enable different sparse element proxies -// These fix a [1] = a [0] = 1, but probably won't work on broken compilers. -// Thanks to Marc Duflot for spotting this. #ifndef BOOST_UBLAS_NO_ELEMENT_PROXIES +// Sparse proxies prevent reference invalidation problems in expressions such as: +// a [1] = a [0] = 1 Thanks to Marc Duflot for spotting this. // #define BOOST_UBLAS_STRICT_STORAGE_SPARSE #define BOOST_UBLAS_STRICT_VECTOR_SPARSE #define BOOST_UBLAS_STRICT_MATRIX_SPARSE +// Hermitian matrices use element proxies to allow assignment to conjugate triangle +#define BOOST_UBLAS_STRICT_HERMITIAN #endif -// Hermitian matrices can also use element proxies to allow assignment to conjugate triangle -// #define BOOST_UBLAS_STRICT_HERMITIAN // Define to enable compile time const propagation for reference, proxy and closure types diff --git a/include/boost/numeric/ublas/hermitian.hpp b/include/boost/numeric/ublas/hermitian.hpp index 1a59d931..3ca0a7ad 100644 --- a/include/boost/numeric/ublas/hermitian.hpp +++ b/include/boost/numeric/ublas/hermitian.hpp @@ -51,6 +51,7 @@ namespace boost { namespace numeric { namespace ublas { typedef M matrix_type; typedef typename M::size_type size_type; typedef typename M::value_type value_type; + typedef const value_type &const_reference; typedef value_type &reference; typedef value_type *pointer; @@ -60,7 +61,7 @@ namespace boost { namespace numeric { namespace ublas { container_reference (m), i_ (i), j_ (j), d_ (d), dirty_ (false) {} BOOST_UBLAS_INLINE hermitian_matrix_element (const hermitian_matrix_element &p): - container_reference (p), it_ (p.it_), i_ (p.i_), d_ (p.d_), dirty_ (p.dirty_) {} + container_reference (p), i_ (p.i_), d_ (p.d_), dirty_ (p.dirty_) {} BOOST_UBLAS_INLINE ~hermitian_matrix_element () { if (dirty_) @@ -68,23 +69,17 @@ namespace boost { namespace numeric { namespace ublas { } // Assignment - template - BOOST_UBLAS_INLINE - hermitian_matrix_element &operator = (const D &d) { - d_ = d; - dirty_ = true; - return *this; - } BOOST_UBLAS_INLINE hermitian_matrix_element &operator = (const hermitian_matrix_element &p) { + // Overide the implict copy assignment d_ = p.d_; dirty_ = true; return *this; } - template + template BOOST_UBLAS_INLINE - hermitian_matrix_element &operator = (const hermitian_matrix_element &p) { - d_ = value_type (p); + hermitian_matrix_element &operator = (const D &d) { + d_ = d; dirty_ = true; return *this; } @@ -95,19 +90,6 @@ namespace boost { namespace numeric { namespace ublas { dirty_ = true; return *this; } - BOOST_UBLAS_INLINE - hermitian_matrix_element &operator += (const hermitian_matrix_element &p) { - d_ += p.d_; - dirty_ = true; - return *this; - } - template - BOOST_UBLAS_INLINE - hermitian_matrix_element &operator += (const hermitian_matrix_element &p) { - d_ += value_type (p); - dirty_ = true; - return *this; - } template BOOST_UBLAS_INLINE hermitian_matrix_element &operator -= (const D &d) { @@ -115,19 +97,6 @@ namespace boost { namespace numeric { namespace ublas { dirty_ = true; return *this; } - BOOST_UBLAS_INLINE - hermitian_matrix_element &operator -= (const hermitian_matrix_element &p) { - d_ -= p.d_; - dirty_ = true; - return *this; - } - template - BOOST_UBLAS_INLINE - hermitian_matrix_element &operator -= (const hermitian_matrix_element &p) { - d_ -= value_type (p); - dirty_ = true; - return *this; - } template BOOST_UBLAS_INLINE hermitian_matrix_element &operator *= (const D &d) { @@ -135,19 +104,6 @@ namespace boost { namespace numeric { namespace ublas { dirty_ = true; return *this; } - BOOST_UBLAS_INLINE - hermitian_matrix_element &operator *= (const hermitian_matrix_element &p) { - d_ *= p.d_; - dirty_ = true; - return *this; - } - template - BOOST_UBLAS_INLINE - hermitian_matrix_element &operator *= (const hermitian_matrix_element &p) { - d_ *= value_type (p); - dirty_ = true; - return *this; - } template BOOST_UBLAS_INLINE hermitian_matrix_element &operator /= (const D &d) { @@ -155,18 +111,17 @@ namespace boost { namespace numeric { namespace ublas { dirty_ = true; return *this; } + + // Comparison + template BOOST_UBLAS_INLINE - hermitian_matrix_element &operator /= (const hermitian_matrix_element &p) { - d_ /= p.d_; - dirty_ = true; - return *this; + bool operator == (const D &d) const { + return d_ == d; } - template + template BOOST_UBLAS_INLINE - hermitian_matrix_element &operator /= (const hermitian_matrix_element &p) { - d_ /= value_type (p); - dirty_ = true; - return *this; + bool operator != (const D &d) const { + return d_ != d; } // Conversion @@ -296,14 +251,13 @@ namespace boost { namespace numeric { namespace ublas { #else typedef hermitian_matrix_element > reference; #endif - typedef const T *const_pointer; - typedef T *pointer; + typedef A array_type; + private: typedef F1 functor1_type; typedef F2 functor2_type; - typedef const A const_array_type; - typedef A array_type; typedef const hermitian_matrix const_self_type; typedef hermitian_matrix self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const matrix_const_reference const_closure_type; #else @@ -356,7 +310,7 @@ namespace boost { namespace numeric { namespace ublas { return size_; } BOOST_UBLAS_INLINE - const_array_type &data () const { + const array_type &data () const { return data_; } BOOST_UBLAS_INLINE @@ -445,13 +399,6 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - hermitian_matrix &reset (const matrix_expression &ae) { - self_type temporary (ae); - resize (temporary.size1 (), temporary.size2 (), false); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE hermitian_matrix &assign (const matrix_expression &ae) { matrix_assign (scalar_assign (), *this, ae); return *this; @@ -567,6 +514,7 @@ namespace boost { namespace numeric { namespace ublas { std::fill (data ().begin (), data ().end (), value_type (0)); } + // Iterator types #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_iterator1 iterator1; typedef indexed_iterator2 iterator2; @@ -624,10 +572,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename hermitian_matrix::difference_type difference_type; typedef typename hermitian_matrix::value_type value_type; + typedef typename hermitian_matrix::difference_type difference_type; typedef typename hermitian_matrix::const_reference reference; - typedef typename hermitian_matrix::const_pointer pointer; + typedef const typename hermitian_matrix::value_type *pointer; #endif typedef const_iterator2 dual_iterator_type; typedef const_reverse_iterator2 dual_reverse_iterator_type; @@ -764,10 +712,10 @@ namespace boost { namespace numeric { namespace ublas { public: typedef packed_random_access_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename hermitian_matrix::difference_type difference_type; typedef typename hermitian_matrix::value_type value_type; + typedef typename hermitian_matrix::difference_type difference_type; typedef typename hermitian_matrix::reference reference; - typedef typename hermitian_matrix::pointer pointer; + typedef typename hermitian_matrix::value_type *pointer; #endif typedef iterator2 dual_iterator_type; typedef reverse_iterator2 dual_reverse_iterator_type; @@ -905,10 +853,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename hermitian_matrix::difference_type difference_type; typedef typename hermitian_matrix::value_type value_type; + typedef typename hermitian_matrix::difference_type difference_type; typedef typename hermitian_matrix::const_reference reference; - typedef typename hermitian_matrix::const_pointer pointer; + typedef const typename hermitian_matrix::value_type *pointer; #endif typedef const_iterator1 dual_iterator_type; typedef const_reverse_iterator1 dual_reverse_iterator_type; @@ -1045,10 +993,10 @@ namespace boost { namespace numeric { namespace ublas { public: typedef packed_random_access_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename hermitian_matrix::difference_type difference_type; typedef typename hermitian_matrix::value_type value_type; + typedef typename hermitian_matrix::difference_type difference_type; typedef typename hermitian_matrix::reference reference; - typedef typename hermitian_matrix::pointer pointer; + typedef typename hermitian_matrix::value_type *pointer; #endif typedef iterator1 dual_iterator_type; typedef reverse_iterator1 dual_reverse_iterator_type; @@ -1250,14 +1198,7 @@ namespace boost { namespace numeric { namespace ublas { #else typedef hermitian_matrix_element > reference; #endif - typedef typename M::const_pointer const_pointer; - typedef typename M::pointer pointer; #else - // FIXME: no better way to not return the address of a temporary? - // typedef typename M::const_reference const_reference; - // typedef typename boost::mpl::if_, - // typename M::const_reference, - // typename M::reference>::type reference; typedef typename M::value_type const_reference; #ifndef BOOST_UBLAS_STRICT_HERMITIAN typedef typename boost::mpl::if_, @@ -1268,10 +1209,6 @@ namespace boost { namespace numeric { namespace ublas { typename M::value_type, hermitian_matrix_element > >::type reference; #endif - typedef typename M::const_pointer const_pointer; - typedef typename boost::mpl::if_, - typename M::const_pointer, - typename M::pointer>::type pointer; #endif #ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS typedef typename M::closure_type matrix_closure_type; @@ -1280,25 +1217,12 @@ namespace boost { namespace numeric { namespace ublas { typename M::const_closure_type, typename M::closure_type>::type matrix_closure_type; #endif + private: typedef const hermitian_adaptor const_self_type; typedef hermitian_adaptor self_type; + public: typedef const_self_type const_closure_type; typedef self_type closure_type; -#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS - typedef typename M::const_iterator1 const_iterator1_type; - typedef typename M::iterator1 iterator1_type; - typedef typename M::const_iterator2 const_iterator2_type; - typedef typename M::iterator2 iterator2_type; -#else - typedef typename M::const_iterator1 const_iterator1_type; - typedef typename boost::mpl::if_, - typename M::const_iterator1, - typename M::iterator1>::type iterator1_type; - typedef typename M::const_iterator2 const_iterator2_type; - typedef typename boost::mpl::if_, - typename M::const_iterator2, - typename M::iterator2>::type iterator2_type; -#endif typedef typename storage_restrict_traits::storage_category storage_category; typedef typename F::packed_category packed_category; @@ -1506,6 +1430,26 @@ namespace boost { namespace numeric { namespace ublas { } #endif + // Iterator types + private: + // Use matrix iterator +#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS + typedef typename M::const_iterator1 const_iterator1_type; + typedef typename M::iterator1 iterator1_type; + typedef typename M::const_iterator2 const_iterator2_type; + typedef typename M::iterator2 iterator2_type; +#else + typedef typename M::const_iterator1 const_iterator1_type; + typedef typename boost::mpl::if_, + typename M::const_iterator1, + typename M::iterator1>::type iterator1_type; + typedef typename M::const_iterator2 const_iterator2_type; + typedef typename boost::mpl::if_, + typename M::const_iterator2, + typename M::iterator2>::type iterator2_type; +#endif + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_iterator1 iterator1; typedef indexed_iterator2 iterator2; @@ -1602,8 +1546,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename const_iterator1_type::difference_type difference_type; typedef typename const_iterator1_type::value_type value_type; + typedef typename const_iterator1_type::difference_type difference_type; // FIXME: no better way to not return the address of a temporary? // typedef typename const_iterator1_type::reference reference; typedef typename const_iterator1_type::value_type reference; @@ -1923,8 +1867,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename iterator1_type::difference_type difference_type; typedef typename iterator1_type::value_type value_type; + typedef typename iterator1_type::difference_type difference_type; typedef typename iterator1_type::reference reference; typedef typename iterator1_type::pointer pointer; #else @@ -2061,8 +2005,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename const_iterator2_type::difference_type difference_type; typedef typename const_iterator2_type::value_type value_type; + typedef typename const_iterator2_type::difference_type difference_type; // FIXME: no better way to not return the address of a temporary? // typedef typename const_iterator2_type::reference reference; typedef typename const_iterator2_type::value_type reference; @@ -2382,8 +2326,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename iterator2_type::difference_type difference_type; typedef typename iterator2_type::value_type value_type; + typedef typename iterator2_type::difference_type difference_type; typedef typename iterator2_type::reference reference; typedef typename iterator2_type::pointer pointer; #else diff --git a/include/boost/numeric/ublas/matrix.hpp b/include/boost/numeric/ublas/matrix.hpp index ef271346..300a531a 100644 --- a/include/boost/numeric/ublas/matrix.hpp +++ b/include/boost/numeric/ublas/matrix.hpp @@ -41,8 +41,6 @@ namespace boost { namespace numeric { namespace ublas { typedef T value_type; typedef const T &const_reference; typedef T &reference; - typedef const T *const_pointer; - typedef T *pointer; typedef A array_type; private: typedef F functor_type; @@ -66,7 +64,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE matrix (): matrix_expression (), - size1_ (0), size2_ (0), data_ (0) {} + size1_ (0), size2_ (0), data_ () {} BOOST_UBLAS_INLINE matrix (size_type size1, size_type size2): matrix_expression (), @@ -150,6 +148,13 @@ namespace boost { namespace numeric { namespace ublas { data () = m.data (); return *this; } + template // Generic matrix assignment without temporary + BOOST_UBLAS_INLINE + matrix &operator = (const matrix &m) { + resize (m.size1 (), m.size2 ()); + assign (m); + return *this; + } BOOST_UBLAS_INLINE matrix &assign_temporary (matrix &m) { swap (m); @@ -168,14 +173,6 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - matrix &reset (const matrix_expression &ae) { - self_type temporary (ae); - // FIXME resizing here would seems to destroy temporary - // resize (temporary.size1 (), temporary.size2 (), false); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE matrix &assign (const matrix_expression &ae) { matrix_assign (scalar_assign (), *this, ae); return *this; @@ -338,10 +335,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename matrix::difference_type difference_type; typedef typename matrix::value_type value_type; + typedef typename matrix::difference_type difference_type; typedef typename matrix::const_reference reference; - typedef typename matrix::const_pointer pointer; + typedef const typename matrix::value_type *pointer; #endif typedef const_iterator2 dual_iterator_type; typedef const_reverse_iterator2 dual_reverse_iterator_type; @@ -481,10 +478,10 @@ namespace boost { namespace numeric { namespace ublas { public: typedef dense_random_access_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename matrix::difference_type difference_type; typedef typename matrix::value_type value_type; + typedef typename matrix::difference_type difference_type; typedef typename matrix::reference reference; - typedef typename matrix::pointer pointer; + typedef typename matrix::value_type *pointer; #endif typedef iterator2 dual_iterator_type; typedef reverse_iterator2 dual_reverse_iterator_type; @@ -623,10 +620,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename matrix::difference_type difference_type; typedef typename matrix::value_type value_type; + typedef typename matrix::difference_type difference_type; typedef typename matrix::const_reference reference; - typedef typename matrix::const_pointer pointer; + typedef const typename matrix::value_type *pointer; #endif typedef const_iterator1 dual_iterator_type; typedef const_reverse_iterator1 dual_reverse_iterator_type; @@ -766,10 +763,10 @@ namespace boost { namespace numeric { namespace ublas { public: typedef dense_random_access_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename matrix::difference_type difference_type; typedef typename matrix::value_type value_type; + typedef typename matrix::difference_type difference_type; typedef typename matrix::reference reference; - typedef typename matrix::pointer pointer; + typedef typename matrix::value_type *pointer; #endif typedef iterator1 dual_iterator_type; typedef reverse_iterator1 dual_reverse_iterator_type; @@ -958,6 +955,13 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE bounded_matrix (std::size_t size1, std::size_t size2): matrix_type (size1, size2) {} + BOOST_UBLAS_INLINE + bounded_matrix (const bounded_matrix &m): + matrix_type (m) {} + template // Allow matrix > construction + BOOST_UBLAS_INLINE + bounded_matrix (const matrix &m): + matrix_type (m) {} template BOOST_UBLAS_INLINE bounded_matrix (const matrix_expression &ae): @@ -971,13 +975,12 @@ namespace boost { namespace numeric { namespace ublas { matrix_type::operator = (m); return *this; } - /* FIXME This overload would be useful but is never chosen - template + template // Generic matrix assignment BOOST_UBLAS_INLINE - bounded_matrix &operator = (const matrix > &m) { + bounded_matrix &operator = (const matrix &m) { matrix_type::operator = (m); return *this; - }*/ + } template BOOST_UBLAS_INLINE bounded_matrix &operator = (const matrix_expression &ae) { @@ -999,8 +1002,6 @@ namespace boost { namespace numeric { namespace ublas { typedef T value_type; typedef const T &const_reference; typedef T &reference; - typedef const T *const_pointer; - typedef T *pointer; typedef A array_type; private: typedef F functor_type; @@ -1109,14 +1110,6 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - vector_of_vector &reset (const matrix_expression &ae) { - self_type temporary (ae); - // FIXME resizing here would seems to destroy temporary - // resize (temporary.size1 (), temporary.size2 (), false); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE vector_of_vector &assign (const matrix_expression &ae) { matrix_assign (scalar_assign (), *this, ae); return *this; @@ -1279,10 +1272,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename vector_of_vector::difference_type difference_type; typedef typename vector_of_vector::value_type value_type; + typedef typename vector_of_vector::difference_type difference_type; typedef typename vector_of_vector::const_reference reference; - typedef typename vector_of_vector::const_reference pointer; + typedef const typename vector_of_vector::value_type *pointer; #endif typedef const_iterator2 dual_iterator_type; typedef const_reverse_iterator2 dual_reverse_iterator_type; @@ -1439,10 +1432,10 @@ namespace boost { namespace numeric { namespace ublas { public: typedef dense_random_access_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename vector_of_vector::difference_type difference_type; typedef typename vector_of_vector::value_type value_type; + typedef typename vector_of_vector::difference_type difference_type; typedef typename vector_of_vector::reference reference; - typedef typename vector_of_vector::pointer pointer; + typedef typename vector_of_vector::value_type *pointer; #endif typedef iterator2 dual_iterator_type; typedef reverse_iterator2 dual_reverse_iterator_type; @@ -1598,10 +1591,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename vector_of_vector::difference_type difference_type; typedef typename vector_of_vector::value_type value_type; + typedef typename vector_of_vector::difference_type difference_type; typedef typename vector_of_vector::const_reference reference; - typedef typename vector_of_vector::const_pointer pointer; + typedef const typename vector_of_vector::value_type *pointer; #endif typedef const_iterator1 dual_iterator_type; typedef const_reverse_iterator1 dual_reverse_iterator_type; @@ -1758,10 +1751,10 @@ namespace boost { namespace numeric { namespace ublas { public: typedef dense_random_access_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename vector_of_vector::difference_type difference_type; typedef typename vector_of_vector::value_type value_type; + typedef typename vector_of_vector::difference_type difference_type; typedef typename vector_of_vector::reference reference; - typedef typename vector_of_vector::pointer pointer; + typedef typename vector_of_vector::value_type *pointer; #endif typedef iterator1 dual_iterator_type; typedef reverse_iterator1 dual_reverse_iterator_type; @@ -1964,8 +1957,6 @@ namespace boost { namespace numeric { namespace ublas { typedef T value_type; typedef const T &const_reference; typedef T &reference; - typedef const T *const_pointer; - typedef T *pointer; private: typedef const identity_matrix const_self_type; typedef identity_matrix self_type; @@ -2108,10 +2099,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename identity_matrix::difference_type difference_type; typedef typename identity_matrix::value_type value_type; + typedef typename identity_matrix::difference_type difference_type; typedef typename identity_matrix::const_reference reference; - typedef typename identity_matrix::const_pointer pointer; + typedef const typename identity_matrix::value_type *pointer; #endif typedef const_iterator2 dual_iterator_type; typedef const_reverse_iterator2 dual_reverse_iterator_type; @@ -2253,10 +2244,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename identity_matrix::difference_type difference_type; typedef typename identity_matrix::value_type value_type; + typedef typename identity_matrix::difference_type difference_type; typedef typename identity_matrix::const_reference reference; - typedef typename identity_matrix::const_pointer pointer; + typedef const typename identity_matrix::value_type *pointer; #endif typedef const_iterator1 dual_iterator_type; typedef const_reverse_iterator1 dual_reverse_iterator_type; @@ -2441,8 +2432,6 @@ namespace boost { namespace numeric { namespace ublas { typedef T value_type; typedef const T &const_reference; typedef T &reference; - typedef const T *const_pointer; - typedef T *pointer; private: typedef const zero_matrix const_self_type; typedef zero_matrix self_type; @@ -2577,10 +2566,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename zero_matrix::difference_type difference_type; typedef typename zero_matrix::value_type value_type; + typedef typename zero_matrix::difference_type difference_type; typedef typename zero_matrix::const_reference reference; - typedef typename zero_matrix::const_pointer pointer; + typedef const typename zero_matrix::value_type *pointer; #endif typedef const_iterator2 dual_iterator_type; typedef const_reverse_iterator2 dual_reverse_iterator_type; @@ -2716,10 +2705,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename zero_matrix::difference_type difference_type; typedef typename zero_matrix::value_type value_type; + typedef typename zero_matrix::difference_type difference_type; typedef typename zero_matrix::const_reference reference; - typedef typename zero_matrix::const_pointer pointer; + typedef const typename zero_matrix::value_type *pointer; #endif typedef const_iterator1 dual_iterator_type; typedef const_reverse_iterator1 dual_reverse_iterator_type; @@ -2897,8 +2886,6 @@ namespace boost { namespace numeric { namespace ublas { typedef T value_type; typedef const T &const_reference; typedef T &reference; - typedef const T *const_pointer; - typedef T *pointer; private: typedef const scalar_matrix const_self_type; typedef scalar_matrix self_type; @@ -3022,10 +3009,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename scalar_matrix::difference_type difference_type; typedef typename scalar_matrix::value_type value_type; + typedef typename scalar_matrix::difference_type difference_type; typedef typename scalar_matrix::const_reference reference; - typedef typename scalar_matrix::const_pointer pointer; + typedef const typename scalar_matrix::value_type *pointer; #endif typedef const_iterator2 dual_iterator_type; typedef const_reverse_iterator2 dual_reverse_iterator_type; @@ -3167,10 +3154,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename scalar_matrix::difference_type difference_type; typedef typename scalar_matrix::value_type value_type; + typedef typename scalar_matrix::difference_type difference_type; typedef typename scalar_matrix::const_reference reference; - typedef typename scalar_matrix::const_pointer pointer; + typedef const typename scalar_matrix::value_type *pointer; #endif typedef const_iterator1 dual_iterator_type; typedef const_reverse_iterator1 dual_reverse_iterator_type; @@ -3473,14 +3460,6 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - c_matrix &reset (const matrix_expression &ae) { - self_type temporary (ae); - // FIXME resizing here would seems to destroy temporary - // resize (temporary.size1 (), temporary.size2 (), false); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE c_matrix &assign (const matrix_expression &ae) { matrix_assign (scalar_assign (), *this, ae); return *this; diff --git a/include/boost/numeric/ublas/matrix_expression.hpp b/include/boost/numeric/ublas/matrix_expression.hpp index 37d417ac..d9da00c2 100644 --- a/include/boost/numeric/ublas/matrix_expression.hpp +++ b/include/boost/numeric/ublas/matrix_expression.hpp @@ -206,8 +206,6 @@ namespace boost { namespace numeric { namespace ublas { typedef typename E::value_type value_type; typedef typename E::const_reference const_reference; typedef const_reference reference; - typedef typename E::const_pointer const_pointer; - typedef const_pointer pointer; private: typedef E expression_type; public: @@ -356,17 +354,11 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef typename E::const_reference const_reference; typedef typename E::reference reference; - typedef typename E::const_pointer const_pointer; - typedef typename E::pointer pointer; #else typedef typename E::const_reference const_reference; typedef typename boost::mpl::if_, typename E::const_reference, typename E::reference>::type reference; - typedef typename E::const_pointer const_pointer; - typedef typename boost::mpl::if_, - typename E::const_pointer, - typename E::pointer>::type pointer; #endif private: typedef E expression_type; @@ -431,12 +423,6 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - matrix_reference &reset (const matrix_expression &ae) { - expression ().reset (ae); - return *this; - } - template - BOOST_UBLAS_INLINE matrix_reference &assign (const matrix_expression &ae) { expression ().assign (ae); return *this; @@ -644,9 +630,8 @@ namespace boost { namespace numeric { namespace ublas { typedef typename F::result_type value_type; typedef value_type const_reference; typedef const_reference reference; - typedef const value_type *const_pointer; - typedef const_pointer pointer; private: + typedef const value_type *const_pointer; typedef E1 expression1_type; typedef E2 expression2_type; typedef typename E1::const_closure_type expression1_closure_type; @@ -1168,9 +1153,8 @@ namespace boost { namespace numeric { namespace ublas { typedef typename F::result_type value_type; typedef value_type const_reference; typedef const_reference reference; - typedef const value_type *const_pointer; - typedef const_pointer pointer; private: + typedef const value_type *const_pointer; typedef E expression_type; typedef F functor_type; typedef typename E::const_closure_type expression_closure_type; @@ -1627,9 +1611,9 @@ namespace boost { namespace numeric { namespace ublas { scalar_identity >, typename E::reference, value_type>::type reference; - typedef const value_type *const_pointer; - typedef const_pointer pointer; + private: + typedef const value_type *const_pointer; typedef typename boost::mpl::if_ >, E, @@ -2092,9 +2076,8 @@ namespace boost { namespace numeric { namespace ublas { typedef typename F::result_type value_type; typedef value_type const_reference; typedef const_reference reference; - typedef const value_type *const_pointer; - typedef const_pointer pointer; private: + typedef const value_type *const_pointer; typedef E1 expression1_type; typedef E2 expression2_type; typedef F functor_type; @@ -2842,9 +2825,9 @@ namespace boost { namespace numeric { namespace ublas { typedef typename F::result_type value_type; typedef value_type const_reference; typedef const_reference reference; - typedef const value_type *const_pointer; - typedef const_pointer pointer; + private: + typedef const value_type *const_pointer; typedef E1 expression1_type; typedef E2 expression2_type; typedef F functor_type; @@ -3297,9 +3280,9 @@ namespace boost { namespace numeric { namespace ublas { typedef typename F::result_type value_type; typedef value_type const_reference; typedef const_reference reference; - typedef const value_type *const_pointer; - typedef const_pointer pointer; + private: + typedef const value_type *const_pointer; typedef E1 expression1_type; typedef E2 expression2_type; typedef F functor_type; @@ -3763,9 +3746,8 @@ namespace boost { namespace numeric { namespace ublas { typedef typename F::result_type value_type; typedef value_type const_reference; typedef const_reference reference; - typedef const value_type *const_pointer; - typedef const_pointer pointer; private: + typedef const value_type *const_pointer; typedef E1 expression1_type; typedef E2 expression2_type; typedef F functor_type; @@ -4162,9 +4144,8 @@ namespace boost { namespace numeric { namespace ublas { typedef typename F::result_type value_type; typedef value_type const_reference; typedef const_reference reference; - typedef const value_type *const_pointer; - typedef const_pointer pointer; private: + typedef const value_type *const_pointer; typedef E1 expression1_type; typedef E2 expression2_type; typedef F functor_type; @@ -4238,7 +4219,6 @@ namespace boost { namespace numeric { namespace ublas { #endif } - // Iterator simply is a pointer. #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator: @@ -4563,9 +4543,9 @@ namespace boost { namespace numeric { namespace ublas { typedef typename F::result_type value_type; typedef value_type const_reference; typedef const_reference reference; - typedef const value_type *const_pointer; - typedef const_pointer pointer; + private: + typedef const value_type *const_pointer; typedef E1 expression1_type; typedef E2 expression2_type; typedef F functor_type; diff --git a/include/boost/numeric/ublas/matrix_proxy.hpp b/include/boost/numeric/ublas/matrix_proxy.hpp index 3e5b5c1e..414fe7ab 100644 --- a/include/boost/numeric/ublas/matrix_proxy.hpp +++ b/include/boost/numeric/ublas/matrix_proxy.hpp @@ -41,17 +41,11 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS typedef typename M::const_reference const_reference; typedef typename M::reference reference; - typedef typename M::const_pointer const_pointer; - typedef typename M::pointer pointer; #else typedef typename M::const_reference const_reference; typedef typename boost::mpl::if_, typename M::const_reference, typename M::reference>::type reference; - typedef typename M::const_pointer const_pointer; - typedef typename boost::mpl::if_, - typename M::const_pointer, - typename M::pointer>::type pointer; #endif #ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS typedef typename M::closure_type matrix_closure_type; @@ -277,8 +271,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename const_iterator_type::iterator_category iterator_category; - typedef typename const_iterator_type::difference_type difference_type; typedef typename const_iterator_type::value_type value_type; + typedef typename const_iterator_type::difference_type difference_type; typedef typename const_iterator_type::reference reference; typedef typename const_iterator_type::pointer pointer; @@ -385,8 +379,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename iterator_type::iterator_category iterator_category; - typedef typename iterator_type::difference_type difference_type; typedef typename iterator_type::value_type value_type; + typedef typename iterator_type::difference_type difference_type; typedef typename iterator_type::reference reference; typedef typename iterator_type::pointer pointer; @@ -554,17 +548,11 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS typedef typename M::const_reference const_reference; typedef typename M::reference reference; - typedef typename M::const_pointer const_pointer; - typedef typename M::pointer pointer; #else typedef typename M::const_reference const_reference; typedef typename boost::mpl::if_, typename M::const_reference, typename M::reference>::type reference; - typedef typename M::const_pointer const_pointer; - typedef typename boost::mpl::if_, - typename M::const_pointer, - typename M::pointer>::type pointer; #endif #ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS typedef typename M::closure_type matrix_closure_type; @@ -778,8 +766,6 @@ namespace boost { namespace numeric { namespace ublas { #endif } - // Iterators simply are pointers. - #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator: public container_const_reference, @@ -792,8 +778,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename const_iterator_type::iterator_category iterator_category; - typedef typename const_iterator_type::difference_type difference_type; typedef typename const_iterator_type::value_type value_type; + typedef typename const_iterator_type::difference_type difference_type; typedef typename const_iterator_type::reference reference; typedef typename const_iterator_type::pointer pointer; @@ -900,8 +886,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename iterator_type::iterator_category iterator_category; - typedef typename iterator_type::difference_type difference_type; typedef typename iterator_type::value_type value_type; + typedef typename iterator_type::difference_type difference_type; typedef typename iterator_type::reference reference; typedef typename iterator_type::pointer pointer; @@ -1069,17 +1055,11 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS typedef typename M::const_reference const_reference; typedef typename M::reference reference; - typedef typename M::const_pointer const_pointer; - typedef typename M::pointer pointer; #else typedef typename M::const_reference const_reference; typedef typename boost::mpl::if_, typename M::const_reference, typename M::reference>::type reference; - typedef typename M::const_pointer const_pointer; - typedef typename boost::mpl::if_, - typename M::const_pointer, - typename M::pointer>::type pointer; #endif #ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS typedef typename M::closure_type matrix_closure_type; @@ -1296,10 +1276,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename matrix_vector_range::difference_type difference_type; typedef typename matrix_vector_range::value_type value_type; + typedef typename matrix_vector_range::difference_type difference_type; typedef typename matrix_vector_range::const_reference reference; - typedef typename matrix_vector_range::const_pointer pointer; + typedef const typename matrix_vector_range::value_type *pointer; #endif // Construction and destruction @@ -1412,10 +1392,10 @@ namespace boost { namespace numeric { namespace ublas { typedef typename iterator_restrict_traits::iterator_category iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename matrix_vector_range::difference_type difference_type; typedef typename matrix_vector_range::value_type value_type; + typedef typename matrix_vector_range::difference_type difference_type; typedef typename matrix_vector_range::reference reference; - typedef typename matrix_vector_range::pointer pointer; + typedef typename matrix_vector_range::value_type *pointer; #endif // Construction and destruction @@ -1570,17 +1550,11 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS typedef typename M::const_reference const_reference; typedef typename M::reference reference; - typedef typename M::const_pointer const_pointer; - typedef typename M::pointer pointer; #else typedef typename M::const_reference const_reference; typedef typename boost::mpl::if_, typename M::const_reference, typename M::reference>::type reference; - typedef typename M::const_pointer const_pointer; - typedef typename boost::mpl::if_, - typename M::const_pointer, - typename M::pointer>::type pointer; #endif #ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS typedef typename M::closure_type matrix_closure_type; @@ -1806,10 +1780,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename matrix_vector_slice::difference_type difference_type; typedef typename matrix_vector_slice::value_type value_type; + typedef typename matrix_vector_slice::difference_type difference_type; typedef typename matrix_vector_slice::const_reference reference; - typedef typename matrix_vector_slice::const_pointer pointer; + typedef const typename matrix_vector_slice::value_type *pointer; #endif // Construction and destruction @@ -1922,10 +1896,10 @@ namespace boost { namespace numeric { namespace ublas { typedef typename iterator_restrict_traits::iterator_category iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename matrix_vector_slice::difference_type difference_type; typedef typename matrix_vector_slice::value_type value_type; + typedef typename matrix_vector_slice::difference_type difference_type; typedef typename matrix_vector_slice::reference reference; - typedef typename matrix_vector_slice::pointer pointer; + typedef typename matrix_vector_slice::value_type *pointer; #endif // Construction and destruction @@ -2082,17 +2056,11 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS typedef typename M::const_reference const_reference; typedef typename M::reference reference; - typedef typename M::const_pointer const_pointer; - typedef typename M::pointer pointer; #else typedef typename M::const_reference const_reference; typedef typename boost::mpl::if_, typename M::const_reference, typename M::reference>::type reference; - typedef typename M::const_pointer const_pointer; - typedef typename boost::mpl::if_, - typename M::const_pointer, - typename M::pointer>::type pointer; #endif #ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS typedef typename M::closure_type matrix_closure_type; @@ -2317,10 +2285,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename matrix_vector_indirect::difference_type difference_type; typedef typename matrix_vector_indirect::value_type value_type; + typedef typename matrix_vector_indirect::difference_type difference_type; typedef typename matrix_vector_indirect::const_reference reference; - typedef typename matrix_vector_indirect::const_pointer pointer; + typedef const typename matrix_vector_indirect::value_type *pointer; #endif // Construction and destruction @@ -2433,10 +2401,10 @@ namespace boost { namespace numeric { namespace ublas { typedef typename iterator_restrict_traits::iterator_category iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename matrix_vector_indirect::difference_type difference_type; typedef typename matrix_vector_indirect::value_type value_type; + typedef typename matrix_vector_indirect::difference_type difference_type; typedef typename matrix_vector_indirect::reference reference; - typedef typename matrix_vector_indirect::pointer pointer; + typedef typename matrix_vector_indirect::value_type *pointer; #endif // Construction and destruction @@ -2591,17 +2559,11 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS typedef typename M::const_reference const_reference; typedef typename M::reference reference; - typedef typename M::const_pointer const_pointer; - typedef typename M::pointer pointer; #else typedef typename M::const_reference const_reference; typedef typename boost::mpl::if_, typename M::const_reference, typename M::reference>::type reference; - typedef typename M::const_pointer const_pointer; - typedef typename boost::mpl::if_, - typename M::const_pointer, - typename M::pointer>::type pointer; #endif #ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS typedef typename M::closure_type matrix_closure_type; @@ -2862,7 +2824,6 @@ namespace boost { namespace numeric { namespace ublas { #endif } - // Iterators simply are pointers. #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator1: @@ -2876,8 +2837,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename const_iterator1_type::iterator_category iterator_category; - typedef typename const_iterator1_type::difference_type difference_type; typedef typename const_iterator1_type::value_type value_type; + typedef typename const_iterator1_type::difference_type difference_type; typedef typename const_iterator1_type::reference reference; typedef typename const_iterator1_type::pointer pointer; typedef const_iterator2 dual_iterator_type; @@ -3016,8 +2977,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename iterator1_type::iterator_category iterator_category; - typedef typename iterator1_type::difference_type difference_type; typedef typename iterator1_type::value_type value_type; + typedef typename iterator1_type::difference_type difference_type; typedef typename iterator1_type::reference reference; typedef typename iterator1_type::pointer pointer; typedef iterator2 dual_iterator_type; @@ -3155,8 +3116,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename const_iterator2_type::iterator_category iterator_category; - typedef typename const_iterator2_type::difference_type difference_type; typedef typename const_iterator2_type::value_type value_type; + typedef typename const_iterator2_type::difference_type difference_type; typedef typename const_iterator2_type::reference reference; typedef typename const_iterator2_type::pointer pointer; typedef const_iterator1 dual_iterator_type; @@ -3295,8 +3256,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename iterator2_type::iterator_category iterator_category; - typedef typename iterator2_type::difference_type difference_type; typedef typename iterator2_type::value_type value_type; + typedef typename iterator2_type::difference_type difference_type; typedef typename iterator2_type::reference reference; typedef typename iterator2_type::pointer pointer; typedef iterator1 dual_iterator_type; @@ -3519,17 +3480,11 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS typedef typename M::const_reference const_reference; typedef typename M::reference reference; - typedef typename M::const_pointer const_pointer; - typedef typename M::pointer pointer; #else typedef typename M::const_reference const_reference; typedef typename boost::mpl::if_, typename M::const_reference, typename M::reference>::type reference; - typedef typename M::const_pointer const_pointer; - typedef typename boost::mpl::if_, - typename M::const_pointer, - typename M::pointer>::type pointer; #endif #ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS typedef typename M::closure_type matrix_closure_type; @@ -3801,8 +3756,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename M::const_iterator1::iterator_category iterator_category; - typedef typename M::const_iterator1::difference_type difference_type; typedef typename M::const_iterator1::value_type value_type; + typedef typename M::const_iterator1::difference_type difference_type; typedef typename M::const_iterator1::reference reference; typedef typename M::const_iterator1::pointer pointer; typedef const_iterator2 dual_iterator_type; @@ -3944,8 +3899,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename M::iterator1::iterator_category iterator_category; - typedef typename M::iterator1::difference_type difference_type; typedef typename M::iterator1::value_type value_type; + typedef typename M::iterator1::difference_type difference_type; typedef typename M::iterator1::reference reference; typedef typename M::iterator1::pointer pointer; typedef iterator2 dual_iterator_type; @@ -4086,8 +4041,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename M::const_iterator2::iterator_category iterator_category; - typedef typename M::const_iterator2::difference_type difference_type; typedef typename M::const_iterator2::value_type value_type; + typedef typename M::const_iterator2::difference_type difference_type; typedef typename M::const_iterator2::reference reference; typedef typename M::const_iterator2::pointer pointer; typedef const_iterator1 dual_iterator_type; @@ -4229,8 +4184,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename M::iterator2::iterator_category iterator_category; - typedef typename M::iterator2::difference_type difference_type; typedef typename M::iterator2::value_type value_type; + typedef typename M::iterator2::difference_type difference_type; typedef typename M::iterator2::reference reference; typedef typename M::iterator2::pointer pointer; typedef iterator1 dual_iterator_type; @@ -4474,17 +4429,11 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS typedef typename M::const_reference const_reference; typedef typename M::reference reference; - typedef typename M::const_pointer const_pointer; - typedef typename M::pointer pointer; #else typedef typename M::const_reference const_reference; typedef typename boost::mpl::if_, typename M::const_reference, typename M::reference>::type reference; - typedef typename M::const_pointer const_pointer; - typedef typename boost::mpl::if_, - typename M::const_pointer, - typename M::pointer>::type pointer; #endif #ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS typedef typename M::closure_type matrix_closure_type; @@ -4749,8 +4698,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename M::const_iterator1::iterator_category iterator_category; - typedef typename M::const_iterator1::difference_type difference_type; typedef typename M::const_iterator1::value_type value_type; + typedef typename M::const_iterator1::difference_type difference_type; typedef typename M::const_iterator1::reference reference; typedef typename M::const_iterator1::pointer pointer; typedef const_iterator2 dual_iterator_type; @@ -4892,8 +4841,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename M::iterator1::iterator_category iterator_category; - typedef typename M::iterator1::difference_type difference_type; typedef typename M::iterator1::value_type value_type; + typedef typename M::iterator1::difference_type difference_type; typedef typename M::iterator1::reference reference; typedef typename M::iterator1::pointer pointer; typedef iterator2 dual_iterator_type; @@ -5034,8 +4983,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename M::const_iterator2::iterator_category iterator_category; - typedef typename M::const_iterator2::difference_type difference_type; typedef typename M::const_iterator2::value_type value_type; + typedef typename M::const_iterator2::difference_type difference_type; typedef typename M::const_iterator2::reference reference; typedef typename M::const_iterator2::pointer pointer; typedef const_iterator1 dual_iterator_type; @@ -5177,8 +5126,8 @@ namespace boost { namespace numeric { namespace ublas { #endif public: typedef typename M::iterator2::iterator_category iterator_category; - typedef typename M::iterator2::difference_type difference_type; typedef typename M::iterator2::value_type value_type; + typedef typename M::iterator2::difference_type difference_type; typedef typename M::iterator2::reference reference; typedef typename M::iterator2::pointer pointer; typedef iterator1 dual_iterator_type; diff --git a/include/boost/numeric/ublas/matrix_sparse.hpp b/include/boost/numeric/ublas/matrix_sparse.hpp index bb03046c..4bf2ef4f 100644 --- a/include/boost/numeric/ublas/matrix_sparse.hpp +++ b/include/boost/numeric/ublas/matrix_sparse.hpp @@ -42,33 +42,27 @@ namespace boost { namespace numeric { namespace ublas { // Construction and destruction BOOST_UBLAS_INLINE sparse_matrix_element (const value_type &d): - container_reference (), it_ (), i_ (), j_ (), d_ (d), dirty_ (false) { + container_reference (), i_ (), j_ (), d_ (d), dirty_ (false) { external_logic ().raise (); } BOOST_UBLAS_INLINE - sparse_matrix_element (matrix_type &m, pointer it, size_type i, size_type j): - container_reference (m), it_ (it), i_ (i), j_ (j), d_ (*it), dirty_ (false) {} - BOOST_UBLAS_INLINE sparse_matrix_element (matrix_type &m, size_type i, size_type j): - container_reference (m), it_ (), i_ (i), j_ (j), d_ (), dirty_ (false) { + container_reference (m), i_ (i), j_ (j), d_ (), dirty_ (false) { pointer it = (*this) ().find_element (i_, j_); if (it) d_ = *it; } BOOST_UBLAS_INLINE sparse_matrix_element (const sparse_matrix_element &p): - container_reference (p), it_ (p.it_), i_ (p.i_), d_ (p.d_), dirty_ (p.dirty_) {} + container_reference (p), i_ (p.i_), d_ (p.d_), dirty_ (p.dirty_) {} BOOST_UBLAS_INLINE ~sparse_matrix_element () { if (dirty_) { - if (! it_) { - it_ = (*this) ().find_element (i_, j_); - if (! it_) - (*this) ().insert (i_, j_, d_); - else - *it_ = d_; - } else - *it_ = d_; + pointer it = (*this) ().find_element (i_, j_); + if (! it) + (*this) ().insert (i_, j_, d_); + else + *it = d_; } } @@ -152,7 +146,6 @@ namespace boost { namespace numeric { namespace ublas { #endif private: - pointer it_; size_type i_; size_type j_; value_type d_; @@ -250,6 +243,7 @@ namespace boost { namespace numeric { namespace ublas { typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef T value_type; + typedef A array_type; typedef const T &const_reference; #if ! defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) && ! defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) typedef T &reference; @@ -258,10 +252,9 @@ namespace boost { namespace numeric { namespace ublas { #elif defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) typedef typename detail::map_traits::reference reference; #endif - typedef const T *const_pointer; - typedef T *pointer; - typedef A array_type; private: + typedef T &true_reference; + typedef T *pointer; typedef F functor_type; typedef const sparse_matrix const_self_type; typedef sparse_matrix self_type; @@ -296,7 +289,7 @@ namespace boost { namespace numeric { namespace ublas { matrix_expression (), size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), non_zeros_ (non_zeros), data_ () { reserve (non_zeros_); - matrix_assign (scalar_assign (), *this, ae); + matrix_assign (scalar_assign (), *this, ae); } // Accessors @@ -350,6 +343,7 @@ namespace boost { namespace numeric { namespace ublas { // Proxy support #ifdef BOOST_UBLAS_STRICT_MATRIX_SPARSE + BOOST_UBLAS_INLINE pointer find_element (size_type i, size_type j) { iterator_type it (data ().find (functor_type::element (i, size1_, j, size2_))); if (it == data ().end () || (*it).first != functor_type::element (i, size1_, j, size2_)) @@ -360,16 +354,24 @@ namespace boost { namespace numeric { namespace ublas { // Element access BOOST_UBLAS_INLINE - const_reference operator () (size_type i, size_type j) const { + const_reference at_element (size_type i, size_type j) const { const_iterator_type it (data ().find (functor_type::element (i, size1_, j, size2_))); if (it == data ().end () || (*it).first != functor_type::element (i, size1_, j, size2_)) return zero_; return (*it).second; } BOOST_UBLAS_INLINE + true_reference at_element (size_type i, size_type j) { + return data () [functor_type::element (i, size1_, j, size2_)]; + } + BOOST_UBLAS_INLINE + const_reference operator () (size_type i, size_type j) const { + return at_element (i, j); + } + BOOST_UBLAS_INLINE reference operator () (size_type i, size_type j) { #ifndef BOOST_UBLAS_STRICT_MATRIX_SPARSE - return data () [functor_type::element (i, size1_, j, size2_)]; + return at_element (i, j); #else return reference (*this, i, j); #endif @@ -404,15 +406,8 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - sparse_matrix &reset (const matrix_expression &ae) { - self_type temporary (ae, non_zeros_); - resize (temporary.size1 (), temporary.size2 (), non_zeros_); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE sparse_matrix &assign (const matrix_expression &ae) { - matrix_assign (scalar_assign (), *this, ae); + matrix_assign (scalar_assign (), *this, ae); return *this; } template @@ -429,7 +424,7 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE sparse_matrix &plus_assign (const matrix_expression &ae) { - matrix_assign (scalar_plus_assign (), *this, ae); + matrix_assign (scalar_plus_assign (), *this, ae); return *this; } template @@ -446,19 +441,19 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE sparse_matrix &minus_assign (const matrix_expression &ae) { - matrix_assign (scalar_minus_assign (), *this, ae); + matrix_assign (scalar_minus_assign (), *this, ae); return *this; } template BOOST_UBLAS_INLINE sparse_matrix& operator *= (const AT &at) { - matrix_assign_scalar (scalar_multiplies_assign (), *this, at); + matrix_assign_scalar (scalar_multiplies_assign (), *this, at); return *this; } template BOOST_UBLAS_INLINE sparse_matrix& operator /= (const AT &at) { - matrix_assign_scalar (scalar_divides_assign (), *this, at); + matrix_assign_scalar (scalar_divides_assign (), *this, at); return *this; } @@ -500,7 +495,7 @@ namespace boost { namespace numeric { namespace ublas { // Iterator types private: - // Use a storage iterator + // Use storage iterator typedef typename A::const_iterator const_iterator_type; typedef typename A::iterator iterator_type; @@ -653,10 +648,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename sparse_matrix::difference_type difference_type; typedef typename sparse_matrix::value_type value_type; + typedef typename sparse_matrix::difference_type difference_type; typedef typename sparse_matrix::const_reference reference; - typedef typename sparse_matrix::const_pointer pointer; + typedef const typename sparse_matrix::pointer pointer; #endif typedef const_iterator2 dual_iterator_type; typedef const_reverse_iterator2 dual_reverse_iterator_type; @@ -698,7 +693,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1) { return (*it_).second; } else { - return (*this) () (i_, j_); + return (*this) ().at_element (i_, j_); } } @@ -805,9 +800,9 @@ namespace boost { namespace numeric { namespace ublas { public: typedef sparse_bidirectional_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename sparse_matrix::difference_type difference_type; typedef typename sparse_matrix::value_type value_type; - typedef typename sparse_matrix::reference reference; + typedef typename sparse_matrix::difference_type difference_type; + typedef typename sparse_matrix::true_reference reference; typedef typename sparse_matrix::pointer pointer; #endif typedef iterator2 dual_iterator_type; @@ -845,15 +840,13 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); if (rank_ == 1) { -#if ! defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) && ! defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) +#ifndef BOOST_UBLAS_STRICT_STORAGE_SPARSE return (*it_).second; -#elif defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) - return reference ((*this) (), &(*it_).second, index1 (), index2 ()); -#elif defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) +#else return detail::make_reference ((*this) ().data (), it_); #endif } else { - return reference ((*this) () (i_, j_)); + return (*this) ().at_element (i_, j_); } } @@ -964,10 +957,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename sparse_matrix::difference_type difference_type; typedef typename sparse_matrix::value_type value_type; + typedef typename sparse_matrix::difference_type difference_type; typedef typename sparse_matrix::const_reference reference; - typedef typename sparse_matrix::const_pointer pointer; + typedef const typename sparse_matrix::pointer pointer; #endif typedef const_iterator1 dual_iterator_type; typedef const_reverse_iterator1 dual_reverse_iterator_type; @@ -1009,7 +1002,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1) { return (*it_).second; } else { - return (*this) () (i_, j_); + return (*this) ().at_element (i_, j_); } } @@ -1116,9 +1109,9 @@ namespace boost { namespace numeric { namespace ublas { public: typedef sparse_bidirectional_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename sparse_matrix::difference_type difference_type; typedef typename sparse_matrix::value_type value_type; - typedef typename sparse_matrix::reference reference; + typedef typename sparse_matrix::difference_type difference_type; + typedef typename sparse_matrix::true_reference reference; typedef typename sparse_matrix::pointer pointer; #endif typedef iterator1 dual_iterator_type; @@ -1156,15 +1149,13 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); if (rank_ == 1) { -#if ! defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) && ! defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) +#ifndef BOOST_UBLAS_STRICT_STORAGE_SPARSE return (*it_).second; -#elif defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) - return reference ((*this) (), &(*it_).second, index1 (), index2 ()); -#elif defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) +#else return detail::make_reference ((*this) ().data (), it_); #endif } else { - return reference ((*this) () (i_, j_)); + return (*this) ().at_element (i_, j_); } } @@ -1338,9 +1329,9 @@ namespace boost { namespace numeric { namespace ublas { #elif defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) typedef typename detail::map_traits::reference reference; #endif - typedef const T *const_pointer; - typedef T *pointer; private: + typedef T &true_reference; + typedef T *pointer; typedef A array_type; typedef const A const_array_type; typedef F functor_type; @@ -1380,7 +1371,7 @@ namespace boost { namespace numeric { namespace ublas { matrix_expression (), size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), non_zeros_ (non_zeros), data_ () { data_ [functor_type::size1 (size1_, size2_)] = vector_data_value_type (); - matrix_assign (scalar_assign (), *this, ae); + matrix_assign (scalar_assign (), *this, ae); } // Accessors @@ -1420,6 +1411,7 @@ namespace boost { namespace numeric { namespace ublas { // Proxy support #ifdef BOOST_UBLAS_STRICT_MATRIX_SPARSE + BOOST_UBLAS_INLINE pointer find_element (size_type i, size_type j) { vector_iterator_type itv (data ().find (functor_type::element1 (i, size1_, j, size2_))); if (itv == data ().end () || (*itv).first != functor_type::element1 (i, size1_, j, size2_)) @@ -1433,7 +1425,7 @@ namespace boost { namespace numeric { namespace ublas { // Element access BOOST_UBLAS_INLINE - const_reference operator () (size_type i, size_type j) const { + const_reference at_element (size_type i, size_type j) const { vector_const_iterator_type itv (data ().find (functor_type::element1 (i, size1_, j, size2_))); if (itv == data ().end () || (*itv).first != functor_type::element1 (i, size1_, j, size2_)) return zero_; @@ -1443,9 +1435,17 @@ namespace boost { namespace numeric { namespace ublas { return (*it).second; } BOOST_UBLAS_INLINE + true_reference at_element (size_type i, size_type j) { + return data () [functor_type::element1 (i, size1_, j, size2_)] [functor_type::element2 (i, size1_, j, size2_)]; + } + BOOST_UBLAS_INLINE + const_reference operator () (size_type i, size_type j) const { + return at_element (i, j); + } + BOOST_UBLAS_INLINE reference operator () (size_type i, size_type j) { #ifndef BOOST_UBLAS_STRICT_MATRIX_SPARSE - return data () [functor_type::element1 (i, size1_, j, size2_)] [functor_type::element2 (i, size1_, j, size2_)]; + return at_element (i, j); #else return reference (*this, i, j); #endif @@ -1480,15 +1480,8 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - sparse_vector_of_sparse_vector &reset (const matrix_expression &ae) { - self_type temporary (ae, non_zeros_); - resize (temporary.size1 (), temporary.size2 (), non_zeros_); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE sparse_vector_of_sparse_vector &assign (const matrix_expression &ae) { - matrix_assign (scalar_assign (), *this, ae); + matrix_assign (scalar_assign (), *this, ae); return *this; } template @@ -1505,7 +1498,7 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE sparse_vector_of_sparse_vector &plus_assign (const matrix_expression &ae) { - matrix_assign (scalar_plus_assign (), *this, ae); + matrix_assign (scalar_plus_assign (), *this, ae); return *this; } template @@ -1522,19 +1515,19 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE sparse_vector_of_sparse_vector &minus_assign (const matrix_expression &ae) { - matrix_assign (scalar_minus_assign (), *this, ae); + matrix_assign (scalar_minus_assign (), *this, ae); return *this; } template BOOST_UBLAS_INLINE sparse_vector_of_sparse_vector& operator *= (const AT &at) { - matrix_assign_scalar (scalar_multiplies_assign (), *this, at); + matrix_assign_scalar (scalar_multiplies_assign (), *this, at); return *this; } template BOOST_UBLAS_INLINE sparse_vector_of_sparse_vector& operator /= (const AT &at) { - matrix_assign_scalar (scalar_divides_assign (), *this, at); + matrix_assign_scalar (scalar_divides_assign (), *this, at); return *this; } @@ -1773,10 +1766,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename sparse_vector_of_sparse_vector::difference_type difference_type; typedef typename sparse_vector_of_sparse_vector::value_type value_type; + typedef typename sparse_vector_of_sparse_vector::difference_type difference_type; typedef typename sparse_vector_of_sparse_vector::const_reference reference; - typedef typename sparse_vector_of_sparse_vector::const_pointer pointer; + typedef const typename sparse_vector_of_sparse_vector::pointer pointer; #endif typedef const_iterator2 dual_iterator_type; typedef const_reverse_iterator2 dual_reverse_iterator_type; @@ -1836,7 +1829,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1) { return (*it_).second; } else { - return (*this) () (i_, j_); + return (*this) ().at_element (i_, j_); } } @@ -1943,9 +1936,9 @@ namespace boost { namespace numeric { namespace ublas { public: typedef sparse_bidirectional_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename sparse_vector_of_sparse_vector::difference_type difference_type; typedef typename sparse_vector_of_sparse_vector::value_type value_type; - typedef typename sparse_vector_of_sparse_vector::reference reference; + typedef typename sparse_vector_of_sparse_vector::difference_type difference_type; + typedef typename sparse_vector_of_sparse_vector::true_reference reference; typedef typename sparse_vector_of_sparse_vector::pointer pointer; #endif typedef iterator2 dual_iterator_type; @@ -2001,15 +1994,13 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); if (rank_ == 1) { -#if ! defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) && ! defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) +#ifndef BOOST_UBLAS_STRICT_STORAGE_SPARSE return (*it_).second; -#elif defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) - return reference ((*this) (), &(*it_).second, index1 (), index2 ()); -#elif defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) +#else return detail::make_reference ((*itv_).second, it_); #endif } else { - return reference ((*this) () (i_, j_)); + return (*this) ().at_element (i_, j_); } } @@ -2120,10 +2111,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename sparse_vector_of_sparse_vector::difference_type difference_type; typedef typename sparse_vector_of_sparse_vector::value_type value_type; + typedef typename sparse_vector_of_sparse_vector::difference_type difference_type; typedef typename sparse_vector_of_sparse_vector::const_reference reference; - typedef typename sparse_vector_of_sparse_vector::const_pointer pointer; + typedef const typename sparse_vector_of_sparse_vector::pointer pointer; #endif typedef const_iterator1 dual_iterator_type; typedef const_reverse_iterator1 dual_reverse_iterator_type; @@ -2183,7 +2174,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1) { return (*it_).second; } else { - return (*this) () (i_, j_); + return (*this) ().at_element (i_, j_); } } @@ -2290,9 +2281,9 @@ namespace boost { namespace numeric { namespace ublas { public: typedef sparse_bidirectional_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename sparse_vector_of_sparse_vector::difference_type difference_type; typedef typename sparse_vector_of_sparse_vector::value_type value_type; - typedef typename sparse_vector_of_sparse_vector::reference reference; + typedef typename sparse_vector_of_sparse_vector::difference_type difference_type; + typedef typename sparse_vector_of_sparse_vector::true_reference reference; typedef typename sparse_vector_of_sparse_vector::pointer pointer; #endif typedef iterator1 dual_iterator_type; @@ -2348,15 +2339,13 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); if (rank_ == 1) { -#if ! defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) && ! defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) +#ifndef BOOST_UBLAS_STRICT_STORAGE_SPARSE return (*it_).second; -#elif defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) - return reference ((*this) (), &(*it_).second, index1 (), index2 ()); -#elif defined (BOOST_UBLAS_STRICT_STORAGE_SPARSE) +#else return detail::make_reference ((*itv_).second, it_); #endif } else { - return reference ((*this) () (i_, j_)); + return (*this) ().at_element (i_, j_); } } @@ -2530,11 +2519,11 @@ namespace boost { namespace numeric { namespace ublas { #else typedef sparse_matrix_element > reference; #endif - typedef const T *const_pointer; - typedef T *pointer; typedef IA index_array_type; typedef TA value_array_type; private: + typedef T &true_reference; + typedef T *pointer; typedef F functor_type; typedef const compressed_matrix const_self_type; typedef compressed_matrix self_type; @@ -2587,7 +2576,7 @@ namespace boost { namespace numeric { namespace ublas { index2_data_ (non_zeros), value_data_ (non_zeros) { index1_data_ [filled1_ - 1] = k_based (filled2_); reserve (non_zeros_, false); - matrix_assign (scalar_assign (), *this, ae); + matrix_assign (scalar_assign (), *this, ae); } // Accessors @@ -2678,6 +2667,7 @@ namespace boost { namespace numeric { namespace ublas { // Proxy support #ifdef BOOST_UBLAS_STRICT_MATRIX_SPARSE + BOOST_UBLAS_INLINE pointer find_element (size_type i, size_type j) { size_type element1 (functor_type::element1 (i, size1_, j, size2_)); size_type element2 (functor_type::element2 (i, size1_, j, size2_)); @@ -2695,7 +2685,7 @@ namespace boost { namespace numeric { namespace ublas { // Element access BOOST_UBLAS_INLINE - const_reference operator () (size_type i, size_type j) const { + const_reference at_element (size_type i, size_type j) const { size_type element1 (functor_type::element1 (i, size1_, j, size2_)); size_type element2 (functor_type::element2 (i, size1_, j, size2_)); if (filled1_ <= element1 + 1) @@ -2709,8 +2699,7 @@ namespace boost { namespace numeric { namespace ublas { return value_data () [it - index2_data ().begin ()]; } BOOST_UBLAS_INLINE - reference operator () (size_type i, size_type j) { -#ifndef BOOST_UBLAS_STRICT_MATRIX_SPARSE + true_reference at_element (size_type i, size_type j) { size_type element1 (functor_type::element1 (i, size1_, j, size2_)); size_type element2 (functor_type::element2 (i, size1_, j, size2_)); if (filled1_ <= element1 + 1) @@ -2726,6 +2715,15 @@ namespace boost { namespace numeric { namespace ublas { it = detail::lower_bound (it_begin, it_end, k_based (element2), std::less ()); } return value_data () [it - index2_data ().begin ()]; + } + BOOST_UBLAS_INLINE + const_reference operator () (size_type i, size_type j) const { + return at_element (i, j); + } + BOOST_UBLAS_INLINE + reference operator () (size_type i, size_type j) { +#ifndef BOOST_UBLAS_STRICT_MATRIX_SPARSE + return at_element (i, j); #else return reference (*this, i, j); #endif @@ -2767,15 +2765,8 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - compressed_matrix &reset(const matrix_expression &ae) { - self_type temporary (ae, non_zeros_); - resize (temporary.size1 (), temporary.size2 (), non_zeros_, false); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE compressed_matrix &assign (const matrix_expression &ae) { - matrix_assign (scalar_assign (), *this, ae); + matrix_assign (scalar_assign (), *this, ae); return *this; } template @@ -2792,7 +2783,7 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE compressed_matrix &plus_assign (const matrix_expression &ae) { - matrix_assign (scalar_plus_assign (), *this, ae); + matrix_assign (scalar_plus_assign (), *this, ae); return *this; } template @@ -2809,19 +2800,19 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE compressed_matrix &minus_assign (const matrix_expression &ae) { - matrix_assign (scalar_minus_assign (), *this, ae); + matrix_assign (scalar_minus_assign (), *this, ae); return *this; } template BOOST_UBLAS_INLINE compressed_matrix& operator *= (const AT &at) { - matrix_assign_scalar (scalar_multiplies_assign (), *this, at); + matrix_assign_scalar (scalar_multiplies_assign (), *this, at); return *this; } template BOOST_UBLAS_INLINE compressed_matrix& operator /= (const AT &at) { - matrix_assign_scalar (scalar_divides_assign (), *this, at); + matrix_assign_scalar (scalar_divides_assign (), *this, at); return *this; } @@ -3148,10 +3139,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename compressed_matrix::difference_type difference_type; typedef typename compressed_matrix::value_type value_type; + typedef typename compressed_matrix::difference_type difference_type; typedef typename compressed_matrix::const_reference reference; - typedef typename compressed_matrix::const_pointer pointer; + typedef const typename compressed_matrix::pointer pointer; #endif typedef const_iterator2 dual_iterator_type; typedef const_reverse_iterator2 dual_reverse_iterator_type; @@ -3199,7 +3190,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1) { return (*this) ().value_data () [it_ - (*this) ().index2_data ().begin ()]; } else { - return (*this) () (i_, j_); + return (*this) ().at_element (i_, j_); } } @@ -3306,9 +3297,9 @@ namespace boost { namespace numeric { namespace ublas { public: typedef sparse_bidirectional_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename compressed_matrix::difference_type difference_type; typedef typename compressed_matrix::value_type value_type; - typedef typename compressed_matrix::reference reference; + typedef typename compressed_matrix::difference_type difference_type; + typedef typename compressed_matrix::true_reference reference; typedef typename compressed_matrix::pointer pointer; #endif typedef iterator2 dual_iterator_type; @@ -3352,13 +3343,9 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); if (rank_ == 1) { -#if ! defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) return (*this) ().value_data () [it_ - (*this) ().index2_data ().begin ()]; -#else - return reference ((*this) (), &(*this) ().value_data () [it_ - (*this) ().index2_data ().begin ()], index1 (), index2 ()); -#endif } else { - return reference ((*this) () (i_, j_)); + return (*this) ().at_element (i_, j_); } } @@ -3469,10 +3456,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename compressed_matrix::difference_type difference_type; typedef typename compressed_matrix::value_type value_type; + typedef typename compressed_matrix::difference_type difference_type; typedef typename compressed_matrix::const_reference reference; - typedef typename compressed_matrix::const_pointer pointer; + typedef const typename compressed_matrix::pointer pointer; #endif typedef const_iterator1 dual_iterator_type; typedef const_reverse_iterator1 dual_reverse_iterator_type; @@ -3520,7 +3507,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1) { return (*this) ().value_data () [it_ - (*this) ().index2_data ().begin ()]; } else { - return (*this) () (i_, j_); + return (*this) ().at_element (i_, j_); } } @@ -3627,9 +3614,9 @@ namespace boost { namespace numeric { namespace ublas { public: typedef sparse_bidirectional_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename compressed_matrix::difference_type difference_type; typedef typename compressed_matrix::value_type value_type; - typedef typename compressed_matrix::reference reference; + typedef typename compressed_matrix::difference_type difference_type; + typedef typename compressed_matrix::true_reference reference; typedef typename compressed_matrix::pointer pointer; #endif typedef iterator1 dual_iterator_type; @@ -3673,13 +3660,9 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); if (rank_ == 1) { -#if ! defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) return (*this) ().value_data () [it_ - (*this) ().index2_data ().begin ()]; -#else - return reference ((*this) (), &(*this) ().value_data () [it_ - (*this) ().index2_data ().begin ()], index1 (), index2 ()); -#endif } else { - return reference ((*this) () (i_, j_)); + return (*this) ().at_element (i_, j_); } } @@ -3871,11 +3854,11 @@ namespace boost { namespace numeric { namespace ublas { #else typedef sparse_matrix_element > reference; #endif - typedef const T *const_pointer; - typedef T *pointer; typedef IA index_array_type; typedef TA value_array_type; private: + typedef T &true_reference; + typedef T *pointer; typedef F functor_type; typedef const coordinate_matrix const_self_type; typedef coordinate_matrix self_type; @@ -3922,7 +3905,7 @@ namespace boost { namespace numeric { namespace ublas { sorted_ (true), index1_data_ (non_zeros), index2_data_ (non_zeros), value_data_ (non_zeros) { reserve (non_zeros_, false); - matrix_assign (scalar_assign (), *this, ae); + matrix_assign (scalar_assign (), *this, ae); } // Accessors @@ -4006,6 +3989,7 @@ namespace boost { namespace numeric { namespace ublas { // Proxy support #ifdef BOOST_UBLAS_STRICT_MATRIX_SPARSE + BOOST_UBLAS_INLINE pointer find_element (size_type i, size_type j) { sort (); size_type element1 (functor_type::element1 (i, size1_, j, size2_)); @@ -4025,7 +4009,7 @@ namespace boost { namespace numeric { namespace ublas { // Element access BOOST_UBLAS_INLINE - const_reference operator () (size_type i, size_type j) const { + const_reference at_element (size_type i, size_type j) const { sort (); size_type element1 (functor_type::element1 (i, size1_, j, size2_)); size_type element2 (functor_type::element2 (i, size1_, j, size2_)); @@ -4041,8 +4025,7 @@ namespace boost { namespace numeric { namespace ublas { return value_data () [it - index2_data ().begin ()]; } BOOST_UBLAS_INLINE - reference operator () (size_type i, size_type j) { -#ifndef BOOST_UBLAS_STRICT_MATRIX_SPARSE + true_reference at_element (size_type i, size_type j) { sort (); size_type element1 (functor_type::element1 (i, size1_, j, size2_)); size_type element2 (functor_type::element2 (i, size1_, j, size2_)); @@ -4067,6 +4050,15 @@ namespace boost { namespace numeric { namespace ublas { it = detail::lower_bound (it_begin, it_end, k_based (element2), std::less ()); } return value_data () [it - index2_data ().begin ()]; + } + BOOST_UBLAS_INLINE + const_reference operator () (size_type i, size_type j) const { + return at_element (i, j); + } + BOOST_UBLAS_INLINE + reference operator () (size_type i, size_type j) { +#ifndef BOOST_UBLAS_STRICT_MATRIX_SPARSE + return at_element (i, j); #else return reference (*this, i, j); #endif @@ -4108,15 +4100,8 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - coordinate_matrix &reset(const matrix_expression &ae) { - self_type temporary (ae, non_zeros_); - resize (temporary.size1 (), temporary.size2 (), non_zeros_, false); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE coordinate_matrix &assign (const matrix_expression &ae) { - matrix_assign (scalar_assign (), *this, ae); + matrix_assign (scalar_assign (), *this, ae); return *this; } template @@ -4133,7 +4118,7 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE coordinate_matrix &plus_assign (const matrix_expression &ae) { - matrix_assign (scalar_plus_assign (), *this, ae); + matrix_assign (scalar_plus_assign (), *this, ae); return *this; } template @@ -4150,19 +4135,19 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE coordinate_matrix &minus_assign (const matrix_expression &ae) { - matrix_assign (scalar_minus_assign (), *this, ae); + matrix_assign (scalar_minus_assign (), *this, ae); return *this; } template BOOST_UBLAS_INLINE coordinate_matrix& operator *= (const AT &at) { - matrix_assign_scalar (scalar_multiplies_assign (), *this, at); + matrix_assign_scalar (scalar_multiplies_assign (), *this, at); return *this; } template BOOST_UBLAS_INLINE coordinate_matrix& operator /= (const AT &at) { - matrix_assign_scalar (scalar_divides_assign (), *this, at); + matrix_assign_scalar (scalar_divides_assign (), *this, at); return *this; } @@ -4464,10 +4449,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename coordinate_matrix::difference_type difference_type; typedef typename coordinate_matrix::value_type value_type; + typedef typename coordinate_matrix::difference_type difference_type; typedef typename coordinate_matrix::const_reference reference; - typedef typename coordinate_matrix::const_pointer pointer; + typedef const typename coordinate_matrix::pointer pointer; #endif typedef const_iterator2 dual_iterator_type; typedef const_reverse_iterator2 dual_reverse_iterator_type; @@ -4515,7 +4500,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1) { return (*this) ().value_data () [it_ - (*this) ().index2_data ().begin ()]; } else { - return (*this) () (i_, j_); + return (*this) ().at_element (i_, j_); } } @@ -4622,9 +4607,9 @@ namespace boost { namespace numeric { namespace ublas { public: typedef sparse_bidirectional_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename coordinate_matrix::difference_type difference_type; typedef typename coordinate_matrix::value_type value_type; - typedef typename coordinate_matrix::reference reference; + typedef typename coordinate_matrix::difference_type difference_type; + typedef typename coordinate_matrix::true_reference reference; typedef typename coordinate_matrix::pointer pointer; #endif typedef iterator2 dual_iterator_type; @@ -4668,13 +4653,9 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); if (rank_ == 1) { -#if ! defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) return (*this) ().value_data () [it_ - (*this) ().index2_data ().begin ()]; -#else - return reference ((*this) (), &(*this) ().value_data () [it_ - (*this) ().index2_data ().begin ()], index1 (), index2 ()); -#endif } else { - return reference ((*this) () (i_, j_)); + return (*this) ().at_element (i_, j_); } } @@ -4785,10 +4766,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename coordinate_matrix::difference_type difference_type; typedef typename coordinate_matrix::value_type value_type; + typedef typename coordinate_matrix::difference_type difference_type; typedef typename coordinate_matrix::const_reference reference; - typedef typename coordinate_matrix::const_pointer pointer; + typedef const typename coordinate_matrix::pointer pointer; #endif typedef const_iterator1 dual_iterator_type; typedef const_reverse_iterator1 dual_reverse_iterator_type; @@ -4836,7 +4817,7 @@ namespace boost { namespace numeric { namespace ublas { if (rank_ == 1) { return (*this) ().value_data () [it_ - (*this) ().index2_data ().begin ()]; } else { - return (*this) () (i_, j_); + return (*this) ().at_element (i_, j_); } } @@ -4943,9 +4924,9 @@ namespace boost { namespace numeric { namespace ublas { public: typedef sparse_bidirectional_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename coordinate_matrix::difference_type difference_type; typedef typename coordinate_matrix::value_type value_type; - typedef typename coordinate_matrix::reference reference; + typedef typename coordinate_matrix::difference_type difference_type; + typedef typename coordinate_matrix::true_reference reference; typedef typename coordinate_matrix::pointer pointer; #endif typedef iterator1 dual_iterator_type; @@ -4989,13 +4970,9 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ()); BOOST_UBLAS_CHECK (index2 () < (*this) ().size2 (), bad_index ()); if (rank_ == 1) { -#if ! defined (BOOST_UBLAS_STRICT_MATRIX_SPARSE) return (*this) ().value_data () [it_ - (*this) ().index2_data ().begin ()]; -#else - return reference ((*this) (), &(*this) ().value_data () [it_ - (*this) ().index2_data ().begin ()], index1 (), index2 ()); -#endif } else { - return reference ((*this) () (i_, j_)); + return (*this) ().at_element (i_, j_); } } diff --git a/include/boost/numeric/ublas/symmetric.hpp b/include/boost/numeric/ublas/symmetric.hpp index 902fd4f5..a612a4d7 100644 --- a/include/boost/numeric/ublas/symmetric.hpp +++ b/include/boost/numeric/ublas/symmetric.hpp @@ -55,14 +55,13 @@ namespace boost { namespace numeric { namespace ublas { typedef T value_type; typedef const T &const_reference; typedef T &reference; - typedef const T *const_pointer; - typedef T *pointer; + typedef A array_type; + private: typedef F1 functor1_type; typedef F2 functor2_type; - typedef A array_type; - typedef const A const_array_type; typedef const symmetric_matrix const_self_type; typedef symmetric_matrix self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const matrix_const_reference const_closure_type; #else @@ -115,7 +114,7 @@ namespace boost { namespace numeric { namespace ublas { return size_; } BOOST_UBLAS_INLINE - const_array_type &data () const { + const array_type &data () const { return data_; } BOOST_UBLAS_INLINE @@ -180,13 +179,6 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - symmetric_matrix &reset (const matrix_expression &ae) { - self_type temporary (ae); - resize (temporary.size1 (), temporary.size2 (), false); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE symmetric_matrix &assign (const matrix_expression &ae) { matrix_assign (scalar_assign (), *this, ae); return *this; @@ -293,6 +285,7 @@ namespace boost { namespace numeric { namespace ublas { std::fill (data ().begin (), data ().end (), value_type (0)); } + // Iterator types #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_iterator1 iterator1; typedef indexed_iterator2 iterator2; @@ -350,10 +343,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename symmetric_matrix::difference_type difference_type; typedef typename symmetric_matrix::value_type value_type; + typedef typename symmetric_matrix::difference_type difference_type; typedef typename symmetric_matrix::const_reference reference; - typedef typename symmetric_matrix::const_pointer pointer; + typedef const typename symmetric_matrix::value_type *pointer; #endif typedef const_iterator2 dual_iterator_type; typedef const_reverse_iterator2 dual_reverse_iterator_type; @@ -490,10 +483,10 @@ namespace boost { namespace numeric { namespace ublas { public: typedef packed_random_access_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename symmetric_matrix::difference_type difference_type; typedef typename symmetric_matrix::value_type value_type; + typedef typename symmetric_matrix::difference_type difference_type; typedef typename symmetric_matrix::reference reference; - typedef typename symmetric_matrix::pointer pointer; + typedef typename symmetric_matrix::value_type *pointer; #endif typedef iterator2 dual_iterator_type; typedef reverse_iterator2 dual_reverse_iterator_type; @@ -631,10 +624,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename symmetric_matrix::difference_type difference_type; typedef typename symmetric_matrix::value_type value_type; + typedef typename symmetric_matrix::difference_type difference_type; typedef typename symmetric_matrix::const_reference reference; - typedef typename symmetric_matrix::const_pointer pointer; + typedef const typename symmetric_matrix::value_type *pointer; #endif typedef const_iterator1 dual_iterator_type; typedef const_reverse_iterator1 dual_reverse_iterator_type; @@ -771,10 +764,10 @@ namespace boost { namespace numeric { namespace ublas { public: typedef packed_random_access_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename symmetric_matrix::difference_type difference_type; typedef typename symmetric_matrix::value_type value_type; + typedef typename symmetric_matrix::difference_type difference_type; typedef typename symmetric_matrix::reference reference; - typedef typename symmetric_matrix::pointer pointer; + typedef typename symmetric_matrix::value_type *pointer; #endif typedef iterator1 dual_iterator_type; typedef reverse_iterator1 dual_reverse_iterator_type; @@ -962,17 +955,11 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS typedef typename M::const_reference const_reference; typedef typename M::reference reference; - typedef typename M::const_pointer const_pointer; - typedef typename M::pointer pointer; #else typedef typename M::const_reference const_reference; typedef typename boost::mpl::if_, typename M::const_reference, typename M::reference>::type reference; - typedef typename M::const_pointer const_pointer; - typedef typename boost::mpl::if_, - typename M::const_pointer, - typename M::pointer>::type pointer; #endif #ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS typedef typename M::closure_type matrix_closure_type; @@ -981,25 +968,12 @@ namespace boost { namespace numeric { namespace ublas { typename M::const_closure_type, typename M::closure_type>::type matrix_closure_type; #endif + private: typedef const symmetric_adaptor const_self_type; typedef symmetric_adaptor self_type; + public: typedef const_self_type const_closure_type; typedef self_type closure_type; -#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS - typedef typename M::const_iterator1 const_iterator1_type; - typedef typename M::iterator1 iterator1_type; - typedef typename M::const_iterator2 const_iterator2_type; - typedef typename M::iterator2 iterator2_type; -#else - typedef typename M::const_iterator1 const_iterator1_type; - typedef typename boost::mpl::if_, - typename M::const_iterator1, - typename M::iterator1>::type iterator1_type; - typedef typename M::const_iterator2 const_iterator2_type; - typedef typename boost::mpl::if_, - typename M::const_iterator2, - typename M::iterator2>::type iterator2_type; -#endif typedef typename storage_restrict_traits::storage_category storage_category; typedef typename F::packed_category packed_category; @@ -1154,6 +1128,26 @@ namespace boost { namespace numeric { namespace ublas { } #endif + // Iterator types + private: + // Use matrix iterator +#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS + typedef typename M::const_iterator1 const_iterator1_type; + typedef typename M::iterator1 iterator1_type; + typedef typename M::const_iterator2 const_iterator2_type; + typedef typename M::iterator2 iterator2_type; +#else + typedef typename M::const_iterator1 const_iterator1_type; + typedef typename boost::mpl::if_, + typename M::const_iterator1, + typename M::iterator1>::type iterator1_type; + typedef typename M::const_iterator2 const_iterator2_type; + typedef typename boost::mpl::if_, + typename M::const_iterator2, + typename M::iterator2>::type iterator2_type; +#endif + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_iterator1 iterator1; typedef indexed_iterator2 iterator2; @@ -1250,8 +1244,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename const_iterator1_type::difference_type difference_type; typedef typename const_iterator1_type::value_type value_type; + typedef typename const_iterator1_type::difference_type difference_type; typedef typename const_iterator1_type::reference reference; typedef typename const_iterator1_type::pointer pointer; #else @@ -1561,8 +1555,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename iterator1_type::difference_type difference_type; typedef typename iterator1_type::value_type value_type; + typedef typename iterator1_type::difference_type difference_type; typedef typename iterator1_type::reference reference; typedef typename iterator1_type::pointer pointer; #else @@ -1699,8 +1693,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename const_iterator2_type::difference_type difference_type; typedef typename const_iterator2_type::value_type value_type; + typedef typename const_iterator2_type::difference_type difference_type; typedef typename const_iterator2_type::reference reference; typedef typename const_iterator2_type::pointer pointer; #else @@ -2010,8 +2004,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename iterator2_type::difference_type difference_type; typedef typename iterator2_type::value_type value_type; + typedef typename iterator2_type::difference_type difference_type; typedef typename iterator2_type::reference reference; typedef typename iterator2_type::pointer pointer; #else diff --git a/include/boost/numeric/ublas/triangular.hpp b/include/boost/numeric/ublas/triangular.hpp index a005b031..8ae1dfd0 100644 --- a/include/boost/numeric/ublas/triangular.hpp +++ b/include/boost/numeric/ublas/triangular.hpp @@ -38,14 +38,13 @@ namespace boost { namespace numeric { namespace ublas { typedef T value_type; typedef const T &const_reference; typedef T &reference; - typedef const T *const_pointer; - typedef T *pointer; + typedef A array_type; + private: typedef F1 functor1_type; typedef F2 functor2_type; - typedef A array_type; - typedef const A const_array_type; typedef const triangular_matrix const_self_type; typedef triangular_matrix self_type; + public: #ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS typedef const matrix_const_reference const_closure_type; #else @@ -93,7 +92,7 @@ namespace boost { namespace numeric { namespace ublas { return size2_; } BOOST_UBLAS_INLINE - const_array_type &data () const { + const array_type &data () const { return data_; } BOOST_UBLAS_INLINE @@ -166,13 +165,6 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - triangular_matrix &reset (const matrix_expression &ae) { - self_type temporary (ae); - resize (temporary.size1 (), temporary.size2 (), false); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE triangular_matrix &assign (const matrix_expression &ae) { matrix_assign (scalar_assign (), *this, ae); return *this; @@ -273,6 +265,7 @@ namespace boost { namespace numeric { namespace ublas { std::fill (data ().begin (), data ().end (), value_type (0)); } + // Iterator types #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_iterator1 iterator1; typedef indexed_iterator2 iterator2; @@ -334,10 +327,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename triangular_matrix::difference_type difference_type; typedef typename triangular_matrix::value_type value_type; + typedef typename triangular_matrix::difference_type difference_type; typedef typename triangular_matrix::const_reference reference; - typedef typename triangular_matrix::const_pointer pointer; + typedef const typename triangular_matrix::value_type *pointer; #endif typedef const_iterator2 dual_iterator_type; typedef const_reverse_iterator2 dual_reverse_iterator_type; @@ -474,10 +467,10 @@ namespace boost { namespace numeric { namespace ublas { public: typedef packed_random_access_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename triangular_matrix::difference_type difference_type; typedef typename triangular_matrix::value_type value_type; + typedef typename triangular_matrix::difference_type difference_type; typedef typename triangular_matrix::reference reference; - typedef typename triangular_matrix::pointer pointer; + typedef typename triangular_matrix::value_type *pointer; #endif typedef iterator2 dual_iterator_type; typedef reverse_iterator2 dual_reverse_iterator_type; @@ -615,10 +608,10 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference; #else - typedef typename triangular_matrix::difference_type difference_type; typedef typename triangular_matrix::value_type value_type; + typedef typename triangular_matrix::difference_type difference_type; typedef typename triangular_matrix::const_reference reference; - typedef typename triangular_matrix::const_pointer pointer; + typedef const typename triangular_matrix::value_type *pointer; #endif typedef const_iterator1 dual_iterator_type; typedef const_reverse_iterator1 dual_reverse_iterator_type; @@ -755,10 +748,10 @@ namespace boost { namespace numeric { namespace ublas { public: typedef packed_random_access_iterator_tag iterator_category; #ifndef BOOST_MSVC_STD_ITERATOR - typedef typename triangular_matrix::difference_type difference_type; typedef typename triangular_matrix::value_type value_type; + typedef typename triangular_matrix::difference_type difference_type; typedef typename triangular_matrix::reference reference; - typedef typename triangular_matrix::pointer pointer; + typedef typename triangular_matrix::value_type *pointer; #endif typedef iterator1 dual_iterator_type; typedef reverse_iterator1 dual_reverse_iterator_type; @@ -962,17 +955,11 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS typedef typename M::const_reference const_reference; typedef typename M::reference reference; - typedef typename M::const_pointer const_pointer; - typedef typename M::pointer pointer; #else typedef typename M::const_reference const_reference; typedef typename boost::mpl::if_, typename M::const_reference, typename M::reference>::type reference; - typedef typename M::const_pointer const_pointer; - typedef typename boost::mpl::if_, - typename M::const_pointer, - typename M::pointer>::type pointer; #endif #ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS typedef typename M::closure_type matrix_closure_type; @@ -981,25 +968,12 @@ namespace boost { namespace numeric { namespace ublas { typename M::const_closure_type, typename M::closure_type>::type matrix_closure_type; #endif + private: typedef const triangular_adaptor const_self_type; typedef triangular_adaptor self_type; + public: typedef const_self_type const_closure_type; typedef self_type closure_type; -#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS - typedef typename M::const_iterator1 const_iterator1_type; - typedef typename M::iterator1 iterator1_type; - typedef typename M::const_iterator2 const_iterator2_type; - typedef typename M::iterator2 iterator2_type; -#else - typedef typename M::const_iterator1 const_iterator1_type; - typedef typename boost::mpl::if_, - typename M::const_iterator1, - typename M::iterator1>::type iterator1_type; - typedef typename M::const_iterator2 const_iterator2_type; - typedef typename boost::mpl::if_, - typename M::const_iterator2, - typename M::iterator2>::type iterator2_type; -#endif typedef typename storage_restrict_traits::storage_category storage_category; typedef typename F::packed_category packed_category; @@ -1168,6 +1142,26 @@ namespace boost { namespace numeric { namespace ublas { } #endif + // Iterator types + private: +#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS + // Use matrix iterator + typedef typename M::const_iterator1 const_iterator1_type; + typedef typename M::iterator1 iterator1_type; + typedef typename M::const_iterator2 const_iterator2_type; + typedef typename M::iterator2 iterator2_type; +#else + typedef typename M::const_iterator1 const_iterator1_type; + typedef typename boost::mpl::if_, + typename M::const_iterator1, + typename M::iterator1>::type iterator1_type; + typedef typename M::const_iterator2 const_iterator2_type; + typedef typename boost::mpl::if_, + typename M::const_iterator2, + typename M::iterator2>::type iterator2_type; +#endif + + public: #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef indexed_iterator1 iterator1; typedef indexed_iterator2 iterator2; @@ -1228,8 +1222,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename const_iterator1_type::difference_type difference_type; typedef typename const_iterator1_type::value_type value_type; + typedef typename const_iterator1_type::difference_type difference_type; typedef typename const_iterator1_type::reference reference; typedef typename const_iterator1_type::pointer pointer; #else @@ -1375,8 +1369,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename iterator1_type::difference_type difference_type; typedef typename iterator1_type::value_type value_type; + typedef typename iterator1_type::difference_type difference_type; typedef typename iterator1_type::reference reference; typedef typename iterator1_type::pointer pointer; #else @@ -1520,8 +1514,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename const_iterator2_type::difference_type difference_type; typedef typename const_iterator2_type::value_type value_type; + typedef typename const_iterator2_type::difference_type difference_type; typedef typename const_iterator2_type::reference reference; typedef typename const_iterator2_type::pointer pointer; #else @@ -1667,8 +1661,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename iterator_restrict_traits::iterator_category iterator_category; - typedef typename iterator2_type::difference_type difference_type; typedef typename iterator2_type::value_type value_type; + typedef typename iterator2_type::difference_type difference_type; typedef typename iterator2_type::reference reference; typedef typename iterator2_type::pointer pointer; #else diff --git a/include/boost/numeric/ublas/vector.hpp b/include/boost/numeric/ublas/vector.hpp index 67acc58d..740b0a99 100644 --- a/include/boost/numeric/ublas/vector.hpp +++ b/include/boost/numeric/ublas/vector.hpp @@ -108,7 +108,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE vector (): vector_expression (), - data_ (0) {} + data_ () {} explicit BOOST_UBLAS_INLINE vector (size_type size): vector_expression (), @@ -175,6 +175,13 @@ namespace boost { namespace numeric { namespace ublas { data () = v.data (); return *this; } + template // Generic vector assignment without temporary + BOOST_UBLAS_INLINE + vector &operator = (const vector &v) { + resize (v.size ()); + assign (v); + return *this; + } BOOST_UBLAS_INLINE vector &assign_temporary (vector &v) { swap (v); @@ -193,14 +200,6 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - vector &reset (const vector_expression &ae) { - self_type temporary (ae); - // FIXME resizing here would seems to destroy temporary - // resize (temporary.size (), false); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE vector &assign (const vector_expression &ae) { vector_assign (scalar_assign (), *this, ae); return *this; @@ -579,6 +578,13 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE bounded_vector (std::size_t size): vector_type (size) {} + BOOST_UBLAS_INLINE + bounded_vector (const bounded_vector &v): + vector_type (v) {} + template // Allow vector construction + BOOST_UBLAS_INLINE + bounded_vector (const vector &v): + vector_type (v) {} template BOOST_UBLAS_INLINE bounded_vector (const vector_expression &ae): @@ -592,13 +598,12 @@ namespace boost { namespace numeric { namespace ublas { vector_type::operator = (v); return *this; } - /* FIXME This overload would be useful but is never chosen - template + template // Generic vector assignment BOOST_UBLAS_INLINE - bounded_vector &operator = (const vector > &v) { + bounded_vector &operator = (const vector &v) { vector_type::operator = (v); return *this; - }*/ + } template BOOST_UBLAS_INLINE bounded_vector &operator = (const vector_expression &ae) { @@ -1437,14 +1442,6 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - c_vector &reset (const vector_expression &ae) { - self_type temporary (ae); - // FIXME resizing here would seems to destroy temporary - // resize (temporary.size (), false); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE c_vector &assign (const vector_expression &ae) { vector_assign (scalar_assign (), *this, ae); return *this; diff --git a/include/boost/numeric/ublas/vector_expression.hpp b/include/boost/numeric/ublas/vector_expression.hpp index 27ff0b6d..ad4e0be4 100644 --- a/include/boost/numeric/ublas/vector_expression.hpp +++ b/include/boost/numeric/ublas/vector_expression.hpp @@ -291,12 +291,6 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - vector_reference &reset (const vector_expression &ae) { - expression ().reset (ae); - return *this; - } - template - BOOST_UBLAS_INLINE vector_reference &assign (const vector_expression &ae) { expression ().assign (ae); return *this; diff --git a/include/boost/numeric/ublas/vector_of_vector.hpp b/include/boost/numeric/ublas/vector_of_vector.hpp index bbf4b26d..98dd199c 100644 --- a/include/boost/numeric/ublas/vector_of_vector.hpp +++ b/include/boost/numeric/ublas/vector_of_vector.hpp @@ -188,13 +188,6 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - generalized_vector_of_vector &reset (const matrix_expression &ae) { - self_type temporary (ae, non_zeros_); - resize (temporary.size1 (), temporary.size2 (), non_zeros_); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE generalized_vector_of_vector &assign (const matrix_expression &ae) { matrix_assign (scalar_assign (), *this, ae); return *this; diff --git a/include/boost/numeric/ublas/vector_sparse.hpp b/include/boost/numeric/ublas/vector_sparse.hpp index cfc2b2d1..97aba485 100644 --- a/include/boost/numeric/ublas/vector_sparse.hpp +++ b/include/boost/numeric/ublas/vector_sparse.hpp @@ -389,13 +389,6 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - sparse_vector &reset (const vector_expression &ae) { - self_type temporary (ae, non_zeros_); - resize (temporary.size (), non_zeros_); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE sparse_vector &assign (const vector_expression &ae) { vector_assign (scalar_assign (), *this, ae); return *this; @@ -516,8 +509,8 @@ namespace boost { namespace numeric { namespace ublas { #else typedef typename sparse_vector::value_type value_type; typedef typename sparse_vector::difference_type difference_type; - typedef const typename sparse_vector::pointer pointer; typedef typename sparse_vector::const_reference reference; + typedef const typename sparse_vector::pointer pointer; #endif // Construction and destruction @@ -600,8 +593,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename sparse_vector::value_type value_type; typedef typename sparse_vector::difference_type difference_type; - typedef typename sparse_vector::pointer pointer; typedef typename sparse_vector::true_reference reference; + typedef typename sparse_vector::pointer pointer; #endif // Construction and destruction @@ -911,13 +904,6 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - compressed_vector &reset (const vector_expression &ae) { - self_type temporary (ae, non_zeros_); - resize (temporary.size (), non_zeros_, false); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE compressed_vector &assign (const vector_expression &ae) { vector_assign (scalar_assign (), *this, ae); return *this; @@ -1070,8 +1056,8 @@ namespace boost { namespace numeric { namespace ublas { #else typedef typename compressed_vector::value_type value_type; typedef typename compressed_vector::difference_type difference_type; - typedef const typename compressed_vector::pointer pointer; typedef typename compressed_vector::const_reference reference; + typedef const typename compressed_vector::pointer pointer; #endif // Construction and destruction @@ -1154,8 +1140,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename compressed_vector::value_type value_type; typedef typename compressed_vector::difference_type difference_type; - typedef typename compressed_vector::pointer pointer; typedef typename compressed_vector::true_reference reference; + typedef typename compressed_vector::pointer pointer; #endif // Construction and destruction @@ -1482,13 +1468,6 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - coordinate_vector &reset (const vector_expression &ae) { - self_type temporary (ae, non_zeros_); - resize (temporary.size (), non_zeros_, false); - return assign_temporary (temporary); - } - template - BOOST_UBLAS_INLINE coordinate_vector &assign (const vector_expression &ae) { vector_assign (scalar_assign (), *this, ae); return *this; @@ -1664,8 +1643,8 @@ namespace boost { namespace numeric { namespace ublas { #else typedef typename coordinate_vector::value_type value_type; typedef typename coordinate_vector::difference_type difference_type; - typedef const typename coordinate_vector::pointer pointer; typedef typename coordinate_vector::const_reference reference; + typedef const typename coordinate_vector::pointer pointer; #endif // Construction and destruction @@ -1748,8 +1727,8 @@ namespace boost { namespace numeric { namespace ublas { #ifndef BOOST_MSVC_STD_ITERATOR typedef typename coordinate_vector::value_type value_type; typedef typename coordinate_vector::difference_type difference_type; - typedef typename coordinate_vector::pointer pointer; typedef typename coordinate_vector::true_reference reference; + typedef typename coordinate_vector::pointer pointer; #endif // Construction and destruction