diff --git a/include/boost/numeric/ublas/config.hpp b/include/boost/numeric/ublas/config.hpp index 9c311954..8973b449 100644 --- a/include/boost/numeric/ublas/config.hpp +++ b/include/boost/numeric/ublas/config.hpp @@ -357,6 +357,9 @@ bool disable_type_check::value = false; // #define BOOST_UBLAS_PROXY_CONST_MEMBER +// Include declerations and functions #include +#include + #endif diff --git a/include/boost/numeric/ublas/definitions.hpp b/include/boost/numeric/ublas/definitions.hpp new file mode 100644 index 00000000..66cb9699 --- /dev/null +++ b/include/boost/numeric/ublas/definitions.hpp @@ -0,0 +1,191 @@ +// +// Copyright (c) 2000-2002 +// Joerg Walter, Mathias Koch +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appear in all copies and +// that both that copyright notice and this permission notice appear +// in supporting documentation. The authors make no representations +// about the suitability of this software for any purpose. +// It is provided "as is" without express or implied warranty. +// +// The authors gratefully acknowledge the support of +// GeNeSys mbH & Co. KG in producing this work. +// + +#ifndef BOOST_UBLAS_DEFINITIONS_H +#define BOOST_UBLAS_DEFINITIONS_H + + +namespace boost { namespace numeric { namespace ublas { + + // Borrowed from Dave Abraham's noncopyable. + // I believe this should be part of utility.hpp one day... + namespace nonassignable_ // protection from unintended ADL + { + class nonassignable { + protected: + nonassignable () {} + ~nonassignable () {} + private: // emphasize the following members are private + const nonassignable& operator= (const nonassignable &); + }; // nonassignable + } + typedef nonassignable_::nonassignable nonassignable; + + + // Assignment proxy. + // Provides temporary free assigment when LHS has no alias on RHS + template + class noalias_proxy: + private nonassignable { + public: + typedef typename C::closure_type closure_type; + + BOOST_UBLAS_INLINE + noalias_proxy (C& lval): + nonassignable (), lval_ (lval) {} + BOOST_UBLAS_INLINE + noalias_proxy (const noalias_proxy& p): + nonassignable (), lval_ (p.lval_) {} + + template + BOOST_UBLAS_INLINE + closure_type &operator= (const E& e) { + lval_.assign (e); + return lval_; + } + + template + BOOST_UBLAS_INLINE + closure_type &operator+= (const E& e) { + lval_.plus_assign (e); + return lval_; + } + + template + BOOST_UBLAS_INLINE + closure_type &operator-= (const E& e) { + lval_.minus_assign (e); + return lval_; + } + + private: + closure_type lval_; + }; + + // Improve syntax of effcient assignment where no aliases of LHS appear on the RHS + // noalias(lhs) = rhs_expression + template + BOOST_UBLAS_INLINE + noalias_proxy noalias (C& lvalue) { + return noalias_proxy (lvalue); + } + template + BOOST_UBLAS_INLINE + noalias_proxy noalias (const C& lvalue) { + return noalias_proxy (lvalue); + } + + + // Dimension accessors + namespace dimension { + // Generic accessors + template + struct dimension_properties {}; + + template<> + struct dimension_properties<1> { + template + BOOST_UBLAS_INLINE static + typename E::size_type size (const vector_expression &e) { + return e ().size (); + } + template + BOOST_UBLAS_INLINE static + typename E::size_type size (const matrix_expression &e) { + return e ().size1 (); + } + // Note: Index functions cannot deduce dependant template parameter V or M from i + template + BOOST_UBLAS_INLINE static + typename V::size_type index (const typename V::iterator &i) { + return i.index (); + } + template + BOOST_UBLAS_INLINE static + typename M::size_type index (const typename M::iterator1 &i) { + return i.index1 (); + } + template + BOOST_UBLAS_INLINE static + typename M::size_type index (const typename M::iterator2 &i) { + return i.index1 (); + } + }; + template<> + struct dimension_properties<2> { + template + BOOST_UBLAS_INLINE static + typename E::size_type size (const vector_expression &) { + return 1; + } + template + BOOST_UBLAS_INLINE static + typename E::size_type size (const matrix_expression &e) { + return e ().size2 (); + } + template + BOOST_UBLAS_INLINE static + typename V::size_type index (const typename V::iterator &) { + return 1; + } + template + BOOST_UBLAS_INLINE static + typename M::size_type index (const typename M::iterator1 &i) { + return i.index2 (); + } + template + BOOST_UBLAS_INLINE static + typename M::size_type index (const typename M::iterator2 &i) { + return i.index2 (); + } + }; + + template + BOOST_UBLAS_INLINE + typename E::size_type size (const E& e) { + return dimension_properties::size (e); + } + + template + BOOST_UBLAS_INLINE + typename I::container_type::size_type + index (const I& i) { + typedef typename I::container_type container_type; + return dimension_properties::template index (i); + } + + // Named accessors - just syntactic sugar + template + typename V::size_type num_elements (const V &v) { + return v.size (); + } + template + typename M::size_type num_rows (const M &m) { + return m.size1 (); + } + template + typename M::size_type num_columns (const M &m) { + return m.size2 (); + } + template + typename MV::size_type num_non_zeros (const MV &mv) { + return mv.non_zeros (); + } + } + +}}} + +#endif diff --git a/include/boost/numeric/ublas/functional.hpp b/include/boost/numeric/ublas/functional.hpp index e94a94b9..a1b03552 100644 --- a/include/boost/numeric/ublas/functional.hpp +++ b/include/boost/numeric/ublas/functional.hpp @@ -179,7 +179,7 @@ namespace boost { namespace numeric { namespace ublas { template struct scalar_binary_assign_functor { - // Remove reference to avoid reference to reference problems + // ISSUE Remove reference to avoid reference to reference problems typedef typename type_traits::type>::reference argument1_type; typedef typename type_traits::const_reference argument2_type; }; diff --git a/include/boost/numeric/ublas/fwd.hpp b/include/boost/numeric/ublas/fwd.hpp index 6678bf9b..3f143870 100644 --- a/include/boost/numeric/ublas/fwd.hpp +++ b/include/boost/numeric/ublas/fwd.hpp @@ -20,21 +20,6 @@ namespace boost { namespace numeric { namespace ublas { - // Borrowed from Dave Abraham's noncopyable. - // I believe this should be part of utility.hpp one day... - namespace nonassignable_ // protection from unintended ADL - { - class nonassignable { - protected: - nonassignable () {} - ~nonassignable () {} - private: // emphasize the following members are private - const nonassignable& operator= (const nonassignable &); - }; // nonassignable - } - typedef nonassignable_::nonassignable nonassignable; - - // Storage types template > class unbounded_array; @@ -101,10 +86,8 @@ namespace boost { namespace numeric { namespace ublas { template class unit_vector; - template class zero_vector; - template class scalar_vector; @@ -113,10 +96,8 @@ namespace boost { namespace numeric { namespace ublas { template > class sparse_vector; - template, class TA = unbounded_array > class compressed_vector; - template, class TA = unbounded_array > class coordinate_vector; @@ -135,10 +116,8 @@ namespace boost { namespace numeric { namespace ublas { template class identity_matrix; - template class zero_matrix; - template class scalar_matrix; @@ -167,31 +146,25 @@ namespace boost { namespace numeric { namespace ublas { template > class triangular_matrix; - template class triangular_adaptor; template > class symmetric_matrix; - template class symmetric_adaptor; template > class hermitian_matrix; - template class hermitian_adaptor; template > class sparse_matrix; - template > > class sparse_vector_of_sparse_vector; - template, class TA = unbounded_array > class compressed_matrix; - template, class TA = unbounded_array > class coordinate_matrix; @@ -199,24 +172,6 @@ namespace boost { namespace numeric { namespace ublas { struct concrete_tag {}; struct abstract_tag {}; - // Some syntactic sugar. I'd like to drop it ;-) - template - typename V::size_type num_elements (const V &v) { - return v.size (); - } - template - typename M::size_type num_rows (const M &m) { - return m.size1 (); - } - template - typename M::size_type num_columns (const M &m) { - return m.size2 (); - } - template - typename MV::size_type num_non_zeros (const MV &mv) { - return mv.non_zeros (); - } - }}} #endif diff --git a/include/boost/numeric/ublas/noalias.hpp b/include/boost/numeric/ublas/noalias.hpp deleted file mode 100644 index ddb448dd..00000000 --- a/include/boost/numeric/ublas/noalias.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// -// Copyright (c) 2004 Michael Stevens -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef BOOST_UBLAS_NOALIAS_H -#define BOOST_UBLAS_NOALIAS_H - -namespace boost { namespace numeric { namespace ublas { - - // Assignment proxy. - // Provides temporary free assigment when LHS has no alias on RHS - template - class noalias_proxy: - private nonassignable { - public: - typedef typename C::closure_type closure_type; - - BOOST_UBLAS_INLINE - noalias_proxy (C& lval): - nonassignable (), lval_ (lval) {} - BOOST_UBLAS_INLINE - noalias_proxy (const noalias_proxy& p): - nonassignable (), lval_ (p.lval_) {} - - template - BOOST_UBLAS_INLINE - closure_type &operator= (const E& e) { - lval_.assign (e); - return lval_; - } - - template - BOOST_UBLAS_INLINE - closure_type &operator+= (const E& e) { - lval_.plus_assign (e); - return lval_; - } - - template - BOOST_UBLAS_INLINE - closure_type &operator-= (const E& e) { - lval_.minus_assign (e); - return lval_; - } - - private: - closure_type lval_; - }; - - // Improve syntax of effcient assignment where no aliases of LHS appear on the RHS - // noalias(lhs) = rhs_expression - template - BOOST_UBLAS_INLINE - noalias_proxy noalias (C& lvalue) { - return noalias_proxy (lvalue); - } - template - BOOST_UBLAS_INLINE - noalias_proxy noalias (const C& lvalue) { - return noalias_proxy (lvalue); - } - -}}} - -#endif diff --git a/include/boost/numeric/ublas/vector_expression.hpp b/include/boost/numeric/ublas/vector_expression.hpp index b5ee3386..6509d9cc 100644 --- a/include/boost/numeric/ublas/vector_expression.hpp +++ b/include/boost/numeric/ublas/vector_expression.hpp @@ -20,7 +20,6 @@ #include #include #include -#include // Expression templates based on ideas of Todd Veldhuizen and Geoffrey Furnish // Iterators based on ideas of Jeremy Siek