From 334bb7fef5808fdd5db7f6bb7cc0a30965965d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Walter?= Date: Tue, 4 Nov 2003 06:52:25 +0000 Subject: [PATCH] Splitted from config.hpp svn path=/trunk/boost/boost/numeric/ublas/; revision=20631 --- include/boost/numeric/ublas/fwd.hpp | 226 ++++++++++++++++++++++++ include/boost/numeric/ublas/noalias.hpp | 102 +++++++++++ 2 files changed, 328 insertions(+) create mode 100644 include/boost/numeric/ublas/fwd.hpp create mode 100644 include/boost/numeric/ublas/noalias.hpp diff --git a/include/boost/numeric/ublas/fwd.hpp b/include/boost/numeric/ublas/fwd.hpp new file mode 100644 index 00000000..27d8737e --- /dev/null +++ b/include/boost/numeric/ublas/fwd.hpp @@ -0,0 +1,226 @@ +// +// 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_FWD_H +#define BOOST_UBLAS_FWD_H + +namespace boost { + + // Borrowed from Dave Abraham's noncopyable. + // I believe this should be part of utility.hpp one day... + class nonassignable { + protected: + nonassignable(){} + ~nonassignable(){} + private: // emphasize the following members are private + const nonassignable& operator=( const nonassignable& ); + }; // nonassignable + +} + +// Forward declarations +namespace boost { namespace numeric { namespace ublas { + + struct concrete_tag {}; + struct abstract_tag {}; + + template + class unbounded_array; + + class range; + class slice; + template > + class indirect_array; + + template + class map_array; + + struct vector_tag {}; + + template + struct vector_expression; + template + class vector_reference; + + struct matrix_tag {}; + + template + struct matrix_expression; + template + class matrix_reference; + + template + class vector_range; + template + class vector_slice; + template > + class vector_indirect; + + template + class matrix_row; + template + class matrix_column; + template + class matrix_range; + template + class matrix_slice; + template > + class matrix_indirect; + + template > + class vector; + template + class bounded_vector; + + template + class unit_vector; + + template + class scalar_vector; + + template + class c_vector; + + template > + class sparse_vector; + + template, class TA = unbounded_array > + class compressed_vector; + + template, class TA = unbounded_array > + class coordinate_vector; + + struct unknown_orientation_tag {}; + + struct row_major_tag {}; + struct row_major; + + struct column_major_tag {}; + struct column_major; + + template > + class matrix; + template + class bounded_matrix; + + template + class identity_matrix; + + template + class scalar_matrix; + + template + class c_matrix; + + template > > + class vector_of_vector; + + template > + class banded_matrix; + template > + class diagonal_matrix; + + struct lower_tag {}; + struct lower; + + struct upper_tag {}; + struct upper; + + struct unit_lower_tag: public lower_tag {}; + struct unit_lower; + + struct unit_upper_tag: public upper_tag {}; + struct unit_upper; + + 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; + + // 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 new file mode 100644 index 00000000..aa3cc53e --- /dev/null +++ b/include/boost/numeric/ublas/noalias.hpp @@ -0,0 +1,102 @@ +// +// Copyright (c) 2003 +// Michael Stevens +// +// 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. +// + +#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 boost::nonassignable { + public: + typedef typename C::closure_type closure_type; + + BOOST_UBLAS_INLINE + noalias_proxy (C& lval): + lval_ (lval) {} + BOOST_UBLAS_INLINE + noalias_proxy (const noalias_proxy& p): + 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 + + + + + + + + + + + + + + + + + + + + + + + + + + + +