From 5a3559f12daadafc21271f82677f7cc8db7e05eb Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 21 Mar 2006 02:26:31 +0000 Subject: [PATCH 001/280] This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'. svn path=/branches/RC_1_34_0/boost/boost/numeric/ublas/; revision=33417 From 2d5b0744b08828e7fe91c32a521ca3c24c8cb054 Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Fri, 14 Apr 2006 08:45:43 +0000 Subject: [PATCH 002/280] Merge unsupported compiler workaround svn path=/branches/RC_1_34_0/boost/boost/numeric/ublas/; revision=33695 --- include/boost/numeric/ublas/detail/config.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/numeric/ublas/detail/config.hpp b/include/boost/numeric/ublas/detail/config.hpp index 65a03ef2..ef692cf9 100644 --- a/include/boost/numeric/ublas/detail/config.hpp +++ b/include/boost/numeric/ublas/detail/config.hpp @@ -162,13 +162,15 @@ namespace std { #endif -// Detect other compilers with serious defects +// Detect other compilers with serious defects - override by defineing BOOST_UBLAS_UNSUPPORTED_COMPILER=0 +#ifndef BOOST_UBLAS_UNSUPPORTED_COMPILER #if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(BOOST_NO_SFINAE) || defined(BOOST_NO_STDC_NAMESPACE) #define BOOST_UBLAS_UNSUPPORTED_COMPILER #endif +#endif // Cannot continue with an unsupported compiler -#ifdef BOOST_UBLAS_UNSUPPORTED_COMPILER +#if defined(BOOST_UBLAS_UNSUPPORTED_COMPILER) && (BOOST_UBLAS_UNSUPPORTED_COMPILER != 0) #error Your compiler is unsupported by this verions of uBLAS. Boost 1.32.0 includes uBLAS with support for many old compilers. #endif From 4f7d1cb61a9ce617b67ec3334061e529f35bd079 Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Sun, 16 Apr 2006 17:43:50 +0000 Subject: [PATCH 003/280] uBLAS Merge reinstatement of array_adaptors svn path=/branches/RC_1_34_0/boost/boost/numeric/ublas/; revision=33711 --- include/boost/numeric/ublas/storage.hpp | 321 ++++++++++++++++++++---- 1 file changed, 275 insertions(+), 46 deletions(-) diff --git a/include/boost/numeric/ublas/storage.hpp b/include/boost/numeric/ublas/storage.hpp index 28a109b5..54bf2274 100644 --- a/include/boost/numeric/ublas/storage.hpp +++ b/include/boost/numeric/ublas/storage.hpp @@ -18,6 +18,9 @@ #define BOOST_UBLAS_STORAGE_H #include +#ifdef BOOST_UBLAS_SHALLOW_ARRAY_ADAPTOR +#include +#endif #include #include @@ -87,7 +90,6 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE unbounded_array (const unbounded_array &c): - storage_array (), alloc_ (c.alloc_), size_ (c.size_) { if (size_) { data_ = alloc_.allocate (size_); @@ -316,7 +318,6 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE bounded_array (const bounded_array &c): - storage_array (), size_ (c.size_) { // ISSUE elements should be copy constructed here, but we must copy instead as already default constructed std::copy (c.data_, c.data_ + c.size_, data_); @@ -437,13 +438,12 @@ namespace boost { namespace numeric { namespace ublas { }; - // C Array adaptor - // As the element storage must be fixed to a C array this class cannot be copy constructed + // Array adaptor with normal deep copy semantics of elements template - class carray_adaptor: - public storage_array > { + class array_adaptor: + public storage_array > { - typedef carray_adaptor self_type; + typedef array_adaptor self_type; public: typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; @@ -455,60 +455,86 @@ namespace boost { namespace numeric { namespace ublas { // Construction and destruction BOOST_UBLAS_INLINE - carray_adaptor (): - size_ (0), data_ (0) { + array_adaptor (): + size_ (0), own_ (true), data_ (new value_type [0]) { + } + explicit BOOST_UBLAS_INLINE + array_adaptor (size_type size): + size_ (size), own_ (true), data_ (new value_type [size]) { } BOOST_UBLAS_INLINE - carray_adaptor (size_type size, pointer data): - size_ (size), data_ (data) {} - BOOST_UBLAS_INLINE - carray_adaptor (size_type size, pointer data, const value_type &init): - size_ (size), data_ (data) { - std::fill (begin(), end(), init) ; + array_adaptor (size_type size, const value_type &init): + size_ (size), own_ (true), data_ (new value_type [size]) { + std::fill (data_, data_ + size_, init); } BOOST_UBLAS_INLINE - ~carray_adaptor () { + array_adaptor (size_type size, pointer data): + size_ (size), own_ (false), data_ (data) {} + BOOST_UBLAS_INLINE + array_adaptor (const array_adaptor &a): + storage_array (), + size_ (a.size_), own_ (true), data_ (new value_type [a.size_]) { + *this = a; + } + BOOST_UBLAS_INLINE + ~array_adaptor () { + if (own_) { + delete [] data_; + } } - // No copy constructor - private: - carray_adaptor (const carray_adaptor& ); - - public: // Resizing + private: + BOOST_UBLAS_INLINE + void resize_internal (size_type size, value_type init, bool preserve = true) { + if (size != size_) { + pointer data = new value_type [size]; + if (preserve) { + std::copy (data_, data_ + (std::min) (size, size_), data); + std::fill (data + (std::min) (size, size_), data + size, init); + } + if (own_) + delete [] data_; + size_ = size; + own_ = true; + data_ = data; + } + } + BOOST_UBLAS_INLINE + void resize_internal (size_type size, pointer data, value_type init, bool preserve = true) { + if (data != data_) { + if (preserve) { + std::copy (data_, data_ + (std::min) (size, size_), data); + std::fill (data + (std::min) (size, size_), data + size, init); + } + if (own_) + delete [] data_; + own_ = false; + data_ = data; + } + else { + std::fill (data + (std::min) (size, size_), data + size, init); + } + size_ = size; + } + public: BOOST_UBLAS_INLINE void resize (size_type size) { - size_ = size; + resize_internal (size, value_type (), false); } BOOST_UBLAS_INLINE void resize (size_type size, value_type init) { - std::fill (data_ + size_, data_ + size, init); - size_ = size; + resize_internal (size, init, true); } BOOST_UBLAS_INLINE void resize (size_type size, pointer data) { - size_ = size; - data_ = data; + resize_internal (size, data, value_type (), false); } BOOST_UBLAS_INLINE void resize (size_type size, pointer data, value_type init) { - std::copy (data_, data_ + std::min (size_, size), data); - std::fill (data_ + size_, data_ + size, init); - size_ = size; - data_ = data; + resize_internal (size, data, init, true); } - // Random Access Container - BOOST_UBLAS_INLINE - size_type max_size () const { - return std::numeric_limits::max (); - } - - BOOST_UBLAS_INLINE - bool empty () const { - return size_ == 0; - } - BOOST_UBLAS_INLINE size_type size () const { return size_; @@ -528,7 +554,7 @@ namespace boost { namespace numeric { namespace ublas { // Assignment BOOST_UBLAS_INLINE - carray_adaptor &operator = (const carray_adaptor &a) { + array_adaptor &operator = (const array_adaptor &a) { if (this != &a) { resize (a.size_); std::copy (a.data_, a.data_ + a.size_, data_); @@ -536,21 +562,25 @@ namespace boost { namespace numeric { namespace ublas { return *this; } BOOST_UBLAS_INLINE - carray_adaptor &assign_temporary (carray_adaptor &a) { - *this = a; + array_adaptor &assign_temporary (array_adaptor &a) { + if (own_ && a.own_) + swap (a); + else + *this = a; return *this; } // Swapping BOOST_UBLAS_INLINE - void swap (carray_adaptor &a) { + void swap (array_adaptor &a) { if (this != &a) { std::swap (size_, a.size_); + std::swap (own_, a.own_); std::swap (data_, a.data_); } } BOOST_UBLAS_INLINE - friend void swap (carray_adaptor &a1, carray_adaptor &a2) { + friend void swap (array_adaptor &a1, array_adaptor &a2) { a1.swap (a2); } @@ -601,9 +631,208 @@ namespace boost { namespace numeric { namespace ublas { private: size_type size_; + bool own_; pointer data_; }; +#ifdef BOOST_UBLAS_SHALLOW_ARRAY_ADAPTOR + // Array adaptor with shallow (reference) copy semantics of elements. + // shared_array is used to maintain reference counts. + // This class breaks the normal copy semantics for a storage container and is very dangerous! + template + class shallow_array_adaptor: + public storage_array > { + + typedef shallow_array_adaptor self_type; + + template + struct leaker { + typedef void result_type; + typedef TT *argument_type; + + BOOST_UBLAS_INLINE + result_type operator () (argument_type x) {} + }; + + public: + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef T value_type; + typedef const T &const_reference; + typedef T &reference; + typedef const T *const_pointer; + typedef T *pointer; + + // Construction and destruction + BOOST_UBLAS_INLINE + shallow_array_adaptor (): + size_ (0), own_ (true), data_ (new value_type [0]) { + } + explicit BOOST_UBLAS_INLINE + shallow_array_adaptor (size_type size): + size_ (size), own_ (true), data_ (new value_type [size]) { + } + BOOST_UBLAS_INLINE + shallow_array_adaptor (size_type size, const value_type &init): + size_ (size), own_ (true), data_ (new value_type [size]) { + std::fill (data_.get (), data_.get () + size_, init); + } + BOOST_UBLAS_INLINE + shallow_array_adaptor (size_type size, pointer data): + size_ (size), own_ (false), data_ (data, leaker ()) {} + + BOOST_UBLAS_INLINE + shallow_array_adaptor (const shallow_array_adaptor &a): + storage_array (), + size_ (a.size_), own_ (a.own_), data_ (a.data_) {} + + BOOST_UBLAS_INLINE + ~shallow_array_adaptor () { + } + + // Resizing + private: + BOOST_UBLAS_INLINE + void resize_internal (size_type size, value_type init, bool preserve = true) { + if (size != size_) { + shared_array data (new value_type [size]); + if (preserve) { + std::copy (data_.get (), data_.get () + (std::min) (size, size_), data.get ()); + std::fill (data.get () + (std::min) (size, size_), data.get () + size, init); + } + size_ = size; + data_ = data; + } + } + BOOST_UBLAS_INLINE + void resize_internal (size_type size, pointer data, value_type init, bool preserve = true) { + if (preserve) { + std::copy (data_.get (), data_.get () + (std::min) (size, size_), data); + std::fill (data + (std::min) (size, size_), data + size, init); + } + size_ = size; + data_ = data; + } + public: + BOOST_UBLAS_INLINE + void resize (size_type size) { + resize_internal (size, value_type (), false); + } + BOOST_UBLAS_INLINE + void resize (size_type size, value_type init) { + resize_internal (size, init, true); + } + BOOST_UBLAS_INLINE + void resize (size_type size, pointer data) { + resize_internal (size, data, value_type (), false); + } + BOOST_UBLAS_INLINE + void resize (size_type size, pointer data, value_type init) { + resize_internal (size, data, init, true); + } + + BOOST_UBLAS_INLINE + size_type size () const { + return size_; + } + + // Element access + BOOST_UBLAS_INLINE + const_reference operator [] (size_type i) const { + BOOST_UBLAS_CHECK (i < size_, bad_index ()); + return data_ [i]; + } + BOOST_UBLAS_INLINE + reference operator [] (size_type i) { + BOOST_UBLAS_CHECK (i < size_, bad_index ()); + return data_ [i]; + } + + // Assignment + BOOST_UBLAS_INLINE + shallow_array_adaptor &operator = (const shallow_array_adaptor &a) { + if (this != &a) { + resize (a.size_); + std::copy (a.data_.get (), a.data_.get () + a.size_, data_.get ()); + } + return *this; + } + BOOST_UBLAS_INLINE + shallow_array_adaptor &assign_temporary (shallow_array_adaptor &a) { + if (own_ && a.own_) + swap (a); + else + *this = a; + return *this; + } + + // Swapping + BOOST_UBLAS_INLINE + void swap (shallow_array_adaptor &a) { + if (this != &a) { + std::swap (size_, a.size_); + std::swap (own_, a.own_); + std::swap (data_, a.data_); + } + } + BOOST_UBLAS_INLINE + friend void swap (shallow_array_adaptor &a1, shallow_array_adaptor &a2) { + a1.swap (a2); + } + + // Iterators simply are pointers. + + typedef const_pointer const_iterator; + + BOOST_UBLAS_INLINE + const_iterator begin () const { + return data_.get (); + } + BOOST_UBLAS_INLINE + const_iterator end () const { + return data_.get () + size_; + } + + typedef pointer iterator; + + BOOST_UBLAS_INLINE + iterator begin () { + return data_.get (); + } + BOOST_UBLAS_INLINE + iterator end () { + return data_.get () + size_; + } + + // Reverse iterators + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + + BOOST_UBLAS_INLINE + const_reverse_iterator rbegin () const { + return const_reverse_iterator (end ()); + } + BOOST_UBLAS_INLINE + const_reverse_iterator rend () const { + return const_reverse_iterator (begin ()); + } + BOOST_UBLAS_INLINE + reverse_iterator rbegin () { + return reverse_iterator (end ()); + } + BOOST_UBLAS_INLINE + reverse_iterator rend () { + return reverse_iterator (begin ()); + } + + private: + size_type size_; + bool own_; + shared_array data_; + }; + +#endif + // Range class template From 5ff762a9b9823102d778361cd472f0497bdbd1f9 Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Thu, 8 Jun 2006 20:45:01 +0000 Subject: [PATCH 004/280] MERGE from HEAD: FIX Workaround BBc2 problem on linking source from subdirectories. The link command line tried to link on the directory svn path=/branches/RC_1_34_0/boost/libs/numeric/ublas/; revision=34252 --- test/Jamfile | 50 ++++++++++++++++++------------------- test/Jamfile.v2 | 50 ++++++++++++++++++------------------- test/{test1 => }/test1.cpp | 0 test/{test1 => }/test1.hpp | 2 +- test/test1/Jamfile | 31 ----------------------- test/{test1 => }/test11.cpp | 0 test/{test1 => }/test12.cpp | 0 test/{test1 => }/test13.cpp | 0 test/{test2 => }/test2.cpp | 0 test/{test2 => }/test2.hpp | 2 +- test/test2/Jamfile | 28 --------------------- test/{test2 => }/test21.cpp | 0 test/{test2 => }/test22.cpp | 0 test/{test2 => }/test23.cpp | 0 test/{test3 => }/test3.cpp | 0 test/{test3 => }/test3.hpp | 2 +- test/test3/Jamfile | 28 --------------------- test/{test3 => }/test31.cpp | 0 test/{test3 => }/test32.cpp | 0 test/{test3 => }/test33.cpp | 0 test/{test4 => }/test4.cpp | 0 test/{test4 => }/test4.hpp | 2 +- test/test4/Jamfile | 28 --------------------- test/{test4 => }/test42.cpp | 0 test/{test4 => }/test43.cpp | 0 test/{test5 => }/test5.cpp | 0 test/{test5 => }/test5.hpp | 2 +- test/test5/Jamfile | 28 --------------------- test/{test5 => }/test52.cpp | 0 test/{test5 => }/test53.cpp | 0 test/{test6 => }/test6.cpp | 0 test/{test6 => }/test6.hpp | 2 +- test/test6/Jamfile | 28 --------------------- test/{test6 => }/test62.cpp | 0 test/{test6 => }/test63.cpp | 0 test/{test7 => }/test7.cpp | 0 test/{test7 => }/test7.hpp | 2 +- test/test7/Jamfile | 32 ------------------------ test/{test7 => }/test71.cpp | 0 test/{test7 => }/test72.cpp | 0 test/{test7 => }/test73.cpp | 0 41 files changed, 57 insertions(+), 260 deletions(-) rename test/{test1 => }/test1.cpp (100%) rename test/{test1 => }/test1.hpp (97%) delete mode 100644 test/test1/Jamfile rename test/{test1 => }/test11.cpp (100%) rename test/{test1 => }/test12.cpp (100%) rename test/{test1 => }/test13.cpp (100%) rename test/{test2 => }/test2.cpp (100%) rename test/{test2 => }/test2.hpp (97%) delete mode 100644 test/test2/Jamfile rename test/{test2 => }/test21.cpp (100%) rename test/{test2 => }/test22.cpp (100%) rename test/{test2 => }/test23.cpp (100%) rename test/{test3 => }/test3.cpp (100%) rename test/{test3 => }/test3.hpp (97%) delete mode 100644 test/test3/Jamfile rename test/{test3 => }/test31.cpp (100%) rename test/{test3 => }/test32.cpp (100%) rename test/{test3 => }/test33.cpp (100%) rename test/{test4 => }/test4.cpp (100%) rename test/{test4 => }/test4.hpp (97%) delete mode 100644 test/test4/Jamfile rename test/{test4 => }/test42.cpp (100%) rename test/{test4 => }/test43.cpp (100%) rename test/{test5 => }/test5.cpp (100%) rename test/{test5 => }/test5.hpp (97%) delete mode 100644 test/test5/Jamfile rename test/{test5 => }/test52.cpp (100%) rename test/{test5 => }/test53.cpp (100%) rename test/{test6 => }/test6.cpp (100%) rename test/{test6 => }/test6.hpp (97%) delete mode 100644 test/test6/Jamfile rename test/{test6 => }/test62.cpp (100%) rename test/{test6 => }/test63.cpp (100%) rename test/{test7 => }/test7.cpp (100%) rename test/{test7 => }/test7.hpp (97%) delete mode 100644 test/test7/Jamfile rename test/{test7 => }/test71.cpp (100%) rename test/{test7 => }/test72.cpp (100%) rename test/{test7 => }/test73.cpp (100%) diff --git a/test/Jamfile b/test/Jamfile index a2ca2a41..ea55bffe 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -45,10 +45,10 @@ UBLAS_TESTSET_SPARSE ?= test-suite numeric/uBLAS - : [ run test1/test1.cpp - test1/test11.cpp - test1/test12.cpp - test1/test13.cpp + : [ run test1.cpp + test11.cpp + test12.cpp + test13.cpp : # args : # input files : # requirements @@ -56,47 +56,47 @@ test-suite numeric/uBLAS <*>"-fpstkchk" # Try and pick up runtime failures <*>"BOOST_UBLAS_NO_ELEMENT_PROXIES" [ cond [ is-subset Darwin : $(JAMUNAME) ] : <*>"-fabi-version=0" ] ] - [ run test2/test2.cpp - test2/test21.cpp - test2/test22.cpp - test2/test23.cpp + [ run test2.cpp + test21.cpp + test22.cpp + test23.cpp : # args : # input files : # requirements $(UBLAS_TESTSET) <*>"BOOST_UBLAS_NO_ELEMENT_PROXIES" ] - [ run test3/test3.cpp - test3/test31.cpp - test3/test32.cpp - test3/test33.cpp + [ run test3.cpp + test31.cpp + test32.cpp + test33.cpp : # args : # input files : # requirements $(UBLAS_TESTSET_SPARSE) <*>"BOOST_UBLAS_NO_ELEMENT_PROXIES" ] - [ run test4/test4.cpp - test4/test42.cpp - test4/test43.cpp + [ run test4.cpp + test42.cpp + test43.cpp : # args : # input files : # requirements $(UBLAS_TESTSET) <*>"BOOST_UBLAS_NO_ELEMENT_PROXIES" ] - [ run test5/test5.cpp - test5/test52.cpp - test5/test53.cpp + [ run test5.cpp + test52.cpp + test53.cpp : # args : # input files : # requirements $(UBLAS_TESTSET) <*>"BOOST_UBLAS_NO_ELEMENT_PROXIES" ] - [ run test6/test6.cpp - test6/test62.cpp - test6/test63.cpp + [ run test6.cpp + test62.cpp + test63.cpp : # args : # input files : # requirements @@ -105,10 +105,10 @@ test-suite numeric/uBLAS ] # Test7 checks uBLAS operation with interval types. # This causes too much compiler badness. Issues need to be addressed for VC7.1 VC8 CW9 and Intel 8 (windows) -# [ run test7/test7.cpp -# test7/test71.cpp -# test7/test72.cpp -# test7/test73.cpp +# [ run test7.cpp +# test71.cpp +# test72.cpp +# test73.cpp # : # args # : # input files # : # requirements diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 81dd2dab..a1b401ed 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -47,52 +47,52 @@ project test-suite numeric/uBLAS - : [ run test1/test1.cpp - test1/test11.cpp - test1/test12.cpp - test1/test13.cpp + : [ run test1.cpp + test11.cpp + test12.cpp + test13.cpp : # args : # input files : # requirements $(UBLAS_TESTSET) ] - [ run test2/test2.cpp - test2/test21.cpp - test2/test22.cpp - test2/test23.cpp + [ run test2.cpp + test21.cpp + test22.cpp + test23.cpp : : : $(UBLAS_TESTSET) ] - [ run test3/test3.cpp - test3/test31.cpp - test3/test32.cpp - test3/test33.cpp + [ run test3.cpp + test31.cpp + test32.cpp + test33.cpp : : : $(UBLAS_TESTSET_SPARSE) ] - [ run test4/test4.cpp - test4/test42.cpp - test4/test43.cpp + [ run test4.cpp + test42.cpp + test43.cpp : : : $(UBLAS_TESTSET) ] - [ run test5/test5.cpp - test5/test52.cpp - test5/test53.cpp + [ run test5.cpp + test52.cpp + test53.cpp : : : $(UBLAS_TESTSET) ] - [ run test6/test6.cpp - test6/test62.cpp - test6/test63.cpp + [ run test6.cpp + test62.cpp + test63.cpp : : : $(UBLAS_TESTSET) ] # Test commented out, just like in V1 Jamfile -# [ run test7/test7.cpp -# test7/test71.cpp -# test7/test72.cpp -# test7/test73.cpp +# [ run test7.cpp +# test71.cpp +# test72.cpp +# test73.cpp # : : : # BOOST_UBLAS_USE_INTERVAL # $(UBLAS_TESTSET) diff --git a/test/test1/test1.cpp b/test/test1.cpp similarity index 100% rename from test/test1/test1.cpp rename to test/test1.cpp diff --git a/test/test1/test1.hpp b/test/test1.hpp similarity index 97% rename from test/test1/test1.hpp rename to test/test1.hpp index f62dc8bf..84dd7307 100644 --- a/test/test1/test1.hpp +++ b/test/test1.hpp @@ -27,7 +27,7 @@ namespace ublas = boost::numeric::ublas; -#include "../common/init.hpp" +#include "common/init.hpp" void test_vector (); void test_matrix_vector (); diff --git a/test/test1/Jamfile b/test/test1/Jamfile deleted file mode 100644 index dbfef0d7..00000000 --- a/test/test1/Jamfile +++ /dev/null @@ -1,31 +0,0 @@ -# -# 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. -# - -subproject libs/numeric/ublas/test1 ; - -SOURCES = test1 test11 test12 test13 ; - -exe test1 - : $(SOURCES).cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) -# <*>"-fabi-version=0" - <*>"-Xc" - ; - - - - diff --git a/test/test1/test11.cpp b/test/test11.cpp similarity index 100% rename from test/test1/test11.cpp rename to test/test11.cpp diff --git a/test/test1/test12.cpp b/test/test12.cpp similarity index 100% rename from test/test1/test12.cpp rename to test/test12.cpp diff --git a/test/test1/test13.cpp b/test/test13.cpp similarity index 100% rename from test/test1/test13.cpp rename to test/test13.cpp diff --git a/test/test2/test2.cpp b/test/test2.cpp similarity index 100% rename from test/test2/test2.cpp rename to test/test2.cpp diff --git a/test/test2/test2.hpp b/test/test2.hpp similarity index 97% rename from test/test2/test2.hpp rename to test/test2.hpp index b38e5f56..0e9e7777 100644 --- a/test/test2/test2.hpp +++ b/test/test2.hpp @@ -27,7 +27,7 @@ namespace ublas = boost::numeric::ublas; -#include "../common/init.hpp" +#include "common/init.hpp" template struct test_blas_1 { diff --git a/test/test2/Jamfile b/test/test2/Jamfile deleted file mode 100644 index 9e4c3849..00000000 --- a/test/test2/Jamfile +++ /dev/null @@ -1,28 +0,0 @@ -# -# 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. -# - -subproject libs/numeric/ublas/test2 ; - -SOURCES = test2 test21 test22 test23 ; - -exe test2 - : $(SOURCES).cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) -# <*>"-fabi-version=0" - <*>"-Xc" - ; - diff --git a/test/test2/test21.cpp b/test/test21.cpp similarity index 100% rename from test/test2/test21.cpp rename to test/test21.cpp diff --git a/test/test2/test22.cpp b/test/test22.cpp similarity index 100% rename from test/test2/test22.cpp rename to test/test22.cpp diff --git a/test/test2/test23.cpp b/test/test23.cpp similarity index 100% rename from test/test2/test23.cpp rename to test/test23.cpp diff --git a/test/test3/test3.cpp b/test/test3.cpp similarity index 100% rename from test/test3/test3.cpp rename to test/test3.cpp diff --git a/test/test3/test3.hpp b/test/test3.hpp similarity index 97% rename from test/test3/test3.hpp rename to test/test3.hpp index 6a78c38b..99f298f9 100644 --- a/test/test3/test3.hpp +++ b/test/test3.hpp @@ -33,7 +33,7 @@ namespace ublas = boost::numeric::ublas; -#include "../common/init.hpp" +#include "common/init.hpp" void test_vector (); void test_matrix_vector (); diff --git a/test/test3/Jamfile b/test/test3/Jamfile deleted file mode 100644 index 76589e0b..00000000 --- a/test/test3/Jamfile +++ /dev/null @@ -1,28 +0,0 @@ -# -# 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. -# - -subproject libs/numeric/ublas/test3 ; - -SOURCES = test3 test31 test32 test33 ; - -exe test3 - : $(SOURCES).cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) -# <*>"-fabi-version=0" - <*>"-Xc" - ; - diff --git a/test/test3/test31.cpp b/test/test31.cpp similarity index 100% rename from test/test3/test31.cpp rename to test/test31.cpp diff --git a/test/test3/test32.cpp b/test/test32.cpp similarity index 100% rename from test/test3/test32.cpp rename to test/test32.cpp diff --git a/test/test3/test33.cpp b/test/test33.cpp similarity index 100% rename from test/test3/test33.cpp rename to test/test33.cpp diff --git a/test/test4/test4.cpp b/test/test4.cpp similarity index 100% rename from test/test4/test4.cpp rename to test/test4.cpp diff --git a/test/test4/test4.hpp b/test/test4.hpp similarity index 97% rename from test/test4/test4.hpp rename to test/test4.hpp index 24436240..4a4b946d 100644 --- a/test/test4/test4.hpp +++ b/test/test4.hpp @@ -27,7 +27,7 @@ namespace ublas = boost::numeric::ublas; -#include "../common/init.hpp" +#include "common/init.hpp" //#define USE_BANDED #define USE_DIAGONAL diff --git a/test/test4/Jamfile b/test/test4/Jamfile deleted file mode 100644 index e7be5dcf..00000000 --- a/test/test4/Jamfile +++ /dev/null @@ -1,28 +0,0 @@ -# -# 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. -# - -subproject libs/numeric/ublas/test4 ; - -SOURCES = test4 test42 test43 ; - -exe test4 - : $(SOURCES).cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) -# <*>"-fabi-version=0" - <*>"-Xc" - ; - diff --git a/test/test4/test42.cpp b/test/test42.cpp similarity index 100% rename from test/test4/test42.cpp rename to test/test42.cpp diff --git a/test/test4/test43.cpp b/test/test43.cpp similarity index 100% rename from test/test4/test43.cpp rename to test/test43.cpp diff --git a/test/test5/test5.cpp b/test/test5.cpp similarity index 100% rename from test/test5/test5.cpp rename to test/test5.cpp diff --git a/test/test5/test5.hpp b/test/test5.hpp similarity index 97% rename from test/test5/test5.hpp rename to test/test5.hpp index aeec1d8a..a1269310 100644 --- a/test/test5/test5.hpp +++ b/test/test5.hpp @@ -27,7 +27,7 @@ namespace ublas = boost::numeric::ublas; -#include "../common/init.hpp" +#include "common/init.hpp" void test_matrix_vector (); void test_matrix (); diff --git a/test/test5/Jamfile b/test/test5/Jamfile deleted file mode 100644 index 91b34119..00000000 --- a/test/test5/Jamfile +++ /dev/null @@ -1,28 +0,0 @@ -# -# 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. -# - -subproject libs/numeric/ublas/test5 ; - -SOURCES = test5 test52 test53 ; - -exe test5 - : $(SOURCES).cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) -# <*>"-fabi-version=0" - <*>"-Xc" - ; - diff --git a/test/test5/test52.cpp b/test/test52.cpp similarity index 100% rename from test/test5/test52.cpp rename to test/test52.cpp diff --git a/test/test5/test53.cpp b/test/test53.cpp similarity index 100% rename from test/test5/test53.cpp rename to test/test53.cpp diff --git a/test/test6/test6.cpp b/test/test6.cpp similarity index 100% rename from test/test6/test6.cpp rename to test/test6.cpp diff --git a/test/test6/test6.hpp b/test/test6.hpp similarity index 97% rename from test/test6/test6.hpp rename to test/test6.hpp index 0097ac14..0517fa1a 100644 --- a/test/test6/test6.hpp +++ b/test/test6.hpp @@ -27,7 +27,7 @@ namespace ublas = boost::numeric::ublas; -#include "../common/init.hpp" +#include "common/init.hpp" void test_matrix_vector (); void test_matrix (); diff --git a/test/test6/Jamfile b/test/test6/Jamfile deleted file mode 100644 index 7da15ade..00000000 --- a/test/test6/Jamfile +++ /dev/null @@ -1,28 +0,0 @@ -# -# 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. -# - -subproject libs/numeric/ublas/test6 ; - -SOURCES = test6 test62 test63 ; - -exe test6 - : $(SOURCES).cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) -# <*>"-fabi-version=0" - <*>"-Xc" - ; - diff --git a/test/test6/test62.cpp b/test/test62.cpp similarity index 100% rename from test/test6/test62.cpp rename to test/test62.cpp diff --git a/test/test6/test63.cpp b/test/test63.cpp similarity index 100% rename from test/test6/test63.cpp rename to test/test63.cpp diff --git a/test/test7/test7.cpp b/test/test7.cpp similarity index 100% rename from test/test7/test7.cpp rename to test/test7.cpp diff --git a/test/test7/test7.hpp b/test/test7.hpp similarity index 97% rename from test/test7/test7.hpp rename to test/test7.hpp index 94a5c710..75e41a5f 100644 --- a/test/test7/test7.hpp +++ b/test/test7.hpp @@ -30,7 +30,7 @@ namespace ublas = boost::numeric::ublas; -#include "../common/init.hpp" +#include "common/init.hpp" void test_vector (); void test_matrix_vector (); diff --git a/test/test7/Jamfile b/test/test7/Jamfile deleted file mode 100644 index e31f96e1..00000000 --- a/test/test7/Jamfile +++ /dev/null @@ -1,32 +0,0 @@ -# -# 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. -# - -subproject libs/numeric/ublas/test7 ; - -SOURCES = test7 test71 test72 test73 ; - -exe test7 - : $(SOURCES).cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - BOOST_UBLAS_USE_INTERVAL -# <*>"-fabi-version=0" - <*>"-Xc" -; - - - - diff --git a/test/test7/test71.cpp b/test/test71.cpp similarity index 100% rename from test/test7/test71.cpp rename to test/test71.cpp diff --git a/test/test7/test72.cpp b/test/test72.cpp similarity index 100% rename from test/test7/test72.cpp rename to test/test72.cpp diff --git a/test/test7/test73.cpp b/test/test73.cpp similarity index 100% rename from test/test7/test73.cpp rename to test/test73.cpp From d0df432102ce9ff1dcad722ce6b2d7ee2e1abb34 Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Mon, 10 Jul 2006 16:21:28 +0000 Subject: [PATCH 005/280] [uBLAS] FIX unspoorted compilers set BOOST_UBLAS_UNSUPPORTED_COMPILER=1 so we can compare with !=- to override svn path=/branches/RC_1_34_0/boost/boost/numeric/ublas/; revision=34501 --- include/boost/numeric/ublas/detail/config.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/numeric/ublas/detail/config.hpp b/include/boost/numeric/ublas/detail/config.hpp index ef692cf9..37bf297e 100644 --- a/include/boost/numeric/ublas/detail/config.hpp +++ b/include/boost/numeric/ublas/detail/config.hpp @@ -38,7 +38,7 @@ // Version 6.0 and 7.0 #if BOOST_MSVC <= 1300 -#define BOOST_UBLAS_UNSUPPORTED_COMPILER +#define BOOST_UBLAS_UNSUPPORTED_COMPILER 1 #endif // Version 7.1 @@ -63,7 +63,7 @@ #endif #if __GNUC__ < 3 -#define BOOST_UBLAS_UNSUPPORTED_COMPILER +#define BOOST_UBLAS_UNSUPPORTED_COMPILER 1 #endif #endif @@ -78,7 +78,7 @@ #endif #if (BOOST_INTEL < 700) -#define BOOST_UBLAS_UNSUPPORTED_COMPILER +#define BOOST_UBLAS_UNSUPPORTED_COMPILER 1 #endif // Define swap for index_pair and triple. @@ -156,7 +156,7 @@ namespace std { // 8.x #if __MWERKS__ <= 0x3003 -#define BOOST_UBLAS_UNSUPPORTED_COMPILER +#define BOOST_UBLAS_UNSUPPORTED_COMPILER 1 #endif #endif @@ -165,7 +165,7 @@ namespace std { // Detect other compilers with serious defects - override by defineing BOOST_UBLAS_UNSUPPORTED_COMPILER=0 #ifndef BOOST_UBLAS_UNSUPPORTED_COMPILER #if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(BOOST_NO_SFINAE) || defined(BOOST_NO_STDC_NAMESPACE) -#define BOOST_UBLAS_UNSUPPORTED_COMPILER +#define BOOST_UBLAS_UNSUPPORTED_COMPILER 1 #endif #endif From 0b9209d173af71fec29ec8fee63a1ce65a411ec7 Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Thu, 20 Jul 2006 13:41:13 +0000 Subject: [PATCH 006/280] manual merge from trunk: fixed typos reported in http://bugs.debian.org/378016 (there seems to be no mention of the erroneous names in the docs); NOTE(!): license reference text to be fixed; guard macro name beginning with underscore svn path=/branches/RC_1_34_0/boost/boost/numeric/ublas/; revision=34633 --- include/boost/numeric/ublas/matrix_expression.hpp | 10 +++++----- include/boost/numeric/ublas/vector_expression.hpp | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/boost/numeric/ublas/matrix_expression.hpp b/include/boost/numeric/ublas/matrix_expression.hpp index 4576f027..ac86f658 100644 --- a/include/boost/numeric/ublas/matrix_expression.hpp +++ b/include/boost/numeric/ublas/matrix_expression.hpp @@ -42,7 +42,7 @@ namespace boost { namespace numeric { namespace ublas { typedef typename boost::mpl::if_, typename E::const_reference, typename E::reference>::type reference; - typedef E refered_type; + typedef E referred_type; typedef const self_type const_closure_type; typedef self_type closure_type; typedef typename E::orientation_category orientation_category; @@ -50,7 +50,7 @@ namespace boost { namespace numeric { namespace ublas { // Construction and destruction BOOST_UBLAS_INLINE - explicit matrix_reference (refered_type &e): + explicit matrix_reference (referred_type &e): e_ (e) {} // Accessors @@ -66,11 +66,11 @@ namespace boost { namespace numeric { namespace ublas { public: // Expression accessors - const correct BOOST_UBLAS_INLINE - const refered_type &expression () const { + const referred_type &expression () const { return e_; } BOOST_UBLAS_INLINE - refered_type &expression () { + referred_type &expression () { return e_; } @@ -269,7 +269,7 @@ namespace boost { namespace numeric { namespace ublas { } private: - refered_type &e_; + referred_type &e_; }; diff --git a/include/boost/numeric/ublas/vector_expression.hpp b/include/boost/numeric/ublas/vector_expression.hpp index 313f9248..f5588de4 100644 --- a/include/boost/numeric/ublas/vector_expression.hpp +++ b/include/boost/numeric/ublas/vector_expression.hpp @@ -43,14 +43,14 @@ namespace boost { namespace numeric { namespace ublas { typedef typename boost::mpl::if_, typename E::const_reference, typename E::reference>::type reference; - typedef E refered_type; + typedef E referred_type; typedef const self_type const_closure_type; typedef self_type closure_type; typedef typename E::storage_category storage_category; // Construction and destruction BOOST_UBLAS_INLINE - explicit vector_reference (refered_type &e): + explicit vector_reference (referred_type &e): e_ (e) {} // Accessors @@ -62,11 +62,11 @@ namespace boost { namespace numeric { namespace ublas { public: // Expression accessors - const correct BOOST_UBLAS_INLINE - const refered_type &expression () const { + const referred_type &expression () const { return e_; } BOOST_UBLAS_INLINE - refered_type &expression () { + referred_type &expression () { return e_; } @@ -227,7 +227,7 @@ namespace boost { namespace numeric { namespace ublas { } private: - refered_type &e_; + referred_type &e_; }; From 6be5ef8c7d5cd723891a4a5baab9aee0e95cb9e9 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Tue, 29 Aug 2006 20:55:58 +0000 Subject: [PATCH 007/280] Remove tabs. svn path=/branches/RC_1_34_0/boost/libs/numeric/ublas/; revision=34994 --- test/placement_new.cpp | 2 +- test/test11.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/placement_new.cpp b/test/placement_new.cpp index 4179d771..6e07d46c 100644 --- a/test/placement_new.cpp +++ b/test/placement_new.cpp @@ -22,7 +22,7 @@ public: } ~udt () {} // required for GCC prior to 3.4 to generate cookie - static udt* base_pointer; + static udt* base_pointer; }; udt* udt::base_pointer; diff --git a/test/test11.cpp b/test/test11.cpp index 4bbad7fb..ff852edf 100644 --- a/test/test11.cpp +++ b/test/test11.cpp @@ -34,7 +34,7 @@ struct test_my_vector { template void test_expression_with (VP &v1, VP &v2, VP &v3) const { - // Expression type tests + // Expression type tests value_type t; size_type i; real_type n; From 1ffc814a724768ae9d418880305cf3f6244ff320 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Mon, 6 Nov 2006 17:10:46 +0000 Subject: [PATCH 008/280] Remove obsolete Boost.Build v1 files. svn path=/branches/RC_1_34_0/boost/libs/numeric/ublas/; revision=35880 --- bench1/Jamfile | 43 ----- bench2/Jamfile | 28 --- bench3/Jamfile | 29 --- bench4/Jamfile | 30 --- doc/samples/Jamfile | 433 -------------------------------------------- test/Jamfile | 128 ------------- 6 files changed, 691 deletions(-) delete mode 100644 bench1/Jamfile delete mode 100644 bench2/Jamfile delete mode 100644 bench3/Jamfile delete mode 100644 bench4/Jamfile delete mode 100644 doc/samples/Jamfile delete mode 100644 test/Jamfile diff --git a/bench1/Jamfile b/bench1/Jamfile deleted file mode 100644 index 02d4fc9a..00000000 --- a/bench1/Jamfile +++ /dev/null @@ -1,43 +0,0 @@ -# -# 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. -# - -subproject libs/numeric/ublas/bench1 ; - -SOURCES = bench1 bench11 bench12 bench13 ; - -exe bench1 - : $(SOURCES).cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) -# "-s -static -fomit-frame-pointer -fexpensive-optimizations -funroll-loops -malign-double -fschedule-insns2 -march=pentium4 -msse -mfpmath=sse -finline-functions -finline-limit=2048" -# <*>"-fabi-version=0" - "-Xc" - "-unroll -march=pentium4 -Zp16" - ; - - - - - - - - - - - - - - diff --git a/bench2/Jamfile b/bench2/Jamfile deleted file mode 100644 index da2d61bd..00000000 --- a/bench2/Jamfile +++ /dev/null @@ -1,28 +0,0 @@ -# -# 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. -# - -subproject libs/numeric/ublas/bench2 ; - -SOURCES = bench2 bench21 bench22 bench23 ; - -exe bench2 - : $(SOURCES).cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) -# <*>"-fabi-version=0" - <*>"-Xc" - ; - diff --git a/bench3/Jamfile b/bench3/Jamfile deleted file mode 100644 index bb5750c4..00000000 --- a/bench3/Jamfile +++ /dev/null @@ -1,29 +0,0 @@ -# -# 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. -# - -subproject libs/numeric/ublas/bench3 ; - -SOURCES = bench3 bench31 bench32 bench33 ; - -exe bench3 - : $(SOURCES).cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) -# <*>"-fabi-version=0" - <*>"-Xc" - ; - - diff --git a/bench4/Jamfile b/bench4/Jamfile deleted file mode 100644 index 7e44ae3d..00000000 --- a/bench4/Jamfile +++ /dev/null @@ -1,30 +0,0 @@ -# -# 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. -# - -subproject libs/numeric/ublas/bench4 ; - -SOURCES = bench4 bench41 bench42 bench43 ; - -exe bench4 - : $(SOURCES).cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - BOOST_UBLAS_USE_INTERVAL -# <*>"-fabi-version=0" - <*>"-Xc" - ; - - diff --git a/doc/samples/Jamfile b/doc/samples/Jamfile deleted file mode 100644 index 7da70284..00000000 --- a/doc/samples/Jamfile +++ /dev/null @@ -1,433 +0,0 @@ -# -# 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. -# - -subproject libs/numeric/ublas/doc/samples ; - -exe unbounded_array - : unbounded_array.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe bounded_array - : bounded_array.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe range - : range.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe slice - : slice.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe map_array - : map_array.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe vector - : vector.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe unit_vector - : unit_vector.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe zero_vector - : zero_vector.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe mapped_vector - : mapped_vector.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe compressed_vector - : compressed_vector.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe coordinate_vector - : coordinate_vector.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe vector_range - : vector_range.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe vector_range_project - : vector_range_project.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe vector_slice - : vector_slice.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe vector_slice_project - : vector_slice_project.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe vector_unary - : vector_unary.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe vector_binary - : vector_binary.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe vector_binary_outer - : vector_binary_outer.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe vector_binary_scalar - : vector_binary_scalar.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe vector_unary_redux - : vector_unary_redux.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe vector_binary_redux - : vector_binary_redux.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix - : matrix.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe identity_matrix - : identity_matrix.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe zero_matrix - : zero_matrix.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe mapped_matrix - : mapped_matrix.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe compressed_matrix - : compressed_matrix.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe coordinate_matrix - : coordinate_matrix.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_row - : matrix_row.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_row_project - : matrix_row_project.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_column - : matrix_column.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_column_project - : matrix_column_project.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_vector_range - : matrix_vector_range.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_vector_slice - : matrix_vector_slice.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_range - : matrix_range.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_range_project - : matrix_range_project.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_slice - : matrix_slice.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_slice_project - : matrix_slice_project.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_unary - : matrix_unary.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_binary - : matrix_binary.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_binary_scalar - : matrix_binary_scalar.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_vector_binary - : matrix_vector_binary.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_vector_solve - : matrix_vector_solve.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_matrix_binary - : matrix_matrix_binary.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe matrix_matrix_solve - : matrix_matrix_solve.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe banded_matrix - : banded_matrix.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe banded_adaptor - : banded_adaptor.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe hermitian_matrix - : hermitian_matrix.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe hermitian_adaptor - : hermitian_adaptor.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe symmetric_matrix - : symmetric_matrix.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe symmetric_adaptor - : symmetric_adaptor.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe triangular_matrix - : triangular_matrix.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; - -exe triangular_adaptor - : triangular_adaptor.cpp - : $(BOOST_ROOT) - $(BOOST_ROOT) - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - <*>"-w-8026 -w-8027 -w-8057 -w-8084 -w-8092" - ; diff --git a/test/Jamfile b/test/Jamfile deleted file mode 100644 index ea55bffe..00000000 --- a/test/Jamfile +++ /dev/null @@ -1,128 +0,0 @@ -# -# 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. -# - -subproject libs/numeric/ublas/test ; -# bring in rules for testing -import testing ; - -# Define features to test: -# Value types: USE_FLOAT USE_DOUBLE USE_STD_COMPLEX -# Proxies: USE_RANGE USE_SLICE -# Storage types: USE_BOUNDED_ARRAY USE_UNBOUNDED_ARRAY -# Vector types: USE_STD_VECTOR USE_BOUNDED_VECTOR -# Matrix types: USE_MATRIX USE_BOUNDED_MATRIX USE_VECTOR_OF_VECTOR -# Adaptors: USE_ADAPTOR - -UBLAS_TESTSET ?= - USE_DOUBLE USE_STD_COMPLEX - USE_RANGE USE_SLICE - USE_UNBOUNDED_ARRAY USE_BOUNDED_VECTOR USE_MATRIX ; - -# Sparse storage: USE_MAP_ARRAY USE_STD_MAP -# Sparse vectors: USE_MAPPED_VECTOR USE_COMPRESSED_VECTOR USE_COORDINATE_VECTOR -# Sparse matrices: USE_MAPPED_MATRIX USE_COMPRESSED_MATRIX USE_COORDINATE_MATRIX USE_MAPPED_VECTOR_OF_MAPPED_VECTOR USE_GENERALIZED_VECTOR_OF_VECTOR - -UBLAS_TESTSET_SPARSE ?= - USE_DOUBLE USE_STD_COMPLEX -# USE_RANGE USE_SLICE Too complex for regression testing - USE_UNBOUNDED_ARRAY - USE_STD_MAP - USE_MAPPED_VECTOR USE_COMPRESSED_VECTOR USE_COORDINATE_VECTOR - USE_MAPPED_MATRIX USE_COMPRESSED_MATRIX USE_COORDINATE_MATRIX ; - - -test-suite numeric/uBLAS - : [ run test1.cpp - test11.cpp - test12.cpp - test13.cpp - : # args - : # input files - : # requirements - $(UBLAS_TESTSET) - <*>"-fpstkchk" # Try and pick up runtime failures - <*>"BOOST_UBLAS_NO_ELEMENT_PROXIES" - [ cond [ is-subset Darwin : $(JAMUNAME) ] : <*>"-fabi-version=0" ] ] - [ run test2.cpp - test21.cpp - test22.cpp - test23.cpp - : # args - : # input files - : # requirements - $(UBLAS_TESTSET) - <*>"BOOST_UBLAS_NO_ELEMENT_PROXIES" - ] - [ run test3.cpp - test31.cpp - test32.cpp - test33.cpp - : # args - : # input files - : # requirements - $(UBLAS_TESTSET_SPARSE) - <*>"BOOST_UBLAS_NO_ELEMENT_PROXIES" - ] - [ run test4.cpp - test42.cpp - test43.cpp - : # args - : # input files - : # requirements - $(UBLAS_TESTSET) - <*>"BOOST_UBLAS_NO_ELEMENT_PROXIES" - ] - [ run test5.cpp - test52.cpp - test53.cpp - : # args - : # input files - : # requirements - $(UBLAS_TESTSET) - <*>"BOOST_UBLAS_NO_ELEMENT_PROXIES" - ] - [ run test6.cpp - test62.cpp - test63.cpp - : # args - : # input files - : # requirements - $(UBLAS_TESTSET) - <*>"BOOST_UBLAS_NO_ELEMENT_PROXIES" - ] -# Test7 checks uBLAS operation with interval types. -# This causes too much compiler badness. Issues need to be addressed for VC7.1 VC8 CW9 and Intel 8 (windows) -# [ run test7.cpp -# test71.cpp -# test72.cpp -# test73.cpp -# : # args -# : # input files -# : # requirements -# BOOST_UBLAS_USE_INTERVAL -# $(UBLAS_TESTSET) -# <*>"BOOST_UBLAS_NO_ELEMENT_PROXIES" -# ] - - [ run placement_new.cpp - ] - [ compile concepts.cpp - : # requirements - EXTERNAL - <*>"-Xc" - <*>"BOOST_UBLAS_NO_ELEMENT_PROXIES" - ] - ; From 7c744e6d288b89e870589c22f4513fb2e71ffa85 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Tue, 7 Nov 2006 19:27:00 +0000 Subject: [PATCH 009/280] Merged copyright and license addition svn path=/branches/RC_1_34_0/boost/libs/numeric/ublas/; revision=35907 --- index.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index f8ce2ff8..3100f73a 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,10 @@ Automatic redirection failed, please go to -doc/index.htm +doc/index.htm  
+

© Copyright Beman Dawes, 2001

+

Distributed under the Boost Software License, Version 1.0. (See accompanying +file LICENSE_1_0.txt or copy +at www.boost.org/LICENSE_1_0.txt)

- + \ No newline at end of file From 734ac172ceee9c851d71b324931c87b0fb10fc0d Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 24 Jul 2007 19:28:14 +0000 Subject: [PATCH 010/280] This commit was manufactured by cvs2svn to create tag 'Version_1_34_1'. svn path=/tags/Version_1_34_1/boost/boost/numeric/ublas/; revision=38286 From d9b804ed252cbfe07b29d302dc4180cc5afc9707 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Tue, 23 Oct 2007 06:42:50 +0000 Subject: [PATCH 011/280] Recreate release branch from fixed 1.34.1 tag. svn path=/branches/release/boost/numeric/ublas/; revision=40341 From 5ab25df536052893bc8a28ec16de8ac4d2d9343b Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sun, 25 Nov 2007 18:07:19 +0000 Subject: [PATCH 012/280] Full merge from trunk at revision 41356 of entire boost-root tree. svn path=/branches/release/boost/numeric/ublas/; revision=41369 --- include/boost/numeric/ublas/banded.hpp | 31 +- include/boost/numeric/ublas/blas.hpp | 10 +- .../boost/numeric/ublas/detail/concepts.hpp | 10 +- include/boost/numeric/ublas/detail/config.hpp | 14 +- .../numeric/ublas/detail/definitions.hpp | 10 +- include/boost/numeric/ublas/detail/duff.hpp | 10 +- .../boost/numeric/ublas/detail/iterator.hpp | 28 +- .../numeric/ublas/detail/matrix_assign.hpp | 10 +- include/boost/numeric/ublas/detail/raw.hpp | 10 +- .../boost/numeric/ublas/detail/temporary.hpp | 10 +- .../numeric/ublas/detail/vector_assign.hpp | 24 +- include/boost/numeric/ublas/exception.hpp | 21 +- .../boost/numeric/ublas/expression_types.hpp | 10 +- include/boost/numeric/ublas/functional.hpp | 884 +++++++++--------- include/boost/numeric/ublas/fwd.hpp | 22 +- include/boost/numeric/ublas/hermitian.hpp | 26 +- include/boost/numeric/ublas/io.hpp | 11 +- include/boost/numeric/ublas/lu.hpp | 16 +- include/boost/numeric/ublas/matrix.hpp | 311 ++++-- .../boost/numeric/ublas/matrix_expression.hpp | 74 +- include/boost/numeric/ublas/matrix_proxy.hpp | 12 +- include/boost/numeric/ublas/matrix_sparse.hpp | 636 ++++++++----- include/boost/numeric/ublas/operation.hpp | 26 +- .../boost/numeric/ublas/operation_blocked.hpp | 12 +- .../boost/numeric/ublas/operation_sparse.hpp | 28 +- include/boost/numeric/ublas/storage.hpp | 123 ++- .../boost/numeric/ublas/storage_sparse.hpp | 34 +- include/boost/numeric/ublas/symmetric.hpp | 13 +- include/boost/numeric/ublas/traits.hpp | 99 +- include/boost/numeric/ublas/triangular.hpp | 80 +- include/boost/numeric/ublas/vector.hpp | 116 ++- .../boost/numeric/ublas/vector_expression.hpp | 57 +- .../boost/numeric/ublas/vector_of_vector.hpp | 177 ++-- include/boost/numeric/ublas/vector_proxy.hpp | 10 +- include/boost/numeric/ublas/vector_sparse.hpp | 82 +- 35 files changed, 1698 insertions(+), 1349 deletions(-) diff --git a/include/boost/numeric/ublas/banded.hpp b/include/boost/numeric/ublas/banded.hpp index 1fb590a2..c67e0595 100644 --- a/include/boost/numeric/ublas/banded.hpp +++ b/include/boost/numeric/ublas/banded.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -179,21 +175,24 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_UBLAS_OWN_BANDED const size_type k = (std::max) (i, j); const size_type l = lower_ + j - i; - if (k < (std::max) (size1_, size2_) && - l < lower_ + 1 + upper_) - return data () [layout_type::element (k, (std::max) (size1_, size2_), + if (! (k < (std::max) (size1_, size2_) && + l < lower_ + 1 + upper_) ) { + bad_index ().raise (); + // NEVER reached + } + return data () [layout_type::element (k, (std::max) (size1_, size2_), l, lower_ + 1 + upper_)]; #else const size_type k = j; const size_type l = upper_ + i - j; - if (k < size2_ && - l < lower_ + 1 + upper_) - return data () [layout_type::element (k, size2_, + if (! (k < size2_ && + l < lower_ + 1 + upper_) ) { + bad_index ().raise (); + // NEVER reached + } + return data () [layout_type::element (k, size2_, l, lower_ + 1 + upper_)]; #endif - bad_index ().raise (); - // arbitary return value - return const_cast(zero_); } // Element assignment diff --git a/include/boost/numeric/ublas/blas.hpp b/include/boost/numeric/ublas/blas.hpp index ab78cb48..e5c7c059 100644 --- a/include/boost/numeric/ublas/blas.hpp +++ b/include/boost/numeric/ublas/blas.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. diff --git a/include/boost/numeric/ublas/detail/concepts.hpp b/include/boost/numeric/ublas/detail/concepts.hpp index 943672e9..5f150886 100644 --- a/include/boost/numeric/ublas/detail/concepts.hpp +++ b/include/boost/numeric/ublas/detail/concepts.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. diff --git a/include/boost/numeric/ublas/detail/config.hpp b/include/boost/numeric/ublas/detail/config.hpp index 37bf297e..6d25bcc2 100644 --- a/include/boost/numeric/ublas/detail/config.hpp +++ b/include/boost/numeric/ublas/detail/config.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -171,13 +167,13 @@ namespace std { // Cannot continue with an unsupported compiler #if defined(BOOST_UBLAS_UNSUPPORTED_COMPILER) && (BOOST_UBLAS_UNSUPPORTED_COMPILER != 0) -#error Your compiler is unsupported by this verions of uBLAS. Boost 1.32.0 includes uBLAS with support for many old compilers. +#error Your compiler and/or configuration is unsupported by this verions of uBLAS. Define BOOST_UBLAS_UNSUPPORTED_COMPILER=0 to override this message. Boost 1.32.0 includes uBLAS with support for many older compilers. #endif // Enable performance options in RELEASE mode -#ifdef NDEBUG +#if defined (NDEBUG) || defined (BOOST_UBLAS_NDEBUG) #ifndef BOOST_UBLAS_INLINE #define BOOST_UBLAS_INLINE inline diff --git a/include/boost/numeric/ublas/detail/definitions.hpp b/include/boost/numeric/ublas/detail/definitions.hpp index 7a978e7e..8cf71d99 100644 --- a/include/boost/numeric/ublas/detail/definitions.hpp +++ b/include/boost/numeric/ublas/detail/definitions.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. diff --git a/include/boost/numeric/ublas/detail/duff.hpp b/include/boost/numeric/ublas/detail/duff.hpp index bce971f7..b0ec08c9 100644 --- a/include/boost/numeric/ublas/detail/duff.hpp +++ b/include/boost/numeric/ublas/detail/duff.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. diff --git a/include/boost/numeric/ublas/detail/iterator.hpp b/include/boost/numeric/ublas/detail/iterator.hpp index 8fdbffd3..1723a301 100644 --- a/include/boost/numeric/ublas/detail/iterator.hpp +++ b/include/boost/numeric/ublas/detail/iterator.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -203,7 +199,7 @@ namespace boost { namespace numeric { namespace ublas { * is LessThan Comparable. */ template - // ISSUE the default here seems rather dangerous as it can easlly be (silently) incorrect + // ISSUE the default for D seems rather dangerous as it can easily be (silently) incorrect struct random_access_iterator_base: public std::iterator { typedef I derived_iterator_type; @@ -634,7 +630,7 @@ namespace boost { namespace numeric { namespace ublas { /** \brief A class implementing an indexed random access iterator. * - * \param C the mutable container type + * \param C the (mutable) container type * \param IC the iterator category * * This class implements a random access iterator. The current @@ -739,7 +735,7 @@ namespace boost { namespace numeric { namespace ublas { /** \brief A class implementing an indexed random access iterator. * - * \param C the mutable container type + * \param C the (immutable) container type * \param IC the iterator category * * This class implements a random access iterator. The current @@ -857,7 +853,7 @@ namespace boost { namespace numeric { namespace ublas { /** \brief A class implementing an indexed random access iterator * of a matrix. * - * \param C the mutable container type + * \param C the (mutable) container type * \param IC the iterator category * * This class implements a random access iterator. The current @@ -878,7 +874,7 @@ namespace boost { namespace numeric { namespace ublas { public random_access_iterator_base, typename C::value_type, - typename C::reference> { + typename C::difference_type> { public: typedef C container_type; typedef IC iterator_category; @@ -1024,7 +1020,7 @@ namespace boost { namespace numeric { namespace ublas { public random_access_iterator_base, typename C::value_type, - typename C::const_reference> { + typename C::difference_type> { public: typedef C container_type; typedef IC iterator_category; @@ -1150,7 +1146,7 @@ namespace boost { namespace numeric { namespace ublas { /** \brief A class implementing an indexed random access iterator * of a matrix. * - * \param C the mutable container type + * \param C the (mutable) container type * \param IC the iterator category * * This class implements a random access iterator. The current @@ -1169,7 +1165,7 @@ namespace boost { namespace numeric { namespace ublas { public random_access_iterator_base, typename C::value_type, - typename C::reference> { + typename C::difference_type> { public: typedef C container_type; typedef IC iterator_category; @@ -1312,7 +1308,7 @@ namespace boost { namespace numeric { namespace ublas { public random_access_iterator_base, typename C::value_type, - typename C::const_reference> { + typename C::difference_type> { public: typedef C container_type; typedef IC iterator_category; diff --git a/include/boost/numeric/ublas/detail/matrix_assign.hpp b/include/boost/numeric/ublas/detail/matrix_assign.hpp index 195175ca..36bca28d 100644 --- a/include/boost/numeric/ublas/detail/matrix_assign.hpp +++ b/include/boost/numeric/ublas/detail/matrix_assign.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. diff --git a/include/boost/numeric/ublas/detail/raw.hpp b/include/boost/numeric/ublas/detail/raw.hpp index 143d31f4..c36c8b06 100644 --- a/include/boost/numeric/ublas/detail/raw.hpp +++ b/include/boost/numeric/ublas/detail/raw.hpp @@ -2,13 +2,9 @@ // Copyright (c) 2002-2003 // Toon Knapen, Kresimir Fresl, Joerg Walter // -// 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // diff --git a/include/boost/numeric/ublas/detail/temporary.hpp b/include/boost/numeric/ublas/detail/temporary.hpp index 0e793592..c2ae468b 100644 --- a/include/boost/numeric/ublas/detail/temporary.hpp +++ b/include/boost/numeric/ublas/detail/temporary.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. diff --git a/include/boost/numeric/ublas/detail/vector_assign.hpp b/include/boost/numeric/ublas/detail/vector_assign.hpp index a93cd1c4..850c5b48 100644 --- a/include/boost/numeric/ublas/detail/vector_assign.hpp +++ b/include/boost/numeric/ublas/detail/vector_assign.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -17,6 +13,7 @@ #ifndef _BOOST_UBLAS_VECTOR_ASSIGN_ #define _BOOST_UBLAS_VECTOR_ASSIGN_ +#include // scalar_assign // Required for make_conformant storage #include @@ -340,8 +337,9 @@ namespace detail { it += size; } #if BOOST_UBLAS_TYPE_CHECK - if (! disable_type_check::value) - BOOST_UBLAS_CHECK (detail::expression_type_check (v, cv), external_logic ()); + if (! disable_type_check::value) + BOOST_UBLAS_CHECK (detail::expression_type_check (v, cv), + external_logic ("external logic or bad condition of inputs")); #endif } // Sparse case @@ -367,8 +365,9 @@ namespace detail { ++ ite; } #if BOOST_UBLAS_TYPE_CHECK - if (! disable_type_check::value) - BOOST_UBLAS_CHECK (detail::expression_type_check (v, cv), external_logic ()); + if (! disable_type_check::value) + BOOST_UBLAS_CHECK (detail::expression_type_check (v, cv), + external_logic ("external logic or bad condition of inputs")); #endif } // Sparse proxy or functional case @@ -434,7 +433,8 @@ namespace detail { } #if BOOST_UBLAS_TYPE_CHECK if (! disable_type_check::value) - BOOST_UBLAS_CHECK (detail::expression_type_check (v, cv), external_logic ()); + BOOST_UBLAS_CHECK (detail::expression_type_check (v, cv), + external_logic ("external logic or bad condition of inputs")); #endif } diff --git a/include/boost/numeric/ublas/exception.hpp b/include/boost/numeric/ublas/exception.hpp index 90f32e41..d2beec9a 100644 --- a/include/boost/numeric/ublas/exception.hpp +++ b/include/boost/numeric/ublas/exception.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -175,7 +171,6 @@ namespace boost { namespace numeric { namespace ublas { explicit singular (const char *) {} void raise () { - throw *this; std::abort (); } #endif @@ -267,11 +262,19 @@ namespace boost { namespace numeric { namespace ublas { // return (std::min) (size1, size2); // } // #define BOOST_UBLAS_SAME(size1, size2) same_impl ((size1), (size2)) - template + // need two types here because different containers can have + // different size_types (especially sparse types) + template BOOST_UBLAS_INLINE // Kresimir Fresl and Dan Muller reported problems with COMO. // We better change the signature instead of libcomo ;-) // const T &same_impl_ex (const T &size1, const T &size2, const char *file, int line) { + T1 same_impl_ex (const T1 &size1, const T2 &size2, const char *file, int line) { + BOOST_UBLAS_CHECK_EX (size1 == size2, file, line, bad_argument ()); + return (size1 < size2)?(size1):(size2); + } + template + BOOST_UBLAS_INLINE T same_impl_ex (const T &size1, const T &size2, const char *file, int line) { BOOST_UBLAS_CHECK_EX (size1 == size2, file, line, bad_argument ()); return (std::min) (size1, size2); diff --git a/include/boost/numeric/ublas/expression_types.hpp b/include/boost/numeric/ublas/expression_types.hpp index f6147abd..d74f4d14 100644 --- a/include/boost/numeric/ublas/expression_types.hpp +++ b/include/boost/numeric/ublas/expression_types.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. diff --git a/include/boost/numeric/ublas/functional.hpp b/include/boost/numeric/ublas/functional.hpp index d3885dfc..db44c635 100644 --- a/include/boost/numeric/ublas/functional.hpp +++ b/include/boost/numeric/ublas/functional.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -222,7 +218,7 @@ namespace boost { namespace numeric { namespace ublas { #if BOOST_WORKAROUND( __IBMCPP__, <=600 ) static const bool computed ; #else - static const bool computed = true ; + static const bool computed = true ; #endif static BOOST_UBLAS_INLINE @@ -331,35 +327,32 @@ namespace boost { namespace numeric { namespace ublas { // Vector functors // Unary returning scalar - template + template struct vector_scalar_unary_functor { - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef T value_type; - typedef T result_type; + typedef typename V::value_type value_type; + typedef typename V::value_type result_type; }; - template + template struct vector_sum: - public vector_scalar_unary_functor { - typedef typename vector_scalar_unary_functor::size_type size_type; - typedef typename vector_scalar_unary_functor::difference_type difference_type; - typedef typename vector_scalar_unary_functor::value_type value_type; - typedef typename vector_scalar_unary_functor::result_type result_type; + public vector_scalar_unary_functor { + typedef typename vector_scalar_unary_functor::value_type value_type; + typedef typename vector_scalar_unary_functor::result_type result_type; template static BOOST_UBLAS_INLINE result_type apply (const vector_expression &e) { result_type t = result_type (0); - size_type size (e ().size ()); - for (size_type i = 0; i < size; ++ i) + typedef typename E::size_type vector_size_type; + vector_size_type size (e ().size ()); + for (vector_size_type i = 0; i < size; ++ i) t += e () (i); return t; } // Dense case - template + template static BOOST_UBLAS_INLINE - result_type apply (difference_type size, I it) { + result_type apply (D size, I it) { result_type t = result_type (0); while (-- size >= 0) t += *it, ++ it; @@ -377,39 +370,36 @@ namespace boost { namespace numeric { namespace ublas { }; // Unary returning real scalar - template + template struct vector_scalar_real_unary_functor { - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef T value_type; - typedef typename type_traits::real_type real_type; + typedef typename V::value_type value_type; + typedef typename type_traits::real_type real_type; typedef real_type result_type; }; - template + template struct vector_norm_1: - public vector_scalar_real_unary_functor { - typedef typename vector_scalar_real_unary_functor::size_type size_type; - typedef typename vector_scalar_real_unary_functor::difference_type difference_type; - typedef typename vector_scalar_real_unary_functor::value_type value_type; - typedef typename vector_scalar_real_unary_functor::real_type real_type; - typedef typename vector_scalar_real_unary_functor::result_type result_type; + public vector_scalar_real_unary_functor { + typedef typename vector_scalar_real_unary_functor::value_type value_type; + typedef typename vector_scalar_real_unary_functor::real_type real_type; + typedef typename vector_scalar_real_unary_functor::result_type result_type; template static BOOST_UBLAS_INLINE result_type apply (const vector_expression &e) { real_type t = real_type (); - size_type size (e ().size ()); - for (size_type i = 0; i < size; ++ i) { + typedef typename E::size_type vector_size_type; + vector_size_type size (e ().size ()); + for (vector_size_type i = 0; i < size; ++ i) { real_type u (type_traits::type_abs (e () (i))); t += u; } return t; } // Dense case - template + template static BOOST_UBLAS_INLINE - result_type apply (difference_type size, I it) { + result_type apply (D size, I it) { real_type t = real_type (); while (-- size >= 0) { real_type u (type_traits::norm_1 (*it)); @@ -431,22 +421,21 @@ namespace boost { namespace numeric { namespace ublas { return t; } }; - template + template struct vector_norm_2: - public vector_scalar_real_unary_functor { - typedef typename vector_scalar_real_unary_functor::size_type size_type; - typedef typename vector_scalar_real_unary_functor::difference_type difference_type; - typedef typename vector_scalar_real_unary_functor::value_type value_type; - typedef typename vector_scalar_real_unary_functor::real_type real_type; - typedef typename vector_scalar_real_unary_functor::result_type result_type; + public vector_scalar_real_unary_functor { + typedef typename vector_scalar_real_unary_functor::value_type value_type; + typedef typename vector_scalar_real_unary_functor::real_type real_type; + typedef typename vector_scalar_real_unary_functor::result_type result_type; template static BOOST_UBLAS_INLINE result_type apply (const vector_expression &e) { #ifndef BOOST_UBLAS_SCALED_NORM real_type t = real_type (); - size_type size (e ().size ()); - for (size_type i = 0; i < size; ++ i) { + typedef typename E::size_type vector_size_type; + vector_size_type size (e ().size ()); + for (vector_size_type i = 0; i < size; ++ i) { real_type u (type_traits::norm_2 (e () (i))); t += u * u; } @@ -470,9 +459,9 @@ namespace boost { namespace numeric { namespace ublas { #endif } // Dense case - template + template static BOOST_UBLAS_INLINE - result_type apply (difference_type size, I it) { + result_type apply (D size, I it) { #ifndef BOOST_UBLAS_SCALED_NORM real_type t = real_type (); while (-- size >= 0) { @@ -530,21 +519,20 @@ namespace boost { namespace numeric { namespace ublas { #endif } }; - template + template struct vector_norm_inf: - public vector_scalar_real_unary_functor { - typedef typename vector_scalar_real_unary_functor::size_type size_type; - typedef typename vector_scalar_real_unary_functor::difference_type difference_type; - typedef typename vector_scalar_real_unary_functor::value_type value_type; - typedef typename vector_scalar_real_unary_functor::real_type real_type; - typedef typename vector_scalar_real_unary_functor::result_type result_type; + public vector_scalar_real_unary_functor { + typedef typename vector_scalar_real_unary_functor::value_type value_type; + typedef typename vector_scalar_real_unary_functor::real_type real_type; + typedef typename vector_scalar_real_unary_functor::result_type result_type; template static BOOST_UBLAS_INLINE result_type apply (const vector_expression &e) { real_type t = real_type (); - size_type size (e ().size ()); - for (size_type i = 0; i < size; ++ i) { + typedef typename E::size_type vector_size_type; + vector_size_type size (e ().size ()); + for (vector_size_type i = 0; i < size; ++ i) { real_type u (type_traits::norm_inf (e () (i))); if (u > t) t = u; @@ -552,9 +540,9 @@ namespace boost { namespace numeric { namespace ublas { return t; } // Dense case - template + template static BOOST_UBLAS_INLINE - result_type apply (difference_type size, I it) { + result_type apply (D size, I it) { real_type t = real_type (); while (-- size >= 0) { real_type u (type_traits::norm_inf (*it)); @@ -580,23 +568,19 @@ namespace boost { namespace numeric { namespace ublas { }; // Unary returning index - template + template struct vector_scalar_index_unary_functor { - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef T value_type; - typedef typename type_traits::real_type real_type; - typedef size_type result_type; + typedef typename V::value_type value_type; + typedef typename type_traits::real_type real_type; + typedef typename V::size_type result_type; }; - template + template struct vector_index_norm_inf: - public vector_scalar_index_unary_functor { - typedef typename vector_scalar_index_unary_functor::size_type size_type; - typedef typename vector_scalar_index_unary_functor::difference_type difference_type; - typedef typename vector_scalar_index_unary_functor::value_type value_type; - typedef typename vector_scalar_index_unary_functor::real_type real_type; - typedef typename vector_scalar_index_unary_functor::result_type result_type; + public vector_scalar_index_unary_functor { + typedef typename vector_scalar_index_unary_functor::value_type value_type; + typedef typename vector_scalar_index_unary_functor::real_type real_type; + typedef typename vector_scalar_index_unary_functor::result_type result_type; template static BOOST_UBLAS_INLINE @@ -604,8 +588,9 @@ namespace boost { namespace numeric { namespace ublas { // ISSUE For CBLAS compatibility return 0 index in empty case result_type i_norm_inf (0); real_type t = real_type (); - size_type size (e ().size ()); - for (size_type i = 0; i < size; ++ i) { + typedef typename E::size_type vector_size_type; + vector_size_type size (e ().size ()); + for (vector_size_type i = 0; i < size; ++ i) { real_type u (type_traits::norm_inf (e () (i))); if (u > t) { i_norm_inf = i; @@ -615,9 +600,9 @@ namespace boost { namespace numeric { namespace ublas { return i_norm_inf; } // Dense case - template + template static BOOST_UBLAS_INLINE - result_type apply (difference_type size, I it) { + result_type apply (D size, I it) { // ISSUE For CBLAS compatibility return 0 index in empty case result_type i_norm_inf (0); real_type t = real_type (); @@ -651,21 +636,17 @@ namespace boost { namespace numeric { namespace ublas { }; // Binary returning scalar - template + template struct vector_scalar_binary_functor { - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef TR value_type; - typedef TR result_type; + typedef TV value_type; + typedef TV result_type; }; - template + template struct vector_inner_prod: - public vector_scalar_binary_functor { - typedef typename vector_scalar_binary_functor::size_type size_type ; - typedef typename vector_scalar_binary_functor::difference_type difference_type; - typedef typename vector_scalar_binary_functor::value_type value_type; - typedef typename vector_scalar_binary_functor::result_type result_type; + public vector_scalar_binary_functor { + typedef typename vector_scalar_binary_functor::value_type value_type; + typedef typename vector_scalar_binary_functor::result_type result_type; template static BOOST_UBLAS_INLINE @@ -673,23 +654,24 @@ namespace boost { namespace numeric { namespace ublas { const vector_container &c2) { #ifdef BOOST_UBLAS_USE_SIMD using namespace raw; - size_type size (BOOST_UBLAS_SAME (c1 ().size (), c2 ().size ())); - const T1 *data1 = data_const (c1 ()); - const T2 *data2 = data_const (c2 ()); - size_type s1 = stride (c1 ()); - size_type s2 = stride (c2 ()); + typedef typename C1::size_type vector_size_type; + vector_size_type size (BOOST_UBLAS_SAME (c1 ().size (), c2 ().size ())); + const typename V1::value_type *data1 = data_const (c1 ()); + const typename V1::value_type *data2 = data_const (c2 ()); + vector_size_type s1 = stride (c1 ()); + vector_size_type s2 = stride (c2 ()); result_type t = result_type (0); if (s1 == 1 && s2 == 1) { - for (size_type i = 0; i < size; ++ i) + for (vector_size_type i = 0; i < size; ++ i) t += data1 [i] * data2 [i]; } else if (s2 == 1) { - for (size_type i = 0, i1 = 0; i < size; ++ i, i1 += s1) + for (vector_size_type i = 0, i1 = 0; i < size; ++ i, i1 += s1) t += data1 [i1] * data2 [i]; } else if (s1 == 1) { - for (size_type i = 0, i2 = 0; i < size; ++ i, i2 += s2) + for (vector_size_type i = 0, i2 = 0; i < size; ++ i, i2 += s2) t += data1 [i] * data2 [i2]; } else { - for (size_type i = 0, i1 = 0, i2 = 0; i < size; ++ i, i1 += s1, i2 += s2) + for (vector_size_type i = 0, i1 = 0, i2 = 0; i < size; ++ i, i1 += s1, i2 += s2) t += data1 [i1] * data2 [i2]; } return t; @@ -703,21 +685,22 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE result_type apply (const vector_expression &e1, const vector_expression &e2) { - size_type size (BOOST_UBLAS_SAME (e1 ().size (), e2 ().size ())); + typedef typename E1::size_type vector_size_type; + vector_size_type size (BOOST_UBLAS_SAME (e1 ().size (), e2 ().size ())); result_type t = result_type (0); #ifndef BOOST_UBLAS_USE_DUFF_DEVICE - for (size_type i = 0; i < size; ++ i) + for (vector_size_type i = 0; i < size; ++ i) t += e1 () (i) * e2 () (i); #else - size_type i (0); + vector_size_type i (0); DD (size, 4, r, (t += e1 () (i) * e2 () (i), ++ i)); #endif return t; } // Dense case - template + template static BOOST_UBLAS_INLINE - result_type apply (difference_type size, I1 it1, I2 it2) { + result_type apply (D size, I1 it1, I2 it2) { result_type t = result_type (0); #ifndef BOOST_UBLAS_USE_DUFF_DEVICE while (-- size >= 0) @@ -732,13 +715,14 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE result_type apply (I1 it1, const I1 &it1_end, I2 it2, const I2 &it2_end) { result_type t = result_type (0); - difference_type it1_size (it1_end - it1); - difference_type it2_size (it2_end - it2); - difference_type diff (0); + typedef typename I1::difference_type vector_difference_type; + vector_difference_type it1_size (it1_end - it1); + vector_difference_type it2_size (it2_end - it2); + vector_difference_type diff (0); if (it1_size > 0 && it2_size > 0) diff = it2.index () - it1.index (); if (diff != 0) { - difference_type size = (std::min) (diff, it1_size); + vector_difference_type size = (std::min) (diff, it1_size); if (size > 0) { it1 += size; it1_size -= size; @@ -751,7 +735,7 @@ namespace boost { namespace numeric { namespace ublas { diff += size; } } - difference_type size ((std::min) (it1_size, it2_size)); + vector_difference_type size ((std::min) (it1_size, it2_size)); while (-- size >= 0) t += *it1 * *it2, ++ it1, ++ it2; return t; @@ -762,27 +746,18 @@ namespace boost { namespace numeric { namespace ublas { result_type apply (I1 it1, const I1 &it1_end, I2 it2, const I2 &it2_end, sparse_bidirectional_iterator_tag) { result_type t = result_type (0); if (it1 != it1_end && it2 != it2_end) { - size_type it1_index = it1.index (), it2_index = it2.index (); while (true) { - difference_type compare = it1_index - it2_index; - if (compare == 0) { + if (it1.index () == it2.index ()) { t += *it1 * *it2, ++ it1, ++ it2; - if (it1 != it1_end && it2 != it2_end) { - it1_index = it1.index (); - it2_index = it2.index (); - } else + if (it1 == it1_end || it2 == it2_end) break; - } else if (compare < 0) { - increment (it1, it1_end, - compare); - if (it1 != it1_end) - it1_index = it1.index (); - else + } else if (it1.index () < it2.index ()) { + increment (it1, it1_end, it2.index () - it1.index ()); + if (it1 == it1_end) break; - } else if (compare > 0) { - increment (it2, it2_end, compare); - if (it2 != it2_end) - it2_index = it2.index (); - else + } else if (it1.index () > it2.index ()) { + increment (it2, it2_end, it1.index () - it2.index ()); + if (it2 == it2_end) break; } } @@ -794,21 +769,21 @@ namespace boost { namespace numeric { namespace ublas { // Matrix functors // Binary returning vector - template + template struct matrix_vector_binary_functor { - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef TR value_type; - typedef TR result_type; + typedef typename M1::size_type size_type; + typedef typename M1::difference_type difference_type; + typedef TV value_type; + typedef TV result_type; }; - template + template struct matrix_vector_prod1: - public matrix_vector_binary_functor { - typedef typename matrix_vector_binary_functor::size_type size_type; - typedef typename matrix_vector_binary_functor::difference_type difference_type; - typedef typename matrix_vector_binary_functor::value_type value_type; - typedef typename matrix_vector_binary_functor::result_type result_type; + public matrix_vector_binary_functor { + typedef typename matrix_vector_binary_functor::size_type size_type; + typedef typename matrix_vector_binary_functor::difference_type difference_type; + typedef typename matrix_vector_binary_functor::value_type value_type; + typedef typename matrix_vector_binary_functor::result_type result_type; template static BOOST_UBLAS_INLINE @@ -818,8 +793,8 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_UBLAS_USE_SIMD using namespace raw; size_type size = BOOST_UBLAS_SAME (c1 ().size2 (), c2 ().size ()); - const T1 *data1 = data_const (c1 ()) + i * stride1 (c1 ()); - const T2 *data2 = data_const (c2 ()); + const typename M1::value_type *data1 = data_const (c1 ()) + i * stride1 (c1 ()); + const typename M2::value_type *data2 = data_const (c2 ()); size_type s1 = stride2 (c1 ()); size_type s2 = stride (c2 ()); result_type t = result_type (0); @@ -846,7 +821,7 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE result_type apply (const matrix_expression &e1, - const vector_expression &e2, + const vector_expression &e2, size_type i) { size_type size = BOOST_UBLAS_SAME (e1 ().size2 (), e2 ().size ()); result_type t = result_type (0); @@ -905,7 +880,7 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE result_type apply (I1 it1, const I1 &it1_end, I2 it2, const I2 &it2_end, - sparse_bidirectional_iterator_tag, sparse_bidirectional_iterator_tag) { + sparse_bidirectional_iterator_tag, sparse_bidirectional_iterator_tag) { result_type t = result_type (0); if (it1 != it1_end && it2 != it2_end) { size_type it1_index = it1.index2 (), it2_index = it2.index (); @@ -939,7 +914,7 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE result_type apply (I1 it1, const I1 &it1_end, I2 it2, const I2 &/* it2_end */, - sparse_bidirectional_iterator_tag, packed_random_access_iterator_tag) { + sparse_bidirectional_iterator_tag, packed_random_access_iterator_tag) { result_type t = result_type (0); while (it1 != it1_end) { t += *it1 * it2 () (it1.index2 ()); @@ -951,7 +926,7 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE result_type apply (I1 it1, const I1 &/* it1_end */, I2 it2, const I2 &it2_end, - packed_random_access_iterator_tag, sparse_bidirectional_iterator_tag) { + packed_random_access_iterator_tag, sparse_bidirectional_iterator_tag) { result_type t = result_type (0); while (it2 != it2_end) { t += it1 () (it1.index1 (), it2.index ()) * *it2; @@ -963,20 +938,20 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE result_type apply (I1 it1, const I1 &it1_end, I2 it2, const I2 &it2_end, - sparse_bidirectional_iterator_tag) { + sparse_bidirectional_iterator_tag) { typedef typename I1::iterator_category iterator1_category; typedef typename I2::iterator_category iterator2_category; return apply (it1, it1_end, it2, it2_end, iterator1_category (), iterator2_category ()); } }; - template + template struct matrix_vector_prod2: - public matrix_vector_binary_functor { - typedef typename matrix_vector_binary_functor::size_type size_type; - typedef typename matrix_vector_binary_functor::difference_type difference_type; - typedef typename matrix_vector_binary_functor::value_type value_type; - typedef typename matrix_vector_binary_functor::result_type result_type; + public matrix_vector_binary_functor { + typedef typename matrix_vector_binary_functor::size_type size_type; + typedef typename matrix_vector_binary_functor::difference_type difference_type; + typedef typename matrix_vector_binary_functor::value_type value_type; + typedef typename matrix_vector_binary_functor::result_type result_type; template static BOOST_UBLAS_INLINE @@ -986,8 +961,8 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_UBLAS_USE_SIMD using namespace raw; size_type size = BOOST_UBLAS_SAME (c1 ().size (), c2 ().size1 ()); - const T1 *data1 = data_const (c1 ()); - const T2 *data2 = data_const (c2 ()) + i * stride2 (c2 ()); + const typename M1::value_type *data1 = data_const (c1 ()); + const typename M2::value_type *data2 = data_const (c2 ()) + i * stride2 (c2 ()); size_type s1 = stride (c1 ()); size_type s2 = stride1 (c2 ()); result_type t = result_type (0); @@ -1014,7 +989,7 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE result_type apply (const vector_expression &e1, - const matrix_expression &e2, + const matrix_expression &e2, size_type i) { size_type size = BOOST_UBLAS_SAME (e1 ().size (), e2 ().size1 ()); result_type t = result_type (0); @@ -1073,7 +1048,7 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE result_type apply (I1 it1, const I1 &it1_end, I2 it2, const I2 &it2_end, - sparse_bidirectional_iterator_tag, sparse_bidirectional_iterator_tag) { + sparse_bidirectional_iterator_tag, sparse_bidirectional_iterator_tag) { result_type t = result_type (0); if (it1 != it1_end && it2 != it2_end) { size_type it1_index = it1.index (), it2_index = it2.index1 (); @@ -1107,7 +1082,7 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE result_type apply (I1 it1, const I1 &/* it1_end */, I2 it2, const I2 &it2_end, - packed_random_access_iterator_tag, sparse_bidirectional_iterator_tag) { + packed_random_access_iterator_tag, sparse_bidirectional_iterator_tag) { result_type t = result_type (0); while (it2 != it2_end) { t += it1 () (it2.index1 ()) * *it2; @@ -1119,7 +1094,7 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE result_type apply (I1 it1, const I1 &it1_end, I2 it2, const I2 &/* it2_end */, - sparse_bidirectional_iterator_tag, packed_random_access_iterator_tag) { + sparse_bidirectional_iterator_tag, packed_random_access_iterator_tag) { result_type t = result_type (0); while (it1 != it1_end) { t += *it1 * it2 () (it1.index (), it2.index2 ()); @@ -1131,7 +1106,7 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE result_type apply (I1 it1, const I1 &it1_end, I2 it2, const I2 &it2_end, - sparse_bidirectional_iterator_tag) { + sparse_bidirectional_iterator_tag) { typedef typename I1::iterator_category iterator1_category; typedef typename I2::iterator_category iterator2_category; return apply (it1, it1_end, it2, it2_end, iterator1_category (), iterator2_category ()); @@ -1139,21 +1114,21 @@ namespace boost { namespace numeric { namespace ublas { }; // Binary returning matrix - template + template struct matrix_matrix_binary_functor { - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef TR value_type; - typedef TR result_type; + typedef typename M1::size_type size_type; + typedef typename M1::difference_type difference_type; + typedef TV value_type; + typedef TV result_type; }; - template + template struct matrix_matrix_prod: - public matrix_matrix_binary_functor { - typedef typename matrix_matrix_binary_functor::size_type size_type; - typedef typename matrix_matrix_binary_functor::difference_type difference_type; - typedef typename matrix_matrix_binary_functor::value_type value_type; - typedef typename matrix_matrix_binary_functor::result_type result_type; + public matrix_matrix_binary_functor { + typedef typename matrix_matrix_binary_functor::size_type size_type; + typedef typename matrix_matrix_binary_functor::difference_type difference_type; + typedef typename matrix_matrix_binary_functor::value_type value_type; + typedef typename matrix_matrix_binary_functor::result_type result_type; template static BOOST_UBLAS_INLINE @@ -1163,8 +1138,8 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_UBLAS_USE_SIMD using namespace raw; size_type size = BOOST_UBLAS_SAME (c1 ().size2 (), c2 ().sizc1 ()); - const T1 *data1 = data_const (c1 ()) + i * stride1 (c1 ()); - const T2 *data2 = data_const (c2 ()) + j * stride2 (c2 ()); + const typename M1::value_type *data1 = data_const (c1 ()) + i * stride1 (c1 ()); + const typename M2::value_type *data2 = data_const (c2 ()) + j * stride2 (c2 ()); size_type s1 = stride2 (c1 ()); size_type s2 = stride1 (c2 ()); result_type t = result_type (0); @@ -1191,7 +1166,7 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE result_type apply (const matrix_expression &e1, - const matrix_expression &e2, + const matrix_expression &e2, size_type i, size_type j) { size_type size = BOOST_UBLAS_SAME (e1 ().size2 (), e2 ().size1 ()); result_type t = result_type (0); @@ -1254,7 +1229,7 @@ namespace boost { namespace numeric { namespace ublas { if (it1 != it1_end && it2 != it2_end) { size_type it1_index = it1.index2 (), it2_index = it2.index1 (); while (true) { - difference_type compare = it1_index - it2_index; + difference_type compare = difference_type (it1_index - it2_index); if (compare == 0) { t += *it1 * *it2, ++ it1, ++ it2; if (it1 != it1_end && it2 != it2_end) { @@ -1282,33 +1257,30 @@ namespace boost { namespace numeric { namespace ublas { }; // Unary returning scalar norm - template + template struct matrix_scalar_real_unary_functor { - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef T value_type; - typedef typename type_traits::real_type real_type; + typedef typename M::value_type value_type; + typedef typename type_traits::real_type real_type; typedef real_type result_type; }; - template + template struct matrix_norm_1: - public matrix_scalar_real_unary_functor { - typedef typename matrix_scalar_real_unary_functor::size_type size_type; - typedef typename matrix_scalar_real_unary_functor::difference_type difference_type; - typedef typename matrix_scalar_real_unary_functor::value_type value_type; - typedef typename matrix_scalar_real_unary_functor::real_type real_type; - typedef typename matrix_scalar_real_unary_functor::result_type result_type; + public matrix_scalar_real_unary_functor { + typedef typename matrix_scalar_real_unary_functor::value_type value_type; + typedef typename matrix_scalar_real_unary_functor::real_type real_type; + typedef typename matrix_scalar_real_unary_functor::result_type result_type; template static BOOST_UBLAS_INLINE result_type apply (const matrix_expression &e) { real_type t = real_type (); - size_type size2 (e ().size2 ()); - for (size_type j = 0; j < size2; ++ j) { + typedef typename E::size_type matrix_size_type; + matrix_size_type size2 (e ().size2 ()); + for (matrix_size_type j = 0; j < size2; ++ j) { real_type u = real_type (); - size_type size1 (e ().size1 ()); - for (size_type i = 0; i < size1; ++ i) { + matrix_size_type size1 (e ().size1 ()); + for (matrix_size_type i = 0; i < size1; ++ i) { real_type v (type_traits::norm_1 (e () (i, j))); u += v; } @@ -1318,23 +1290,23 @@ namespace boost { namespace numeric { namespace ublas { return t; } }; - template + + template struct matrix_norm_frobenius: - public matrix_scalar_real_unary_functor { - typedef typename matrix_scalar_real_unary_functor::size_type size_type; - typedef typename matrix_scalar_real_unary_functor::difference_type difference_type; - typedef typename matrix_scalar_real_unary_functor::value_type value_type; - typedef typename matrix_scalar_real_unary_functor::real_type real_type; - typedef typename matrix_scalar_real_unary_functor::result_type result_type; + public matrix_scalar_real_unary_functor { + typedef typename matrix_scalar_real_unary_functor::value_type value_type; + typedef typename matrix_scalar_real_unary_functor::real_type real_type; + typedef typename matrix_scalar_real_unary_functor::result_type result_type; template static BOOST_UBLAS_INLINE result_type apply (const matrix_expression &e) { real_type t = real_type (); - size_type size1 (e ().size1 ()); - for (size_type i = 0; i < size1; ++ i) { - size_type size2 (e ().size2 ()); - for (size_type j = 0; j < size2; ++ j) { + typedef typename E::size_type matrix_size_type; + matrix_size_type size1 (e ().size1 ()); + for (matrix_size_type i = 0; i < size1; ++ i) { + matrix_size_type size2 (e ().size2 ()); + for (matrix_size_type j = 0; j < size2; ++ j) { real_type u (type_traits::norm_2 (e () (i, j))); t += u * u; } @@ -1342,24 +1314,24 @@ namespace boost { namespace numeric { namespace ublas { return type_traits::type_sqrt (t); } }; - template + + template struct matrix_norm_inf: - public matrix_scalar_real_unary_functor { - typedef typename matrix_scalar_real_unary_functor::size_type size_type; - typedef typename matrix_scalar_real_unary_functor::difference_type difference_type; - typedef typename matrix_scalar_real_unary_functor::value_type value_type; - typedef typename matrix_scalar_real_unary_functor::real_type real_type; - typedef typename matrix_scalar_real_unary_functor::result_type result_type; + public matrix_scalar_real_unary_functor { + typedef typename matrix_scalar_real_unary_functor::value_type value_type; + typedef typename matrix_scalar_real_unary_functor::real_type real_type; + typedef typename matrix_scalar_real_unary_functor::result_type result_type; template static BOOST_UBLAS_INLINE result_type apply (const matrix_expression &e) { real_type t = real_type (); - size_type size1 (e ().size1 ()); - for (size_type i = 0; i < size1; ++ i) { + typedef typename E::size_type matrix_size_type; + matrix_size_type size1 (e ().size1 ()); + for (matrix_size_type i = 0; i < size1; ++ i) { real_type u = real_type (); - size_type size2 (e ().size2 ()); - for (size_type j = 0; j < size2; ++ j) { + matrix_size_type size2 (e ().size2 ()); + for (matrix_size_type j = 0; j < size2; ++ j) { real_type v (type_traits::norm_inf (e () (i, j))); u += v; } @@ -1370,8 +1342,8 @@ namespace boost { namespace numeric { namespace ublas { } }; - // This functor computes the address translation - // matrix [i] [j] -> storage [i * size2 + j] + // This functor defines storage layout and it's properties + // matrix (i,j) -> storage [i * size_i + j] template struct basic_row_major { typedef Z size_type; @@ -1380,90 +1352,133 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE - size_type storage_size (size_type size1, size_type size2) { + size_type storage_size (size_type size_i, size_type size_j) { // Guard against size_type overflow - BOOST_UBLAS_CHECK (size2 == 0 || size1 <= (std::numeric_limits::max) () / size2, bad_size ()); - return size1 * size2; + BOOST_UBLAS_CHECK (size_j == 0 || size_i <= (std::numeric_limits::max) () / size_j, bad_size ()); + return size_i * size_j; } - // Indexing + // Indexing conversion to storage element static BOOST_UBLAS_INLINE - size_type element (size_type i, size_type size1, size_type j, size_type size2) { - BOOST_UBLAS_CHECK (i < size1, bad_index ()); - BOOST_UBLAS_CHECK (j < size2, bad_index ()); - detail::ignore_unused_variable_warning(size1); + size_type element (size_type i, size_type size_i, size_type j, size_type size_j) { + BOOST_UBLAS_CHECK (i < size_i, bad_index ()); + BOOST_UBLAS_CHECK (j < size_j, bad_index ()); + detail::ignore_unused_variable_warning(size_i); // Guard against size_type overflow - BOOST_UBLAS_CHECK (i <= ((std::numeric_limits::max) () - j) / size2, bad_index ()); - return i * size2 + j; + BOOST_UBLAS_CHECK (i <= ((std::numeric_limits::max) () - j) / size_j, bad_index ()); + return i * size_j + j; } static BOOST_UBLAS_INLINE - size_type address (size_type i, size_type size1, size_type j, size_type size2) { - BOOST_UBLAS_CHECK (i <= size1, bad_index ()); - BOOST_UBLAS_CHECK (j <= size2, bad_index ()); - // Guard against size_type overflow - address may be size2 past end of storage - BOOST_UBLAS_CHECK (size2 == 0 || i <= ((std::numeric_limits::max) () - j) / size2, bad_index ()); - detail::ignore_unused_variable_warning(size1); - return i * size2 + j; + size_type address (size_type i, size_type size_i, size_type j, size_type size_j) { + BOOST_UBLAS_CHECK (i <= size_i, bad_index ()); + BOOST_UBLAS_CHECK (j <= size_j, bad_index ()); + // Guard against size_type overflow - address may be size_j past end of storage + BOOST_UBLAS_CHECK (size_j == 0 || i <= ((std::numeric_limits::max) () - j) / size_j, bad_index ()); + detail::ignore_unused_variable_warning(size_i); + return i * size_j + j; + } + + // Storage element to index conversion + static + BOOST_UBLAS_INLINE + difference_type distance_i (difference_type k, size_type /* size_i */, size_type size_j) { + return size_j != 0 ? k / size_j : 0; } static BOOST_UBLAS_INLINE - difference_type distance1 (difference_type k, size_type /* size1 */, size_type size2) { - return size2 != 0 ? k / size2 : 0; - } - static - BOOST_UBLAS_INLINE - difference_type distance2 (difference_type k, size_type /* size1 */, size_type /* size2 */) { + difference_type distance_j (difference_type k, size_type /* size_i */, size_type /* size_j */) { return k; } static BOOST_UBLAS_INLINE - size_type index1 (difference_type k, size_type /* size1 */, size_type size2) { - return size2 != 0 ? k / size2 : 0; + size_type index_i (difference_type k, size_type /* size_i */, size_type size_j) { + return size_j != 0 ? k / size_j : 0; } static BOOST_UBLAS_INLINE - size_type index2 (difference_type k, size_type /* size1 */, size_type size2) { - return size2 != 0 ? k % size2 : 0; + size_type index_j (difference_type k, size_type /* size_i */, size_type size_j) { + return size_j != 0 ? k % size_j : 0; } static BOOST_UBLAS_INLINE - bool fast1 () { + bool fast_i () { return false; } static BOOST_UBLAS_INLINE - size_type one1 (size_type /* size1 */, size_type size2) { - return size2; - } - static - BOOST_UBLAS_INLINE - bool fast2 () { + bool fast_j () { return true; } + + // Iterating storage elements + template static BOOST_UBLAS_INLINE - size_type one2 (size_type /* size1 */, size_type /* size2 */) { - return 1; + void increment_i (I &it, size_type /* size_i */, size_type size_j) { + it += size_j; + } + template + static + BOOST_UBLAS_INLINE + void increment_i (I &it, difference_type n, size_type /* size_i */, size_type size_j) { + it += n * size_j; + } + template + static + BOOST_UBLAS_INLINE + void decrement_i (I &it, size_type /* size_i */, size_type size_j) { + it -= size_j; + } + template + static + BOOST_UBLAS_INLINE + void decrement_i (I &it, difference_type n, size_type /* size_i */, size_type size_j) { + it -= n * size_j; + } + template + static + BOOST_UBLAS_INLINE + void increment_j (I &it, size_type /* size_i */, size_type /* size_j */) { + ++ it; + } + template + static + BOOST_UBLAS_INLINE + void increment_j (I &it, difference_type n, size_type /* size_i */, size_type /* size_j */) { + it += n; + } + template + static + BOOST_UBLAS_INLINE + void decrement_j (I &it, size_type /* size_i */, size_type /* size_j */) { + -- it; + } + template + static + BOOST_UBLAS_INLINE + void decrement_j (I &it, difference_type n, size_type /* size_i */, size_type /* size_j */) { + it -= n; } + // Triangular access static BOOST_UBLAS_INLINE - size_type triangular_size (size_type size1, size_type size2) { - size_type size = (std::max) (size1, size2); + size_type triangular_size (size_type size_i, size_type size_j) { + size_type size = (std::max) (size_i, size_j); // Guard against size_type overflow - simplified BOOST_UBLAS_CHECK (size == 0 || size / 2 < (std::numeric_limits::max) () / size /* +1/2 */, bad_size ()); return ((size + 1) * size) / 2; } static BOOST_UBLAS_INLINE - size_type lower_element (size_type i, size_type size1, size_type j, size_type size2) { - BOOST_UBLAS_CHECK (i < size1, bad_index ()); - BOOST_UBLAS_CHECK (j < size2, bad_index ()); + size_type lower_element (size_type i, size_type size_i, size_type j, size_type size_j) { + BOOST_UBLAS_CHECK (i < size_i, bad_index ()); + BOOST_UBLAS_CHECK (j < size_j, bad_index ()); BOOST_UBLAS_CHECK (i >= j, bad_index ()); - detail::ignore_unused_variable_warning(size1); - detail::ignore_unused_variable_warning(size2); + detail::ignore_unused_variable_warning(size_i); + detail::ignore_unused_variable_warning(size_j); // FIXME size_type overflow // sigma_i (i + 1) = (i + 1) * i / 2 // i = 0 1 2 3, sigma = 0 1 3 6 @@ -1471,94 +1486,41 @@ namespace boost { namespace numeric { namespace ublas { } static BOOST_UBLAS_INLINE - size_type upper_element (size_type i, size_type size1, size_type j, size_type size2) { - BOOST_UBLAS_CHECK (i < size1, bad_index ()); - BOOST_UBLAS_CHECK (j < size2, bad_index ()); + size_type upper_element (size_type i, size_type size_i, size_type j, size_type size_j) { + BOOST_UBLAS_CHECK (i < size_i, bad_index ()); + BOOST_UBLAS_CHECK (j < size_j, bad_index ()); BOOST_UBLAS_CHECK (i <= j, bad_index ()); // FIXME size_type overflow // sigma_i (size - i) = size * i - i * (i - 1) / 2 // i = 0 1 2 3, sigma = 0 4 7 9 - return (i * (2 * (std::max) (size1, size2) - i + 1)) / 2 + j - i; + return (i * (2 * (std::max) (size_i, size_j) - i + 1)) / 2 + j - i; } + // Major and minor indices static BOOST_UBLAS_INLINE - size_type element1 (size_type i, size_type size1, size_type /* j */, size_type /* size2 */) { - BOOST_UBLAS_CHECK (i < size1, bad_index ()); - detail::ignore_unused_variable_warning(size1); - return i; - } - static - BOOST_UBLAS_INLINE - size_type element2 (size_type /* i */, size_type /* size1 */, size_type j, size_type size2) { - BOOST_UBLAS_CHECK (j < size2, bad_index ()); - detail::ignore_unused_variable_warning(size2); - return j; - } - static - BOOST_UBLAS_INLINE - size_type address1 (size_type i, size_type size1, size_type /* j */, size_type /* size2 */) { - BOOST_UBLAS_CHECK (i <= size1, bad_index ()); - detail::ignore_unused_variable_warning(size1); - return i; - } - static - BOOST_UBLAS_INLINE - size_type address2 (size_type /* i */, size_type /* size1 */, size_type j, size_type size2) { - BOOST_UBLAS_CHECK (j <= size2, bad_index ()); - detail::ignore_unused_variable_warning(size2); - return j; - } - static - BOOST_UBLAS_INLINE - size_type index1 (size_type index1, size_type /* index2 */) { + size_type index_M (size_type index1, size_type /* index2 */) { return index1; } static BOOST_UBLAS_INLINE - size_type index2 (size_type /* index1 */, size_type index2) { + size_type index_m (size_type /* index1 */, size_type index2) { return index2; } static BOOST_UBLAS_INLINE - size_type size1 (size_type size1, size_type /* size2 */) { - return size1; + size_type size_M (size_type size_i, size_type /* size_j */) { + return size_i; } static BOOST_UBLAS_INLINE - size_type size2 (size_type /* size1 */, size_type size2) { - return size2; - } - - // Iterating - template - static - BOOST_UBLAS_INLINE - void increment1 (I &it, size_type /* size1 */, size_type size2) { - it += size2; - } - template - static - BOOST_UBLAS_INLINE - void decrement1 (I &it, size_type /* size1 */, size_type size2) { - it -= size2; - } - template - static - BOOST_UBLAS_INLINE - void increment2 (I &it, size_type /* size1 */, size_type /* size2 */) { - ++ it; - } - template - static - BOOST_UBLAS_INLINE - void decrement2 (I &it, size_type /* size1 */, size_type /* size2 */) { - -- it; + size_type size_m (size_type /* size_i */, size_type size_j) { + return size_j; } }; - // This functor computes the address translation - // matrix [i] [j] -> storage [i + j * size1] + // This functor defines storage layout and it's properties + // matrix (i,j) -> storage [i + j * size_i] template struct basic_column_major { typedef Z size_type; @@ -1567,98 +1529,141 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE - size_type storage_size (size_type size1, size_type size2) { + size_type storage_size (size_type size_i, size_type size_j) { // Guard against size_type overflow - BOOST_UBLAS_CHECK (size1 == 0 || size2 <= (std::numeric_limits::max) () / size1, bad_size ()); - return size1 * size2; + BOOST_UBLAS_CHECK (size_i == 0 || size_j <= (std::numeric_limits::max) () / size_i, bad_size ()); + return size_i * size_j; } - // Indexing + // Indexing conversion to storage element static BOOST_UBLAS_INLINE - size_type element (size_type i, size_type size1, size_type j, size_type size2) { - BOOST_UBLAS_CHECK (i < size1, bad_index ()); - BOOST_UBLAS_CHECK (j < size2, bad_index ()); - detail::ignore_unused_variable_warning(size2); + size_type element (size_type i, size_type size_i, size_type j, size_type size_j) { + BOOST_UBLAS_CHECK (i < size_i, bad_index ()); + BOOST_UBLAS_CHECK (j < size_j, bad_index ()); + detail::ignore_unused_variable_warning(size_j); // Guard against size_type overflow - BOOST_UBLAS_CHECK (j <= ((std::numeric_limits::max) () - i) / size1, bad_index ()); - return i + j * size1; + BOOST_UBLAS_CHECK (j <= ((std::numeric_limits::max) () - i) / size_i, bad_index ()); + return i + j * size_i; } static BOOST_UBLAS_INLINE - size_type address (size_type i, size_type size1, size_type j, size_type size2) { - BOOST_UBLAS_CHECK (i <= size1, bad_index ()); - BOOST_UBLAS_CHECK (j <= size2, bad_index ()); - detail::ignore_unused_variable_warning(size2); - // Guard against size_type overflow - address may be size1 past end of storage - BOOST_UBLAS_CHECK (size1 == 0 || j <= ((std::numeric_limits::max) () - i) / size1, bad_index ()); - return i + j * size1; + size_type address (size_type i, size_type size_i, size_type j, size_type size_j) { + BOOST_UBLAS_CHECK (i <= size_i, bad_index ()); + BOOST_UBLAS_CHECK (j <= size_j, bad_index ()); + detail::ignore_unused_variable_warning(size_j); + // Guard against size_type overflow - address may be size_i past end of storage + BOOST_UBLAS_CHECK (size_i == 0 || j <= ((std::numeric_limits::max) () - i) / size_i, bad_index ()); + return i + j * size_i; } + + // Storage element to index conversion static BOOST_UBLAS_INLINE - difference_type distance1 (difference_type k, size_type /* size1 */, size_type /* size2 */) { + difference_type distance_i (difference_type k, size_type /* size_i */, size_type /* size_j */) { return k; } static BOOST_UBLAS_INLINE - difference_type distance2 (difference_type k, size_type size1, size_type /* size2 */) { - return size1 != 0 ? k / size1 : 0; + difference_type distance_j (difference_type k, size_type size_i, size_type /* size_j */) { + return size_i != 0 ? k / size_i : 0; } static BOOST_UBLAS_INLINE - size_type index1 (difference_type k, size_type size1, size_type /* size2 */) { - return size1 != 0 ? k % size1 : 0; + size_type index_i (difference_type k, size_type size_i, size_type /* size_j */) { + return size_i != 0 ? k % size_i : 0; } static BOOST_UBLAS_INLINE - size_type index2 (difference_type k, size_type size1, size_type /* size2 */) { - return size1 != 0 ? k / size1 : 0; + size_type index_j (difference_type k, size_type size_i, size_type /* size_j */) { + return size_i != 0 ? k / size_i : 0; } static BOOST_UBLAS_INLINE - bool fast1 () { + bool fast_i () { return true; } static BOOST_UBLAS_INLINE - size_type one1 (size_type /* size1 */, size_type /* size2 */) { - return 1; - } - static - BOOST_UBLAS_INLINE - bool fast2 () { + bool fast_j () { return false; } + + // Iterating + template static BOOST_UBLAS_INLINE - size_type one2 (size_type size1, size_type /* size2 */) { - return size1; + void increment_i (I &it, size_type /* size_i */, size_type /* size_j */) { + ++ it; + } + template + static + BOOST_UBLAS_INLINE + void increment_i (I &it, difference_type n, size_type /* size_i */, size_type /* size_j */) { + it += n; + } + template + static + BOOST_UBLAS_INLINE + void decrement_i (I &it, size_type /* size_i */, size_type /* size_j */) { + -- it; + } + template + static + BOOST_UBLAS_INLINE + void decrement_i (I &it, difference_type n, size_type /* size_i */, size_type /* size_j */) { + it -= n; + } + template + static + BOOST_UBLAS_INLINE + void increment_j (I &it, size_type size_i, size_type /* size_j */) { + it += size_i; + } + template + static + BOOST_UBLAS_INLINE + void increment_j (I &it, difference_type n, size_type size_i, size_type /* size_j */) { + it += n * size_i; + } + template + static + BOOST_UBLAS_INLINE + void decrement_j (I &it, size_type size_i, size_type /* size_j */) { + it -= size_i; + } + template + static + BOOST_UBLAS_INLINE + void decrement_j (I &it, difference_type n, size_type size_i, size_type /* size_j */) { + it -= n* size_i; } + // Triangular access static BOOST_UBLAS_INLINE - size_type triangular_size (size_type size1, size_type size2) { - size_type size = (std::max) (size1, size2); + size_type triangular_size (size_type size_i, size_type size_j) { + size_type size = (std::max) (size_i, size_j); // Guard against size_type overflow - simplified BOOST_UBLAS_CHECK (size == 0 || size / 2 < (std::numeric_limits::max) () / size /* +1/2 */, bad_size ()); return ((size + 1) * size) / 2; } static BOOST_UBLAS_INLINE - size_type lower_element (size_type i, size_type size1, size_type j, size_type size2) { - BOOST_UBLAS_CHECK (i < size1, bad_index ()); - BOOST_UBLAS_CHECK (j < size2, bad_index ()); + size_type lower_element (size_type i, size_type size_i, size_type j, size_type size_j) { + BOOST_UBLAS_CHECK (i < size_i, bad_index ()); + BOOST_UBLAS_CHECK (j < size_j, bad_index ()); BOOST_UBLAS_CHECK (i >= j, bad_index ()); // FIXME size_type overflow // sigma_j (size - j) = size * j - j * (j - 1) / 2 // j = 0 1 2 3, sigma = 0 4 7 9 - return i - j + (j * (2 * (std::max) (size1, size2) - j + 1)) / 2; + return i - j + (j * (2 * (std::max) (size_i, size_j) - j + 1)) / 2; } static BOOST_UBLAS_INLINE - size_type upper_element (size_type i, size_type size1, size_type j, size_type size2) { - BOOST_UBLAS_CHECK (i < size1, bad_index ()); - BOOST_UBLAS_CHECK (j < size2, bad_index ()); + size_type upper_element (size_type i, size_type size_i, size_type j, size_type size_j) { + BOOST_UBLAS_CHECK (i < size_i, bad_index ()); + BOOST_UBLAS_CHECK (j < size_j, bad_index ()); BOOST_UBLAS_CHECK (i <= j, bad_index ()); // FIXME size_type overflow // sigma_j (j + 1) = (j + 1) * j / 2 @@ -1666,79 +1671,26 @@ namespace boost { namespace numeric { namespace ublas { return i + ((j + 1) * j) / 2; } + // Major and minor indices static BOOST_UBLAS_INLINE - size_type element1 (size_type /* i */, size_type /* size1 */, size_type j, size_type size2) { - BOOST_UBLAS_CHECK (j < size2, bad_index ()); - detail::ignore_unused_variable_warning(size2); - return j; - } - static - BOOST_UBLAS_INLINE - size_type element2 (size_type i, size_type size1, size_type /* j */, size_type /* size2 */) { - BOOST_UBLAS_CHECK (i < size1, bad_index ()); - detail::ignore_unused_variable_warning(size1); - return i; - } - static - BOOST_UBLAS_INLINE - size_type address1 (size_type /* i */, size_type /* size1 */, size_type j, size_type size2) { - BOOST_UBLAS_CHECK (j <= size2, bad_index ()); - detail::ignore_unused_variable_warning(size2); - return j; - } - static - BOOST_UBLAS_INLINE - size_type address2 (size_type i, size_type size1, size_type /* j */, size_type /* size2 */) { - BOOST_UBLAS_CHECK (i <= size1, bad_index ()); - detail::ignore_unused_variable_warning(size1); - return i; - } - static - BOOST_UBLAS_INLINE - size_type index1 (size_type /* index1 */, size_type index2) { + size_type index_M (size_type /* index1 */, size_type index2) { return index2; } static BOOST_UBLAS_INLINE - size_type index2 (size_type index1, size_type /* index2 */) { + size_type index_m (size_type index1, size_type /* index2 */) { return index1; } static BOOST_UBLAS_INLINE - size_type size1 (size_type /* size1 */, size_type size2) { - return size2; + size_type size_M (size_type /* size_i */, size_type size_j) { + return size_j; } static BOOST_UBLAS_INLINE - size_type size2 (size_type size1, size_type /* size2 */) { - return size1; - } - - // Iterating - template - static - BOOST_UBLAS_INLINE - void increment1 (I &it, size_type /* size1 */, size_type /* size2 */) { - ++ it; - } - template - static - BOOST_UBLAS_INLINE - void decrement1 (I &it, size_type /* size1 */, size_type /* size2 */) { - -- it; - } - template - static - BOOST_UBLAS_INLINE - void increment2 (I &it, size_type size1, size_type /* size2 */) { - it += size1; - } - template - static - BOOST_UBLAS_INLINE - void decrement2 (I &it, size_type size1, size_type /* size2 */) { - it -= size1; + size_type size_m (size_type size_i, size_type /* size_j */) { + return size_i; } }; @@ -1750,8 +1702,8 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE - size_type packed_size (size_type size1, size_type size2) { - return L::storage_size (size1, size2); + size_type packed_size (L, size_type size_i, size_type size_j) { + return L::storage_size (size_i, size_j); } static @@ -1769,6 +1721,26 @@ namespace boost { namespace numeric { namespace ublas { bool other (size_type /* i */, size_type /* j */) { return true; } + static + BOOST_UBLAS_INLINE + size_type restrict1 (size_type i, size_type j) { + return i; + } + static + BOOST_UBLAS_INLINE + size_type restrict2 (size_type i, size_type j) { + return j; + } + static + BOOST_UBLAS_INLINE + size_type mutable_restrict1 (size_type i, size_type j) { + return i; + } + static + BOOST_UBLAS_INLINE + size_type mutable_restrict2 (size_type i, size_type j) { + return j; + } }; template @@ -1778,8 +1750,8 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE - size_type packed_size (L, size_type size1, size_type size2) { - return L::triangular_size (size1, size2); + size_type packed_size (L, size_type size_i, size_type size_j) { + return L::triangular_size (size_i, size_j); } static @@ -1800,8 +1772,8 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE - size_type element (L, size_type i, size_type size1, size_type j, size_type size2) { - return L::lower_element (i, size1, j, size2); + size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) { + return L::lower_element (i, size_i, j, size_j); } static @@ -1832,8 +1804,8 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE - size_type packed_size (L, size_type size1, size_type size2) { - return L::triangular_size (size1, size2); + size_type packed_size (L, size_type size_i, size_type size_j) { + return L::triangular_size (size_i, size_j); } static @@ -1854,8 +1826,8 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE - size_type element (L, size_type i, size_type size1, size_type j, size_type size2) { - return L::upper_element (i, size1, j, size2); + size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) { + return L::upper_element (i, size_i, j, size_j); } static @@ -1886,10 +1858,10 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE - size_type packed_size (L, size_type size1, size_type size2) { + size_type packed_size (L, size_type size_i, size_type size_j) { // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ()); - return L::triangular_size (size1 - 1, size2 - 1); + BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ()); + return L::triangular_size (size_i - 1, size_j - 1); } static @@ -1905,10 +1877,10 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE - size_type element (L, size_type i, size_type size1, size_type j, size_type size2) { + size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) { // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ()); - return L::lower_element (i, size1 - 1, j, size2 - 1); + BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ()); + return L::lower_element (i, size_i - 1, j, size_j - 1); } static @@ -1929,10 +1901,10 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE - size_type packed_size (L, size_type size1, size_type size2) { + size_type packed_size (L, size_type size_i, size_type size_j) { // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ()); - return L::triangular_size (size1 - 1, size2 - 1); + BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ()); + return L::triangular_size (size_i - 1, size_j - 1); } static @@ -1948,10 +1920,10 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE - size_type element (L, size_type i, size_type size1, size_type j, size_type size2) { + size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) { // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ()); - return L::upper_element (i, size1 - 1, j, size2 - 1); + BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ()); + return L::upper_element (i, size_i - 1, j, size_j - 1); } static @@ -1972,10 +1944,10 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE - size_type packed_size (L, size_type size1, size_type size2) { + size_type packed_size (L, size_type size_i, size_type size_j) { // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ()); - return L::triangular_size (size1 - 1, size2 - 1); + BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ()); + return L::triangular_size (size_i - 1, size_j - 1); } static @@ -1996,10 +1968,10 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE - size_type element (L, size_type i, size_type size1, size_type j, size_type size2) { + size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) { // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ()); - return L::lower_element (i, size1 - 1, j, size2 - 1); + BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ()); + return L::lower_element (i, size_i - 1, j, size_j - 1); } static @@ -2030,10 +2002,10 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE - size_type packed_size (L, size_type size1, size_type size2) { + size_type packed_size (L, size_type size_i, size_type size_j) { // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ()); - return L::triangular_size (size1 - 1, size2 - 1); + BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ()); + return L::triangular_size (size_i - 1, size_j - 1); } static @@ -2054,10 +2026,10 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE - size_type element (L, size_type i, size_type size1, size_type j, size_type size2) { + size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) { // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ()); - return L::upper_element (i, size1 - 1, j, size2 - 1); + BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ()); + return L::upper_element (i, size_i - 1, j, size_j - 1); } static diff --git a/include/boost/numeric/ublas/fwd.hpp b/include/boost/numeric/ublas/fwd.hpp index 57f912c6..5baca043 100644 --- a/include/boost/numeric/ublas/fwd.hpp +++ b/include/boost/numeric/ublas/fwd.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -93,11 +89,11 @@ namespace boost { namespace numeric { namespace ublas { template class bounded_vector; - template + template > class unit_vector; - template + template > class zero_vector; - template + template > class scalar_vector; template @@ -130,11 +126,11 @@ namespace boost { namespace numeric { namespace ublas { template class bounded_matrix; - template + template > class identity_matrix; - template + template > class zero_matrix; - template + template > class scalar_matrix; template diff --git a/include/boost/numeric/ublas/hermitian.hpp b/include/boost/numeric/ublas/hermitian.hpp index de88a769..7104d557 100644 --- a/include/boost/numeric/ublas/hermitian.hpp +++ b/include/boost/numeric/ublas/hermitian.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -18,6 +14,7 @@ #define BOOST_UBLAS_HERMITIAN_H #include +#include // for resize_preserve #include // Iterators based on ideas of Jeremy Siek @@ -59,9 +56,6 @@ namespace boost { namespace numeric { namespace ublas { hermitian_matrix_element (matrix_type &m, size_type i, size_type j, value_type d): 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), i_ (p.i_), d_ (p.d_), dirty_ (p.dirty_) {} - BOOST_UBLAS_INLINE ~hermitian_matrix_element () { if (dirty_) (*this) ().insert_element (i_, j_, d_); @@ -320,7 +314,7 @@ namespace boost { namespace numeric { namespace ublas { void resize (size_type size, bool preserve = true) { if (preserve) { self_type temporary (size, size); - detail::matrix_resize_preserve (*this, temporary); + detail::matrix_resize_preserve (*this, temporary); } else { data ().resize (triangular_type::packed_size (layout_type (), size, size)); @@ -360,13 +354,11 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE reference operator () (size_type i, size_type j) { #ifndef BOOST_UBLAS_STRICT_HERMITIAN - if (triangular_type::other (i, j)) - return at_element (i, j); - else { - external_logic ().raise (); - // arbitary return value - return data () [triangular_type::element (layout_type (), j, size_, i, size_)]; + if (!triangular_type::other (i, j)) { + bad_index ().raise (); + // NEVER reached } + return at_element (i, j); #else if (triangular_type::other (i, j)) return reference (*this, i, j, data () [triangular_type::element (layout_type (), i, size_, j, size_)]); diff --git a/include/boost/numeric/ublas/io.hpp b/include/boost/numeric/ublas/io.hpp index ef02d396..795dd9bd 100644 --- a/include/boost/numeric/ublas/io.hpp +++ b/include/boost/numeric/ublas/io.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -19,6 +15,7 @@ // Only forward definition required to define stream operations #include +#include #include diff --git a/include/boost/numeric/ublas/lu.hpp b/include/boost/numeric/ublas/lu.hpp index 73b5fed2..2f785e9e 100644 --- a/include/boost/numeric/ublas/lu.hpp +++ b/include/boost/numeric/ublas/lu.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -101,7 +97,8 @@ namespace boost { namespace numeric { namespace ublas { matrix_column mci (column (m, i)); matrix_row mri (row (m, i)); if (m (i, i) != value_type/*zero*/()) { - project (mci, range (i + 1, size1)) *= value_type (1) / m (i, i); + value_type m_inv = value_type (1) / m (i, i); + project (mci, range (i + 1, size1)) *= m_inv; } else if (singular == 0) { singular = i + 1; } @@ -144,7 +141,8 @@ namespace boost { namespace numeric { namespace ublas { } else { BOOST_UBLAS_CHECK (pm (i) == i_norm_inf, external_logic ()); } - project (mci, range (i + 1, size1)) *= value_type (1) / m (i, i); + value_type m_inv = value_type (1) / m (i, i); + project (mci, range (i + 1, size1)) *= m_inv; } else if (singular == 0) { singular = i + 1; } diff --git a/include/boost/numeric/ublas/matrix.hpp b/include/boost/numeric/ublas/matrix.hpp index 68c57e0d..c667216c 100644 --- a/include/boost/numeric/ublas/matrix.hpp +++ b/include/boost/numeric/ublas/matrix.hpp @@ -1,14 +1,10 @@ // -// Copyright (c) 2000-2002 -// Joerg Walter, Mathias Koch +// Copyright (c) 2000-2007 +// Joerg Walter, Mathias Koch, Gunter Winkler // -// 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -20,6 +16,9 @@ #include #include #include +#include +#include +#include // Iterators based on ideas of Jeremy Siek @@ -41,15 +40,17 @@ namespace boost { namespace numeric { namespace ublas { // Common elements to preserve const size_type size1_min = (std::min) (size1, msize1); const size_type size2_min = (std::min) (size2, msize2); - // Order loop for i-major and j-minor sizes - const size_type i_size = layout_type::size1 (size1_min, size2_min); - const size_type j_size = layout_type::size2 (size1_min, size2_min); - for (size_type i = 0; i != i_size; ++i) { // indexing copy over major - for (size_type j = 0; j != j_size; ++j) { - const size_type element1 = layout_type::element1(i,i_size, j,j_size); - const size_type element2 = layout_type::element2(i,i_size, j,j_size); - temporary.data () [layout_type::element (element1, size1, element2, size2)] = - m.data() [layout_type::element (element1, msize1, element2, msize2)]; + // Order for major and minor sizes + const size_type major_size = layout_type::size_M (size1_min, size2_min); + const size_type minor_size = layout_type::size_m (size1_min, size2_min); + // Indexing copy over major + for (size_type major = 0; major != major_size; ++major) { + for (size_type minor = 0; minor != minor_size; ++minor) { + // find indexes - use invertability of element_ functions + const size_type i1 = layout_type::index_M(major, minor); + const size_type i2 = layout_type::index_m(major, minor); + temporary.data () [layout_type::element (i1, size1, i2, size2)] = + m.data() [layout_type::element (i1, msize1, i2, msize2)]; } } m.assign_temporary (temporary); @@ -95,6 +96,10 @@ namespace boost { namespace numeric { namespace ublas { matrix_container (), size1_ (size1), size2_ (size2), data_ (layout_type::storage_size (size1, size2)) { } + matrix (size_type size1, size_type size2, const value_type &init): + matrix_container (), + size1_ (size1), size2_ (size2), data_ (layout_type::storage_size (size1, size2), init) { + } BOOST_UBLAS_INLINE matrix (size_type size1, size_type size2, const array_type &data): matrix_container (), @@ -355,28 +360,28 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE const_iterator1 &operator ++ () { - layout_type::increment1 (it_, (*this) ().size1 (), (*this) ().size2 ()); + layout_type::increment_i (it_, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE const_iterator1 &operator -- () { - layout_type::decrement1 (it_, (*this) ().size1 (), (*this) ().size2 ()); + layout_type::decrement_i (it_, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE const_iterator1 &operator += (difference_type n) { - it_ += n * layout_type::one1 ((*this) ().size1 (), (*this) ().size2 ()); + layout_type::increment_i (it_, n, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE const_iterator1 &operator -= (difference_type n) { - it_ -= n * layout_type::one1 ((*this) ().size1 (), (*this) ().size2 ()); + layout_type::decrement_i (it_, n, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator1 &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); - return layout_type::distance1 (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ()); + return layout_type::distance_i (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ()); } // Dereference @@ -428,12 +433,12 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { const self_type &m = (*this) (); - return layout_type::index1 (it_ - m.begin1 ().it_, m.size1 (), m.size2 ()); + return layout_type::index_i (it_ - m.begin1 ().it_, m.size1 (), m.size2 ()); } BOOST_UBLAS_INLINE size_type index2 () const { const self_type &m = (*this) (); - return layout_type::index2 (it_ - m.begin1 ().it_, m.size1 (), m.size2 ()); + return layout_type::index_j (it_ - m.begin1 ().it_, m.size1 (), m.size2 ()); } // Assignment @@ -497,28 +502,28 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE iterator1 &operator ++ () { - layout_type::increment1 (it_, (*this) ().size1 (), (*this) ().size2 ()); + layout_type::increment_i (it_, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE iterator1 &operator -- () { - layout_type::decrement1 (it_, (*this) ().size1 (), (*this) ().size2 ()); + layout_type::decrement_i (it_, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE iterator1 &operator += (difference_type n) { - it_ += n * layout_type::one1 ((*this) ().size1 (), (*this) ().size2 ()); + layout_type::increment_i (it_, n, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE iterator1 &operator -= (difference_type n) { - it_ -= n * layout_type::one1 ((*this) ().size1 (), (*this) ().size2 ()); + layout_type::decrement_i (it_, n, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE difference_type operator - (const iterator1 &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); - return layout_type::distance1 (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ()); + return layout_type::distance_i (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ()); } // Dereference @@ -570,12 +575,12 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { self_type &m = (*this) (); - return layout_type::index1 (it_ - m.begin1 ().it_, m.size1 (), m.size2 ()); + return layout_type::index_i (it_ - m.begin1 ().it_, m.size1 (), m.size2 ()); } BOOST_UBLAS_INLINE size_type index2 () const { self_type &m = (*this) (); - return layout_type::index2 (it_ - m.begin1 ().it_, m.size1 (), m.size2 ()); + return layout_type::index_j (it_ - m.begin1 ().it_, m.size1 (), m.size2 ()); } // Assignment @@ -642,28 +647,28 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE const_iterator2 &operator ++ () { - layout_type::increment2 (it_, (*this) ().size1 (), (*this) ().size2 ()); + layout_type::increment_j (it_, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE const_iterator2 &operator -- () { - layout_type::decrement2 (it_, (*this) ().size1 (), (*this) ().size2 ()); + layout_type::decrement_j (it_, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE const_iterator2 &operator += (difference_type n) { - it_ += n * layout_type::one2 ((*this) ().size1 (), (*this) ().size2 ()); + layout_type::increment_j (it_, n, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE const_iterator2 &operator -= (difference_type n) { - it_ -= n * layout_type::one2 ((*this) ().size1 (), (*this) ().size2 ()); + layout_type::decrement_j (it_, n, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator2 &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); - return layout_type::distance2 (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ()); + return layout_type::distance_j (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ()); } // Dereference @@ -715,12 +720,12 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { const self_type &m = (*this) (); - return layout_type::index1 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ()); + return layout_type::index_i (it_ - m.begin2 ().it_, m.size1 (), m.size2 ()); } BOOST_UBLAS_INLINE size_type index2 () const { const self_type &m = (*this) (); - return layout_type::index2 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ()); + return layout_type::index_j (it_ - m.begin2 ().it_, m.size1 (), m.size2 ()); } // Assignment @@ -784,28 +789,28 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE iterator2 &operator ++ () { - layout_type::increment2 (it_, (*this) ().size1 (), (*this) ().size2 ()); + layout_type::increment_j (it_, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE iterator2 &operator -- () { - layout_type::decrement2 (it_, (*this) ().size1 (), (*this) ().size2 ()); + layout_type::decrement_j (it_, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE iterator2 &operator += (difference_type n) { - it_ += n * layout_type::one2 ((*this) ().size1 (), (*this) ().size2 ()); + layout_type::increment_j (it_, n, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE iterator2 &operator -= (difference_type n) { - it_ -= n * layout_type::one2 ((*this) ().size1 (), (*this) ().size2 ()); + layout_type::decrement_j (it_, n, (*this) ().size1 (), (*this) ().size2 ()); return *this; } BOOST_UBLAS_INLINE difference_type operator - (const iterator2 &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); - return layout_type::distance2 (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ()); + return layout_type::distance_j (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ()); } // Dereference @@ -857,12 +862,12 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { self_type &m = (*this) (); - return layout_type::index1 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ()); + return layout_type::index_i (it_ - m.begin2 ().it_, m.size1 (), m.size2 ()); } BOOST_UBLAS_INLINE size_type index2 () const { self_type &m = (*this) (); - return layout_type::index2 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ()); + return layout_type::index_j (it_ - m.begin2 ().it_, m.size1 (), m.size2 ()); } // Assignment @@ -939,6 +944,27 @@ namespace boost { namespace numeric { namespace ublas { return reverse_iterator2 (begin2 ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + + // we need to copy to a collection_size_type to get a portable + // and efficient serialization + serialization::collection_size_type s1 (size1_); + serialization::collection_size_type s2 (size2_); + + // serialize the sizes + ar & serialization::make_nvp("size1",s1) + & serialization::make_nvp("size2",s2); + + // copy the values back if loading + if (Archive::is_loading::value) { + size1_ = s1; + size2_ = s2; + } + ar & serialization::make_nvp("data",data_); + } + private: size_type size1_; size_type size2_; @@ -1052,9 +1078,9 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE vector_of_vector (const matrix_expression &ae): matrix_container (), - size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ (layout_type::size1 (size1_, size2_) + 1) { - for (size_type k = 0; k < layout_type::size1 (size1_, size2_); ++ k) - data ()[k].resize (layout_type::size2 (size1_, size2_)); + size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ (layout_type::size_M (size1_, size2_) + 1) { + for (size_type k = 0; k < layout_type::size_M (size1_, size2_); ++ k) + data ()[k].resize (layout_type::size_m (size1_, size2_)); matrix_assign (*this, ae); } @@ -1084,25 +1110,25 @@ namespace boost { namespace numeric { namespace ublas { size1_ = size1; size2_ = size2; if (preserve) - data ().resize (layout_type::size1 (size1, size2) + 1, typename array_type::value_type ()); + data ().resize (layout_type::size_M (size1, size2) + 1, typename array_type::value_type ()); else - data ().resize (layout_type::size1 (size1, size2) + 1); - for (size_type k = 0; k < layout_type::size1 (size1, size2); ++ k) { + data ().resize (layout_type::size_M (size1, size2) + 1); + for (size_type k = 0; k < layout_type::size_M (size1, size2); ++ k) { if (preserve) - data () [k].resize (layout_type::size2 (size1, size2), value_type ()); + data () [k].resize (layout_type::size_m (size1, size2), value_type ()); else - data () [k].resize (layout_type::size2 (size1, size2)); + data () [k].resize (layout_type::size_m (size1, size2)); } } // Element access BOOST_UBLAS_INLINE const_reference operator () (size_type i, size_type j) const { - return data () [layout_type::element1 (i, size1_, j, size2_)] [layout_type::element2 (i, size1_, j, size2_)]; + return data () [layout_type::index_M (i, j)] [layout_type::index_m (i, j)]; } BOOST_UBLAS_INLINE reference at_element (size_type i, size_type j) { - return data () [layout_type::element1 (i, size1_, j, size2_)] [layout_type::element2 (i, size1_, j, size2_)]; + return data () [layout_type::index_M (i, j)] [layout_type::index_m (i, j)]; } BOOST_UBLAS_INLINE reference operator () (size_type i, size_type j) { @@ -1122,7 +1148,7 @@ namespace boost { namespace numeric { namespace ublas { // Zeroing BOOST_UBLAS_INLINE void clear () { - for (size_type k = 0; k < layout_type::size1 (size1_, size2_); ++ k) + for (size_type k = 0; k < layout_type::size_M (size1_, size2_); ++ k) std::fill (data () [k].begin (), data () [k].end (), value_type/*zero*/()); } @@ -1249,7 +1275,7 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator1 (*this, i, j); #else - return const_iterator1 (*this, i, j, data () [layout_type::address1 (i, size1_, j, size2_)].begin () + layout_type::address2 (i, size1_, j, size2_)); + return const_iterator1 (*this, i, j, data () [layout_type::index_M (i, j)].begin () + layout_type::index_m (i, j)); #endif } BOOST_UBLAS_INLINE @@ -1257,7 +1283,7 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator1 (*this, i, j); #else - return iterator1 (*this, i, j, data () [layout_type::address1 (i, size1_, j, size2_)].begin () + layout_type::address2 (i, size1_, j, size2_)); + return iterator1 (*this, i, j, data () [layout_type::index_M (i, j)].begin () + layout_type::index_m (i, j)); #endif } BOOST_UBLAS_INLINE @@ -1265,7 +1291,7 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator2 (*this, i, j); #else - return const_iterator2 (*this, i, j, data () [layout_type::address1 (i, size1_, j, size2_)].begin () + layout_type::address2 (i, size1_, j, size2_)); + return const_iterator2 (*this, i, j, data () [layout_type::index_M (i, j)].begin () + layout_type::index_m (i, j)); #endif } BOOST_UBLAS_INLINE @@ -1273,7 +1299,7 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return iterator2 (*this, i, j); #else - return iterator2 (*this, i, j, data () [layout_type::address1 (i, size1_, j, size2_)].begin () + layout_type::address2 (i, size1_, j, size2_)); + return iterator2 (*this, i, j, data () [layout_type::index_M (i, j)].begin () + layout_type::index_m (i, j)); #endif } @@ -1308,7 +1334,7 @@ namespace boost { namespace numeric { namespace ublas { const_iterator1 &operator ++ () { ++ i_; const self_type &m = (*this) (); - if (layout_type::fast1 ()) + if (layout_type::fast_i ()) ++ it_; else it_ = m.find1 (1, i_, j_).it_; @@ -1318,7 +1344,7 @@ namespace boost { namespace numeric { namespace ublas { const_iterator1 &operator -- () { -- i_; const self_type &m = (*this) (); - if (layout_type::fast1 ()) + if (layout_type::fast_i ()) -- it_; else it_ = m.find1 (1, i_, j_).it_; @@ -1467,7 +1493,7 @@ namespace boost { namespace numeric { namespace ublas { iterator1 &operator ++ () { ++ i_; self_type &m = (*this) (); - if (layout_type::fast1 ()) + if (layout_type::fast_i ()) ++ it_; else it_ = m.find1 (1, i_, j_).it_; @@ -1477,7 +1503,7 @@ namespace boost { namespace numeric { namespace ublas { iterator1 &operator -- () { -- i_; self_type &m = (*this) (); - if (layout_type::fast1 ()) + if (layout_type::fast_i ()) -- it_; else it_ = m.find1 (1, i_, j_).it_; @@ -1629,7 +1655,7 @@ namespace boost { namespace numeric { namespace ublas { const_iterator2 &operator ++ () { ++ j_; const self_type &m = (*this) (); - if (layout_type::fast2 ()) + if (layout_type::fast_j ()) ++ it_; else it_ = m.find2 (1, i_, j_).it_; @@ -1639,7 +1665,7 @@ namespace boost { namespace numeric { namespace ublas { const_iterator2 &operator -- () { -- j_; const self_type &m = (*this) (); - if (layout_type::fast2 ()) + if (layout_type::fast_j ()) -- it_; else it_ = m.find2 (1, i_, j_).it_; @@ -1788,7 +1814,7 @@ namespace boost { namespace numeric { namespace ublas { iterator2 &operator ++ () { ++ j_; self_type &m = (*this) (); - if (layout_type::fast2 ()) + if (layout_type::fast_j ()) ++ it_; else it_ = m.find2 (1, i_, j_).it_; @@ -1798,7 +1824,7 @@ namespace boost { namespace numeric { namespace ublas { iterator2 &operator -- () { -- j_; self_type &m = (*this) (); - if (layout_type::fast2 ()) + if (layout_type::fast_j ()) -- it_; else it_ = m.find2 (1, i_, j_).it_; @@ -1958,6 +1984,27 @@ namespace boost { namespace numeric { namespace ublas { return reverse_iterator2 (begin2 ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + + // we need to copy to a collection_size_type to get a portable + // and efficient serialization + serialization::collection_size_type s1 (size1_); + serialization::collection_size_type s2 (size2_); + + // serialize the sizes + ar & serialization::make_nvp("size1",s1) + & serialization::make_nvp("size2",s2); + + // copy the values back if loading + if (Archive::is_loading::value) { + size1_ = s1; + size2_ = s2; + } + ar & serialization::make_nvp("data",data_); + } + private: size_type size1_; size_type size2_; @@ -1966,18 +2013,18 @@ namespace boost { namespace numeric { namespace ublas { // Zero matrix class - template + template class zero_matrix: - public matrix_container > { + public matrix_container > { typedef const T *const_pointer; - typedef zero_matrix self_type; + typedef zero_matrix self_type; public: #ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS using matrix_container::operator (); #endif - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; + typedef typename ALLOC::size_type size_type; + typedef typename ALLOC::difference_type difference_type; typedef T value_type; typedef const T &const_reference; typedef T &reference; @@ -2169,6 +2216,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE bool operator == (const const_iterator1 &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + detail::ignore_unused_variable_warning(it); return true; } }; @@ -2278,6 +2326,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE bool operator == (const const_iterator2 &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); + detail::ignore_unused_variable_warning(it); return true; } }; @@ -2313,29 +2362,49 @@ namespace boost { namespace numeric { namespace ublas { return const_reverse_iterator2 (begin2 ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + + // we need to copy to a collection_size_type to get a portable + // and efficient serialization + serialization::collection_size_type s1 (size1_); + serialization::collection_size_type s2 (size2_); + + // serialize the sizes + ar & serialization::make_nvp("size1",s1) + & serialization::make_nvp("size2",s2); + + // copy the values back if loading + if (Archive::is_loading::value) { + size1_ = s1; + size2_ = s2; + } + } + private: size_type size1_; size_type size2_; static const value_type zero_; }; - template - const typename zero_matrix::value_type zero_matrix::zero_ (0); + template + const typename zero_matrix::value_type zero_matrix::zero_ = T(/*zero*/); // Identity matrix class - template + template class identity_matrix: - public matrix_container > { + public matrix_container > { typedef const T *const_pointer; - typedef identity_matrix self_type; + typedef identity_matrix self_type; public: #ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS using matrix_container::operator (); #endif - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; + typedef typename ALLOC::size_type size_type; + typedef typename ALLOC::difference_type difference_type; typedef T value_type; typedef const T &const_reference; typedef T &reference; @@ -2693,6 +2762,27 @@ namespace boost { namespace numeric { namespace ublas { return const_reverse_iterator2 (begin2 ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + + // we need to copy to a collection_size_type to get a portable + // and efficient serialization + serialization::collection_size_type s1 (size1_); + serialization::collection_size_type s2 (size2_); + + // serialize the sizes + ar & serialization::make_nvp("size1",s1) + & serialization::make_nvp("size2",s2); + + // copy the values back if loading + if (Archive::is_loading::value) { + size1_ = s1; + size2_ = s2; + size_common_ = ((std::min)(size1_, size2_)); + } + } + private: size_type size1_; size_type size2_; @@ -2701,19 +2791,19 @@ namespace boost { namespace numeric { namespace ublas { static const value_type one_; }; - template - const typename identity_matrix::value_type identity_matrix::zero_ (0); - template - const typename identity_matrix::value_type identity_matrix::one_ (1); + template + const typename identity_matrix::value_type identity_matrix::zero_ = T(/*zero*/); + template + const typename identity_matrix::value_type identity_matrix::one_ (1); // ISSUE: need 'one'-traits here // Scalar matrix class - template + template class scalar_matrix: - public matrix_container > { + public matrix_container > { typedef const T *const_pointer; - typedef scalar_matrix self_type; + typedef scalar_matrix self_type; public: #ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS using matrix_container::operator (); @@ -2724,6 +2814,7 @@ namespace boost { namespace numeric { namespace ublas { typedef const T &const_reference; typedef T &reference; typedef const matrix_reference const_closure_type; + typedef matrix_reference closure_type; typedef dense_tag storage_category; typedef unknown_orientation_tag orientation_category; @@ -3131,6 +3222,28 @@ namespace boost { namespace numeric { namespace ublas { return const_reverse_iterator2 (begin2 ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + + // we need to copy to a collection_size_type to get a portable + // and efficient serialization + serialization::collection_size_type s1 (size1_); + serialization::collection_size_type s2 (size2_); + + // serialize the sizes + ar & serialization::make_nvp("size1",s1) + & serialization::make_nvp("size2",s2); + + // copy the values back if loading + if (Archive::is_loading::value) { + size1_ = s1; + size2_ = s2; + } + + ar & serialization::make_nvp("value", value_); + } + private: size_type size1_; size_type size2_; @@ -4034,6 +4147,28 @@ namespace boost { namespace numeric { namespace ublas { return reverse_iterator2 (begin2 ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + + // we need to copy to a collection_size_type to get a portable + // and efficient serialization + serialization::collection_size_type s1 (size1_); + serialization::collection_size_type s2 (size2_); + + // serialize the sizes + ar & serialization::make_nvp("size1",s1) + & serialization::make_nvp("size2",s2); + + // copy the values back if loading + if (Archive::is_loading::value) { + size1_ = s1; + size2_ = s2; + } + // could probably use make_array( &(data[0][0]), N*M ) + ar & serialization::make_array(data_, N); + } + private: size_type size1_; size_type size2_; diff --git a/include/boost/numeric/ublas/matrix_expression.hpp b/include/boost/numeric/ublas/matrix_expression.hpp index ac86f658..37ef2204 100644 --- a/include/boost/numeric/ublas/matrix_expression.hpp +++ b/include/boost/numeric/ublas/matrix_expression.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -2482,7 +2478,7 @@ namespace boost { namespace numeric { namespace ublas { operator + (const matrix_expression &e1, const matrix_expression &e2) { typedef typename matrix_binary_traits >::expression_type expression_type; + typename E2::value_type> >::expression_type expression_type; return expression_type (e1 (), e2 ()); } @@ -2494,7 +2490,7 @@ namespace boost { namespace numeric { namespace ublas { operator - (const matrix_expression &e1, const matrix_expression &e2) { typedef typename matrix_binary_traits >::expression_type expression_type; + typename E2::value_type> >::expression_type expression_type; return expression_type (e1 (), e2 ()); } @@ -2506,7 +2502,7 @@ namespace boost { namespace numeric { namespace ublas { element_prod (const matrix_expression &e1, const matrix_expression &e2) { typedef typename matrix_binary_traits >::expression_type expression_type; + typename E2::value_type> >::expression_type expression_type; return expression_type (e1 (), e2 ()); } @@ -2514,11 +2510,11 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE typename matrix_binary_traits >::result_type + typename E2::value_type> >::result_type element_div (const matrix_expression &e1, const matrix_expression &e2) { typedef typename matrix_binary_traits >::expression_type expression_type; + typename E2::value_type> >::expression_type expression_type; return expression_type (e1 (), e2 ()); } @@ -3689,7 +3685,7 @@ namespace boost { namespace numeric { namespace ublas { typedef unknown_storage_tag storage_category; typedef row_major_tag orientation_category; typedef typename promote_traits::promote_type promote_type; - typedef matrix_vector_binary1 > expression_type; + typedef matrix_vector_binary1 > expression_type; #ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else @@ -3706,7 +3702,7 @@ namespace boost { namespace numeric { namespace ublas { unknown_storage_tag, row_major_tag) { typedef typename matrix_vector_binary1_traits::expression_type expression_type; + typename E2::value_type, E2>::expression_type expression_type; return expression_type (e1 (), e2 ()); } @@ -3719,9 +3715,9 @@ namespace boost { namespace numeric { namespace ublas { const vector_expression &e2) { BOOST_STATIC_ASSERT (E2::complexity == 0); typedef typename matrix_vector_binary1_traits::storage_category storage_category; + typename E2::value_type, E2>::storage_category storage_category; typedef typename matrix_vector_binary1_traits::orientation_category orientation_category; + typename E2::value_type, E2>::orientation_category orientation_category; return prod (e1, e2, storage_category (), orientation_category ()); } @@ -3734,7 +3730,7 @@ namespace boost { namespace numeric { namespace ublas { unknown_storage_tag, row_major_tag) { typedef typename matrix_vector_binary1_traits::precision_type, E1, - typename type_traits::precision_type, E2>::expression_type expression_type; + typename type_traits::precision_type, E2>::expression_type expression_type; return expression_type (e1 (), e2 ()); } @@ -3747,9 +3743,9 @@ namespace boost { namespace numeric { namespace ublas { const vector_expression &e2) { BOOST_STATIC_ASSERT (E2::complexity == 0); typedef typename matrix_vector_binary1_traits::precision_type, E1, - typename type_traits::precision_type, E2>::storage_category storage_category; + typename type_traits::precision_type, E2>::storage_category storage_category; typedef typename matrix_vector_binary1_traits::precision_type, E1, - typename type_traits::precision_type, E2>::orientation_category orientation_category; + typename type_traits::precision_type, E2>::orientation_category orientation_category; return prec_prod (e1, e2, storage_category (), orientation_category ()); } @@ -4079,7 +4075,7 @@ namespace boost { namespace numeric { namespace ublas { typedef unknown_storage_tag storage_category; typedef column_major_tag orientation_category; typedef typename promote_traits::promote_type promote_type; - typedef matrix_vector_binary2 > expression_type; + typedef matrix_vector_binary2 > expression_type; #ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else @@ -4096,7 +4092,7 @@ namespace boost { namespace numeric { namespace ublas { unknown_storage_tag, column_major_tag) { typedef typename matrix_vector_binary2_traits::expression_type expression_type; + typename E2::value_type, E2>::expression_type expression_type; return expression_type (e1 (), e2 ()); } @@ -4109,9 +4105,9 @@ namespace boost { namespace numeric { namespace ublas { const matrix_expression &e2) { BOOST_STATIC_ASSERT (E1::complexity == 0); typedef typename matrix_vector_binary2_traits::storage_category storage_category; + typename E2::value_type, E2>::storage_category storage_category; typedef typename matrix_vector_binary2_traits::orientation_category orientation_category; + typename E2::value_type, E2>::orientation_category orientation_category; return prod (e1, e2, storage_category (), orientation_category ()); } @@ -4124,7 +4120,7 @@ namespace boost { namespace numeric { namespace ublas { unknown_storage_tag, column_major_tag) { typedef typename matrix_vector_binary2_traits::precision_type, E1, - typename type_traits::precision_type, E2>::expression_type expression_type; + typename type_traits::precision_type, E2>::expression_type expression_type; return expression_type (e1 (), e2 ()); } @@ -4137,9 +4133,9 @@ namespace boost { namespace numeric { namespace ublas { const matrix_expression &e2) { BOOST_STATIC_ASSERT (E1::complexity == 0); typedef typename matrix_vector_binary2_traits::precision_type, E1, - typename type_traits::precision_type, E2>::storage_category storage_category; + typename type_traits::precision_type, E2>::storage_category storage_category; typedef typename matrix_vector_binary2_traits::precision_type, E1, - typename type_traits::precision_type, E2>::orientation_category orientation_category; + typename type_traits::precision_type, E2>::orientation_category orientation_category; return prec_prod (e1, e2, storage_category (), orientation_category ()); } @@ -4784,7 +4780,7 @@ namespace boost { namespace numeric { namespace ublas { typedef unknown_storage_tag storage_category; typedef unknown_orientation_tag orientation_category; typedef typename promote_traits::promote_type promote_type; - typedef matrix_matrix_binary > expression_type; + typedef matrix_matrix_binary > expression_type; #ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG typedef expression_type result_type; #else @@ -4801,7 +4797,7 @@ namespace boost { namespace numeric { namespace ublas { unknown_storage_tag, unknown_orientation_tag) { typedef typename matrix_matrix_binary_traits::expression_type expression_type; + typename E2::value_type, E2>::expression_type expression_type; return expression_type (e1 (), e2 ()); } @@ -4814,9 +4810,9 @@ namespace boost { namespace numeric { namespace ublas { const matrix_expression &e2) { BOOST_STATIC_ASSERT (E1::complexity == 0 && E2::complexity == 0); typedef typename matrix_matrix_binary_traits::storage_category storage_category; + typename E2::value_type, E2>::storage_category storage_category; typedef typename matrix_matrix_binary_traits::orientation_category orientation_category; + typename E2::value_type, E2>::orientation_category orientation_category; return prod (e1, e2, storage_category (), orientation_category ()); } @@ -4829,7 +4825,7 @@ namespace boost { namespace numeric { namespace ublas { unknown_storage_tag, unknown_orientation_tag) { typedef typename matrix_matrix_binary_traits::precision_type, E1, - typename type_traits::precision_type, E2>::expression_type expression_type; + typename type_traits::precision_type, E2>::expression_type expression_type; return expression_type (e1 (), e2 ()); } @@ -4842,9 +4838,9 @@ namespace boost { namespace numeric { namespace ublas { const matrix_expression &e2) { BOOST_STATIC_ASSERT (E1::complexity == 0 && E2::complexity == 0); typedef typename matrix_matrix_binary_traits::precision_type, E1, - typename type_traits::precision_type, E2>::storage_category storage_category; + typename type_traits::precision_type, E2>::storage_category storage_category; typedef typename matrix_matrix_binary_traits::precision_type, E1, - typename type_traits::precision_type, E2>::orientation_category orientation_category; + typename type_traits::precision_type, E2>::orientation_category orientation_category; return prec_prod (e1, e2, storage_category (), orientation_category ()); } @@ -4925,25 +4921,25 @@ namespace boost { namespace numeric { namespace ublas { template BOOST_UBLAS_INLINE - typename matrix_scalar_unary_traits >::result_type + typename matrix_scalar_unary_traits >::result_type norm_1 (const matrix_expression &e) { - typedef typename matrix_scalar_unary_traits >::expression_type expression_type; + typedef typename matrix_scalar_unary_traits >::expression_type expression_type; return expression_type (e ()); } template BOOST_UBLAS_INLINE - typename matrix_scalar_unary_traits >::result_type + typename matrix_scalar_unary_traits >::result_type norm_frobenius (const matrix_expression &e) { - typedef typename matrix_scalar_unary_traits >::expression_type expression_type; + typedef typename matrix_scalar_unary_traits >::expression_type expression_type; return expression_type (e ()); } template BOOST_UBLAS_INLINE - typename matrix_scalar_unary_traits >::result_type + typename matrix_scalar_unary_traits >::result_type norm_inf (const matrix_expression &e) { - typedef typename matrix_scalar_unary_traits >::expression_type expression_type; + typedef typename matrix_scalar_unary_traits >::expression_type expression_type; return expression_type (e ()); } diff --git a/include/boost/numeric/ublas/matrix_proxy.hpp b/include/boost/numeric/ublas/matrix_proxy.hpp index 764461d2..d097af79 100644 --- a/include/boost/numeric/ublas/matrix_proxy.hpp +++ b/include/boost/numeric/ublas/matrix_proxy.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -4111,7 +4107,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE matrix_slice subslice (const M &data, typename M::size_type start1, typename M::difference_type stride1, typename M::size_type size1, typename M::size_type start2, typename M::difference_type stride2, typename M::size_type size2) { typedef basic_slice slice_type; - return matrix_slice (data (), slice_type (start1, stride1, size1), slice_type (start2, stride2, size2)); + return matrix_slice (data, slice_type (start1, stride1, size1), slice_type (start2, stride2, size2)); } // Generic Projections diff --git a/include/boost/numeric/ublas/matrix_sparse.hpp b/include/boost/numeric/ublas/matrix_sparse.hpp index 3bb02f95..4c24e925 100644 --- a/include/boost/numeric/ublas/matrix_sparse.hpp +++ b/include/boost/numeric/ublas/matrix_sparse.hpp @@ -1,14 +1,10 @@ // -// Copyright (c) 2000-2002 -// Joerg Walter, Mathias Koch +// Copyright (c) 2000-2007 +// Joerg Walter, Mathias Koch, Gunter Winkler // -// 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -552,8 +548,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 = size_type (-1); size_type index2 = size_type (-1); while (rank == 1 && it != it_end) { - index1 = layout_type::index1 ((*it).first, size1_, size2_); - index2 = layout_type::index2 ((*it).first, size1_, size2_); + index1 = layout_type::index_i ((*it).first, size1_, size2_); + index2 = layout_type::index_j ((*it).first, size1_, size2_); if (direction > 0) { if ((index1 >= i && index2 == j) || (i >= size1_)) break; @@ -581,8 +577,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 = size_type (-1); size_type index2 = size_type (-1); while (rank == 1 && it != it_end) { - index1 = layout_type::index1 ((*it).first, size1_, size2_); - index2 = layout_type::index2 ((*it).first, size1_, size2_); + index1 = layout_type::index_i ((*it).first, size1_, size2_); + index2 = layout_type::index_j ((*it).first, size1_, size2_); if (direction > 0) { if ((index1 >= i && index2 == j) || (i >= size1_)) break; @@ -610,8 +606,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 = size_type (-1); size_type index2 = size_type (-1); while (rank == 1 && it != it_end) { - index1 = layout_type::index1 ((*it).first, size1_, size2_); - index2 = layout_type::index2 ((*it).first, size1_, size2_); + index1 = layout_type::index_i ((*it).first, size1_, size2_); + index2 = layout_type::index_j ((*it).first, size1_, size2_); if (direction > 0) { if ((index2 >= j && index1 == i) || (j >= size2_)) break; @@ -639,8 +635,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 = size_type (-1); size_type index2 = size_type (-1); while (rank == 1 && it != it_end) { - index1 = layout_type::index1 ((*it).first, size1_, size2_); - index2 = layout_type::index2 ((*it).first, size1_, size2_); + index1 = layout_type::index_i ((*it).first, size1_, size2_); + index2 = layout_type::index_j ((*it).first, size1_, size2_); if (direction > 0) { if ((index2 >= j && index1 == i) || (j >= size2_)) break; @@ -690,7 +686,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE const_iterator1 &operator ++ () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) ++ it_; else *this = (*this) ().find1 (rank_, index1 () + 1, j_, 1); @@ -698,7 +694,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator1 &operator -- () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) -- it_; else *this = (*this) ().find1 (rank_, index1 () - 1, j_, -1); @@ -756,8 +752,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ()); if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); + return layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()); } else { return i_; } @@ -766,8 +762,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index2 () const { if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); + return layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()); } else { return j_; } @@ -836,7 +832,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE iterator1 &operator ++ () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) ++ it_; else *this = (*this) ().find1 (rank_, index1 () + 1, j_, 1); @@ -844,7 +840,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE iterator1 &operator -- () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) -- it_; else *this = (*this) ().find1 (rank_, index1 () - 1, j_, -1); @@ -902,8 +898,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ()); if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); + return layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()); } else { return i_; } @@ -912,8 +908,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index2 () const { if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); + return layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()); } else { return j_; } @@ -987,7 +983,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE const_iterator2 &operator ++ () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) ++ it_; else *this = (*this) ().find2 (rank_, i_, index2 () + 1, 1); @@ -995,7 +991,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator2 &operator -- () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) -- it_; else *this = (*this) ().find2 (rank_, i_, index2 () - 1, -1); @@ -1052,8 +1048,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 () const { if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); + return layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()); } else { return i_; } @@ -1063,8 +1059,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ()); if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); + return layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()); } else { return j_; } @@ -1133,7 +1129,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE iterator2 &operator ++ () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) ++ it_; else *this = (*this) ().find2 (rank_, i_, index2 () + 1, 1); @@ -1141,7 +1137,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE iterator2 &operator -- () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) -- it_; else *this = (*this) ().find2 (rank_, i_, index2 () - 1, -1); @@ -1198,8 +1194,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 () const { if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); + return layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()); } else { return i_; } @@ -1209,8 +1205,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ()); if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); + return layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()); } else { return j_; } @@ -1295,6 +1291,20 @@ namespace boost { namespace numeric { namespace ublas { return reverse_iterator2 (begin2 ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + serialization::collection_size_type s1 (size1_); + serialization::collection_size_type s2 (size2_); + ar & serialization::make_nvp("size1",s1); + ar & serialization::make_nvp("size2",s2); + if (Archive::is_loading::value) { + size1_ = s1; + size2_ = s2; + } + ar & serialization::make_nvp("data", data_); + } + private: size_type size1_; size_type size2_; @@ -1344,13 +1354,13 @@ namespace boost { namespace numeric { namespace ublas { mapped_vector_of_mapped_vector (): matrix_container (), size1_ (0), size2_ (0), data_ () { - data_ [layout_type::size1 (size1_, size2_)] = vector_data_value_type (); + data_ [layout_type::size_M (size1_, size2_)] = vector_data_value_type (); } BOOST_UBLAS_INLINE mapped_vector_of_mapped_vector (size_type size1, size_type size2, size_type non_zeros = 0): matrix_container (), size1_ (size1), size2_ (size2), data_ () { - data_ [layout_type::size1 (size1_, size2_)] = vector_data_value_type (); + data_ [layout_type::size_M (size1_, size2_)] = vector_data_value_type (); } BOOST_UBLAS_INLINE mapped_vector_of_mapped_vector (const mapped_vector_of_mapped_vector &m): @@ -1361,7 +1371,7 @@ namespace boost { namespace numeric { namespace ublas { mapped_vector_of_mapped_vector (const matrix_expression &ae, size_type non_zeros = 0): matrix_container (), size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ () { - data_ [layout_type::size1 (size1_, size2_)] = vector_data_value_type (); + data_ [layout_type::size_M (size1_, size2_)] = vector_data_value_type (); matrix_assign (*this, ae); } @@ -1407,7 +1417,7 @@ namespace boost { namespace numeric { namespace ublas { size1_ = size1; size2_ = size2; data ().clear (); - data () [layout_type::size1 (size1_, size2_)] = vector_data_value_type (); + data () [layout_type::size_M (size1_, size2_)] = vector_data_value_type (); } // Element support @@ -1417,8 +1427,8 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_pointer find_element (size_type i, size_type j) const { - const size_type element1 = layout_type::element1 (i, size1_, j, size2_); - const size_type element2 = layout_type::element2 (i, size1_, j, size2_); + const size_type element1 = layout_type::index_M (i, j); + const size_type element2 = layout_type::index_m (i, j); vector_const_subiterator_type itv (data ().find (element1)); if (itv == data ().end ()) return 0; @@ -1433,8 +1443,8 @@ namespace boost { namespace numeric { namespace ublas { // Element access BOOST_UBLAS_INLINE const_reference operator () (size_type i, size_type j) const { - const size_type element1 = layout_type::element1 (i, size1_, j, size2_); - const size_type element2 = layout_type::element2 (i, size1_, j, size2_); + const size_type element1 = layout_type::index_M (i, j); + const size_type element2 = layout_type::index_m (i, j); vector_const_subiterator_type itv (data ().find (element1)); if (itv == data ().end ()) return zero_; @@ -1448,8 +1458,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE reference operator () (size_type i, size_type j) { #ifndef BOOST_UBLAS_STRICT_MATRIX_SPARSE - const size_type element1 = layout_type::element1 (i, size1_, j, size2_); - const size_type element2 = layout_type::element2 (i, size1_, j, size2_); + const size_type element1 = layout_type::index_M (i, j); + const size_type element2 = layout_type::index_m (i, j); vector_data_value_type& vd (data () [element1]); std::pair ii (vd.insert (typename array_type::value_type::second_type::value_type (element2, value_type/*zero*/()))); BOOST_UBLAS_CHECK ((ii.first)->first == element2, internal_logic ()); // broken map @@ -1463,8 +1473,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE true_reference insert_element (size_type i, size_type j, const_reference t) { BOOST_UBLAS_CHECK (!find_element (i, j), bad_index ()); // duplicate element - const size_type element1 = layout_type::element1 (i, size1_, j, size2_); - const size_type element2 = layout_type::element2 (i, size1_, j, size2_); + const size_type element1 = layout_type::index_M (i, j); + const size_type element2 = layout_type::index_m (i, j); vector_data_value_type& vd (data () [element1]); std::pair ii (vd.insert (typename vector_data_value_type::value_type (element2, t))); @@ -1475,10 +1485,10 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE void erase_element (size_type i, size_type j) { - vector_subiterator_type itv (data ().find (layout_type::element1 (i, size1_, j, size2_))); + vector_subiterator_type itv (data ().find (layout_type::index_M (i, j))); if (itv == data ().end ()) return; - subiterator_type it ((*itv).second.find (layout_type::element2 (i, size1_, j, size2_))); + subiterator_type it ((*itv).second.find (layout_type::index_m (i, j))); if (it == (*itv).second.end ()) return; (*itv).second.erase (it); @@ -1488,7 +1498,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE void clear () { data ().clear (); - data_ [layout_type::size1 (size1_, size2_)] = vector_data_value_type (); + data_ [layout_type::size_M (size1_, size2_)] = vector_data_value_type (); } // Assignment @@ -1598,8 +1608,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE true_reference at_element (size_type i, size_type j) { - const size_type element1 = layout_type::element1 (i, size1_, j, size2_); - const size_type element2 = layout_type::element2 (i, size1_, j, size2_); + const size_type element1 = layout_type::index_M (i, j); + const size_type element2 = layout_type::index_m (i, j); vector_subiterator_type itv (data ().find (element1)); BOOST_UBLAS_CHECK (itv != data ().end(), bad_index ()); BOOST_UBLAS_CHECK ((*itv).first == element1, internal_logic ()); // broken map @@ -1625,19 +1635,29 @@ namespace boost { namespace numeric { namespace ublas { const_iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) const { BOOST_UBLAS_CHECK (data ().begin () != data ().end (), internal_logic ()); for (;;) { - vector_const_subiterator_type itv (data ().lower_bound (layout_type::address1 (i, size1_, j, size2_))); + vector_const_subiterator_type itv (data ().lower_bound (layout_type::index_M (i, j))); vector_const_subiterator_type itv_end (data ().end ()); if (itv == itv_end) return const_iterator1 (*this, rank, i, j, itv_end, (*(-- itv)).second.end ()); - const_subiterator_type it ((*itv).second.lower_bound (layout_type::address2 (i, size1_, j, size2_))); + const_subiterator_type it ((*itv).second.lower_bound (layout_type::index_m (i, j))); const_subiterator_type it_end ((*itv).second.end ()); - if (rank == 0) - return const_iterator1 (*this, rank, i, j, itv, it); - if (it != it_end && (*it).first == layout_type::address2 (i, size1_, j, size2_)) + if (rank == 0) { + // advance to the first available major index + size_type M = itv->first; + size_type m; + if (it != it_end) { + m = it->first; + } else { + m = layout_type::size_m(size1_, size2_); + } + size_type first_i = layout_type::index_M(M,m); + return const_iterator1 (*this, rank, first_i, j, itv, it); + } + if (it != it_end && (*it).first == layout_type::index_m (i, j)) return const_iterator1 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == it_end) return const_iterator1 (*this, rank, i, j, itv, it); i = (*it).first; @@ -1647,7 +1667,7 @@ namespace boost { namespace numeric { namespace ublas { ++ i; } } else /* if (direction < 0) */ { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == (*itv).second.begin ()) return const_iterator1 (*this, rank, i, j, itv, it); -- it; @@ -1664,19 +1684,29 @@ namespace boost { namespace numeric { namespace ublas { iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) { BOOST_UBLAS_CHECK (data ().begin () != data ().end (), internal_logic ()); for (;;) { - vector_subiterator_type itv (data ().lower_bound (layout_type::address1 (i, size1_, j, size2_))); + vector_subiterator_type itv (data ().lower_bound (layout_type::index_M (i, j))); vector_subiterator_type itv_end (data ().end ()); if (itv == itv_end) return iterator1 (*this, rank, i, j, itv_end, (*(-- itv)).second.end ()); - subiterator_type it ((*itv).second.lower_bound (layout_type::address2 (i, size1_, j, size2_))); + subiterator_type it ((*itv).second.lower_bound (layout_type::index_m (i, j))); subiterator_type it_end ((*itv).second.end ()); - if (rank == 0) - return iterator1 (*this, rank, i, j, itv, it); - if (it != it_end && (*it).first == layout_type::address2 (i, size1_, j, size2_)) + if (rank == 0) { + // advance to the first available major index + size_type M = itv->first; + size_type m; + if (it != it_end) { + m = it->first; + } else { + m = layout_type::size_m(size1_, size2_); + } + size_type first_i = layout_type::index_M(M,m); + return iterator1 (*this, rank, first_i, j, itv, it); + } + if (it != it_end && (*it).first == layout_type::index_m (i, j)) return iterator1 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == it_end) return iterator1 (*this, rank, i, j, itv, it); i = (*it).first; @@ -1686,7 +1716,7 @@ namespace boost { namespace numeric { namespace ublas { ++ i; } } else /* if (direction < 0) */ { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == (*itv).second.begin ()) return iterator1 (*this, rank, i, j, itv, it); -- it; @@ -1703,19 +1733,29 @@ namespace boost { namespace numeric { namespace ublas { const_iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) const { BOOST_UBLAS_CHECK (data ().begin () != data ().end (), internal_logic ()); for (;;) { - vector_const_subiterator_type itv (data ().lower_bound (layout_type::address1 (i, size1_, j, size2_))); + vector_const_subiterator_type itv (data ().lower_bound (layout_type::index_M (i, j))); vector_const_subiterator_type itv_end (data ().end ()); if (itv == itv_end) return const_iterator2 (*this, rank, i, j, itv_end, (*(-- itv)).second.end ()); - const_subiterator_type it ((*itv).second.lower_bound (layout_type::address2 (i, size1_, j, size2_))); + const_subiterator_type it ((*itv).second.lower_bound (layout_type::index_m (i, j))); const_subiterator_type it_end ((*itv).second.end ()); - if (rank == 0) - return const_iterator2 (*this, rank, i, j, itv, it); - if (it != it_end && (*it).first == layout_type::address2 (i, size1_, j, size2_)) + if (rank == 0) { + // advance to the first available major index + size_type M = itv->first; + size_type m; + if (it != it_end) { + m = it->first; + } else { + m = layout_type::size_m(size1_, size2_); + } + size_type first_j = layout_type::index_m(M,m); + return const_iterator2 (*this, rank, i, first_j, itv, it); + } + if (it != it_end && (*it).first == layout_type::index_m (i, j)) return const_iterator2 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == it_end) return const_iterator2 (*this, rank, i, j, itv, it); j = (*it).first; @@ -1725,7 +1765,7 @@ namespace boost { namespace numeric { namespace ublas { ++ j; } } else /* if (direction < 0) */ { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == (*itv).second.begin ()) return const_iterator2 (*this, rank, i, j, itv, it); -- it; @@ -1742,19 +1782,29 @@ namespace boost { namespace numeric { namespace ublas { iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) { BOOST_UBLAS_CHECK (data ().begin () != data ().end (), internal_logic ()); for (;;) { - vector_subiterator_type itv (data ().lower_bound (layout_type::address1 (i, size1_, j, size2_))); + vector_subiterator_type itv (data ().lower_bound (layout_type::index_M (i, j))); vector_subiterator_type itv_end (data ().end ()); if (itv == itv_end) return iterator2 (*this, rank, i, j, itv_end, (*(-- itv)).second.end ()); - subiterator_type it ((*itv).second.lower_bound (layout_type::address2 (i, size1_, j, size2_))); + subiterator_type it ((*itv).second.lower_bound (layout_type::index_m (i, j))); subiterator_type it_end ((*itv).second.end ()); - if (rank == 0) - return iterator2 (*this, rank, i, j, itv, it); - if (it != it_end && (*it).first == layout_type::address2 (i, size1_, j, size2_)) + if (rank == 0) { + // advance to the first available major index + size_type M = itv->first; + size_type m; + if (it != it_end) { + m = it->first; + } else { + m = layout_type::size_m(size1_, size2_); + } + size_type first_j = layout_type::index_m(M,m); + return iterator2 (*this, rank, i, first_j, itv, it); + } + if (it != it_end && (*it).first == layout_type::index_m (i, j)) return iterator2 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == it_end) return iterator2 (*this, rank, i, j, itv, it); j = (*it).first; @@ -1764,7 +1814,7 @@ namespace boost { namespace numeric { namespace ublas { ++ j; } } else /* if (direction < 0) */ { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == (*itv).second.begin ()) return iterator2 (*this, rank, i, j, itv, it); -- it; @@ -1805,11 +1855,16 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE const_iterator1 &operator ++ () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) ++ it_; else { const self_type &m = (*this) (); - i_ = index1 () + 1; + if (rank_ == 0) { + ++ itv_; + i_ = itv_->first; + } else { + i_ = index1 () + 1; + } if (rank_ == 1 && ++ itv_ == m.end1 ().itv_) *this = m.find1 (rank_, i_, j_, 1); else if (rank_ == 1) { @@ -1822,11 +1877,17 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator1 &operator -- () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) -- it_; else { const self_type &m = (*this) (); - i_ = index1 () - 1; + if (rank_ == 0) { + -- itv_; + i_ = itv_->first; + } else { + i_ = index1 () - 1; + } + // FIXME: this expression should never become true! if (rank_ == 1 && -- itv_ == m.end1 ().itv_) *this = m.find1 (rank_, i_, j_, -1); else if (rank_ == 1) { @@ -1888,8 +1949,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 ((*itv_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_M ((*itv_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*itv_).first, (*it_).first); } else { return i_; } @@ -1897,8 +1958,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index2 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 ((*itv_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_m ((*itv_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*itv_).first, (*it_).first); } else { return j_; } @@ -1969,11 +2030,16 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE iterator1 &operator ++ () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) ++ it_; else { self_type &m = (*this) (); - i_ = index1 () + 1; + if (rank_ == 0) { + ++ itv_; + i_ = itv_->first; + } else { + i_ = index1 () + 1; + } if (rank_ == 1 && ++ itv_ == m.end1 ().itv_) *this = m.find1 (rank_, i_, j_, 1); else if (rank_ == 1) { @@ -1986,11 +2052,17 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE iterator1 &operator -- () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) -- it_; else { self_type &m = (*this) (); - i_ = index1 () - 1; + if (rank_ == 0) { + -- itv_; + i_ = itv_->first; + } else { + i_ = index1 () - 1; + } + // FIXME: this expression should never become true! if (rank_ == 1 && -- itv_ == m.end1 ().itv_) *this = m.find1 (rank_, i_, j_, -1); else if (rank_ == 1) { @@ -2052,8 +2124,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 ((*itv_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_M ((*itv_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*itv_).first, (*it_).first); } else { return i_; } @@ -2061,8 +2133,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index2 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 ((*itv_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_m ((*itv_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*itv_).first, (*it_).first); } else { return j_; } @@ -2138,11 +2210,16 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE const_iterator2 &operator ++ () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) ++ it_; else { const self_type &m = (*this) (); - j_ = index2 () + 1; + if (rank_ == 0) { + ++ itv_; + j_ = itv_->first; + } else { + j_ = index2 () + 1; + } if (rank_ == 1 && ++ itv_ == m.end2 ().itv_) *this = m.find2 (rank_, i_, j_, 1); else if (rank_ == 1) { @@ -2155,11 +2232,17 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator2 &operator -- () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) -- it_; else { const self_type &m = (*this) (); - j_ = index2 () - 1; + if (rank_ == 0) { + -- itv_; + j_ = itv_->first; + } else { + j_ = index2 () - 1; + } + // FIXME: this expression should never become true! if (rank_ == 1 && -- itv_ == m.end2 ().itv_) *this = m.find2 (rank_, i_, j_, -1); else if (rank_ == 1) { @@ -2220,8 +2303,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 ((*itv_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_M ((*itv_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*itv_).first, (*it_).first); } else { return i_; } @@ -2230,8 +2313,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index2 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 ((*itv_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_m ((*itv_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*itv_).first, (*it_).first); } else { return j_; } @@ -2302,11 +2385,16 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE iterator2 &operator ++ () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) ++ it_; else { self_type &m = (*this) (); - j_ = index2 () + 1; + if (rank_ == 0) { + ++ itv_; + j_ = itv_->first; + } else { + j_ = index2 () + 1; + } if (rank_ == 1 && ++ itv_ == m.end2 ().itv_) *this = m.find2 (rank_, i_, j_, 1); else if (rank_ == 1) { @@ -2319,11 +2407,17 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE iterator2 &operator -- () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) -- it_; else { self_type &m = (*this) (); - j_ = index2 () - 1; + if (rank_ == 0) { + -- itv_; + j_ = itv_->first; + } else { + j_ = index2 () - 1; + } + // FIXME: this expression should never become true! if (rank_ == 1 && -- itv_ == m.end2 ().itv_) *this = m.find2 (rank_, i_, j_, -1); else if (rank_ == 1) { @@ -2384,8 +2478,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 ((*itv_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_M ((*itv_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*itv_).first, (*it_).first); } else { return i_; } @@ -2394,8 +2488,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index2 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 ((*itv_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_m ((*itv_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*itv_).first, (*it_).first); } else { return j_; } @@ -2482,6 +2576,20 @@ namespace boost { namespace numeric { namespace ublas { return reverse_iterator2 (begin2 ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + serialization::collection_size_type s1 (size1_); + serialization::collection_size_type s2 (size2_); + ar & serialization::make_nvp("size1",s1); + ar & serialization::make_nvp("size2",s2); + if (Archive::is_loading::value) { + size1_ = s1; + size2_ = s2; + } + ar & serialization::make_nvp("data", data_); + } + private: size_type size1_; size_type size2_; @@ -2512,7 +2620,7 @@ namespace boost { namespace numeric { namespace ublas { // is_convertable (IA::size_type, TA::size_type) typedef typename IA::value_type size_type; // size_type for the data arrays. - typedef typename IA::size_type array_size_type; + typedef typename IA::size_type array_size_type; // FIXME difference type for sparse storage iterators should it be in the container? typedef typename IA::difference_type difference_type; typedef T value_type; @@ -2537,7 +2645,7 @@ namespace boost { namespace numeric { namespace ublas { matrix_container (), size1_ (0), size2_ (0), capacity_ (restrict_capacity (0)), filled1_ (1), filled2_ (0), - index1_data_ (layout_type::size1 (size1_, size2_) + 1), index2_data_ (capacity_), value_data_ (capacity_) { + index1_data_ (layout_type::size_M (size1_, size2_) + 1), index2_data_ (capacity_), value_data_ (capacity_) { index1_data_ [filled1_ - 1] = k_based (filled2_); storage_invariants (); } @@ -2546,7 +2654,7 @@ namespace boost { namespace numeric { namespace ublas { matrix_container (), size1_ (size1), size2_ (size2), capacity_ (restrict_capacity (non_zeros)), filled1_ (1), filled2_ (0), - index1_data_ (layout_type::size1 (size1_, size2_) + 1), index2_data_ (capacity_), value_data_ (capacity_) { + index1_data_ (layout_type::size_M (size1_, size2_) + 1), index2_data_ (capacity_), value_data_ (capacity_) { index1_data_ [filled1_ - 1] = k_based (filled2_); storage_invariants (); } @@ -2563,7 +2671,7 @@ namespace boost { namespace numeric { namespace ublas { compressed_matrix (const coordinate_matrix &m): matrix_container (), size1_ (m.size1()), size2_ (m.size2()), - index1_data_ (layout_type::size1 (size1_, size2_) + 1) + index1_data_ (layout_type::size_M (size1_, size2_) + 1) { m.sort(); reserve(m.nnz(), false); @@ -2572,7 +2680,7 @@ namespace boost { namespace numeric { namespace ublas { const_subiterator_type i_end = (i_start + filled2_); const_subiterator_type i = i_start; size_type r = 1; - for (; (r < layout_type::size1 (size1_, size2_)) && (i != i_end); ++r) { + for (; (r < layout_type::size_M (size1_, size2_)) && (i != i_end); ++r) { i = std::lower_bound(i, i_end, r); index1_data_[r] = k_based( i - i_start ); } @@ -2589,7 +2697,7 @@ namespace boost { namespace numeric { namespace ublas { matrix_container (), size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), capacity_ (restrict_capacity (non_zeros)), filled1_ (1), filled2_ (0), - index1_data_ (layout_type::size1 (ae ().size1 (), ae ().size2 ()) + 1), + index1_data_ (layout_type::size_M (ae ().size1 (), ae ().size2 ()) + 1), index2_data_ (capacity_), value_data_ (capacity_) { index1_data_ [filled1_ - 1] = k_based (filled2_); storage_invariants (); @@ -2659,7 +2767,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE void complete_index1_data () { - while (filled1_ <= layout_type::size1 (size1_, size2_)) { + while (filled1_ <= layout_type::size_M (size1_, size2_)) { this->index1_data_ [filled1_] = k_based (filled2_); ++ this->filled1_; } @@ -2686,7 +2794,7 @@ namespace boost { namespace numeric { namespace ublas { capacity_ = restrict_capacity (capacity_); filled1_ = 1; filled2_ = 0; - index1_data_.resize (layout_type::size1 (size1_, size2_) + 1); + index1_data_.resize (layout_type::size_M (size1_, size2_) + 1); index2_data_.resize (capacity_); value_data_.resize (capacity_); index1_data_ [filled1_ - 1] = k_based (filled2_); @@ -2719,8 +2827,8 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_pointer find_element (size_type i, size_type j) const { - size_type element1 (layout_type::element1 (i, size1_, j, size2_)); - size_type element2 (layout_type::element2 (i, size1_, j, size2_)); + size_type element1 (layout_type::index_M (i, j)); + size_type element2 (layout_type::index_m (i, j)); if (filled1_ <= element1 + 1) return 0; vector_const_subiterator_type itv (index1_data_.begin () + element1); @@ -2744,8 +2852,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE reference operator () (size_type i, size_type j) { #ifndef BOOST_UBLAS_STRICT_MATRIX_SPARSE - size_type element1 (layout_type::element1 (i, size1_, j, size2_)); - size_type element2 (layout_type::element2 (i, size1_, j, size2_)); + size_type element1 (layout_type::index_M (i, j)); + size_type element2 (layout_type::index_m (i, j)); if (filled1_ <= element1 + 1) return insert_element (i, j, value_type/*zero*/()); pointer p = find_element (i, j); @@ -2765,8 +2873,8 @@ namespace boost { namespace numeric { namespace ublas { if (filled2_ >= capacity_) reserve (2 * filled2_, true); BOOST_UBLAS_CHECK (filled2_ < capacity_, internal_logic ()); - size_type element1 = layout_type::element1 (i, size1_, j, size2_); - size_type element2 = layout_type::element2 (i, size1_, j, size2_); + size_type element1 = layout_type::index_M (i, j); + size_type element2 = layout_type::index_m (i, j); while (filled1_ <= element1 + 1) { index1_data_ [filled1_] = k_based (filled2_); ++ filled1_; @@ -2793,8 +2901,8 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE void erase_element (size_type i, size_type j) { - size_type element1 = layout_type::element1 (i, size1_, j, size2_); - size_type element2 = layout_type::element2 (i, size1_, j, size2_); + size_type element1 = layout_type::index_M (i, j); + size_type element2 = layout_type::index_m (i, j); if (element1 + 1 > filled1_) return; vector_subiterator_type itv (index1_data_.begin () + element1); @@ -2943,8 +3051,8 @@ namespace boost { namespace numeric { namespace ublas { if (filled2_ >= capacity_) reserve (2 * filled2_, true); BOOST_UBLAS_CHECK (filled2_ < capacity_, internal_logic ()); - size_type element1 = layout_type::element1 (i, size1_, j, size2_); - size_type element2 = layout_type::element2 (i, size1_, j, size2_); + size_type element1 = layout_type::index_M (i, j); + size_type element2 = layout_type::index_m (i, j); while (filled1_ < element1 + 2) { index1_data_ [filled1_] = k_based (filled2_); ++ filled1_; @@ -3000,8 +3108,8 @@ namespace boost { namespace numeric { namespace ublas { // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. const_iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) const { for (;;) { - array_size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - array_size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + array_size_type address1 (layout_type::index_M (i, j)); + array_size_type address2 (layout_type::index_m (i, j)); vector_const_subiterator_type itv (index1_data_.begin () + (std::min) (filled1_ - 1, address1)); if (filled1_ <= address1 + 1) return const_iterator1 (*this, rank, i, j, itv, index2_data_.begin () + filled2_); @@ -3015,7 +3123,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) return const_iterator1 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == it_end) return const_iterator1 (*this, rank, i, j, itv, it); i = zero_based (*it); @@ -3025,7 +3133,7 @@ namespace boost { namespace numeric { namespace ublas { ++ i; } } else /* if (direction < 0) */ { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == index2_data_.begin () + zero_based (*itv)) return const_iterator1 (*this, rank, i, j, itv, it); i = zero_based (*(it - 1)); @@ -3040,8 +3148,8 @@ namespace boost { namespace numeric { namespace ublas { // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) { for (;;) { - array_size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - array_size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + array_size_type address1 (layout_type::index_M (i, j)); + array_size_type address2 (layout_type::index_m (i, j)); vector_subiterator_type itv (index1_data_.begin () + (std::min) (filled1_ - 1, address1)); if (filled1_ <= address1 + 1) return iterator1 (*this, rank, i, j, itv, index2_data_.begin () + filled2_); @@ -3055,7 +3163,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) return iterator1 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == it_end) return iterator1 (*this, rank, i, j, itv, it); i = zero_based (*it); @@ -3065,7 +3173,7 @@ namespace boost { namespace numeric { namespace ublas { ++ i; } } else /* if (direction < 0) */ { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == index2_data_.begin () + zero_based (*itv)) return iterator1 (*this, rank, i, j, itv, it); i = zero_based (*(it - 1)); @@ -3080,8 +3188,8 @@ namespace boost { namespace numeric { namespace ublas { // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. const_iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) const { for (;;) { - array_size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - array_size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + array_size_type address1 (layout_type::index_M (i, j)); + array_size_type address2 (layout_type::index_m (i, j)); vector_const_subiterator_type itv (index1_data_.begin () + (std::min) (filled1_ - 1, address1)); if (filled1_ <= address1 + 1) return const_iterator2 (*this, rank, i, j, itv, index2_data_.begin () + filled2_); @@ -3095,7 +3203,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) return const_iterator2 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == it_end) return const_iterator2 (*this, rank, i, j, itv, it); j = zero_based (*it); @@ -3105,7 +3213,7 @@ namespace boost { namespace numeric { namespace ublas { ++ j; } } else /* if (direction < 0) */ { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == index2_data_.begin () + zero_based (*itv)) return const_iterator2 (*this, rank, i, j, itv, it); j = zero_based (*(it - 1)); @@ -3120,8 +3228,8 @@ namespace boost { namespace numeric { namespace ublas { // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) { for (;;) { - array_size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - array_size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + array_size_type address1 (layout_type::index_M (i, j)); + array_size_type address2 (layout_type::index_m (i, j)); vector_subiterator_type itv (index1_data_.begin () + (std::min) (filled1_ - 1, address1)); if (filled1_ <= address1 + 1) return iterator2 (*this, rank, i, j, itv, index2_data_.begin () + filled2_); @@ -3135,7 +3243,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) return iterator2 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == it_end) return iterator2 (*this, rank, i, j, itv, it); j = zero_based (*it); @@ -3145,7 +3253,7 @@ namespace boost { namespace numeric { namespace ublas { ++ j; } } else /* if (direction < 0) */ { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == index2_data_.begin () + zero_based (*itv)) return iterator2 (*this, rank, i, j, itv, it); j = zero_based (*(it - 1)); @@ -3186,7 +3294,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE const_iterator1 &operator ++ () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) ++ it_; else { i_ = index1 () + 1; @@ -3197,10 +3305,10 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator1 &operator -- () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) -- it_; else { - i_ = index1 () - 1; + --i_; if (rank_ == 1) *this = (*this) ().find1 (rank_, i_, j_, -1); } @@ -3257,8 +3365,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return i_; } @@ -3266,8 +3374,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index2 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return j_; } @@ -3338,7 +3446,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE iterator1 &operator ++ () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) ++ it_; else { i_ = index1 () + 1; @@ -3349,10 +3457,10 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE iterator1 &operator -- () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) -- it_; else { - i_ = index1 () - 1; + --i_; if (rank_ == 1) *this = (*this) ().find1 (rank_, i_, j_, -1); } @@ -3409,8 +3517,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return i_; } @@ -3418,8 +3526,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index2 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return j_; } @@ -3495,7 +3603,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE const_iterator2 &operator ++ () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) ++ it_; else { j_ = index2 () + 1; @@ -3506,10 +3614,10 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator2 &operator -- () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) -- it_; else { - j_ = index2 () - 1; + --j_; if (rank_ == 1) *this = (*this) ().find2 (rank_, i_, j_, -1); } @@ -3565,8 +3673,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return i_; } @@ -3575,8 +3683,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index2 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return j_; } @@ -3647,7 +3755,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE iterator2 &operator ++ () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) ++ it_; else { j_ = index2 () + 1; @@ -3658,10 +3766,10 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE iterator2 &operator -- () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) -- it_; else { - j_ = index2 (); + --j_; if (rank_ == 1) *this = (*this) ().find2 (rank_, i_, j_, -1); } @@ -3717,8 +3825,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return i_; } @@ -3727,8 +3835,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index2 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return j_; } @@ -3815,12 +3923,32 @@ namespace boost { namespace numeric { namespace ublas { return reverse_iterator2 (begin2 ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + serialization::collection_size_type s1 (size1_); + serialization::collection_size_type s2 (size2_); + ar & serialization::make_nvp("size1",s1); + ar & serialization::make_nvp("size2",s2); + if (Archive::is_loading::value) { + size1_ = s1; + size2_ = s2; + } + ar & serialization::make_nvp("capacity", capacity_); + ar & serialization::make_nvp("filled1", filled1_); + ar & serialization::make_nvp("filled2", filled2_); + ar & serialization::make_nvp("index1_data", index1_data_); + ar & serialization::make_nvp("index2_data", index2_data_); + ar & serialization::make_nvp("value_data", value_data_); + storage_invariants(); + } + private: void storage_invariants () const { - BOOST_UBLAS_CHECK (layout_type::size1 (size1_, size2_) + 1 == index1_data_.size (), internal_logic ()); + BOOST_UBLAS_CHECK (layout_type::size_M (size1_, size2_) + 1 == index1_data_.size (), internal_logic ()); BOOST_UBLAS_CHECK (capacity_ == index2_data_.size (), internal_logic ()); BOOST_UBLAS_CHECK (capacity_ == value_data_.size (), internal_logic ()); - BOOST_UBLAS_CHECK (filled1_ > 0 && filled1_ <= layout_type::size1 (size1_, size2_) + 1, internal_logic ()); + BOOST_UBLAS_CHECK (filled1_ > 0 && filled1_ <= layout_type::size_M (size1_, size2_) + 1, internal_logic ()); BOOST_UBLAS_CHECK (filled2_ <= capacity_, internal_logic ()); BOOST_UBLAS_CHECK (index1_data_ [filled1_ - 1] == k_based (filled2_), internal_logic ()); } @@ -3869,13 +3997,12 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS using matrix_container::operator (); #endif - // ISSUE require type consistency check - // is_convertable (IA::size_type, TA::size_type) + // ISSUE require type consistency check, is_convertable (IA::size_type, TA::size_type) typedef typename IA::value_type size_type; + // ISSUE difference_type cannot be deduced for sparse indices, we only know the value_type + typedef std::ptrdiff_t difference_type; // size_type for the data arrays. - typedef typename IA::size_type array_size_type; - // FIXME difference type for sprase storage iterators should it be in the container? - typedef typename IA::difference_type difference_type; + typedef typename IA::size_type array_size_type; typedef T value_type; typedef const T &const_reference; #ifndef BOOST_UBLAS_STRICT_MATRIX_SPARSE @@ -3902,7 +4029,7 @@ namespace boost { namespace numeric { namespace ublas { storage_invariants (); } BOOST_UBLAS_INLINE - coordinate_matrix (size_type size1, size_type size2, size_type non_zeros = 0): + coordinate_matrix (size_type size1, size_type size2, array_size_type non_zeros = 0): matrix_container (), size1_ (size1), size2_ (size2), capacity_ (restrict_capacity (non_zeros)), filled_ (0), sorted_filled_ (filled_), sorted_ (true), @@ -3919,7 +4046,7 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - coordinate_matrix (const matrix_expression &ae, size_type non_zeros = 0): + coordinate_matrix (const matrix_expression &ae, array_size_type non_zeros = 0): matrix_container (), size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), capacity_ (restrict_capacity (non_zeros)), filled_ (0), sorted_filled_ (filled_), sorted_ (true), @@ -3993,9 +4120,9 @@ namespace boost { namespace numeric { namespace ublas { // Resizing private: BOOST_UBLAS_INLINE - size_type restrict_capacity (size_type non_zeros) const { + array_size_type restrict_capacity (array_size_type non_zeros) const { // minimum non_zeros - non_zeros = (std::max) (non_zeros, (std::min) (size1_, size2_)); + non_zeros = (std::max) (non_zeros, array_size_type((std::min) (size1_, size2_))); // ISSUE no maximum as coordinate may contain inserted duplicates return non_zeros; } @@ -4018,7 +4145,7 @@ namespace boost { namespace numeric { namespace ublas { // Reserving BOOST_UBLAS_INLINE - void reserve (size_type non_zeros, bool preserve = true) { + void reserve (array_size_type non_zeros, bool preserve = true) { sort (); // remove duplicate elements capacity_ = restrict_capacity (non_zeros); if (preserve) { @@ -4045,8 +4172,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_pointer find_element (size_type i, size_type j) const { sort (); - size_type element1 (layout_type::element1 (i, size1_, j, size2_)); - size_type element2 (layout_type::element2 (i, size1_, j, size2_)); + size_type element1 (layout_type::index_M (i, j)); + size_type element2 (layout_type::index_m (i, j)); vector_const_subiterator_type itv_begin (detail::lower_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (element1), std::less ())); vector_const_subiterator_type itv_end (detail::upper_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (element1), std::less ())); if (itv_begin == itv_end) @@ -4087,8 +4214,8 @@ namespace boost { namespace numeric { namespace ublas { if (filled_ >= capacity_) reserve (2 * filled_, true); BOOST_UBLAS_CHECK (filled_ < capacity_, internal_logic ()); - size_type element1 = layout_type::element1 (i, size1_, j, size2_); - size_type element2 = layout_type::element2 (i, size1_, j, size2_); + size_type element1 = layout_type::index_M (i, j); + size_type element2 = layout_type::index_m (i, j); index1_data_ [filled_] = k_based (element1); index2_data_ [filled_] = k_based (element2); value_data_ [filled_] = t; @@ -4104,8 +4231,8 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE void erase_element (size_type i, size_type j) { - size_type element1 = layout_type::element1 (i, size1_, j, size2_); - size_type element2 = layout_type::element2 (i, size1_, j, size2_); + size_type element1 = layout_type::index_M (i, j); + size_type element2 = layout_type::index_m (i, j); sort (); vector_subiterator_type itv_begin (detail::lower_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (element1), std::less ())); vector_subiterator_type itv_end (detail::upper_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (element1), std::less ())); @@ -4284,8 +4411,8 @@ namespace boost { namespace numeric { namespace ublas { // Back element insertion and erasure BOOST_UBLAS_INLINE void push_back (size_type i, size_type j, const_reference t) { - size_type element1 = layout_type::element1 (i, size1_, j, size2_); - size_type element2 = layout_type::element2 (i, size1_, j, size2_); + size_type element1 = layout_type::index_M (i, j); + size_type element2 = layout_type::index_m (i, j); // must maintain sort order BOOST_UBLAS_CHECK (sorted_ && (filled_ == 0 || @@ -4342,8 +4469,8 @@ namespace boost { namespace numeric { namespace ublas { const_iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) const { sort (); for (;;) { - size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + size_type address1 (layout_type::index_M (i, j)); + size_type address2 (layout_type::index_m (i, j)); vector_const_subiterator_type itv_begin (detail::lower_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); vector_const_subiterator_type itv_end (detail::upper_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); @@ -4357,7 +4484,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) return const_iterator1 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == it_end) return const_iterator1 (*this, rank, i, j, itv, it); i = zero_based (*it); @@ -4367,8 +4494,8 @@ namespace boost { namespace numeric { namespace ublas { ++ i; } } else /* if (direction < 0) */ { - if (layout_type::fast1 ()) { - if (it == index2_data_.begin () + zero_based (*itv)) + if (layout_type::fast_i ()) { + if (it == index2_data_.begin () + array_size_type (zero_based (*itv))) return const_iterator1 (*this, rank, i, j, itv, it); i = zero_based (*(it - 1)); } else { @@ -4383,8 +4510,8 @@ namespace boost { namespace numeric { namespace ublas { iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) { sort (); for (;;) { - size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + size_type address1 (layout_type::index_M (i, j)); + size_type address2 (layout_type::index_m (i, j)); vector_subiterator_type itv_begin (detail::lower_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); vector_subiterator_type itv_end (detail::upper_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); @@ -4398,7 +4525,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) return iterator1 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == it_end) return iterator1 (*this, rank, i, j, itv, it); i = zero_based (*it); @@ -4408,8 +4535,8 @@ namespace boost { namespace numeric { namespace ublas { ++ i; } } else /* if (direction < 0) */ { - if (layout_type::fast1 ()) { - if (it == index2_data_.begin () + zero_based (*itv)) + if (layout_type::fast_i ()) { + if (it == index2_data_.begin () + array_size_type (zero_based (*itv))) return iterator1 (*this, rank, i, j, itv, it); i = zero_based (*(it - 1)); } else { @@ -4424,8 +4551,8 @@ namespace boost { namespace numeric { namespace ublas { const_iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) const { sort (); for (;;) { - size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + size_type address1 (layout_type::index_M (i, j)); + size_type address2 (layout_type::index_m (i, j)); vector_const_subiterator_type itv_begin (detail::lower_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); vector_const_subiterator_type itv_end (detail::upper_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); @@ -4439,7 +4566,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) return const_iterator2 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == it_end) return const_iterator2 (*this, rank, i, j, itv, it); j = zero_based (*it); @@ -4449,8 +4576,8 @@ namespace boost { namespace numeric { namespace ublas { ++ j; } } else /* if (direction < 0) */ { - if (layout_type::fast2 ()) { - if (it == index2_data_.begin () + zero_based (*itv)) + if (layout_type::fast_j ()) { + if (it == index2_data_.begin () + array_size_type (zero_based (*itv))) return const_iterator2 (*this, rank, i, j, itv, it); j = zero_based (*(it - 1)); } else { @@ -4465,8 +4592,8 @@ namespace boost { namespace numeric { namespace ublas { iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) { sort (); for (;;) { - size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + size_type address1 (layout_type::index_M (i, j)); + size_type address2 (layout_type::index_m (i, j)); vector_subiterator_type itv_begin (detail::lower_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); vector_subiterator_type itv_end (detail::upper_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); @@ -4480,7 +4607,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) return iterator2 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == it_end) return iterator2 (*this, rank, i, j, itv, it); j = zero_based (*it); @@ -4490,8 +4617,8 @@ namespace boost { namespace numeric { namespace ublas { ++ j; } } else /* if (direction < 0) */ { - if (layout_type::fast2 ()) { - if (it == index2_data_.begin () + zero_based (*itv)) + if (layout_type::fast_j ()) { + if (it == index2_data_.begin () + array_size_type (zero_based (*itv))) return iterator2 (*this, rank, i, j, itv, it); j = zero_based (*(it - 1)); } else { @@ -4531,7 +4658,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE const_iterator1 &operator ++ () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) ++ it_; else { i_ = index1 () + 1; @@ -4542,7 +4669,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator1 &operator -- () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) -- it_; else { i_ = index1 () - 1; @@ -4602,8 +4729,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return i_; } @@ -4611,8 +4738,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index2 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return j_; } @@ -4683,7 +4810,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE iterator1 &operator ++ () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) ++ it_; else { i_ = index1 () + 1; @@ -4694,7 +4821,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE iterator1 &operator -- () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) -- it_; else { i_ = index1 () - 1; @@ -4754,8 +4881,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return i_; } @@ -4763,8 +4890,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index2 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return j_; } @@ -4840,7 +4967,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE const_iterator2 &operator ++ () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) ++ it_; else { j_ = index2 () + 1; @@ -4851,7 +4978,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator2 &operator -- () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) -- it_; else { j_ = index2 () - 1; @@ -4910,8 +5037,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return i_; } @@ -4920,8 +5047,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index2 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return j_; } @@ -4992,7 +5119,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE iterator2 &operator ++ () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) ++ it_; else { j_ = index2 () + 1; @@ -5003,7 +5130,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE iterator2 &operator -- () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) -- it_; else { j_ = index2 (); @@ -5062,8 +5189,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return i_; } @@ -5072,8 +5199,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index2 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return j_; } @@ -5160,6 +5287,27 @@ namespace boost { namespace numeric { namespace ublas { return reverse_iterator2 (begin2 ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + serialization::collection_size_type s1 (size1_); + serialization::collection_size_type s2 (size2_); + ar & serialization::make_nvp("size1",s1); + ar & serialization::make_nvp("size2",s2); + if (Archive::is_loading::value) { + size1_ = s1; + size2_ = s2; + } + ar & serialization::make_nvp("capacity", capacity_); + ar & serialization::make_nvp("filled", filled_); + ar & serialization::make_nvp("sorted_filled", sorted_filled_); + ar & serialization::make_nvp("sorted", sorted_); + ar & serialization::make_nvp("index1_data", index1_data_); + ar & serialization::make_nvp("index2_data", index2_data_); + ar & serialization::make_nvp("value_data", value_data_); + storage_invariants(); + } + private: void storage_invariants () const { diff --git a/include/boost/numeric/ublas/operation.hpp b/include/boost/numeric/ublas/operation.hpp index 48bf2056..16b7c02a 100644 --- a/include/boost/numeric/ublas/operation.hpp +++ b/include/boost/numeric/ublas/operation.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -29,10 +25,10 @@ namespace boost { namespace numeric { namespace ublas { - template + template BOOST_UBLAS_INLINE V & - axpy_prod (const compressed_matrix &e1, + axpy_prod (const compressed_matrix &e1, const vector_expression &e2, V &v, row_major_tag) { typedef typename V::size_type size_type; @@ -49,10 +45,10 @@ namespace boost { namespace numeric { namespace ublas { return v; } - template + template BOOST_UBLAS_INLINE V & - axpy_prod (const compressed_matrix &e1, + axpy_prod (const compressed_matrix &e1, const vector_expression &e2, V &v, column_major_tag) { typedef typename V::size_type size_type; @@ -119,8 +115,8 @@ namespace boost { namespace numeric { namespace ublas { } for (size_type i = 0; i < e1.nnz(); ++i) { - size_type row_index = layout_type::element1( e1.index1_data () [i], size1, e1.index2_data () [i], size2 ); - size_type col_index = layout_type::element2( e1.index1_data () [i], size1, e1.index2_data () [i], size2 ); + size_type row_index = layout_type::index_M( e1.index1_data () [i], e1.index2_data () [i] ); + size_type col_index = layout_type::index_m( e1.index1_data () [i], e1.index2_data () [i] ); v( row_index ) += e1.value_data () [i] * e2 () (col_index); } return v; @@ -642,8 +638,8 @@ namespace boost { namespace numeric { namespace ublas { typename matrix_column::const_iterator itc (mc.begin ()); typename matrix_column::const_iterator itc_end (mc.end ()); while (itc != itc_end) { - if (triangular_restriction::functor_type ().other (itc.index (), it2.index2 ())) - m (itc.index (), it2.index2 ()) += *it1 * *itc; + if(triangular_restriction::other (itc.index (), it2.index2 ())) + m (itc.index (), it2.index2 ()) += *it1 * *itc; ++ itc; } ++ it1; diff --git a/include/boost/numeric/ublas/operation_blocked.hpp b/include/boost/numeric/ublas/operation_blocked.hpp index d5c5e5a0..812b24ea 100644 --- a/include/boost/numeric/ublas/operation_blocked.hpp +++ b/include/boost/numeric/ublas/operation_blocked.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -18,6 +14,8 @@ #define _BOOST_UBLAS_OPERATION_BLOCKED_ #include +#include // indexing_vector_assign +#include // indexing_matrix_assign namespace boost { namespace numeric { namespace ublas { diff --git a/include/boost/numeric/ublas/operation_sparse.hpp b/include/boost/numeric/ublas/operation_sparse.hpp index 8210a21f..b537d581 100644 --- a/include/boost/numeric/ublas/operation_sparse.hpp +++ b/include/boost/numeric/ublas/operation_sparse.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -41,12 +37,6 @@ namespace boost { namespace numeric { namespace ublas { // ISSUE why is there a dense vector here? vector temporary (e2 ().size2 ()); temporary.clear (); -#if BOOST_UBLAS_TYPE_CHECK - matrix cm (m.size1 (), m.size2 ()); - typedef typename type_traits::real_type real_type; - real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); - indexing_matrix_assign (cm, prod (e1, e2), row_major_tag ()); -#endif typename expression1_type::const_iterator1 it1 (e1 ().begin1 ()); typename expression1_type::const_iterator1 it1_end (e1 ().end1 ()); while (it1 != it1_end) { @@ -86,9 +76,6 @@ namespace boost { namespace numeric { namespace ublas { } ++ it1; } -#if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); -#endif return m; } @@ -109,12 +96,6 @@ namespace boost { namespace numeric { namespace ublas { // ISSUE why is there a dense vector here? vector temporary (e1 ().size1 ()); temporary.clear (); -#if BOOST_UBLAS_TYPE_CHECK - matrix cm (m.size1 (), m.size2 ()); - typedef typename type_traits::real_type real_type; - real_type merrorbound (norm_1 (m) + norm_1 (e1) * norm_1 (e2)); - indexing_matrix_assign (cm, prod (e1, e2), column_major_tag ()); -#endif typename expression2_type::const_iterator2 it2 (e2 ().begin2 ()); typename expression2_type::const_iterator2 it2_end (e2 ().end2 ()); while (it2 != it2_end) { @@ -154,9 +135,6 @@ namespace boost { namespace numeric { namespace ublas { } ++ it2; } -#if BOOST_UBLAS_TYPE_CHECK - BOOST_UBLAS_CHECK (norm_1 (m - cm) <= 2 * std::numeric_limits::epsilon () * merrorbound, internal_logic ()); -#endif return m; } diff --git a/include/boost/numeric/ublas/storage.hpp b/include/boost/numeric/ublas/storage.hpp index 54bf2274..a2d9b315 100644 --- a/include/boost/numeric/ublas/storage.hpp +++ b/include/boost/numeric/ublas/storage.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -22,7 +18,12 @@ #include #endif +#include +#include +#include + #include +#include #include @@ -63,19 +64,15 @@ namespace boost { namespace numeric { namespace ublas { explicit BOOST_UBLAS_INLINE unbounded_array (size_type size, const ALLOC &a = ALLOC()): alloc_(a), size_ (size) { - if (size_) { - data_ = alloc_.allocate (size_); - // ISSUE some compilers may zero POD here -#ifdef BOOST_UBLAS_USEFUL_ARRAY_PLACEMENT_NEW - // array form fails on some compilers due to size cookie, is it standard conforming? - new (data_) value_type[size_]; -#else - for (pointer d = data_; d != data_ + size_; ++d) - new (d) value_type; -#endif - } - else - data_ = 0; + if (size_) { + data_ = alloc_.allocate (size_); + if (! detail::has_trivial_constructor::value) { + for (pointer d = data_; d != data_ + size_; ++d) + alloc_.construct(d, value_type()); + } + } + else + data_ = 0; } // No value initialised, but still be default constructed BOOST_UBLAS_INLINE @@ -90,6 +87,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE unbounded_array (const unbounded_array &c): + storage_array >(), alloc_ (c.alloc_), size_ (c.size_) { if (size_) { data_ = alloc_.allocate (size_); @@ -101,9 +99,12 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE ~unbounded_array () { if (size_) { - const iterator i_end = end(); - for (iterator i = begin (); i != i_end; ++i) { - iterator_destroy (i); + if (! detail::has_trivial_destructor::value) { + // std::_Destroy (begin(), end(), alloc_); + const iterator i_end = end(); + for (iterator i = begin (); i != i_end; ++i) { + iterator_destroy (i); + } } alloc_.deallocate (data_, size_); } @@ -137,20 +138,18 @@ namespace boost { namespace numeric { namespace ublas { } } else { - // ISSUE some compilers may zero POD here -#ifdef BOOST_UBLAS_USEFUL_ARRAY_PLACEMENT_NEW - // array form fails on some compilers due to size cookie, is it standard conforming? - new (data_) value_type[size]; -#else - for (pointer di = data_; di != data_ + size; ++di) - new (di) value_type; -#endif + if (! detail::has_trivial_constructor::value) { + for (pointer di = data_; di != data_ + size; ++di) + alloc_.construct (di, value_type()); + } } } if (size_) { - for (pointer si = p_data; si != p_data + size_; ++si) - alloc_.destroy (si); + if (! detail::has_trivial_destructor::value) { + for (pointer si = p_data; si != p_data + size_; ++si) + alloc_.destroy (si); + } alloc_.deallocate (p_data, size_); } @@ -269,6 +268,21 @@ namespace boost { namespace numeric { namespace ublas { return alloc_; } + private: + friend class boost::serialization::access; + + // Serialization + template + void serialize(Archive & ar, const unsigned int version) + { + serialization::collection_size_type s(size_); + ar & serialization::make_nvp("size",s); + if ( Archive::is_loading::value ) { + resize(s); + } + ar & serialization::make_array(data_, s); + } + private: // Handle explict destroy on a (possibly indexed) iterator BOOST_UBLAS_INLINE @@ -320,7 +334,7 @@ namespace boost { namespace numeric { namespace ublas { bounded_array (const bounded_array &c): size_ (c.size_) { // ISSUE elements should be copy constructed here, but we must copy instead as already default constructed - std::copy (c.data_, c.data_ + c.size_, data_); + std::copy (c.begin(), c.end(), begin()); } // Resizing @@ -432,6 +446,22 @@ namespace boost { namespace numeric { namespace ublas { return reverse_iterator (begin ()); } + private: + // Serialization + friend class boost::serialization::access; + + template + void serialize(Archive & ar, const unsigned int version) + { + serialization::collection_size_type s(size_); + ar & serialization::make_nvp("size", s); + if ( Archive::is_loading::value ) { + if (s > N) bad_size("too large size in bounded_array::load()\n").raise(); + resize(s); + } + ar & serialization::make_array(data_, s); + } + private: size_type size_; BOOST_UBLAS_BOUNDED_ARRAY_ALIGN value_type data_ [N]; @@ -1582,6 +1612,7 @@ namespace boost { namespace numeric { namespace ublas { bool equal(const self_type& rhs) const { return (v1_ == rhs.v1_); } + BOOST_UBLAS_INLINE bool less(const self_type& rhs) const { return (v1_ < rhs.v1_); } @@ -1597,6 +1628,18 @@ namespace boost { namespace numeric { namespace ublas { friend bool operator < (const self_type& lhs, const self_type& rhs) { return lhs.less(rhs); } + BOOST_UBLAS_INLINE + friend bool operator >= (const self_type& lhs, const self_type& rhs) { + return !lhs.less(rhs); + } + BOOST_UBLAS_INLINE + friend bool operator > (const self_type& lhs, const self_type& rhs) { + return rhs.less(lhs); + } + BOOST_UBLAS_INLINE + friend bool operator <= (const self_type& lhs, const self_type& rhs) { + return !rhs.less(lhs); + } private: size_type i_; @@ -1758,6 +1801,18 @@ namespace boost { namespace numeric { namespace ublas { friend bool operator < (const self_type& lhs, const self_type& rhs) { return lhs.less(rhs); } + BOOST_UBLAS_INLINE + friend bool operator >= (const self_type& lhs, const self_type& rhs) { + return !lhs.less(rhs); + } + BOOST_UBLAS_INLINE + friend bool operator > (const self_type& lhs, const self_type& rhs) { + return rhs.less(lhs); + } + BOOST_UBLAS_INLINE + friend bool operator <= (const self_type& lhs, const self_type& rhs) { + return !rhs.less(lhs); + } private: size_type i_; diff --git a/include/boost/numeric/ublas/storage_sparse.hpp b/include/boost/numeric/ublas/storage_sparse.hpp index efe7a108..47be61f3 100644 --- a/include/boost/numeric/ublas/storage_sparse.hpp +++ b/include/boost/numeric/ublas/storage_sparse.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -18,6 +14,11 @@ #define _BOOST_UBLAS_STORAGE_SPARSE_ #include +#include +#include +#include +#include +#include #include @@ -197,8 +198,16 @@ namespace boost { namespace numeric { namespace ublas { // FIXME should use ALLOC for map but std::allocator of std::pair and std::pair fail to compile template class map_std : public std::map { + public: + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + ar & serialization::make_nvp("base", boost::serialization::base_object< std::map >(*this)); + } }; + + // Map array // Implementation requires pair allocator definition (without const) @@ -478,6 +487,17 @@ namespace boost { namespace numeric { namespace ublas { return alloc_; } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + serialization::collection_size_type s (size_); + ar & serialization::make_nvp("size",s); + if (Archive::is_loading::value) { + resize(s); + } + ar & serialization::make_array(data_, s); + } + private: // Provide destroy as a non member function BOOST_UBLAS_INLINE diff --git a/include/boost/numeric/ublas/symmetric.hpp b/include/boost/numeric/ublas/symmetric.hpp index 949e83ae..0ebbe639 100644 --- a/include/boost/numeric/ublas/symmetric.hpp +++ b/include/boost/numeric/ublas/symmetric.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -18,6 +14,7 @@ #define _BOOST_UBLAS_SYMMETRIC_ #include +#include #include // Iterators based on ideas of Jeremy Siek @@ -125,7 +122,7 @@ namespace boost { namespace numeric { namespace ublas { void resize (size_type size, bool preserve = true) { if (preserve) { self_type temporary (size, size); - detail::matrix_resize_preserve (*this, temporary); + detail::matrix_resize_preserve (*this, temporary); } else { data ().resize (triangular_type::packed_size (layout_type (), size, size)); diff --git a/include/boost/numeric/ublas/traits.hpp b/include/boost/numeric/ublas/traits.hpp index a23fa171..f1e8e8e1 100644 --- a/include/boost/numeric/ublas/traits.hpp +++ b/include/boost/numeric/ublas/traits.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -25,6 +21,8 @@ #include #include +#include +#include namespace boost { namespace numeric { namespace ublas { @@ -49,7 +47,7 @@ namespace boost { namespace numeric { namespace ublas { }; - // Type traits - generic numeric properties and functions + // Type traits - generic numeric properties and functions template struct type_traits; @@ -86,13 +84,17 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE real_type type_abs (const_reference t) { - return std::abs (t); // must use explict std:: as bultin types are not in std namespace + // we'll find either std::abs or else another version via ADL: + using namespace std; + return abs (t); } static BOOST_UBLAS_INLINE value_type type_sqrt (const_reference t) { - // force a type conversion back to value_type for intgral types - return value_type (std::sqrt (t)); // must use explict std:: as bultin types are not in std namespace + using namespace std; + // force a type conversion back to value_type for intgral types + // we'll find either std::sqrt or else another version via ADL: + return value_type (sqrt (t)); } static @@ -264,59 +266,9 @@ namespace boost { namespace numeric { namespace ublas { }; #ifdef BOOST_UBLAS_USE_INTERVAL - // Define properties for a generic scalar interval type - template - struct scalar_interval_type_traits : scalar_type_traits { - typedef scalar_interval_type_traits self_type; - typedef boost::numeric::interval value_type; - typedef const value_type &const_reference; - typedef value_type &reference; - typedef value_type real_type; - typedef real_type precision_type; // we do not know what type has more precision then the real_type - - static const unsigned plus_complexity = 1; - static const unsigned multiplies_complexity = 1; - - static - BOOST_UBLAS_INLINE - real_type type_abs (const_reference t) { - return abs (t); - } - static - BOOST_UBLAS_INLINE - value_type type_sqrt (const_reference t) { - return sqrt (t); - } - - static - BOOST_UBLAS_INLINE - real_type norm_1 (const_reference t) { - return self_type::type_abs (t); - } - static - BOOST_UBLAS_INLINE - real_type norm_2 (const_reference t) { - return self_type::type_abs (t); - } - static - BOOST_UBLAS_INLINE - real_type norm_inf (const_reference t) { - return self_type::type_abs (t); - } - - static - BOOST_UBLAS_INLINE - bool equals (const_reference t1, const_reference t2) { - return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON * - (std::max) ((std::max) (self_type::norm_inf (t1), - self_type::norm_inf (t2)), - BOOST_UBLAS_TYPE_CHECK_MIN); - } - }; - // Define scalar interval type traits template<> - struct type_traits > : scalar_interval_type_traits > { + struct type_traits > : scalar_traits > { typedef type_traits > self_type; typedef boost::numeric::interval value_type; typedef const value_type &const_reference; @@ -326,7 +278,7 @@ namespace boost { namespace numeric { namespace ublas { }; template<> - struct type_traits > : scalar_interval_type_traits > { + struct type_traits > : scalar_traits > { typedef type_traits > self_type; typedef boost::numeric::interval value_type; typedef const value_type &const_reference; @@ -335,7 +287,7 @@ namespace boost { namespace numeric { namespace ublas { typedef boost::numeric::interval precision_type; }; template<> - struct type_traits > : scalar_interval_type_traits > { + struct type_traits > : scalar_traits > { typedef type_traits > self_type; typedef boost::numeric::interval value_type; typedef const value_type &const_reference; @@ -343,7 +295,6 @@ namespace boost { namespace numeric { namespace ublas { typedef value_type real_type; typedef value_type precision_type; }; - #endif @@ -532,6 +483,24 @@ namespace boost { namespace numeric { namespace ublas { it = it_end; } + namespace detail { + + // specialisation which define whether a type has a trivial constructor + // or not. This is used by array types. + template + struct has_trivial_constructor : public boost::has_trivial_constructor {}; + + template + struct has_trivial_destructor : public boost::has_trivial_destructor {}; + + template + struct has_trivial_constructor > : public boost::true_type {}; + + template + struct has_trivial_destructor > : public boost::true_type {}; + + } + }}} #endif diff --git a/include/boost/numeric/ublas/triangular.hpp b/include/boost/numeric/ublas/triangular.hpp index 3979282a..f0be81e9 100644 --- a/include/boost/numeric/ublas/triangular.hpp +++ b/include/boost/numeric/ublas/triangular.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -25,6 +21,42 @@ namespace boost { namespace numeric { namespace ublas { + namespace detail { + using namespace boost::numeric::ublas; + + // Matrix resizing algorithm + template + BOOST_UBLAS_INLINE + void matrix_resize_preserve (M& m, M& temporary) { + typedef L layout_type; + typedef T triangular_type; + typedef typename M::size_type size_type; + const size_type msize1 (m.size1 ()); // original size + const size_type msize2 (m.size2 ()); + const size_type size1 (temporary.size1 ()); // new size is specified by temporary + const size_type size2 (temporary.size2 ()); + // Common elements to preserve + const size_type size1_min = (std::min) (size1, msize1); + const size_type size2_min = (std::min) (size2, msize2); + // Order for major and minor sizes + const size_type major_size = layout_type::size_M (size1_min, size2_min); + const size_type minor_size = layout_type::size_m (size1_min, size2_min); + // Indexing copy over major + for (size_type major = 0; major != major_size; ++major) { + for (size_type minor = 0; minor != minor_size; ++minor) { + // find indexes - use invertability of element_ functions + const size_type i1 = layout_type::index_M(major, minor); + const size_type i2 = layout_type::index_m(major, minor); + if ( triangular_type::other(i1,i2) ) { + temporary.data () [triangular_type::element (layout_type (), i1, size1, i2, size2)] = + m.data() [triangular_type::element (layout_type (), i1, msize1, i2, msize2)]; + } + } + } + m.assign_temporary (temporary); + } + } + // Array based triangular matrix class template class triangular_matrix: @@ -104,7 +136,7 @@ namespace boost { namespace numeric { namespace ublas { void resize (size_type size1, size_type size2, bool preserve = true) { if (preserve) { self_type temporary (size1, size2); - detail::matrix_resize_preserve (*this, temporary); + detail::matrix_resize_preserve (*this, temporary); } else { data ().resize (triangular_type::packed_size (layout_type (), size1, size2)); @@ -141,13 +173,11 @@ namespace boost { namespace numeric { namespace ublas { reference operator () (size_type i, size_type j) { BOOST_UBLAS_CHECK (i < size1_, bad_index ()); BOOST_UBLAS_CHECK (j < size2_, bad_index ()); - if (triangular_type::other (i, j)) - return data () [triangular_type::element (layout_type (), i, size1_, j, size2_)]; - else { + if (!triangular_type::other (i, j)) { bad_index ().raise (); - // arbitary return value - return const_cast(zero_); + // NEVER reached } + return data () [triangular_type::element (layout_type (), i, size1_, j, size2_)]; } // Element assignment @@ -987,34 +1017,22 @@ namespace boost { namespace numeric { namespace ublas { reference operator () (size_type i, size_type j) { BOOST_UBLAS_CHECK (i < size1 (), bad_index ()); BOOST_UBLAS_CHECK (j < size2 (), bad_index ()); - if (triangular_type::other (i, j)) - return data () (i, j); - else if (triangular_type::one (i, j)) { + if (!triangular_type::other (i, j)) { bad_index ().raise (); - // arbitary return value - return const_cast(one_); - } else { - bad_index ().raise (); - // arbitary return value - return const_cast(zero_); + // NEVER reached } + return data () (i, j); } #else BOOST_UBLAS_INLINE reference operator () (size_type i, size_type j) const { BOOST_UBLAS_CHECK (i < size1 (), bad_index ()); BOOST_UBLAS_CHECK (j < size2 (), bad_index ()); - if (triangular_type::other (i, j)) - return data () (i, j); - else if (triangular_type::one (i, j)) { + if (!triangular_type::other (i, j)) { bad_index ().raise (); - // arbitary return value - return const_cast(one_); - } else { - bad_index ().raise (); - // arbitary return value - return const_cast(zero_); + // NEVER reached } + return data () (i, j); } #endif diff --git a/include/boost/numeric/ublas/vector.hpp b/include/boost/numeric/ublas/vector.hpp index 7c4e47ed..253b6649 100644 --- a/include/boost/numeric/ublas/vector.hpp +++ b/include/boost/numeric/ublas/vector.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -20,6 +16,8 @@ #include #include #include +#include +#include // Iterators based on ideas of Jeremy Siek @@ -63,6 +61,10 @@ namespace boost { namespace numeric { namespace ublas { vector_container (), data_ (data) {} BOOST_UBLAS_INLINE + vector (size_type size, const value_type &init): + vector_container (), + data_ (size, init) {} + BOOST_UBLAS_INLINE vector (const vector &v): vector_container (), data_ (v.data_) {} @@ -299,7 +301,7 @@ namespace boost { namespace numeric { namespace ublas { const_iterator (const self_type &v, const const_subiterator_type &it): container_const_reference (v), it_ (it) {} BOOST_UBLAS_INLINE - const_iterator (const typename vector::iterator &it): // ISSUE vector:: stops VC8 using std::iterator here + const_iterator (const typename self_type::iterator &it): // ISSUE vector:: stops VC8 using std::iterator here container_const_reference (it ()), it_ (it.it_) {} // Arithmetic @@ -505,6 +507,12 @@ namespace boost { namespace numeric { namespace ublas { return reverse_iterator (begin ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + ar & serialization::make_nvp("data",data_); + } + private: array_type data_; }; @@ -569,18 +577,18 @@ namespace boost { namespace numeric { namespace ublas { // Zero vector class - template + template class zero_vector: - public vector_container > { + public vector_container > { typedef const T *const_pointer; - typedef zero_vector self_type; + typedef zero_vector self_type; public: #ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS using vector_container::operator (); #endif - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; + typedef typename ALLOC::size_type size_type; + typedef typename ALLOC::difference_type difference_type; typedef T value_type; typedef const T &const_reference; typedef T &reference; @@ -748,29 +756,39 @@ namespace boost { namespace numeric { namespace ublas { return const_reverse_iterator (begin ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + serialization::collection_size_type s (size_); + ar & serialization::make_nvp("size",s); + if (Archive::is_loading::value) { + size_ = s; + } + } + private: size_type size_; typedef const value_type const_value_type; static const_value_type zero_; }; - template - typename zero_vector::const_value_type zero_vector::zero_ (0); + template + typename zero_vector::const_value_type zero_vector::zero_ = T(/*zero*/); // Unit vector class - template + template class unit_vector: - public vector_container > { + public vector_container > { typedef const T *const_pointer; - typedef unit_vector self_type; + typedef unit_vector self_type; public: #ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS using vector_container::operator (); #endif - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; + typedef typename ALLOC::size_type size_type; + typedef typename ALLOC::difference_type difference_type; typedef T value_type; typedef const T &const_reference; typedef T &reference; @@ -867,7 +885,7 @@ namespace boost { namespace numeric { namespace ublas { // Element lookup BOOST_UBLAS_INLINE const_iterator find (size_type i) const { - return const_iterator (*this, i == index_); + return const_iterator (*this, i <= index_); } class const_iterator: @@ -958,6 +976,17 @@ namespace boost { namespace numeric { namespace ublas { return const_reverse_iterator (begin ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + serialization::collection_size_type s (size_); + ar & serialization::make_nvp("size",s); + if (Archive::is_loading::value) { + size_ = s; + } + ar & serialization::make_nvp("index", index_); + } + private: size_type size_; size_type index_; @@ -966,29 +995,30 @@ namespace boost { namespace numeric { namespace ublas { static const_value_type one_; }; - template - typename unit_vector::const_value_type unit_vector::zero_ (0); - template - typename unit_vector::const_value_type unit_vector::one_ (1); + template + typename unit_vector::const_value_type unit_vector::zero_ = T(/*zero*/); + template + typename unit_vector::const_value_type unit_vector::one_ (1); // ISSUE: need 'one'-traits here // Scalar vector class - template + template class scalar_vector: - public vector_container > { + public vector_container > { typedef const T *const_pointer; - typedef scalar_vector self_type; + typedef scalar_vector self_type; public: #ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS using vector_container::operator (); #endif - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; + typedef typename ALLOC::size_type size_type; + typedef typename ALLOC::difference_type difference_type; typedef T value_type; typedef const T &const_reference; typedef T &reference; typedef const vector_reference const_closure_type; + typedef vector_reference closure_type; typedef dense_tag storage_category; // Construction and destruction @@ -1191,6 +1221,17 @@ namespace boost { namespace numeric { namespace ublas { return const_reverse_iterator (begin ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + serialization::collection_size_type s (size_); + ar & serialization::make_nvp("size",s); + if (Archive::is_loading::value) { + size_ = s; + } + ar & serialization::make_nvp("value", value_); + } + private: size_type size_; value_type value_; @@ -1673,6 +1714,21 @@ namespace boost { namespace numeric { namespace ublas { return reverse_iterator (begin ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + serialization::collection_size_type s (size_); + ar & serialization::make_nvp("size",s); + + // copy the value back if loading + if (Archive::is_loading::value) { + if (s > N) bad_size("too large size in bounded_vector::load()\n").raise(); + size_ = s; + } + // ISSUE: this writes the full array + ar & serialization::make_nvp("data",data_); + } + private: size_type size_; array_type data_; diff --git a/include/boost/numeric/ublas/vector_expression.hpp b/include/boost/numeric/ublas/vector_expression.hpp index f5588de4..46cf7a98 100644 --- a/include/boost/numeric/ublas/vector_expression.hpp +++ b/include/boost/numeric/ublas/vector_expression.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -1427,8 +1423,6 @@ namespace boost { namespace numeric { namespace ublas { typedef typename E::const_iterator::iterator_category iterator_category; typedef vector_scalar_unary self_type; public: - typedef typename F::size_type size_type; - typedef typename F::difference_type difference_type; typedef typename F::result_type value_type; typedef const self_type const_closure_type; typedef const_closure_type closure_type; @@ -1501,9 +1495,9 @@ namespace boost { namespace numeric { namespace ublas { // sum v = sum (v [i]) template BOOST_UBLAS_INLINE - typename vector_scalar_unary_traits >::result_type + typename vector_scalar_unary_traits >::result_type sum (const vector_expression &e) { - typedef typename vector_scalar_unary_traits >::expression_type expression_type; + typedef typename vector_scalar_unary_traits >::expression_type expression_type; return expression_type (e ()); } @@ -1511,9 +1505,9 @@ namespace boost { namespace numeric { namespace ublas { // complex: norm_1 v = sum (abs (real (v [i])) + abs (imag (v [i]))) template BOOST_UBLAS_INLINE - typename vector_scalar_unary_traits >::result_type + typename vector_scalar_unary_traits >::result_type norm_1 (const vector_expression &e) { - typedef typename vector_scalar_unary_traits >::expression_type expression_type; + typedef typename vector_scalar_unary_traits >::expression_type expression_type; return expression_type (e ()); } @@ -1521,9 +1515,9 @@ namespace boost { namespace numeric { namespace ublas { // complex: norm_2 v = sqrt (sum (v [i] * conj (v [i]))) template BOOST_UBLAS_INLINE - typename vector_scalar_unary_traits >::result_type + typename vector_scalar_unary_traits >::result_type norm_2 (const vector_expression &e) { - typedef typename vector_scalar_unary_traits >::expression_type expression_type; + typedef typename vector_scalar_unary_traits >::expression_type expression_type; return expression_type (e ()); } @@ -1531,18 +1525,18 @@ namespace boost { namespace numeric { namespace ublas { // complex: norm_inf v = maximum (maximum (abs (real (v [i])), abs (imag (v [i])))) template BOOST_UBLAS_INLINE - typename vector_scalar_unary_traits >::result_type + typename vector_scalar_unary_traits >::result_type norm_inf (const vector_expression &e) { - typedef typename vector_scalar_unary_traits >::expression_type expression_type; + typedef typename vector_scalar_unary_traits >::expression_type expression_type; return expression_type (e ()); } // real: index_norm_inf v = minimum (i: abs (v [i]) == maximum (abs (v [i]))) template BOOST_UBLAS_INLINE - typename vector_scalar_unary_traits >::result_type + typename vector_scalar_unary_traits >::result_type index_norm_inf (const vector_expression &e) { - typedef typename vector_scalar_unary_traits >::expression_type expression_type; + typedef typename vector_scalar_unary_traits >::expression_type expression_type; return expression_type (e ()); } @@ -1560,8 +1554,6 @@ namespace boost { namespace numeric { namespace ublas { typedef vector_scalar_binary self_type; public: static const unsigned complexity = 1; - typedef typename F::size_type size_type; - typedef typename F::difference_type difference_type; typedef typename F::result_type value_type; typedef const self_type const_closure_type; typedef const_closure_type closure_type; @@ -1593,6 +1585,7 @@ namespace boost { namespace numeric { namespace ublas { // Dense random access specialization BOOST_UBLAS_INLINE value_type evaluate (dense_random_access_iterator_tag) const { + BOOST_UBLAS_CHECK (e1_.size () == e2_.size (), external_logic()); #ifdef BOOST_UBLAS_USE_INDEXING return functor_type::apply (e1_, e2_); #elif BOOST_UBLAS_USE_ITERATING @@ -1610,12 +1603,14 @@ namespace boost { namespace numeric { namespace ublas { // Packed bidirectional specialization BOOST_UBLAS_INLINE value_type evaluate (packed_random_access_iterator_tag) const { + BOOST_UBLAS_CHECK (e1_.size () == e2_.size (), external_logic()); return functor_type::apply (e1_.begin (), e1_.end (), e2_.begin (), e2_.end ()); } // Sparse bidirectional specialization BOOST_UBLAS_INLINE value_type evaluate (sparse_bidirectional_iterator_tag) const { + BOOST_UBLAS_CHECK (e1_.size () == e2_.size (), external_logic()); return functor_type::apply (e1_.begin (), e1_.end (), e2_.begin (), e2_.end (), sparse_bidirectional_iterator_tag ()); } @@ -1639,31 +1634,27 @@ namespace boost { namespace numeric { namespace ublas { // inner_prod (v1, v2) = sum (v1 [i] * v2 [i]) template BOOST_UBLAS_INLINE - typename vector_scalar_binary_traits::promote_type> >::result_type inner_prod (const vector_expression &e1, const vector_expression &e2) { - typedef typename vector_scalar_binary_traits::promote_type> >::expression_type expression_type; + typedef typename vector_scalar_binary_traits::promote_type> >::expression_type expression_type; return expression_type (e1 (), e2 ()); } template BOOST_UBLAS_INLINE - typename vector_scalar_binary_traits::promote_type>::precision_type> >::result_type prec_inner_prod (const vector_expression &e1, const vector_expression &e2) { - typedef typename vector_scalar_binary_traits::promote_type>::precision_type> >::expression_type expression_type; + typedef typename vector_scalar_binary_traits::promote_type>::precision_type> >::expression_type expression_type; return expression_type (e1 (), e2 ()); } diff --git a/include/boost/numeric/ublas/vector_of_vector.hpp b/include/boost/numeric/ublas/vector_of_vector.hpp index bbc48cc7..e2e911ef 100644 --- a/include/boost/numeric/ublas/vector_of_vector.hpp +++ b/include/boost/numeric/ublas/vector_of_vector.hpp @@ -2,13 +2,9 @@ // Copyright (c) 2003 // Gunter Winkler, Joerg Walter // -// 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -64,7 +60,7 @@ namespace boost { namespace numeric { namespace ublas { generalized_vector_of_vector (): matrix_container (), size1_ (0), size2_ (0), data_ (1) { - const size_type sizeM = layout_type::size1 (size1_, size2_); + const size_type sizeM = layout_type::size_M (size1_, size2_); // create size1+1 empty vector elements data_.insert_element (sizeM, vector_data_value_type ()); storage_invariants (); @@ -72,9 +68,9 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE generalized_vector_of_vector (size_type size1, size_type size2, size_type non_zeros = 0): matrix_container (), - size1_ (size1), size2_ (size2), data_ (layout_type::size1 (size1_, size2_) + 1) { - const size_type sizeM = layout_type::size1 (size1_, size2_); - const size_type sizem = layout_type::size2 (size1_, size2_); + size1_ (size1), size2_ (size2), data_ (layout_type::size_M (size1_, size2_) + 1) { + const size_type sizeM = layout_type::size_M (size1_, size2_); + const size_type sizem = layout_type::size_m (size1_, size2_); for (size_type i = 0; i < sizeM; ++ i) // create size1 vector elements data_.insert_element (i, vector_data_value_type ()) .resize (sizem, false); data_.insert_element (sizeM, vector_data_value_type ()); @@ -90,9 +86,9 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE generalized_vector_of_vector (const matrix_expression &ae, size_type non_zeros = 0): matrix_container (), - size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ (layout_type::size1 (size1_, size2_) + 1) { - const size_type sizeM = layout_type::size1 (size1_, size2_); - const size_type sizem = layout_type::size2 (size1_, size2_); + size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ (layout_type::size_M (size1_, size2_) + 1) { + const size_type sizeM = layout_type::size_M (size1_, size2_); + const size_type sizem = layout_type::size_m (size1_, size2_); for (size_type i = 0; i < sizeM; ++ i) // create size1 vector elements data_.insert_element (i, vector_data_value_type ()) .resize (sizem, false); data_.insert_element (sizeM, vector_data_value_type ()); @@ -110,10 +106,17 @@ namespace boost { namespace numeric { namespace ublas { return size2_; } BOOST_UBLAS_INLINE - size_type non_zeros () const { + size_type nnz_capacity () const { size_type non_zeros = 0; - for (const_vectoriterator_type itv = data_ ().begin (); itv != data_ ().end (); ++ itv) - non_zeros += (*itv).size (); + for (const_vectoriterator_type itv = data_.begin (); itv != data_.end (); ++ itv) + non_zeros += (*itv).nnz_capacity (); + return non_zeros; + } + BOOST_UBLAS_INLINE + size_type nnz () const { + size_type non_zeros = 0; + for (const_vectoriterator_type itv = data_.begin (); itv != data_.end (); ++ itv) + non_zeros += (*itv).nnz (); return non_zeros; } @@ -130,11 +133,11 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE void resize (size_type size1, size_type size2, bool preserve = true) { - const size_type oldM = layout_type::size1 (size1_, size2_); + const size_type oldM = layout_type::size_M (size1_, size2_); size1_ = size1; size2_ = size2; - const size_type sizeM = layout_type::size1 (size1_, size2_); - const size_type sizem = layout_type::size2 (size1_, size2_); + const size_type sizeM = layout_type::size_M (size1_, size2_); + const size_type sizem = layout_type::size_m (size1_, size2_); data ().resize (sizeM + 1, preserve); if (preserve) { for (size_type i = 0; (i <= oldM) && (i < sizeM); ++ i) @@ -161,8 +164,8 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_pointer find_element (size_type i, size_type j) const { - const size_type elementM = layout_type::element1 (i, size1_, j, size2_); - const size_type elementm = layout_type::element2 (i, size1_, j, size2_); + const size_type elementM = layout_type::index_M (i, j); + const size_type elementm = layout_type::index_m (i, j); // optimise: check the storage_type and index directly if element always exists if (boost::is_convertible::value) { return & (data () [elementM] [elementm]); @@ -293,31 +296,31 @@ namespace boost { namespace numeric { namespace ublas { // Element insertion and erasure BOOST_UBLAS_INLINE true_reference insert_element (size_type i, size_type j, const_reference t) { - const size_type elementM = layout_type::element1 (i, size1_, j, size2_); - const size_type elementm = layout_type::element2 (i, size1_, j, size2_); + const size_type elementM = layout_type::index_M (i, j); + const size_type elementm = layout_type::index_m (i, j); vector_data_value_type& vd (ref (data () [elementM])); storage_invariants (); return vd.insert_element (elementm, t); } BOOST_UBLAS_INLINE void append_element (size_type i, size_type j, const_reference t) { - const size_type elementM = layout_type::element1 (i, size1_, j, size2_); - const size_type elementm = layout_type::element2 (i, size1_, j, size2_); + const size_type elementM = layout_type::index_M (i, j); + const size_type elementm = layout_type::index_m (i, j); vector_data_value_type& vd (ref (data () [elementM])); storage_invariants (); return vd.append_element (elementm, t); } BOOST_UBLAS_INLINE void erase_element (size_type i, size_type j) { - vectoriterator_type itv (data ().find (layout_type::element1 (i, size1_, j, size2_))); + vectoriterator_type itv (data ().find (layout_type::index_M (i, j))); if (itv == data ().end ()) return; - (*itv).erase_element (layout_type::element2 (i, size1_, j, size2_)); + (*itv).erase_element (layout_type::index_m (i, j)); storage_invariants (); } BOOST_UBLAS_INLINE void clear () { - const size_type sizeM = layout_type::size1 (size1_, size2_); + const size_type sizeM = layout_type::size_M (size1_, size2_); // FIXME should clear data () if this is done via value_type/*zero*/() then it is not size preserving for (size_type i = 0; i < sizeM; ++ i) ref (data () [i]).clear (); @@ -334,7 +337,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE true_reference at_element (size_type i, size_type j) { - return ref (ref (data () [layout_type::element1 (i, size1_, j, size2_)]) [layout_type::element2 (i, size1_, j, size2_)]); + return ref (ref (data () [layout_type::index_M (i, j)]) [layout_type::index_m (i, j)]); } public: @@ -351,19 +354,19 @@ namespace boost { namespace numeric { namespace ublas { // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. const_iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) const { for (;;) { - const_vectoriterator_type itv (data ().find (layout_type::address1 (i, size1_, j, size2_))); + const_vectoriterator_type itv (data ().find (layout_type::index_M (i, j))); const_vectoriterator_type itv_end (data ().end ()); if (itv == itv_end) return const_iterator1 (*this, rank, i, j, itv_end, (*(-- itv)).end ()); - const_subiterator_type it ((*itv).find (layout_type::address2 (i, size1_, j, size2_))); + const_subiterator_type it ((*itv).find (layout_type::index_m (i, j))); const_subiterator_type it_end ((*itv).end ()); if (rank == 0) return const_iterator1 (*this, rank, i, j, itv, it); - if (it != it_end && it.index () == layout_type::address2 (i, size1_, j, size2_)) + if (it != it_end && it.index () == layout_type::index_m (i, j)) return const_iterator1 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == it_end) return const_iterator1 (*this, rank, i, j, itv, it); i = it.index (); @@ -373,7 +376,7 @@ namespace boost { namespace numeric { namespace ublas { ++ i; } } else /* if (direction < 0) */ { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == (*itv).begin ()) return const_iterator1 (*this, rank, i, j, itv, it); --it; @@ -389,19 +392,19 @@ namespace boost { namespace numeric { namespace ublas { // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) { for (;;) { - vectoriterator_type itv (data ().find (layout_type::address1 (i, size1_, j, size2_))); + vectoriterator_type itv (data ().find (layout_type::index_M (i, j))); vectoriterator_type itv_end (data ().end ()); if (itv == itv_end) return iterator1 (*this, rank, i, j, itv_end, (*(-- itv)).end ()); - subiterator_type it ((*itv).find (layout_type::address2 (i, size1_, j, size2_))); + subiterator_type it ((*itv).find (layout_type::index_m (i, j))); subiterator_type it_end ((*itv).end ()); if (rank == 0) return iterator1 (*this, rank, i, j, itv, it); - if (it != it_end && it.index () == layout_type::address2 (i, size1_, j, size2_)) + if (it != it_end && it.index () == layout_type::index_m (i, j)) return iterator1 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == it_end) return iterator1 (*this, rank, i, j, itv, it); i = it.index (); @@ -411,7 +414,7 @@ namespace boost { namespace numeric { namespace ublas { ++ i; } } else /* if (direction < 0) */ { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == (*itv).begin ()) return iterator1 (*this, rank, i, j, itv, it); --it; @@ -427,19 +430,19 @@ namespace boost { namespace numeric { namespace ublas { // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. const_iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) const { for (;;) { - const_vectoriterator_type itv (data ().find (layout_type::address1 (i, size1_, j, size2_))); + const_vectoriterator_type itv (data ().find (layout_type::index_M (i, j))); const_vectoriterator_type itv_end (data ().end ()); if (itv == itv_end) return const_iterator2 (*this, rank, i, j, itv_end, (*(-- itv)).end ()); - const_subiterator_type it ((*itv).find (layout_type::address2 (i, size1_, j, size2_))); + const_subiterator_type it ((*itv).find (layout_type::index_m (i, j))); const_subiterator_type it_end ((*itv).end ()); if (rank == 0) return const_iterator2 (*this, rank, i, j, itv, it); - if (it != it_end && it.index () == layout_type::address2 (i, size1_, j, size2_)) + if (it != it_end && it.index () == layout_type::index_m (i, j)) return const_iterator2 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == it_end) return const_iterator2 (*this, rank, i, j, itv, it); j = it.index (); @@ -449,7 +452,7 @@ namespace boost { namespace numeric { namespace ublas { ++ j; } } else /* if (direction < 0) */ { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == (*itv).begin ()) return const_iterator2 (*this, rank, i, j, itv, it); --it; @@ -465,19 +468,19 @@ namespace boost { namespace numeric { namespace ublas { // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) { for (;;) { - vectoriterator_type itv (data ().find (layout_type::address1 (i, size1_, j, size2_))); + vectoriterator_type itv (data ().find (layout_type::index_M (i, j))); vectoriterator_type itv_end (data ().end ()); if (itv == itv_end) return iterator2 (*this, rank, i, j, itv_end, (*(-- itv)).end ()); - subiterator_type it ((*itv).find (layout_type::address2 (i, size1_, j, size2_))); + subiterator_type it ((*itv).find (layout_type::index_m (i, j))); subiterator_type it_end ((*itv).end ()); if (rank == 0) return iterator2 (*this, rank, i, j, itv, it); - if (it != it_end && it.index () == layout_type::address2 (i, size1_, j, size2_)) + if (it != it_end && it.index () == layout_type::index_m (i, j)) return iterator2 (*this, rank, i, j, itv, it); if (direction > 0) { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == it_end) return iterator2 (*this, rank, i, j, itv, it); j = it.index (); @@ -487,7 +490,7 @@ namespace boost { namespace numeric { namespace ublas { ++ j; } } else /* if (direction < 0) */ { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == (*itv).begin ()) return iterator2 (*this, rank, i, j, itv, it); --it; @@ -529,7 +532,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE const_iterator1 &operator ++ () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) ++ it_; else { const self_type &m = (*this) (); @@ -546,7 +549,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator1 &operator -- () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) -- it_; else { const self_type &m = (*this) (); @@ -612,8 +615,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 (itv_.index (), it_.index ()); + BOOST_UBLAS_CHECK (layout_type::index_M (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M (itv_.index (), it_.index ()); } else { return i_; } @@ -622,8 +625,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index2 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 (itv_.index (), it_.index ()); + BOOST_UBLAS_CHECK (layout_type::index_m (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m (itv_.index (), it_.index ()); } else { return j_; } @@ -694,7 +697,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE iterator1 &operator ++ () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) ++ it_; else { self_type &m = (*this) (); @@ -711,7 +714,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE iterator1 &operator -- () { - if (rank_ == 1 && layout_type::fast1 ()) + if (rank_ == 1 && layout_type::fast_i ()) -- it_; else { self_type &m = (*this) (); @@ -777,8 +780,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 (itv_.index (), it_.index ()); + BOOST_UBLAS_CHECK (layout_type::index_M (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M (itv_.index (), it_.index ()); } else { return i_; } @@ -787,8 +790,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index2 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 (itv_.index (), it_.index ()); + BOOST_UBLAS_CHECK (layout_type::index_m (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m (itv_.index (), it_.index ()); } else { return j_; } @@ -864,7 +867,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE const_iterator2 &operator ++ () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) ++ it_; else { const self_type &m = (*this) (); @@ -881,7 +884,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_iterator2 &operator -- () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) -- it_; else { const self_type &m = (*this) (); @@ -947,8 +950,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 (itv_.index (), it_.index ()); + BOOST_UBLAS_CHECK (layout_type::index_M (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M (itv_.index (), it_.index ()); } else { return i_; } @@ -957,8 +960,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index2 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 (itv_.index (), it_.index ()); + BOOST_UBLAS_CHECK (layout_type::index_m (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m (itv_.index (), it_.index ()); } else { return j_; } @@ -1029,7 +1032,7 @@ namespace boost { namespace numeric { namespace ublas { // Arithmetic BOOST_UBLAS_INLINE iterator2 &operator ++ () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) ++ it_; else { self_type &m = (*this) (); @@ -1046,7 +1049,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE iterator2 &operator -- () { - if (rank_ == 1 && layout_type::fast2 ()) + if (rank_ == 1 && layout_type::fast_j ()) -- it_; else { self_type &m = (*this) (); @@ -1112,8 +1115,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 (itv_.index (), it_.index ()); + BOOST_UBLAS_CHECK (layout_type::index_M (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M (itv_.index (), it_.index ()); } else { return i_; } @@ -1122,8 +1125,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index2 () const { BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ()); if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 (itv_.index (), it_.index ()); + BOOST_UBLAS_CHECK (layout_type::index_m (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m (itv_.index (), it_.index ()); } else { return j_; } @@ -1210,10 +1213,34 @@ namespace boost { namespace numeric { namespace ublas { return reverse_iterator2 (begin2 ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + + // we need to copy to a collection_size_type to get a portable + // and efficient serialization + serialization::collection_size_type s1 (size1_); + serialization::collection_size_type s2 (size2_); + + // serialize the sizes + ar & serialization::make_nvp("size1",s1) + & serialization::make_nvp("size2",s2); + + // copy the values back if loading + if (Archive::is_loading::value) { + size1_ = s1; + size2_ = s2; + } + + ar & serialization::make_nvp("data", data_); + + storage_invariants(); + } + private: void storage_invariants () const { - BOOST_UBLAS_CHECK (layout_type::size1 (size1_, size2_) + 1 == data_.size (), internal_logic ()); + BOOST_UBLAS_CHECK (layout_type::size_M (size1_, size2_) + 1 == data_.size (), internal_logic ()); BOOST_UBLAS_CHECK (data ().begin () != data ().end (), internal_logic ()); } diff --git a/include/boost/numeric/ublas/vector_proxy.hpp b/include/boost/numeric/ublas/vector_proxy.hpp index 8c5cbcea..6e80a27c 100644 --- a/include/boost/numeric/ublas/vector_proxy.hpp +++ b/include/boost/numeric/ublas/vector_proxy.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. diff --git a/include/boost/numeric/ublas/vector_sparse.hpp b/include/boost/numeric/ublas/vector_sparse.hpp index abbd28dc..2e66f2c6 100644 --- a/include/boost/numeric/ublas/vector_sparse.hpp +++ b/include/boost/numeric/ublas/vector_sparse.hpp @@ -2,13 +2,9 @@ // 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. @@ -738,6 +734,17 @@ namespace boost { namespace numeric { namespace ublas { return reverse_iterator (begin ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + serialization::collection_size_type s (size_); + ar & serialization::make_nvp("size",s); + if (Archive::is_loading::value) { + size_ = s; + } + ar & serialization::make_nvp("data", data_); + } + private: size_type size_; array_type data_; @@ -868,13 +875,21 @@ namespace boost { namespace numeric { namespace ublas { public: BOOST_UBLAS_INLINE void resize (size_type size, bool preserve = true) { - // FIXME preserve unimplemented - BOOST_UBLAS_CHECK (!preserve, internal_logic ()); size_ = size; capacity_ = restrict_capacity (capacity_); - index_data_. resize (capacity_); - value_data_. resize (capacity_); - filled_ = 0; + if (preserve) { + index_data_. resize (capacity_, size_type ()); + value_data_. resize (capacity_, value_type ()); + filled_ = (std::min) (capacity_, filled_); + while ((filled_ > 0) && (zero_based(index_data_[filled_ - 1]) >= size)) { + --filled_; + } + } + else { + index_data_. resize (capacity_); + value_data_. resize (capacity_); + filled_ = 0; + } storage_invariants (); } @@ -1310,12 +1325,30 @@ namespace boost { namespace numeric { namespace ublas { return reverse_iterator (begin ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + serialization::collection_size_type s (size_); + ar & serialization::make_nvp("size",s); + if (Archive::is_loading::value) { + size_ = s; + } + // ISSUE: filled may be much less than capacity + // ISSUE: index_data_ and value_data_ are undefined between filled and capacity (trouble with 'nan'-values) + ar & serialization::make_nvp("capacity", capacity_); + ar & serialization::make_nvp("filled", filled_); + ar & serialization::make_nvp("index_data", index_data_); + ar & serialization::make_nvp("value_data", value_data_); + storage_invariants(); + } + private: void storage_invariants () const { BOOST_UBLAS_CHECK (capacity_ == index_data_.size (), internal_logic ()); BOOST_UBLAS_CHECK (capacity_ == value_data_.size (), internal_logic ()); BOOST_UBLAS_CHECK (filled_ <= capacity_, internal_logic ()); + BOOST_UBLAS_CHECK ((0 == filled_) || (zero_based(index_data_[filled_ - 1]) < size_), internal_logic ()); } size_type size_; @@ -1471,11 +1504,15 @@ namespace boost { namespace numeric { namespace ublas { void resize (size_type size, bool preserve = true) { if (preserve) sort (); // remove duplicate elements. + size_ = size; capacity_ = restrict_capacity (capacity_); if (preserve) { index_data_. resize (capacity_, size_type ()); value_data_. resize (capacity_, value_type ()); filled_ = (std::min) (capacity_, filled_); + while ((filled_ > 0) && (zero_based(index_data_[filled_ - 1]) >= size)) { + --filled_; + } } else { index_data_. resize (capacity_); @@ -1483,7 +1520,6 @@ namespace boost { namespace numeric { namespace ublas { filled_ = 0; } sorted_filled_ = filled_; - size_ = size; storage_invariants (); } // Reserving @@ -1969,6 +2005,25 @@ namespace boost { namespace numeric { namespace ublas { return reverse_iterator (begin ()); } + // Serialization + template + void serialize(Archive & ar, const unsigned int /* file_version */){ + serialization::collection_size_type s (size_); + ar & serialization::make_nvp("size",s); + if (Archive::is_loading::value) { + size_ = s; + } + // ISSUE: filled may be much less than capacity + // ISSUE: index_data_ and value_data_ are undefined between filled and capacity (trouble with 'nan'-values) + ar & serialization::make_nvp("capacity", capacity_); + ar & serialization::make_nvp("filled", filled_); + ar & serialization::make_nvp("sorted_filled", sorted_filled_); + ar & serialization::make_nvp("sorted", sorted_); + ar & serialization::make_nvp("index_data", index_data_); + ar & serialization::make_nvp("value_data", value_data_); + storage_invariants(); + } + private: void storage_invariants () const { @@ -1977,6 +2032,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (filled_ <= capacity_, internal_logic ()); BOOST_UBLAS_CHECK (sorted_filled_ <= filled_, internal_logic ()); BOOST_UBLAS_CHECK (sorted_ == (sorted_filled_ == filled_), internal_logic ()); + BOOST_UBLAS_CHECK ((0 == filled_) || (zero_based(index_data_[filled_ - 1]) < size_), internal_logic ()); } size_type size_; From b4bc0573379c37af2067b00d073e2dc7c85eea91 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sat, 15 Mar 2008 09:36:05 +0000 Subject: [PATCH 013/280] Merged fixes for inspection report failures from the main Trunk. svn path=/branches/release/boost/numeric/ublas/; revision=43616 --- doc/Release_notes.txt | 15 ++++++++++++++- doc/banded.htm | 13 +++++++------ doc/blas.htm | 11 ++++++----- doc/bounded_array.htm | 11 +++++++++++ doc/container_concept.htm | 12 +++++++----- doc/doxygen.css | 11 +++++++++++ doc/expression_concept.htm | 12 +++++++----- doc/hermitian.htm | 12 +++++++----- doc/index.htm | 12 +++++++----- doc/index.html | 10 ++++++++++ doc/iterator_concept.htm | 12 +++++++----- doc/matrix.htm | 12 +++++++----- doc/matrix_expression.htm | 12 +++++++----- doc/matrix_proxy.htm | 12 +++++++----- doc/matrix_sparse.htm | 12 +++++++----- doc/operations_overview.htm | 12 +++++++----- doc/overview.htm | 12 +++++++----- doc/products.htm | 12 +++++++----- doc/range.htm | 11 +++++++++++ doc/storage_concept.htm | 12 +++++++----- doc/storage_sparse.htm | 12 +++++++----- doc/symmetric.htm | 12 +++++++----- doc/triangular.htm | 12 +++++++----- doc/types_overview.htm | 12 +++++++----- doc/ublas.css | 11 +++++++++++ doc/unbounded_array.htm | 12 +++++++----- doc/vector.htm | 12 +++++++----- doc/vector_expression.htm | 12 +++++++----- doc/vector_proxy.htm | 12 +++++++----- doc/vector_sparse.htm | 12 +++++++----- .../boost/numeric/ublas/detail/documentation.hpp | 12 ++++-------- test/README | 6 ++++++ test/manual/sp_resize.cpp | 2 +- 33 files changed, 246 insertions(+), 131 deletions(-) diff --git a/doc/Release_notes.txt b/doc/Release_notes.txt index 7cfb2ecd..621ef4b1 100644 --- a/doc/Release_notes.txt +++ b/doc/Release_notes.txt @@ -1,3 +1,16 @@ +UBLAS +~~~~~ + +Copyright (c) 2000-2004 Joerg Walter, Mathias Koch + +Distributed under the Boost Software License, Version 1.0. (See +accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + +1.35.0 + Updated all files to BSL v1 with permission of the authors. + PRE 1.34.0 - FIX size_type and difference_type can be non defaults and uBLAS expressions use the correct types. + FIX size_type and difference_type can be non defaults and uBLAS + expressions use the correct types. \ No newline at end of file diff --git a/doc/banded.htm b/doc/banded.htm index a9f21796..fe50d518 100644 --- a/doc/banded.htm +++ b/doc/banded.htm @@ -1,4 +1,4 @@ - @@ -562,10 +562,11 @@ the reversed banded_adaptor.

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

+ 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). +

diff --git a/doc/blas.htm b/doc/blas.htm index 011cfb38..29f62854 100644 --- a/doc/blas.htm +++ b/doc/blas.htm @@ -434,10 +434,11 @@ generalized hermitian rank k update: m1 = t1 * m1 + <

Copyright (©) 2000-2004 Michael Stevens, Mathias Koch, Joerg Walter, Gunter Winkler
-Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

+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). +

diff --git a/doc/bounded_array.htm b/doc/bounded_array.htm index 0dd3283f..cb4fc59f 100644 --- a/doc/bounded_array.htm +++ b/doc/bounded_array.htm @@ -196,5 +196,16 @@ member inside this model of the concept. +
+

+ Copyright (©) 2000-2004 Michael Stevens, Mathias Koch, + Joerg Walter, Gunter Winkler
+ 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 + ). +

diff --git a/doc/container_concept.htm b/doc/container_concept.htm index 7625769a..2613b6fe 100644 --- a/doc/container_concept.htm +++ b/doc/container_concept.htm @@ -405,10 +405,12 @@ size.

As a user you need not care about Matrix being a refinement of the MatrixExpression. Being a refinement of the MatrixExpression is only important for the template-expression engine but not the user.


Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

+ 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 + ). +

diff --git a/doc/doxygen.css b/doc/doxygen.css index dc9da522..6dbaf573 100644 --- a/doc/doxygen.css +++ b/doc/doxygen.css @@ -1,3 +1,14 @@ +/* + * Copyright 2000-2004 Michael Stevens, Mathias Koch, + * Joerg Walter, Gunter Winkler. + * + * 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). + */ + + H1 { text-align: center; font-family: Geneva, Arial, Helvetica, sans-serif; diff --git a/doc/expression_concept.htm b/doc/expression_concept.htm index ade2a507..df18d007 100644 --- a/doc/expression_concept.htm +++ b/doc/expression_concept.htm @@ -1029,10 +1029,12 @@ the distance from m.rbegin2 () to m.rend2

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

+ 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 + ). +

diff --git a/doc/hermitian.htm b/doc/hermitian.htm index 03c9722c..5a915cbf 100644 --- a/doc/hermitian.htm +++ b/doc/hermitian.htm @@ -578,10 +578,12 @@ Supported parameters for the type of the hermitian adaptor are lower and upper.


Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

+ 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 + ). +

diff --git a/doc/index.htm b/doc/index.htm index 542f9f1d..b49a2ae0 100644 --- a/doc/index.htm +++ b/doc/index.htm @@ -298,10 +298,12 @@ reintroducing temporaries using either prod (A, > (B, C)).


Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

+ 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 + ). +

diff --git a/doc/index.html b/doc/index.html index 32626624..35f0862f 100644 --- a/doc/index.html +++ b/doc/index.html @@ -8,5 +8,15 @@

Please update your bookmarks to point to index.htm. You will be redirected in a second.

+

+ Copyright (©) 2000-2004 Michael Stevens, Mathias Koch, + Joerg Walter, Gunter Winkler
+ 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 + ). +

diff --git a/doc/iterator_concept.htm b/doc/iterator_concept.htm index 2b06024b..7789f8bc 100644 --- a/doc/iterator_concept.htm +++ b/doc/iterator_concept.htm @@ -1149,10 +1149,12 @@ it2 + (it1 - it2)
.

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

+ 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 + ). +

diff --git a/doc/matrix.htm b/doc/matrix.htm index a3de0969..52393556 100644 --- a/doc/matrix.htm +++ b/doc/matrix.htm @@ -749,10 +749,12 @@ end of the reversed scalar_matrix.

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

+ 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 + ). +

diff --git a/doc/matrix_expression.htm b/doc/matrix_expression.htm index eef0af40..9aa92d4d 100644 --- a/doc/matrix_expression.htm +++ b/doc/matrix_expression.htm @@ -1409,10 +1409,12 @@ int main () {

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

+ 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 + ). +

diff --git a/doc/matrix_proxy.htm b/doc/matrix_proxy.htm index 77acb906..d3f790b6 100644 --- a/doc/matrix_proxy.htm +++ b/doc/matrix_proxy.htm @@ -1409,10 +1409,12 @@ int main () {

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

+ 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 + ). +

diff --git a/doc/matrix_sparse.htm b/doc/matrix_sparse.htm index 75675260..f22ba9f4 100644 --- a/doc/matrix_sparse.htm +++ b/doc/matrix_sparse.htm @@ -964,10 +964,12 @@ Supported parameters for the adapted array are std::vector<> .


Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

+ 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 + ). +

diff --git a/doc/operations_overview.htm b/doc/operations_overview.htm index 48f19633..01d5304d 100644 --- a/doc/operations_overview.htm +++ b/doc/operations_overview.htm @@ -242,10 +242,12 @@ depends on numerical properties of A and the result of the prod(B,C).

Copyright (©) 2000-2007 Joerg Walter, Mathias Koch, Gunter Winkler, Michael Stevens
-Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

+ 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 + ). +

diff --git a/doc/overview.htm b/doc/overview.htm index a008b38a..0780b72b 100644 --- a/doc/overview.htm +++ b/doc/overview.htm @@ -948,10 +948,12 @@ generic vector and matrix classes seems to remain. The difference w.r.t. alias assumptions remains visible, too.


Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

+ 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 + ). +

diff --git a/doc/products.htm b/doc/products.htm index 9587a4eb..f3178c7d 100644 --- a/doc/products.htm +++ b/doc/products.htm @@ -300,10 +300,12 @@ This function may give a speedup if A has less columns than rows, b

Copyright (©) 2000-2004 Michael Stevens, Mathias Koch, Joerg Walter, Gunter Winkler
-Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

+ 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 + ). +

diff --git a/doc/range.htm b/doc/range.htm index 666c7fb7..843fbead 100644 --- a/doc/range.htm +++ b/doc/range.htm @@ -206,5 +206,16 @@ end of the reversed slice.
  • None all strides are vaild. However when an index is returned or an iterator is dereferenced its value must be representable as the size_type.
  • +
    +

    + Copyright (©) 2000-2004 Michael Stevens, Mathias Koch, + Joerg Walter, Gunter Winkler
    + 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 + ). +

    diff --git a/doc/storage_concept.htm b/doc/storage_concept.htm index f1ec40a1..64efe3db 100644 --- a/doc/storage_concept.htm +++ b/doc/storage_concept.htm @@ -137,11 +137,13 @@ each element value may be a previously assigned value or default construced valu

    Notes


    Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
    -Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

    + 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 + ). +

    \ No newline at end of file diff --git a/doc/storage_sparse.htm b/doc/storage_sparse.htm index a29d6aec..e8a42f12 100644 --- a/doc/storage_sparse.htm +++ b/doc/storage_sparse.htm @@ -269,10 +269,12 @@ the reversed map_array.

    Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
    -Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

    + 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 + ). +

    diff --git a/doc/symmetric.htm b/doc/symmetric.htm index 79882b85..11110fad 100644 --- a/doc/symmetric.htm +++ b/doc/symmetric.htm @@ -569,10 +569,12 @@ Supported parameters for the type of the symmetric adaptor are lower and upper.


    Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
    -Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

    + 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 + ). +

    diff --git a/doc/triangular.htm b/doc/triangular.htm index 05ae8455..eea59333 100644 --- a/doc/triangular.htm +++ b/doc/triangular.htm @@ -579,10 +579,12 @@ Supported parameters for the type of the triangular adaptor are and unit_upper .


    Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
    -Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

    + 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 + ). +

    diff --git a/doc/types_overview.htm b/doc/types_overview.htm index b2da64e4..b6037234 100644 --- a/doc/types_overview.htm +++ b/doc/types_overview.htm @@ -561,10 +561,12 @@ The storage layout usually is BLAS compliant.

    Copyright (©) 2000-2004 Joerg Walter, Mathias Koch, Gunter Winkler, Michael Stevens
    -Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

    + 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 + ). +

    diff --git a/doc/ublas.css b/doc/ublas.css index be6854e1..1b7ec044 100644 --- a/doc/ublas.css +++ b/doc/ublas.css @@ -1,3 +1,14 @@ +/* + * Copyright 2000-2004 Michael Stevens, Mathias Koch, + * Joerg Walter, Gunter Winkler. + * + * 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). + */ + + table { border-width: medium; background-color: #F8F8F8; diff --git a/doc/unbounded_array.htm b/doc/unbounded_array.htm index f7e56071..19626730 100644 --- a/doc/unbounded_array.htm +++ b/doc/unbounded_array.htm @@ -200,10 +200,12 @@ the unbounded_array.

    Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
    -Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

    + 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 + ). +

    diff --git a/doc/vector.htm b/doc/vector.htm index 125bebfd..de920542 100644 --- a/doc/vector.htm +++ b/doc/vector.htm @@ -736,10 +736,12 @@ end of the reversed scalar_vector.

    Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
    -Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

    + 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 + ). +

    diff --git a/doc/vector_expression.htm b/doc/vector_expression.htm index 1ec6759f..7f5d8c88 100644 --- a/doc/vector_expression.htm +++ b/doc/vector_expression.htm @@ -950,10 +950,12 @@ int main () {

    Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
    -Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

    + 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 + ). +

    diff --git a/doc/vector_proxy.htm b/doc/vector_proxy.htm index af675d82..648cbd0c 100644 --- a/doc/vector_proxy.htm +++ b/doc/vector_proxy.htm @@ -508,10 +508,12 @@ int main () {

    Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
    -Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

    + 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 + ). +

    diff --git a/doc/vector_sparse.htm b/doc/vector_sparse.htm index 53190c73..7659ccec 100644 --- a/doc/vector_sparse.htm +++ b/doc/vector_sparse.htm @@ -781,10 +781,12 @@ Supported parameters for the adapted array are std::vector<> .


    Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
    -Permission to copy, use, modify, sell and distribute this document -is granted provided this copyright notice appears in all copies. -This document is provided ``as is'' without express or implied -warranty, and with no claim as to its suitability for any -purpose.

    + 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 + ). +

    diff --git a/include/boost/numeric/ublas/detail/documentation.hpp b/include/boost/numeric/ublas/detail/documentation.hpp index 6c91e328..4b2bcf0b 100644 --- a/include/boost/numeric/ublas/detail/documentation.hpp +++ b/include/boost/numeric/ublas/detail/documentation.hpp @@ -1,14 +1,10 @@ // // Copyright (c) 2000-2004 -// Joerg Walter, Mathias Koch and uBLAS developers +// 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. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. diff --git a/test/README b/test/README index 685ebc18..2e3e7177 100644 --- a/test/README +++ b/test/README @@ -1,3 +1,9 @@ +Copyright (c) 2000-2004 Joerg Walter, Mathias Koch + +Distributed under the Boost Software License, Version 1.0. (See +accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) + uBLAS test director Use boost::test to test various uBLAS containers and expressions diff --git a/test/manual/sp_resize.cpp b/test/manual/sp_resize.cpp index 665a4a5a..2d52dbbd 100644 --- a/test/manual/sp_resize.cpp +++ b/test/manual/sp_resize.cpp @@ -15,7 +15,7 @@ template void printV(const V& v) { std::cout << "size: " << v.size() << " nnz_capacity: " << v.nnz_capacity() << " nnz: " << v.nnz() << std::endl; for (typename V::const_iterator i = v.begin(); i != v.end(); i++) { - std::cout << i.index() << ":" << (*i) << " "; + std::cout << i.index() << ":" << (*i) << " "; } std::cout << std::endl; } From 12f797c938214b5205a181f79b43e87e948bc57b Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Wed, 23 Jul 2008 15:15:27 +0000 Subject: [PATCH 014/280] Merge trunk svn path=/branches/release/boost/numeric/ublas/; revision=47717 --- doc/overview.htm | 2 +- .../boost/numeric/ublas/expression_types.hpp | 32 ++++++------ include/boost/numeric/ublas/functional.hpp | 49 +++++++++++-------- .../boost/numeric/ublas/vector_expression.hpp | 2 + 4 files changed, 48 insertions(+), 37 deletions(-) diff --git a/doc/overview.htm b/doc/overview.htm index 0780b72b..412b8384 100644 --- a/doc/overview.htm +++ b/doc/overview.htm @@ -286,7 +286,7 @@ matrices.

    sasum OR dasum norm_1 (x) -sum xi +sum |xi| Computes the l1 (sum) norm of a real vector. diff --git a/include/boost/numeric/ublas/expression_types.hpp b/include/boost/numeric/ublas/expression_types.hpp index d74f4d14..095c798d 100644 --- a/include/boost/numeric/ublas/expression_types.hpp +++ b/include/boost/numeric/ublas/expression_types.hpp @@ -217,13 +217,13 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - const vector_indirect operator () (const indirect_array &ia) const { - return vector_indirect (operator () (), ia); + const vector_indirect > operator () (const indirect_array &ia) const { + return vector_indirect > (operator () (), ia); } template BOOST_UBLAS_INLINE - vector_indirect operator () (const indirect_array &ia) { - return vector_indirect (operator () (), ia); + vector_indirect > operator () (const indirect_array &ia) { + return vector_indirect > (operator () (), ia); } BOOST_UBLAS_INLINE @@ -244,13 +244,13 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - const vector_indirect project (const indirect_array &ia) const { - return vector_indirect (operator () (), ia); + const vector_indirect > project (const indirect_array &ia) const { + return vector_indirect > (operator () (), ia); } template BOOST_UBLAS_INLINE - vector_indirect project (const indirect_array &ia) { - return vector_indirect (operator () (), ia); + vector_indirect > project (const indirect_array &ia) { + return vector_indirect > (operator () (), ia); } #endif }; @@ -371,13 +371,13 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - const matrix_indirect operator () (const indirect_array &ia1, const indirect_array &ia2) const { - return matrix_indirect (operator () (), ia1, ia2); + const matrix_indirect > operator () (const indirect_array &ia1, const indirect_array &ia2) const { + return matrix_indirect > (operator () (), ia1, ia2); } template BOOST_UBLAS_INLINE - matrix_indirect operator () (const indirect_array &ia1, const indirect_array &ia2) { - return matrix_indirect (operator () (), ia1, ia2); + matrix_indirect > operator () (const indirect_array &ia1, const indirect_array &ia2) { + return matrix_indirect > (operator () (), ia1, ia2); } BOOST_UBLAS_INLINE @@ -398,13 +398,13 @@ namespace boost { namespace numeric { namespace ublas { } template BOOST_UBLAS_INLINE - const matrix_indirect project (const indirect_array &ia1, const indirect_array &ia2) const { - return matrix_indirect (operator () (), ia1, ia2); + const matrix_indirect > project (const indirect_array &ia1, const indirect_array &ia2) const { + return matrix_indirect > (operator () (), ia1, ia2); } template BOOST_UBLAS_INLINE - matrix_indirect project (const indirect_array &ia1, const indirect_array &ia2) { - return matrix_indirect (operator () (), ia1, ia2); + matrix_indirect > project (const indirect_array &ia1, const indirect_array &ia2) { + return matrix_indirect > (operator () (), ia1, ia2); } #endif }; diff --git a/include/boost/numeric/ublas/functional.hpp b/include/boost/numeric/ublas/functional.hpp index db44c635..cdbcaf94 100644 --- a/include/boost/numeric/ublas/functional.hpp +++ b/include/boost/numeric/ublas/functional.hpp @@ -446,6 +446,7 @@ namespace boost { namespace numeric { namespace ublas { size_type size (e ().size ()); for (size_type i = 0; i < size; ++ i) { real_type u (type_traits::norm_2 (e () (i))); + if ( real_type () /* zero */ == u ) continue; if (scale < u) { real_type v (scale / u); sum_squares = sum_squares * v * v + real_type (1); @@ -1851,6 +1852,8 @@ namespace boost { namespace numeric { namespace ublas { return (std::max) (i, j); } }; + + // the first row only contains a single 1. Thus it is not stored. template struct basic_unit_lower : public basic_lower { typedef Z size_type; @@ -1879,21 +1882,23 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) { // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ()); - return L::lower_element (i, size_i - 1, j, size_j - 1); + BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0 && i != 0, bad_index ()); + return L::lower_element (i-1, size_i - 1, j, size_j - 1); } static BOOST_UBLAS_INLINE size_type mutable_restrict1 (size_type i, size_type j) { - return (std::max) (i, j); + return (std::max) ( (std::max)(1, i), j); } static BOOST_UBLAS_INLINE size_type mutable_restrict2 (size_type i, size_type j) { - return (std::min) (i, j); + return (std::min) ( (std::max)(1, i), j); } }; + + // the last row only contains a single 1. Thus it is not stored. template struct basic_unit_upper : public basic_upper { typedef Z size_type; @@ -1922,21 +1927,23 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) { // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ()); - return L::upper_element (i, size_i - 1, j, size_j - 1); + BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0 && j != 0, bad_index ()); + return L::upper_element (i, size_i - 1, j-1, size_j - 1); } static BOOST_UBLAS_INLINE size_type mutable_restrict1 (size_type i, size_type j) { - return (std::min) (i, j); + return (std::min) (i, (std::max)(1, j)); } static BOOST_UBLAS_INLINE size_type mutable_restrict2 (size_type i, size_type j) { - return (std::max) (i, j); + return (std::max) (i, (std::max)(1, j)); } }; + + // the first row only contains a single 1. Thus it is not stored. template struct basic_strict_lower : public basic_lower { typedef Z size_type; @@ -1970,31 +1977,33 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) { // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ()); - return L::lower_element (i, size_i - 1, j, size_j - 1); + BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0 && i != 0, bad_index ()); + return L::lower_element (i-1, size_i - 1, j, size_j - 1); } static BOOST_UBLAS_INLINE size_type restrict1 (size_type i, size_type j) { - return (std::max) (i, j); + return (std::max) ( (std::max)(1, i), j); } static BOOST_UBLAS_INLINE size_type restrict2 (size_type i, size_type j) { - return (std::min) (i, j); + return (std::min) ( (std::max)(1, i), j); } static BOOST_UBLAS_INLINE size_type mutable_restrict1 (size_type i, size_type j) { - return (std::max) (i, j); + return (std::max) ( (std::max)(1, i), j); } static BOOST_UBLAS_INLINE size_type mutable_restrict2 (size_type i, size_type j) { - return (std::min) (i, j); + return (std::min) ( (std::max)(1, i), j); } }; + + // the last row only contains a single 1. Thus it is not stored. template struct basic_strict_upper : public basic_upper { typedef Z size_type; @@ -2028,29 +2037,29 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) { // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ()); - return L::upper_element (i, size_i - 1, j, size_j - 1); + BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0 && j != 0, bad_index ()); + return L::upper_element (i, size_i - 1, j-1, size_j - 1); } static BOOST_UBLAS_INLINE size_type restrict1 (size_type i, size_type j) { - return (std::min) (i, j); + return (std::min) (i, (std::max)(1, j)); } static BOOST_UBLAS_INLINE size_type restrict2 (size_type i, size_type j) { - return (std::max) (i, j); + return (std::max) (i, (std::max)(1, j)); } static BOOST_UBLAS_INLINE size_type mutable_restrict1 (size_type i, size_type j) { - return (std::min) (i, j); + return (std::min) (i, (std::max)(1, j)); } static BOOST_UBLAS_INLINE size_type mutable_restrict2 (size_type i, size_type j) { - return (std::max) (i, j); + return (std::max) (i, (std::max)(1, j)); } }; diff --git a/include/boost/numeric/ublas/vector_expression.hpp b/include/boost/numeric/ublas/vector_expression.hpp index 46cf7a98..e383ab38 100644 --- a/include/boost/numeric/ublas/vector_expression.hpp +++ b/include/boost/numeric/ublas/vector_expression.hpp @@ -1424,6 +1424,7 @@ namespace boost { namespace numeric { namespace ublas { typedef vector_scalar_unary self_type; public: typedef typename F::result_type value_type; + typedef typename E::difference_type difference_type; typedef const self_type const_closure_type; typedef const_closure_type closure_type; typedef unknown_storage_tag storage_category; @@ -1555,6 +1556,7 @@ namespace boost { namespace numeric { namespace ublas { public: static const unsigned complexity = 1; typedef typename F::result_type value_type; + typedef typename E1::difference_type difference_type; typedef const self_type const_closure_type; typedef const_closure_type closure_type; typedef unknown_storage_tag storage_category; From bffc00628316ba9563fcc798b7cc982c386a038c Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Fri, 12 Sep 2008 19:17:57 +0000 Subject: [PATCH 015/280] - fixed ADL problem with std::abs and std::sqrt - fixed problem that iterator1 and iterator2 of triangular matrices (and related) sometimes pointed to wrong element or outside the storage svn path=/branches/release/boost/numeric/ublas/; revision=48756 --- include/boost/numeric/ublas/functional.hpp | 341 ++++++++++----------- include/boost/numeric/ublas/hermitian.hpp | 16 +- include/boost/numeric/ublas/symmetric.hpp | 8 +- include/boost/numeric/ublas/traits.hpp | 22 +- include/boost/numeric/ublas/triangular.hpp | 32 +- 5 files changed, 219 insertions(+), 200 deletions(-) diff --git a/include/boost/numeric/ublas/functional.hpp b/include/boost/numeric/ublas/functional.hpp index cdbcaf94..2d420d41 100644 --- a/include/boost/numeric/ublas/functional.hpp +++ b/include/boost/numeric/ublas/functional.hpp @@ -1722,6 +1722,7 @@ namespace boost { namespace numeric { namespace ublas { bool other (size_type /* i */, size_type /* j */) { return true; } + // FIXME: this should not be used at all static BOOST_UBLAS_INLINE size_type restrict1 (size_type i, size_type j) { @@ -1744,6 +1745,84 @@ namespace boost { namespace numeric { namespace ublas { } }; + namespace detail { + template < class L > + struct transposed_structure { + typedef typename L::size_type size_type; + + template + static + BOOST_UBLAS_INLINE + size_type packed_size (LAYOUT l, size_type size_i, size_type size_j) { + return L::packed_size(l, size_j, size_i); + } + + static + BOOST_UBLAS_INLINE + bool zero (size_type i, size_type j) { + return L::zero(j, i); + } + static + BOOST_UBLAS_INLINE + bool one (size_type i, size_type j) { + return L::one(j, i); + } + static + BOOST_UBLAS_INLINE + bool other (size_type i, size_type j) { + return L::other(j, i); + } + template + static + BOOST_UBLAS_INLINE + size_type element (LAYOUT l, size_type i, size_type size_i, size_type j, size_type size_j) { + return L::element(l, j, size_j, i, size_i); + } + + static + BOOST_UBLAS_INLINE + size_type restrict1 (size_type i, size_type j, size_type size1, size_type size2) { + return L::restrict2(j, i, size2, size1); + } + static + BOOST_UBLAS_INLINE + size_type restrict2 (size_type i, size_type j, size_type size1, size_type size2) { + return L::restrict1(j, i, size2, size1); + } + static + BOOST_UBLAS_INLINE + size_type mutable_restrict1 (size_type i, size_type j, size_type size1, size_type size2) { + return L::mutable_restrict2(j, i, size2, size1); + } + static + BOOST_UBLAS_INLINE + size_type mutable_restrict2 (size_type i, size_type j, size_type size1, size_type size2) { + return L::mutable_restrict1(j, i, size2, size1); + } + + static + BOOST_UBLAS_INLINE + size_type global_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { + return L::global_restrict2(index2, size2, index1, size1); + } + static + BOOST_UBLAS_INLINE + size_type global_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { + return L::global_restrict1(index2, size2, index1, size1); + } + static + BOOST_UBLAS_INLINE + size_type global_mutable_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { + return L::global_mutable_restrict2(index2, size2, index1, size1); + } + static + BOOST_UBLAS_INLINE + size_type global_mutable_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { + return L::global_mutable_restrict1(index2, size2, index1, size1); + } + }; + } + template struct basic_lower { typedef Z size_type; @@ -1777,80 +1856,56 @@ namespace boost { namespace numeric { namespace ublas { return L::lower_element (i, size_i, j, size_j); } + // return nearest valid index in column j static BOOST_UBLAS_INLINE - size_type restrict1 (size_type i, size_type j) { - return (std::max) (i, j); + size_type restrict1 (size_type i, size_type j, size_type size1, size_type size2) { + return (std::max)(j, (std::min) (size1, i)); } + // return nearest valid index in row i static BOOST_UBLAS_INLINE - size_type restrict2 (size_type i, size_type j) { - return (std::min) (i + 1, j); + size_type restrict2 (size_type i, size_type j, size_type /* size1 */, size_type /* size2 */) { + return (std::max)(size_type(0), (std::min) (i+1, j)); } + // return nearest valid mutable index in column j static BOOST_UBLAS_INLINE - size_type mutable_restrict1 (size_type i, size_type j) { - return (std::max) (i, j); + size_type mutable_restrict1 (size_type i, size_type j, size_type size1, size_type size2) { + return (std::max)(j, (std::min) (size1, i)); } + // return nearest valid mutable index in row i static BOOST_UBLAS_INLINE - size_type mutable_restrict2 (size_type i, size_type j) { - return (std::min) (i + 1, j); - } - }; - template - struct basic_upper { - typedef Z size_type; - - template - static - BOOST_UBLAS_INLINE - size_type packed_size (L, size_type size_i, size_type size_j) { - return L::triangular_size (size_i, size_j); + size_type mutable_restrict2 (size_type i, size_type j, size_type /* size1 */, size_type /* size2 */) { + return (std::max)(size_type(0), (std::min) (i+1, j)); } - static - BOOST_UBLAS_INLINE - bool zero (size_type i, size_type j) { - return j < i; - } - static - BOOST_UBLAS_INLINE - bool one (size_type /* i */, size_type /* j */) { - return false; - } - static - BOOST_UBLAS_INLINE - bool other (size_type i, size_type j) { - return j >= i; - } - template - static - BOOST_UBLAS_INLINE - size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) { - return L::upper_element (i, size_i, j, size_j); - } + // return an index between the first and (1+last) filled row + static + BOOST_UBLAS_INLINE + size_type global_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { + return (std::max)(size_type(0), (std::min)(size1, index1) ); + } + // return an index between the first and (1+last) filled column + static + BOOST_UBLAS_INLINE + size_type global_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { + return (std::max)(size_type(0), (std::min)(size2, index2) ); + } - static - BOOST_UBLAS_INLINE - size_type restrict1 (size_type i, size_type j) { - return (std::min) (i, j + 1); - } - static - BOOST_UBLAS_INLINE - size_type restrict2 (size_type i, size_type j) { - return (std::max) (i, j); - } - static - BOOST_UBLAS_INLINE - size_type mutable_restrict1 (size_type i, size_type j) { - return (std::min) (i, j + 1); - } - static - BOOST_UBLAS_INLINE - size_type mutable_restrict2 (size_type i, size_type j) { - return (std::max) (i, j); - } + // return an index between the first and (1+last) filled mutable row + static + BOOST_UBLAS_INLINE + size_type global_mutable_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { + return (std::max)(size_type(0), (std::min)(size1, index1) ); + } + // return an index between the first and (1+last) filled mutable column + static + BOOST_UBLAS_INLINE + size_type global_mutable_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { + return (std::max)(size_type(0), (std::min)(size2, index2) ); + } }; // the first row only contains a single 1. Thus it is not stored. @@ -1888,64 +1943,33 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE - size_type mutable_restrict1 (size_type i, size_type j) { - return (std::max) ( (std::max)(1, i), j); + size_type mutable_restrict1 (size_type i, size_type j, size_type size1, size_type size2) { + return (std::max)(j+1, (std::min) (size1, i)); } static BOOST_UBLAS_INLINE - size_type mutable_restrict2 (size_type i, size_type j) { - return (std::min) ( (std::max)(1, i), j); + size_type mutable_restrict2 (size_type i, size_type j, size_type size1, size_type size2) { + return (std::max)(size_type(0), (std::min) (i, j)); } + + // return an index between the first and (1+last) filled mutable row + static + BOOST_UBLAS_INLINE + size_type global_mutable_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { + return (std::max)(size_type(1), (std::min)(size1, index1) ); + } + // return an index between the first and (1+last) filled mutable column + static + BOOST_UBLAS_INLINE + size_type global_mutable_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { + BOOST_UBLAS_CHECK( size2 >= 1 , external_logic() ); + return (std::max)(size_type(0), (std::min)(size2-1, index2) ); + } }; - // the last row only contains a single 1. Thus it is not stored. + // the first row only contains no element. Thus it is not stored. template - struct basic_unit_upper : public basic_upper { - typedef Z size_type; - - template - static - BOOST_UBLAS_INLINE - size_type packed_size (L, size_type size_i, size_type size_j) { - // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ()); - return L::triangular_size (size_i - 1, size_j - 1); - } - - static - BOOST_UBLAS_INLINE - bool one (size_type i, size_type j) { - return j == i; - } - static - BOOST_UBLAS_INLINE - bool other (size_type i, size_type j) { - return j > i; - } - template - static - BOOST_UBLAS_INLINE - size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) { - // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0 && j != 0, bad_index ()); - return L::upper_element (i, size_i - 1, j-1, size_j - 1); - } - - static - BOOST_UBLAS_INLINE - size_type mutable_restrict1 (size_type i, size_type j) { - return (std::min) (i, (std::max)(1, j)); - } - static - BOOST_UBLAS_INLINE - size_type mutable_restrict2 (size_type i, size_type j) { - return (std::max) (i, (std::max)(1, j)); - } - }; - - // the first row only contains a single 1. Thus it is not stored. - template - struct basic_strict_lower : public basic_lower { + struct basic_strict_lower : public basic_unit_lower { typedef Z size_type; template @@ -1983,85 +2007,42 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE - size_type restrict1 (size_type i, size_type j) { - return (std::max) ( (std::max)(1, i), j); + size_type restrict1 (size_type i, size_type j, size_type size1, size_type size2) { + return mutable_restrict1(i, j, size1, size2); } static BOOST_UBLAS_INLINE - size_type restrict2 (size_type i, size_type j) { - return (std::min) ( (std::max)(1, i), j); - } - static - BOOST_UBLAS_INLINE - size_type mutable_restrict1 (size_type i, size_type j) { - return (std::max) ( (std::max)(1, i), j); - } - static - BOOST_UBLAS_INLINE - size_type mutable_restrict2 (size_type i, size_type j) { - return (std::min) ( (std::max)(1, i), j); + size_type restrict2 (size_type i, size_type j, size_type size1, size_type size2) { + return mutable_restrict2(i, j, size1, size2); } + + // return an index between the first and (1+last) filled row + static + BOOST_UBLAS_INLINE + size_type global_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { + return global_mutable_restrict1(index1, size1, index2, size2); + } + // return an index between the first and (1+last) filled column + static + BOOST_UBLAS_INLINE + size_type global_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { + return global_mutable_restrict2(index1, size1, index2, size2); + } }; - // the last row only contains a single 1. Thus it is not stored. + template - struct basic_strict_upper : public basic_upper { - typedef Z size_type; + struct basic_upper : public detail::transposed_structure > + { }; - template - static - BOOST_UBLAS_INLINE - size_type packed_size (L, size_type size_i, size_type size_j) { - // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ()); - return L::triangular_size (size_i - 1, size_j - 1); - } + template + struct basic_unit_upper : public detail::transposed_structure > + { }; - static - BOOST_UBLAS_INLINE - bool zero (size_type i, size_type j) { - return j <= i; - } - static - BOOST_UBLAS_INLINE - bool one (size_type /*i*/, size_type /*j*/) { - return false; - } - static - BOOST_UBLAS_INLINE - bool other (size_type i, size_type j) { - return j > i; - } - template - static - BOOST_UBLAS_INLINE - size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) { - // Zero size strict triangles are bad at this point - BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0 && j != 0, bad_index ()); - return L::upper_element (i, size_i - 1, j-1, size_j - 1); - } + template + struct basic_strict_upper : public detail::transposed_structure > + { }; - static - BOOST_UBLAS_INLINE - size_type restrict1 (size_type i, size_type j) { - return (std::min) (i, (std::max)(1, j)); - } - static - BOOST_UBLAS_INLINE - size_type restrict2 (size_type i, size_type j) { - return (std::max) (i, (std::max)(1, j)); - } - static - BOOST_UBLAS_INLINE - size_type mutable_restrict1 (size_type i, size_type j) { - return (std::min) (i, (std::max)(1, j)); - } - static - BOOST_UBLAS_INLINE - size_type mutable_restrict2 (size_type i, size_type j) { - return (std::max) (i, (std::max)(1, j)); - } - }; }}} diff --git a/include/boost/numeric/ublas/hermitian.hpp b/include/boost/numeric/ublas/hermitian.hpp index 7104d557..b6001e9a 100644 --- a/include/boost/numeric/ublas/hermitian.hpp +++ b/include/boost/numeric/ublas/hermitian.hpp @@ -498,7 +498,9 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 find1 (int rank, size_type i, size_type j) { if (rank == 1) - i = triangular_type::mutable_restrict1 (i, j); + i = triangular_type::mutable_restrict1 (i, j, size1(), size2()); + if (rank == 0) + i = triangular_type::global_mutable_restrict1 (i, size1(), j, size2()); return iterator1 (*this, i, j); } BOOST_UBLAS_INLINE @@ -508,7 +510,9 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 find2 (int rank, size_type i, size_type j) { if (rank == 1) - j = triangular_type::mutable_restrict2 (i, j); + j = triangular_type::mutable_restrict2 (i, j, size1(), size2()); + if (rank == 0) + j = triangular_type::global_mutable_restrict2 (i, size1(), j, size2()); return iterator2 (*this, i, j); } @@ -1416,7 +1420,9 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 find1 (int rank, size_type i, size_type j) { if (rank == 1) - i = triangular_type::mutable_restrict1 (i, j); + i = triangular_type::mutable_restrict1 (i, j, size1(), size2()); + if (rank == 0) + i = triangular_type::global_mutable_restrict1 (i, size1(), j, size2()); return iterator1 (*this, data ().find1 (rank, i, j)); } BOOST_UBLAS_INLINE @@ -1446,7 +1452,9 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 find2 (int rank, size_type i, size_type j) { if (rank == 1) - j = triangular_type::mutable_restrict2 (i, j); + j = triangular_type::mutable_restrict2 (i, j, size1(), size2()); + if (rank == 0) + j = triangular_type::global_mutable_restrict2 (i, size1(), j, size2()); return iterator2 (*this, data ().find2 (rank, i, j)); } diff --git a/include/boost/numeric/ublas/symmetric.hpp b/include/boost/numeric/ublas/symmetric.hpp index 0ebbe639..8aede25a 100644 --- a/include/boost/numeric/ublas/symmetric.hpp +++ b/include/boost/numeric/ublas/symmetric.hpp @@ -281,7 +281,9 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 find1 (int rank, size_type i, size_type j) { if (rank == 1) - i = triangular_type::mutable_restrict1 (i, j); + i = triangular_type::mutable_restrict1 (i, j, size1(), size2()); + if (rank == 0) + i = triangular_type::global_mutable_restrict1 (i, size1(), j, size2()); return iterator1 (*this, i, j); } BOOST_UBLAS_INLINE @@ -291,7 +293,9 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 find2 (int rank, size_type i, size_type j) { if (rank == 1) - j = triangular_type::mutable_restrict2 (i, j); + j = triangular_type::mutable_restrict2 (i, j, size1(), size2()); + if (rank == 0) + j = triangular_type::global_mutable_restrict2 (i, size1(), j, size2()); return iterator2 (*this, i, j); } diff --git a/include/boost/numeric/ublas/traits.hpp b/include/boost/numeric/ublas/traits.hpp index f1e8e8e1..6e5c576f 100644 --- a/include/boost/numeric/ublas/traits.hpp +++ b/include/boost/numeric/ublas/traits.hpp @@ -24,6 +24,20 @@ #include #include +// anonymous namespace to avoid ADL issues +namespace { + template T boost_numeric_ublas_sqrt (const T& t) { + using namespace std; + // we'll find either std::sqrt or else another version via ADL: + return sqrt (t); + } + template T boost_numeric_ublas_abs (const T& t) { + using namespace std; + // we'll find either std::abs or else another version via ADL: + return abs (t); + } +} + namespace boost { namespace numeric { namespace ublas { // Use Joel de Guzman's return type deduction @@ -84,17 +98,13 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE real_type type_abs (const_reference t) { - // we'll find either std::abs or else another version via ADL: - using namespace std; - return abs (t); + return boost_numeric_ublas_abs (t); } static BOOST_UBLAS_INLINE value_type type_sqrt (const_reference t) { - using namespace std; // force a type conversion back to value_type for intgral types - // we'll find either std::sqrt or else another version via ADL: - return value_type (sqrt (t)); + return value_type (boost_numeric_ublas_sqrt (t)); } static diff --git a/include/boost/numeric/ublas/triangular.hpp b/include/boost/numeric/ublas/triangular.hpp index f0be81e9..a0b39fb9 100644 --- a/include/boost/numeric/ublas/triangular.hpp +++ b/include/boost/numeric/ublas/triangular.hpp @@ -295,25 +295,33 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 find1 (int rank, size_type i, size_type j) const { if (rank == 1) - i = triangular_type::restrict1 (i, j); + i = triangular_type::restrict1 (i, j, size1_, size2_); + if (rank == 0) + i = triangular_type::global_restrict1 (i, size1_, j, size2_); return const_iterator1 (*this, i, j); } BOOST_UBLAS_INLINE iterator1 find1 (int rank, size_type i, size_type j) { if (rank == 1) - i = triangular_type::mutable_restrict1 (i, j); + i = triangular_type::mutable_restrict1 (i, j, size1_, size2_); + if (rank == 0) + i = triangular_type::global_mutable_restrict1 (i, size1_, j, size2_); return iterator1 (*this, i, j); } BOOST_UBLAS_INLINE const_iterator2 find2 (int rank, size_type i, size_type j) const { if (rank == 1) - j = triangular_type::restrict2 (i, j); + j = triangular_type::restrict2 (i, j, size1_, size2_); + if (rank == 0) + j = triangular_type::global_restrict2 (i, size1_, j, size2_); return const_iterator2 (*this, i, j); } BOOST_UBLAS_INLINE iterator2 find2 (int rank, size_type i, size_type j) { if (rank == 1) - j = triangular_type::mutable_restrict2 (i, j); + j = triangular_type::mutable_restrict2 (i, j, size1_, size2_); + if (rank == 0) + j = triangular_type::global_mutable_restrict2 (i, size1_, j, size2_); return iterator2 (*this, i, j); } @@ -1145,25 +1153,33 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 find1 (int rank, size_type i, size_type j) const { if (rank == 1) - i = triangular_type::restrict1 (i, j); + i = triangular_type::restrict1 (i, j, size1(), size2()); + if (rank == 0) + i = triangular_type::global_restrict1 (i, size1(), j, size2()); return const_iterator1 (*this, data ().find1 (rank, i, j)); } BOOST_UBLAS_INLINE iterator1 find1 (int rank, size_type i, size_type j) { if (rank == 1) - i = triangular_type::mutable_restrict1 (i, j); + i = triangular_type::mutable_restrict1 (i, j, size1(), size2()); + if (rank == 0) + i = triangular_type::global_mutable_restrict1 (i, size1(), j, size2()); return iterator1 (*this, data ().find1 (rank, i, j)); } BOOST_UBLAS_INLINE const_iterator2 find2 (int rank, size_type i, size_type j) const { if (rank == 1) - j = triangular_type::restrict2 (i, j); + j = triangular_type::restrict2 (i, j, size1(), size2()); + if (rank == 0) + j = triangular_type::global_restrict2 (i, size1(), j, size2()); return const_iterator2 (*this, data ().find2 (rank, i, j)); } BOOST_UBLAS_INLINE iterator2 find2 (int rank, size_type i, size_type j) { if (rank == 1) - j = triangular_type::mutable_restrict2 (i, j); + j = triangular_type::mutable_restrict2 (i, j, size1(), size2()); + if (rank == 0) + j = triangular_type::global_mutable_restrict2 (i, size1(), j, size2()); return iterator2 (*this, data ().find2 (rank, i, j)); } From 91bcffd0d59a0f913b063401d3499bcd4a5237ae Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 3 Oct 2008 19:55:50 +0000 Subject: [PATCH 016/280] Merge placement new fix from trunk svn path=/branches/release/libs/numeric/ublas/; revision=49130 --- test/placement_new.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/placement_new.cpp b/test/placement_new.cpp index 6e07d46c..940da7da 100644 --- a/test/placement_new.cpp +++ b/test/placement_new.cpp @@ -12,6 +12,7 @@ #include #include +#include // User defined type to capture base pointer on construction From 13631700ffc10616b5472b31847e40245b513578 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Mon, 13 Oct 2008 09:00:03 +0000 Subject: [PATCH 017/280] Merge fixes from Trunk. Fixes #2392. Change includes of to . Previously if Boost.TR1 was in the include path then including pulls in all the new TR1 math functions, which in turn also requires linking to an external library. With auto-linking support this requires that library to have been built and be present in the library search path, even if the actual library under use is header only. svn path=/branches/release/boost/numeric/ublas/; revision=49314 --- include/boost/numeric/ublas/traits.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/numeric/ublas/traits.hpp b/include/boost/numeric/ublas/traits.hpp index 6e5c576f..4c26919b 100644 --- a/include/boost/numeric/ublas/traits.hpp +++ b/include/boost/numeric/ublas/traits.hpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include From 24362fdfd45038096aa2ec11ea14ec271cca4a85 Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sat, 24 Jan 2009 18:57:20 +0000 Subject: [PATCH 018/280] merge of cmake build files from trunk per beman svn path=/branches/release/libs/numeric/ublas/; revision=50756 --- test/CMakeLists.txt | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 test/CMakeLists.txt diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..fdb8beee --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,71 @@ +# Define features to test: +# Value types: USE_FLOAT USE_DOUBLE USE_STD_COMPLEX +# Proxies: USE_RANGE USE_SLICE +# Storage types: USE_BOUNDED_ARRAY USE_UNBOUNDED_ARRAY +# Vector types: USE_STD_VECTOR USE_BOUNDED_VECTOR +# Matrix types: USE_MATRIX USE_BOUNDED_MATRIX USE_VECTOR_OF_VECTOR +# Adaptors: USE_ADAPTOR + +set(UBLAS_TESTSET_DEFINES + "-DUSE_DOUBLE -DUSE_STD_COMPLEX -DUSE_RANGE -DUSE_SLICE -DUSE_UNBOUNDED_ARRAY -DUSE_STD_VECTOR -DUSE_BOUNDED_VECTOR -DUSE_MATRIX") + +# Sparse storage: USE_MAP_ARRAY USE_STD_MAP +# Sparse vectors: USE_MAPPED_VECTOR USE_COMPRESSED_VECTOR USE_COORDINATE_VECTOR +# Sparse matrices: USE_MAPPED_MATRIX USE_COMPRESSED_MATRIX USE_COORDINATE_MATRIX USE_MAPPED_VECTOR_OF_MAPPED_VECTOR USE_GENERALIZED_VECTOR_OF_VECTOR + +set(UBLAS_TESTSET_SPARSE_DEFINES + "-DUSE_DOUBLE -DUSE_STD_COMPLEX -DUSE_UNBOUNDED_ARRAY -DUSE_MAP_ARRAY -DUSE_STD_MAP -DUSE_MAPPED_VECTOR -DUSE_COMPRESSED_VECTOR -DUSE_COORDINATE_VECTOR -DUSE_MAPPED_MATRIX -DUSE_COMPRESSED_MATRIX -DUSE_COORDINATE_MATRIX") + +# Definitions for uBLAS tests +add_definitions(-DBOOST_UBLAS_NO_EXCEPTIONS) +# TODO: vacpp:"BOOST_UBLAS_NO_ELEMENT_PROXIES" + +#------------------------------------------------------------------------- +#-- Needed include directories for the tests +boost_additional_test_dependencies(numeric BOOST_DEPENDS test) +#------------------------------------------------------------------------- + + +boost_test_run(ublas_test1 + test1.cpp test11.cpp test12.cpp test13.cpp + COMPILE_FLAGS "${UBLAS_TESTSET_DEFINES}") + +boost_test_run(ublas_test2 + test2.cpp test21.cpp test22.cpp test23.cpp + COMPILE_FLAGS "${UBLAS_TESTSET_DEFINES}") + +boost_test_run(ublas_test3 + test3.cpp test31.cpp test32.cpp test33.cpp + COMPILE_FLAGS "${UBLAS_TESTSET_SPARSE_DEFINES}") + +boost_test_run(ublas_test4 + test4.cpp test42.cpp test43.cpp + COMPILE_FLAGS "${UBLAS_TESTSET_DEFINES}") + +boost_test_run(ublas_test5 + test5.cpp test52.cpp test53.cpp + COMPILE_FLAGS "${UBLAS_TESTSET_DEFINES}") + +boost_test_run(ublas_test6 + test6.cpp test62.cpp test63.cpp + COMPILE_FLAGS "${UBLAS_TESTSET_DEFINES}") + +# Test commented out, just like in V1 and V2 Jamfiles +# boost_test_run(test7 +# test7.cpp test71.cpp test72.cpp test73.cpp +# COMPILE_FLAGS "-DBOOST_UBLAS_USE_INTERVAL ${UBLAS_TESTSET_DEFINES}") + +boost_test_run(placement_new) + + +SET(test_compile_flags "-DEXTERNAL") +#-- Intel Compiler flags +IF( ${CMAKE_CXX_COMPILER} MATCHES "icpc" ) + SET(test_compile_flags "${test_compile_flags} -Xc") +ENDIF( ${CMAKE_CXX_COMPILER} MATCHES "icpc" ) + +IF (APPLE) + SET(test_compile_flags "${test_compile_flags} -fabi-version=0") +ENDIF (APPLE) + +boost_test_compile(concepts COMPILE_FLAGS "-DEXTERNAL") From 2986f34aeee4a84e33cec0e976d07ce95b29642c Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Mon, 9 Mar 2009 20:24:11 +0000 Subject: [PATCH 019/280] detail/concepts.hpp: added read only vector concept storage_sparse.hpp: removed wrong structure check, added check for empty sequence to erase(it1, it2) svn path=/branches/release/boost/numeric/ublas/; revision=51666 --- include/boost/numeric/ublas/detail/concepts.hpp | 10 ++++++++++ include/boost/numeric/ublas/storage_sparse.hpp | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/boost/numeric/ublas/detail/concepts.hpp b/include/boost/numeric/ublas/detail/concepts.hpp index 5f150886..c1d58bd1 100644 --- a/include/boost/numeric/ublas/detail/concepts.hpp +++ b/include/boost/numeric/ublas/detail/concepts.hpp @@ -942,6 +942,16 @@ namespace boost { namespace numeric { namespace ublas { } #endif + // read only vectors + { + typedef vector_view container_model; + function_requires< RandomAccessContainerConcept >(); + function_requires< VectorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + function_requires< IndexedRandomAccess1DIteratorConcept >(); + } + + // Vector #if defined (INTERNAL_VECTOR) || defined (INTERNAL_VECTOR_DENSE) { diff --git a/include/boost/numeric/ublas/storage_sparse.hpp b/include/boost/numeric/ublas/storage_sparse.hpp index 47be61f3..72584b8b 100644 --- a/include/boost/numeric/ublas/storage_sparse.hpp +++ b/include/boost/numeric/ublas/storage_sparse.hpp @@ -390,7 +390,6 @@ namespace boost { namespace numeric { namespace ublas { if (it != end () && it->first == p.first) return std::make_pair (it, false); difference_type n = it - begin (); - BOOST_UBLAS_CHECK (size () == 0 || size () == size_type (n), external_logic ()); resize (size () + 1); it = begin () + n; // allow for invalidation std::copy_backward (it, end () - 1, end ()); @@ -410,6 +409,7 @@ namespace boost { namespace numeric { namespace ublas { } // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. void erase (iterator it1, iterator it2) { + if (it1 == it2) return /* nothing to erase */; BOOST_UBLAS_CHECK (begin () <= it1 && it1 < it2 && it2 <= end (), bad_index ()); std::copy (it2, end (), it1); resize (size () - (it2 - it1)); From 507ac8d629feb3f42efbdf77b8ce81f5e011334f Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Thu, 2 Apr 2009 22:15:10 +0000 Subject: [PATCH 020/280] ublas/expression_types.hpp: added typedef ublas_expression::self_type ublas/fwd.hpp: added default template arguments to declaration of generalized_vector_of_vector ublas/lu.hpp: added constructor from vector to permutation_matrix ublas/storage.hpp: fix #2891 ublas/detail/concepts.hpp: added documentation and some missing concept checks ublas/traits.hpp: added new traits classes: container_traits, matrix_traits, vector_traits they work for all ublas classes and c-arrays (T[M][N] and T[M]) ublas/functional.hpp: added triangular type tags fix #2800 added my name to copyright message svn path=/branches/release/boost/numeric/ublas/; revision=52145 --- .../boost/numeric/ublas/detail/concepts.hpp | 27 ++++++ .../boost/numeric/ublas/expression_types.hpp | 2 + include/boost/numeric/ublas/functional.hpp | 26 ++++-- include/boost/numeric/ublas/fwd.hpp | 3 + include/boost/numeric/ublas/lu.hpp | 6 ++ include/boost/numeric/ublas/storage.hpp | 4 +- include/boost/numeric/ublas/traits.hpp | 83 +++++++++++++++++++ 7 files changed, 143 insertions(+), 8 deletions(-) diff --git a/include/boost/numeric/ublas/detail/concepts.hpp b/include/boost/numeric/ublas/detail/concepts.hpp index c1d58bd1..d68690c5 100644 --- a/include/boost/numeric/ublas/detail/concepts.hpp +++ b/include/boost/numeric/ublas/detail/concepts.hpp @@ -237,11 +237,22 @@ namespace boost { namespace numeric { namespace ublas { } }; + /** \brief Scalar expression concept. + * + * requirements + * \li \c SE::value_type is the type of the scalar expression + * \li \c SE must be convertable to \c SE::value_type + * \li the constant \c SE::complexity must exist + * + * \param SE the type of the scalar expression + */ template struct ScalarExpressionConcept { typedef SE scalar_expression_type; typedef typename SE::value_type value_type; + static const unsigned complexity = SE::complexity; + void constraints () { scalar_expression_type *sp; scalar_expression_type s = *sp; @@ -252,12 +263,28 @@ namespace boost { namespace numeric { namespace ublas { } }; + /** \brief Vector expression concept. + * + * requirements + * \li \c VE::value_type is the type of the elements + * \li \c VE::const_reference The return type when accessing an element of a constant vector + * expression. Must be convertable to a \c value_type. + * \li \c VE::size_type is the (unsigned) type of the indices + * \li \c VE::difference_type is the (signed) type of distances between indices + * \li \c VE::category + * + * \li the constant \c SE::complexity must exist + * + * \param SE the type of the scalar expression + */ template struct VectorExpressionConcept { typedef VE vector_expression_type; typedef typename VE::type_category type_category; typedef typename VE::size_type size_type; + typedef typename VE::difference_type difference_type; typedef typename VE::value_type value_type; + typedef typename VE::const_reference const_reference; typedef typename VE::const_iterator const_iterator_type; typedef typename VE::const_reverse_iterator const_reverse_iterator_type; diff --git a/include/boost/numeric/ublas/expression_types.hpp b/include/boost/numeric/ublas/expression_types.hpp index 095c798d..86241a9f 100644 --- a/include/boost/numeric/ublas/expression_types.hpp +++ b/include/boost/numeric/ublas/expression_types.hpp @@ -291,6 +291,8 @@ namespace boost { namespace numeric { namespace ublas { template class matrix_expression: public ublas_expression { + private: + typedef matrix_expression self_type; public: static const unsigned complexity = 0; typedef E expression_type; diff --git a/include/boost/numeric/ublas/functional.hpp b/include/boost/numeric/ublas/functional.hpp index 2d420d41..b13a557d 100644 --- a/include/boost/numeric/ublas/functional.hpp +++ b/include/boost/numeric/ublas/functional.hpp @@ -1,6 +1,6 @@ // -// Copyright (c) 2000-2002 -// Joerg Walter, Mathias Koch +// Copyright (c) 2000-2009 +// Joerg Walter, Mathias Koch, Gunter Winkler // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -1343,6 +1343,9 @@ namespace boost { namespace numeric { namespace ublas { } }; + // forward declaration + template struct basic_column_major; + // This functor defines storage layout and it's properties // matrix (i,j) -> storage [i * size_i + j] template @@ -1350,6 +1353,7 @@ namespace boost { namespace numeric { namespace ublas { typedef Z size_type; typedef D difference_type; typedef row_major_tag orientation_category; + typedef basic_column_major transposed_layout; static BOOST_UBLAS_INLINE @@ -1527,6 +1531,7 @@ namespace boost { namespace numeric { namespace ublas { typedef Z size_type; typedef D difference_type; typedef column_major_tag orientation_category; + typedef basic_row_major transposed_layout; static BOOST_UBLAS_INLINE @@ -1776,7 +1781,7 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type element (LAYOUT l, size_type i, size_type size_i, size_type j, size_type size_j) { - return L::element(l, j, size_j, i, size_i); + return L::element(typename LAYOUT::transposed_layout(), j, size_j, i, size_i); } static @@ -1826,6 +1831,7 @@ namespace boost { namespace numeric { namespace ublas { template struct basic_lower { typedef Z size_type; + typedef lower_tag triangular_type; template static @@ -1912,6 +1918,7 @@ namespace boost { namespace numeric { namespace ublas { template struct basic_unit_lower : public basic_lower { typedef Z size_type; + typedef unit_lower_tag triangular_type; template static @@ -1971,6 +1978,7 @@ namespace boost { namespace numeric { namespace ublas { template struct basic_strict_lower : public basic_unit_lower { typedef Z size_type; + typedef strict_lower_tag triangular_type; template static @@ -2033,15 +2041,21 @@ namespace boost { namespace numeric { namespace ublas { template struct basic_upper : public detail::transposed_structure > - { }; + { + typedef upper_tag triangular_type; + }; template struct basic_unit_upper : public detail::transposed_structure > - { }; + { + typedef unit_upper_tag triangular_type; + }; template struct basic_strict_upper : public detail::transposed_structure > - { }; + { + typedef strict_upper_tag triangular_type; + }; }}} diff --git a/include/boost/numeric/ublas/fwd.hpp b/include/boost/numeric/ublas/fwd.hpp index 5baca043..17ff588d 100644 --- a/include/boost/numeric/ublas/fwd.hpp +++ b/include/boost/numeric/ublas/fwd.hpp @@ -139,6 +139,9 @@ namespace boost { namespace numeric { namespace ublas { template > > class vector_of_vector; + template > > + class generalized_vector_of_vector; + // Triangular matrix type struct lower_tag {}; struct upper_tag {}; diff --git a/include/boost/numeric/ublas/lu.hpp b/include/boost/numeric/ublas/lu.hpp index 2f785e9e..a24037b8 100644 --- a/include/boost/numeric/ublas/lu.hpp +++ b/include/boost/numeric/ublas/lu.hpp @@ -32,12 +32,18 @@ namespace boost { namespace numeric { namespace ublas { // Construction and destruction BOOST_UBLAS_INLINE + explicit permutation_matrix (size_type size): vector (size) { for (size_type i = 0; i < size; ++ i) (*this) (i) = i; } BOOST_UBLAS_INLINE + explicit + permutation_matrix (const vector_type & init) + : vector_type(init) + { } + BOOST_UBLAS_INLINE ~permutation_matrix () {} // Assignment diff --git a/include/boost/numeric/ublas/storage.hpp b/include/boost/numeric/ublas/storage.hpp index a2d9b315..ba176c41 100644 --- a/include/boost/numeric/ublas/storage.hpp +++ b/include/boost/numeric/ublas/storage.hpp @@ -340,12 +340,12 @@ namespace boost { namespace numeric { namespace ublas { // Resizing BOOST_UBLAS_INLINE void resize (size_type size) { - BOOST_UBLAS_CHECK (size_ <= N, bad_size ()); + BOOST_UBLAS_CHECK (size <= N, bad_size ()); size_ = size; } BOOST_UBLAS_INLINE void resize (size_type size, value_type init) { - BOOST_UBLAS_CHECK (size_ <= N, bad_size ()); + BOOST_UBLAS_CHECK (size <= N, bad_size ()); if (size > size_) std::fill (data_ + size_, data_ + size, init); size_ = size; diff --git a/include/boost/numeric/ublas/traits.hpp b/include/boost/numeric/ublas/traits.hpp index 4c26919b..75f6925b 100644 --- a/include/boost/numeric/ublas/traits.hpp +++ b/include/boost/numeric/ublas/traits.hpp @@ -511,6 +511,89 @@ namespace boost { namespace numeric { namespace ublas { } + + /** \brief Traits class to extract type information from a matrix or vector CONTAINER. + * + */ + template < class E > + struct container_traits { + /// type of indices + typedef typename E::size_type size_type; + /// type of differences of indices + typedef typename E::difference_type difference_type; + + /// storage category: \c unknown_storage_tag, \c dense_tag, \c packed_tag, ... + typedef typename E::storage_category storage_category; + + /// type of elements + typedef typename E::value_type value_type; + /// reference to an element + typedef typename E::reference reference; + /// const reference to an element + typedef typename E::const_reference const_reference; + + /// type used in expressions to mark a reference to this class (usually a container_reference or the class itself) + typedef typename E::closure_type closure_type; + /// type used in expressions to mark a reference to this class (usually a const container_reference or the class itself) + typedef typename E::const_closure_type const_closure_type; + }; + + /** \brief Traits class to extract type information from a MATRIX. + * + */ + template < class MATRIX > + struct matrix_traits : container_traits { + + /// orientation of the matrix, either \c row_major_tag, \c column_major_tag or \c unknown_orientation_tag + typedef typename MATRIX::orientation_category orientation_category; + + }; + + /** \brief Traits class to extract type information from a VECTOR. + * + */ + template < class VECTOR > + struct vector_traits : container_traits { + + }; + + template < class T, int M, int N > + struct matrix_traits < T[M][N] > { + typedef T matrix_type[M][N]; + + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + typedef row_major_tag orientation_category; + typedef dense_tag storage_category; + + typedef T value_type; + typedef T *reference; + typedef const T *const_reference; + + // \todo { define correct wrapper } + typedef matrix_reference closure_type; + typedef const matrix_reference const_closure_type; + }; + + template < class T, int N > + struct vector_traits < T[N] > { + typedef T vector_type[N]; + + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + typedef dense_tag storage_category; + + typedef T value_type; + typedef T *reference; + typedef const T *const_reference; + + // \todo { define correct wrapper } + typedef vector_reference closure_type; + typedef const vector_reference const_closure_type; + }; + }}} #endif From 1a6a47b021aaf7c5e4aff5de9fd2df3acbe2fde2 Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Thu, 2 Apr 2009 22:36:39 +0000 Subject: [PATCH 021/280] ublas/doc/samples/ex_triangular.cpp: added new example ublas/doc/samples/Jamfile.v2: added build section for ex_triangular ublas/doc/container_concept.htm: fixed wrong description of array_type ublas/doc/triangular.htm: fixed lower/upper confusion and added link to ex_triangular ublas/test/test_lu.cpp: added unit test for LU decomposition ublas/test/triangular_access.cpp: added unit test for accessing triangular/symmetric matrices ublas/test/triangular_layout.cpp: added unit test for testing storage layout of triangular/symmetric matrices ublas/test/common/testhelper.hpp: support routines for new unit tests ublas/test/CMakeLists.txt: added new tests (still experimental) test_lu, triangular_access. triangular_layout ublas/test/Jamfile.v2: added new tests (still experimental) test_lu, triangular_access. triangular_layout disabled broken test7 (maybe a fix of boost::interval is needed, see #2473) ublas/test/test71.cpp, ublas/test/test73.cpp, ublas/test/test7.cpp: added first fixes to support boost::interval as scalar type ublas/test/common/init.hpp: initialize all matrices/vectors with floats instead of (unsigned) ints this helps to fix broken test7 for boost::interval svn path=/branches/release/libs/numeric/ublas/; revision=52147 --- doc/container_concept.htm | 4 +- doc/samples/Jamfile.v2 | 4 + doc/samples/ex_triangular.cpp | 58 ++++++++++ doc/triangular.htm | 6 +- test/CMakeLists.txt | 11 +- test/Jamfile.v2 | 10 +- test/common/init.hpp | 6 +- test/common/testhelper.hpp | 74 +++++++++++++ test/test7.cpp | 2 + test/test71.cpp | 2 +- test/test73.cpp | 2 +- test/test_lu.cpp | 70 ++++++++++++ test/triangular_access.cpp | 201 ++++++++++++++++++++++++++++++++++ test/triangular_layout.cpp | 139 +++++++++++++++++++++++ 14 files changed, 579 insertions(+), 10 deletions(-) create mode 100644 doc/samples/ex_triangular.cpp create mode 100644 test/common/testhelper.hpp create mode 100644 test/test_lu.cpp create mode 100644 test/triangular_access.cpp create mode 100644 test/triangular_layout.cpp diff --git a/doc/container_concept.htm b/doc/container_concept.htm index 2613b6fe..141f4e1a 100644 --- a/doc/container_concept.htm +++ b/doc/container_concept.htm @@ -110,7 +110,7 @@ Dense Vector ONLY. The type of underlying storage array used to store the elemen Storage v.data() v is mutable and Dense. -array_type& if a is mutable, const array_type& otherwise +array_type& if v is mutable, const array_type& otherwise @@ -307,7 +307,7 @@ following expressions must be valid.

    Storage m.data() m is mutable and Dense. -array_type& if a is mutable, const array_type& otherwise +array_type& if m is mutable, const array_type& otherwise diff --git a/doc/samples/Jamfile.v2 b/doc/samples/Jamfile.v2 index d32c8742..55a8e6a6 100644 --- a/doc/samples/Jamfile.v2 +++ b/doc/samples/Jamfile.v2 @@ -222,3 +222,7 @@ exe triangular_matrix exe triangular_adaptor : triangular_adaptor.cpp ; + +exe ex_triangular + : ex_triangular.cpp + ; diff --git a/doc/samples/ex_triangular.cpp b/doc/samples/ex_triangular.cpp new file mode 100644 index 00000000..a2a34d96 --- /dev/null +++ b/doc/samples/ex_triangular.cpp @@ -0,0 +1,58 @@ +// Copyright Gunter Winkler 2004 - 2009. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#include + +#include +#include + +#include + +using std::cout; +using std::endl; + + + +namespace ublas = boost::numeric::ublas; + + +int main(int argc, char * argv[] ) { + + ublas::matrix M (3, 3); + for (std::size_t i=0; i < M.data().size(); ++i) { M.data()[i] = 1+i ; } + + std::cout << "full M = " << M << "\n" ; + + ublas::triangular_matrix L; + ublas::triangular_matrix UL; + ublas::triangular_matrix SL; + + L = ublas::triangular_adaptor, ublas::lower> (M); + SL = ublas::triangular_adaptor, ublas::strict_lower> (M); + UL = ublas::triangular_adaptor, ublas::unit_lower> (M); + + std::cout << "lower L = " << L << "\n" + << "strict lower SL = " << SL << "\n" + << "unit lower UL = " << UL << "\n" ; + + ublas::triangular_matrix U; + ublas::triangular_matrix UU; + ublas::triangular_matrix SU; + + U = ublas::triangular_adaptor, ublas::upper> (M); + SU = ublas::triangular_adaptor, ublas::strict_upper> (M); + UU = ublas::triangular_adaptor, ublas::unit_upper> (M); + + std::cout << "upper U = " << U << "\n" + << "strict upper SU = " << SU << "\n" + << "unit upper UU = " << UU << "\n" ; + + std::cout << "M = L + SU ? " << ((norm_inf( M - (L + SU) ) == 0.0)?"ok":"failed") << "\n"; + std::cout << "M = U + SL ? " << ((norm_inf( M - (U + SL) ) == 0.0)?"ok":"failed") << "\n"; + +} + + diff --git a/doc/triangular.htm b/doc/triangular.htm index eea59333..f2ff474c 100644 --- a/doc/triangular.htm +++ b/doc/triangular.htm @@ -21,7 +21,7 @@ For a (n x n )-dimensional lower triangular matrix and ti, j = 0 , if i > j. If furthermore holds ti, i= 1 the matrix is called unit lower triangular. For a (n x n -)-dimensional upper triangular matrix and 0 <= i < +)-dimensional lower triangular matrix and 0 <= i < n,0 <= j < n holds ti, j = 0 , if i < j. If furthermore holds ti, i= 1 the matrix is called @@ -46,6 +46,8 @@ int main () { std::cout << mu << std::endl; } +

    Please read the full triangular example for more details.

    +

    Definition

    Defined in the header triangular.hpp.

    Template parameters

    @@ -348,6 +350,8 @@ int main () { std::cout << tau << std::endl; } +

    Please read the full triangular example for more details.

    +

    Definition

    Defined in the header triangular.hpp.

    Template parameters

    diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fdb8beee..8b2a0b8f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -50,13 +50,22 @@ boost_test_run(ublas_test6 test6.cpp test62.cpp test63.cpp COMPILE_FLAGS "${UBLAS_TESTSET_DEFINES}") -# Test commented out, just like in V1 and V2 Jamfiles +# Test commented out because boost::interval does not behave like a scalar # boost_test_run(test7 # test7.cpp test71.cpp test72.cpp test73.cpp # COMPILE_FLAGS "-DBOOST_UBLAS_USE_INTERVAL ${UBLAS_TESTSET_DEFINES}") boost_test_run(placement_new) +boost_test_run(test_lu) + +boost_test_run(triangular_access + triangular_access.cpp + COMPILE_FLAGS "-DNOMESSAGES") + +boost_test_run(triangular_layout + triangular_layout.cpp) + SET(test_compile_flags "-DEXTERNAL") #-- Intel Compiler flags diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index a1b401ed..0bd12e83 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -88,7 +88,7 @@ test-suite numeric/uBLAS : : : $(UBLAS_TESTSET) ] -# Test commented out, just like in V1 Jamfile +# Test commented out because boost::interval does not behave like a scalar type # [ run test7.cpp # test71.cpp # test72.cpp @@ -106,4 +106,12 @@ test-suite numeric/uBLAS intel-linux:"-Xc" darwin:"-fabi-version=0" ] + [ run test_lu.cpp + ] + [ run triangular_access.cpp + : : : + NOMESSAGES + ] + [ run triangular_layout.cpp + ] ; diff --git a/test/common/init.hpp b/test/common/init.hpp index e3a23ed5..a9691b4e 100644 --- a/test/common/init.hpp +++ b/test/common/init.hpp @@ -43,7 +43,7 @@ template void initialize_vector (V &v) { typename V::size_type size = v.size (); for (typename V::size_type i = 0; i < size; ++ i) - v [i] = typename V::value_type (i + 1); + v [i] = typename V::value_type ( i + 1.f ); } template @@ -52,11 +52,11 @@ void initialize_matrix_impl (M &m, ublas::packed_proxy_tag) { #ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION for (typename M::iterator1 i = m.begin1(); i != m.end1(); ++ i) for (typename M::iterator2 j = i.begin(); j != i.end(); ++ j) - *j = typename M::value_type (i.index1() * size1 + j.index2() + 1); + *j = typename M::value_type ( i.index1() * size1 + j.index2() + 1.f ); #else for (typename M::iterator1 i = m.begin1(); i != m.end1(); ++ i) for (typename M::iterator2 j = ublas::begin (i, ublas::iterator1_tag ()); j != ublas::end (i, ublas::iterator1_tag ()); ++ j) - *j = typename M::value_type (i.index1() * size1 + j.index2() + 1); + *j = typename M::value_type ( i.index1() * size1 + j.index2() + 1.f ); #endif } diff --git a/test/common/testhelper.hpp b/test/common/testhelper.hpp new file mode 100644 index 00000000..4fbf9c4d --- /dev/null +++ b/test/common/testhelper.hpp @@ -0,0 +1,74 @@ +// Copyright 2008 Gunter Winkler +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef _HPP_TESTHELPER_ +#define _HPP_TESTHELPER_ + +#include + +static unsigned _success_counter = 0; +static unsigned _fail_counter = 0; + +static inline +void assertTrue(const char* message, bool condition) { +#ifndef NOMESSAGES + std::cout << message; +#endif + if ( condition ) { + ++ _success_counter; + std::cout << "1\n"; // success + } else { + ++ _fail_counter; + std::cout << "0\n"; // failed + } +} + +template < class T > +void assertEquals(const char* message, T expected, T actual) { +#ifndef NOMESSAGES + std::cout << message; +#endif + if ( expected == actual ) { + ++ _success_counter; + std::cout << "1\n"; // success + } else { + #ifndef NOMESSAGES + std::cout << " expected " << expected << " actual " << actual << " "; + #endif + ++ _fail_counter; + std::cout << "0\n"; // failed + } +} + +static +std::pair getResults() { + return std::make_pair(_success_counter, _fail_counter); +} + +template < class M1, class M2 > +bool compare( const boost::numeric::ublas::matrix_expression & m1, + const boost::numeric::ublas::matrix_expression & m2 ) { + size_t size1 = (std::min)(m1().size1(), m2().size1()); + size_t size2 = (std::min)(m1().size2(), m2().size2()); + for (size_t i=0; i < size1; ++i) { + for (size_t j=0; j < size2; ++j) { + if ( m1()(i,j) != m2()(i,j) ) return false; + } + } + return true; +} + +template < class M1, class M2 > +bool compare( const boost::numeric::ublas::vector_expression & m1, + const boost::numeric::ublas::vector_expression & m2 ) { + size_t size = (std::min)(m1().size(), m2().size()); + for (size_t i=0; i < size; ++i) { + if ( m1()(i) != m2()(i) ) return false; + } + return true; +} + +#endif diff --git a/test/test7.cpp b/test/test7.cpp index 4782975f..f564031c 100644 --- a/test/test7.cpp +++ b/test/test7.cpp @@ -21,6 +21,8 @@ #include "test7.hpp" +// this testcase requires fix of task #2473 + int main () { test_vector (); test_matrix_vector (); diff --git a/test/test71.cpp b/test/test71.cpp index 3d397bd3..89e9ccf7 100644 --- a/test/test71.cpp +++ b/test/test71.cpp @@ -36,7 +36,7 @@ struct test_my_vector { std::cout << "v1.swap (v2) = " << v1 << " " << v2 << std::endl; // Zero assignment - v1 = ublas::zero_vector<> (v1.size ()); + v1 = ublas::zero_vector (v1.size ()); std::cout << "v1.zero_vector = " << v1 << std::endl; v1 = v2; diff --git a/test/test73.cpp b/test/test73.cpp index cb0a55b5..e2d68cee 100644 --- a/test/test73.cpp +++ b/test/test73.cpp @@ -33,7 +33,7 @@ struct test_my_matrix { std::cout << "m1.swap (m2) = " << m1 << " " << m2 << std::endl; // Zero assignment - m1 = ublas::zero_matrix<> (m1.size (), m1.size2 ()); + m1 = ublas::zero_matrix (m1.size1 (), m1.size2 ()); std::cout << "m1.zero_matrix = " << m1 << std::endl; m1 = m2; diff --git a/test/test_lu.cpp b/test/test_lu.cpp new file mode 100644 index 00000000..e2b203f8 --- /dev/null +++ b/test/test_lu.cpp @@ -0,0 +1,70 @@ +// Copyright 2008 Gunter Winkler +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// switch automatic singular check off +#define BOOST_UBLAS_TYPE_CHECK 0 + +#include +#include +#include + +#include "common/testhelper.hpp" + +#include +#include + +using namespace boost::numeric::ublas; +using std::string; + +static const string matrix_IN = "[3,3]((1,2,2),(2,3,3),(3,4,6))\0"; +static const string matrix_LU = "[3,3]((3,4,6),(3.33333343e-01,6.66666627e-01,0),(6.66666687e-01,4.99999911e-01,-1))\0"; +static const string matrix_INV= "[3,3]((-3,2,-7.94728621e-08),(1.50000012,0,-5.00000060e-01),(4.99999911e-01,-1,5.00000060e-01))\0"; +static const string matrix_PM = "[3](2,2,2)"; + +int main () { + + typedef float TYPE; + + typedef matrix MATRIX; + + MATRIX A; + MATRIX LU; + MATRIX INV; + + { + std::istringstream is(matrix_IN); + is >> A; + } + { + std::istringstream is(matrix_LU); + is >> LU; + } + { + std::istringstream is(matrix_INV); + is >> INV; + } + permutation_matrix<>::vector_type temp; + { + std::istringstream is(matrix_PM); + is >> temp; + } + permutation_matrix<> PM(temp); + + permutation_matrix<> pm(3); + + int result = lu_factorize >(A, pm); + + assertTrue("factorization completed: ", 0 == result); + assertTrue("LU factors are correct: ", compare(A, LU)); + assertTrue("permutation is correct: ", compare(pm, PM)); + + MATRIX B = identity_matrix(A.size2()); + + lu_substitute(A, pm, B); + + assertTrue("inverse is correct: ", compare(B, INV)); + + return (getResults().second > 0) ? boost::exit_failure : boost::exit_success; +} diff --git a/test/triangular_access.cpp b/test/triangular_access.cpp new file mode 100644 index 00000000..cccf80d0 --- /dev/null +++ b/test/triangular_access.cpp @@ -0,0 +1,201 @@ +/* Test program to test find functions of triagular matrices + * + * author: Gunter Winkler ( guwi17 at gmx dot de ) + */ +// Copyright 2008 Gunter Winkler +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#include +#include +#include + +#include "common/testhelper.hpp" + + +template < class MAT > +void test_iterator( MAT & A ) { + +#ifndef NOMESSAGES + std::cout << "=>"; +#endif + // check mutable iterators + typename MAT::iterator1 it1 = A.begin1(); + typename MAT::iterator1 it1_end = A.end1(); + + for ( ; it1 != it1_end; ++it1 ) { + typename MAT::iterator2 it2 = it1.begin(); + typename MAT::iterator2 it2_end = it1.end(); + for ( ; it2 != it2_end ; ++ it2 ) { +#ifndef NOMESSAGES + std::cout << "( " << it2.index1() << ", " << it2.index2() << ") " << std::flush; +#endif + * it2 = ( 10 * it2.index1() + it2.index2() ); + } +#ifndef NOMESSAGES + std::cout << std::endl; +#endif + } + +} + +template < class MAT > +void test_iterator2( MAT & A ) { + +#ifndef NOMESSAGES + std::cout << "=>"; +#endif + // check mutable iterators + typename MAT::iterator2 it2 = A.begin2(); + typename MAT::iterator2 it2_end = A.end2(); + + for ( ; it2 != it2_end; ++it2 ) { + typename MAT::iterator1 it1 = it2.begin(); + typename MAT::iterator1 it1_end = it2.end(); + for ( ; it1 != it1_end ; ++ it1 ) { +#ifndef NOMESSAGES + std::cout << "( " << it1.index1() << ", " << it1.index2() << ") " << std::flush; +#endif + * it1 = ( 10 * it1.index1() + it1.index2() ); + } +#ifndef NOMESSAGES + std::cout << std::endl; +#endif + } + +} + +template < class MAT > +typename MAT::value_type +test_iterator3( const MAT & A ) { + +#ifndef NOMESSAGES + std::cout << "=>"; +#endif + typename MAT::value_type result = 0; + + // check mutable iterators + typename MAT::const_iterator1 it1 = A.begin1(); + typename MAT::const_iterator1 it1_end = A.end1(); + + for ( ; it1 != it1_end; ++it1 ) { + typename MAT::const_iterator2 it2 = it1.begin(); + typename MAT::const_iterator2 it2_end = it1.end(); + for ( ; it2 != it2_end ; ++ it2 ) { +#ifndef NOMESSAGES + std::cout << "( " << it2.index1() << ", " << it2.index2() << ") " << std::flush; +#endif + result += * it2; + } +#ifndef NOMESSAGES + std::cout << std::endl; +#endif + } + return result; + +} + + +int main (int argc, char * argv[]) { + using namespace boost::numeric::ublas; + + typedef double VALUE_TYPE; + typedef triangular_matrix LT; + typedef triangular_matrix ULT; + typedef triangular_matrix SLT; + typedef triangular_matrix UT; + typedef triangular_matrix UUT; + typedef triangular_matrix SUT; + + LT A(5,5); + + test_iterator(A); + test_iterator2(A); + + ULT B(5,5); + + test_iterator(B); + test_iterator2(B); + + SLT C(5,5); + + test_iterator(C); + test_iterator2(C); + + UT D(5,5); + + test_iterator(D); + test_iterator2(D); + + UUT E(5,5); + + test_iterator(E); + test_iterator2(E); + + SUT F(5,5); + + test_iterator(F); + test_iterator2(F); + + assertTrue("Write access using iterators: ", true); + + assertEquals(" LT: ",420.0,test_iterator3(A)); + assertEquals("ULT: ",315.0,test_iterator3(B)); + assertEquals("SLT: ",310.0,test_iterator3(C)); + assertEquals(" UT: ",240.0,test_iterator3(D)); + assertEquals("UUT: ",135.0,test_iterator3(E)); + assertEquals("SUT: ",130.0,test_iterator3(F)); + + assertTrue("Read access using iterators: ", true); + +#ifndef NOMESSAGES + std::cout << A << B << C << D << E << F << std::endl; +#endif + + typedef matrix MATRIX; + MATRIX mat(5,5); + triangular_adaptor lta((mat)); + triangular_adaptor ulta((mat)); + triangular_adaptor slta((mat)); + triangular_adaptor uta((mat)); + triangular_adaptor uuta((mat)); + triangular_adaptor suta((mat)); + + test_iterator ( lta ); + test_iterator2( lta ); + + test_iterator ( ulta ); + test_iterator2( ulta ); + + test_iterator ( slta ); + test_iterator2( slta ); + + test_iterator ( uta ); + test_iterator2( uta ); + + test_iterator ( uuta ); + test_iterator2( uuta ); + + test_iterator ( suta ); + test_iterator2( suta ); + + assertTrue("Write access using adaptors: ", true); + + assertEquals(" LTA: ",420.0,test_iterator3( lta )); + assertEquals("ULTA: ",315.0,test_iterator3( ulta )); + assertEquals("SLTA: ",310.0,test_iterator3( slta )); + + assertEquals(" UTA: ",240.0,test_iterator3( uta )); + assertEquals("UUTA: ",135.0,test_iterator3( uuta )); + assertEquals("SUTA: ",130.0,test_iterator3( suta )); + + assertTrue("Read access using adaptors: ", true); + +#ifndef NOMESSAGES + std::cout << mat << std::endl; +#endif + + return (getResults().second > 0) ? boost::exit_failure : boost::exit_success; +} diff --git a/test/triangular_layout.cpp b/test/triangular_layout.cpp new file mode 100644 index 00000000..8906bc86 --- /dev/null +++ b/test/triangular_layout.cpp @@ -0,0 +1,139 @@ +// Copyright 2008 Gunter Winkler +// Thanks to Tiago Requeijo for providing this test +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +using namespace std; +namespace ublas = boost::numeric::ublas; + +int main(int argc, char* argv[]) +{ + int sz = 4; + ublas::symmetric_matrix UpCol (sz, sz); + ublas::symmetric_matrix UpRow (sz, sz); + ublas::symmetric_matrix LoCol (sz, sz); + ublas::symmetric_matrix LoRow (sz, sz); + + ublas::triangular_matrix TrUpCol (sz, sz); + ublas::triangular_matrix TrUpRow (sz, sz); + ublas::triangular_matrix TrLoCol (sz, sz); + ublas::triangular_matrix TrLoRow (sz, sz); + + for(int i=0; i Date: Fri, 3 Apr 2009 20:15:44 +0000 Subject: [PATCH 022/280] ublas/detail/concepts.hpp: added conditional to enable/disable test of experimental vector_view svn path=/branches/release/boost/numeric/ublas/; revision=52162 --- include/boost/numeric/ublas/detail/concepts.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/boost/numeric/ublas/detail/concepts.hpp b/include/boost/numeric/ublas/detail/concepts.hpp index d68690c5..5a600d97 100644 --- a/include/boost/numeric/ublas/detail/concepts.hpp +++ b/include/boost/numeric/ublas/detail/concepts.hpp @@ -969,7 +969,8 @@ namespace boost { namespace numeric { namespace ublas { } #endif - // read only vectors +#if defined (VECTOR_VIEW) + // read only vectors { typedef vector_view container_model; function_requires< RandomAccessContainerConcept >(); @@ -977,7 +978,7 @@ namespace boost { namespace numeric { namespace ublas { function_requires< IndexedRandomAccess1DIteratorConcept >(); function_requires< IndexedRandomAccess1DIteratorConcept >(); } - +#endif // Vector #if defined (INTERNAL_VECTOR) || defined (INTERNAL_VECTOR_DENSE) From 5e7c2ef86e155060c706902ad16030c3cad885e7 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Wed, 20 May 2009 19:41:20 +0000 Subject: [PATCH 023/280] Fixed almost all tab and min/max issues found by inspect tool svn path=/branches/release/boost/numeric/ublas/; revision=53142 --- .../boost/numeric/ublas/detail/concepts.hpp | 2 +- include/boost/numeric/ublas/functional.hpp | 256 +++++++++--------- include/boost/numeric/ublas/triangular.hpp | 34 +-- test/triangular_layout.cpp | 192 ++++++------- 4 files changed, 242 insertions(+), 242 deletions(-) diff --git a/include/boost/numeric/ublas/detail/concepts.hpp b/include/boost/numeric/ublas/detail/concepts.hpp index 5a600d97..c0a0cfd0 100644 --- a/include/boost/numeric/ublas/detail/concepts.hpp +++ b/include/boost/numeric/ublas/detail/concepts.hpp @@ -969,7 +969,7 @@ namespace boost { namespace numeric { namespace ublas { } #endif -#if defined (VECTOR_VIEW) +#if defined (VECTOR_VIEW) // read only vectors { typedef vector_view container_model; diff --git a/include/boost/numeric/ublas/functional.hpp b/include/boost/numeric/ublas/functional.hpp index b13a557d..85f14d0c 100644 --- a/include/boost/numeric/ublas/functional.hpp +++ b/include/boost/numeric/ublas/functional.hpp @@ -446,7 +446,7 @@ namespace boost { namespace numeric { namespace ublas { size_type size (e ().size ()); for (size_type i = 0; i < size; ++ i) { real_type u (type_traits::norm_2 (e () (i))); - if ( real_type () /* zero */ == u ) continue; + if ( real_type () /* zero */ == u ) continue; if (scale < u) { real_type v (scale / u); sum_squares = sum_squares * v * v + real_type (1); @@ -1727,7 +1727,7 @@ namespace boost { namespace numeric { namespace ublas { bool other (size_type /* i */, size_type /* j */) { return true; } - // FIXME: this should not be used at all + // FIXME: this should not be used at all static BOOST_UBLAS_INLINE size_type restrict1 (size_type i, size_type j) { @@ -1751,81 +1751,81 @@ namespace boost { namespace numeric { namespace ublas { }; namespace detail { - template < class L > - struct transposed_structure { - typedef typename L::size_type size_type; + template < class L > + struct transposed_structure { + typedef typename L::size_type size_type; - template - static - BOOST_UBLAS_INLINE - size_type packed_size (LAYOUT l, size_type size_i, size_type size_j) { - return L::packed_size(l, size_j, size_i); - } + template + static + BOOST_UBLAS_INLINE + size_type packed_size (LAYOUT l, size_type size_i, size_type size_j) { + return L::packed_size(l, size_j, size_i); + } - static - BOOST_UBLAS_INLINE - bool zero (size_type i, size_type j) { - return L::zero(j, i); - } - static - BOOST_UBLAS_INLINE - bool one (size_type i, size_type j) { - return L::one(j, i); - } - static - BOOST_UBLAS_INLINE - bool other (size_type i, size_type j) { - return L::other(j, i); - } - template - static - BOOST_UBLAS_INLINE - size_type element (LAYOUT l, size_type i, size_type size_i, size_type j, size_type size_j) { - return L::element(typename LAYOUT::transposed_layout(), j, size_j, i, size_i); - } + static + BOOST_UBLAS_INLINE + bool zero (size_type i, size_type j) { + return L::zero(j, i); + } + static + BOOST_UBLAS_INLINE + bool one (size_type i, size_type j) { + return L::one(j, i); + } + static + BOOST_UBLAS_INLINE + bool other (size_type i, size_type j) { + return L::other(j, i); + } + template + static + BOOST_UBLAS_INLINE + size_type element (LAYOUT l, size_type i, size_type size_i, size_type j, size_type size_j) { + return L::element(typename LAYOUT::transposed_layout(), j, size_j, i, size_i); + } - static - BOOST_UBLAS_INLINE - size_type restrict1 (size_type i, size_type j, size_type size1, size_type size2) { - return L::restrict2(j, i, size2, size1); - } - static - BOOST_UBLAS_INLINE - size_type restrict2 (size_type i, size_type j, size_type size1, size_type size2) { - return L::restrict1(j, i, size2, size1); - } - static - BOOST_UBLAS_INLINE - size_type mutable_restrict1 (size_type i, size_type j, size_type size1, size_type size2) { - return L::mutable_restrict2(j, i, size2, size1); - } - static - BOOST_UBLAS_INLINE - size_type mutable_restrict2 (size_type i, size_type j, size_type size1, size_type size2) { - return L::mutable_restrict1(j, i, size2, size1); - } + static + BOOST_UBLAS_INLINE + size_type restrict1 (size_type i, size_type j, size_type size1, size_type size2) { + return L::restrict2(j, i, size2, size1); + } + static + BOOST_UBLAS_INLINE + size_type restrict2 (size_type i, size_type j, size_type size1, size_type size2) { + return L::restrict1(j, i, size2, size1); + } + static + BOOST_UBLAS_INLINE + size_type mutable_restrict1 (size_type i, size_type j, size_type size1, size_type size2) { + return L::mutable_restrict2(j, i, size2, size1); + } + static + BOOST_UBLAS_INLINE + size_type mutable_restrict2 (size_type i, size_type j, size_type size1, size_type size2) { + return L::mutable_restrict1(j, i, size2, size1); + } - static - BOOST_UBLAS_INLINE - size_type global_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { - return L::global_restrict2(index2, size2, index1, size1); - } - static - BOOST_UBLAS_INLINE - size_type global_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { - return L::global_restrict1(index2, size2, index1, size1); - } - static - BOOST_UBLAS_INLINE - size_type global_mutable_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { - return L::global_mutable_restrict2(index2, size2, index1, size1); - } - static - BOOST_UBLAS_INLINE - size_type global_mutable_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { - return L::global_mutable_restrict1(index2, size2, index1, size1); - } - }; + static + BOOST_UBLAS_INLINE + size_type global_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { + return L::global_restrict2(index2, size2, index1, size1); + } + static + BOOST_UBLAS_INLINE + size_type global_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { + return L::global_restrict1(index2, size2, index1, size1); + } + static + BOOST_UBLAS_INLINE + size_type global_mutable_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { + return L::global_mutable_restrict2(index2, size2, index1, size1); + } + static + BOOST_UBLAS_INLINE + size_type global_mutable_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { + return L::global_mutable_restrict1(index2, size2, index1, size1); + } + }; } template @@ -1862,56 +1862,56 @@ namespace boost { namespace numeric { namespace ublas { return L::lower_element (i, size_i, j, size_j); } - // return nearest valid index in column j + // return nearest valid index in column j static BOOST_UBLAS_INLINE size_type restrict1 (size_type i, size_type j, size_type size1, size_type size2) { return (std::max)(j, (std::min) (size1, i)); } - // return nearest valid index in row i + // return nearest valid index in row i static BOOST_UBLAS_INLINE size_type restrict2 (size_type i, size_type j, size_type /* size1 */, size_type /* size2 */) { return (std::max)(size_type(0), (std::min) (i+1, j)); } - // return nearest valid mutable index in column j + // return nearest valid mutable index in column j static BOOST_UBLAS_INLINE size_type mutable_restrict1 (size_type i, size_type j, size_type size1, size_type size2) { return (std::max)(j, (std::min) (size1, i)); } - // return nearest valid mutable index in row i + // return nearest valid mutable index in row i static BOOST_UBLAS_INLINE size_type mutable_restrict2 (size_type i, size_type j, size_type /* size1 */, size_type /* size2 */) { return (std::max)(size_type(0), (std::min) (i+1, j)); } - // return an index between the first and (1+last) filled row - static - BOOST_UBLAS_INLINE - size_type global_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { - return (std::max)(size_type(0), (std::min)(size1, index1) ); - } - // return an index between the first and (1+last) filled column - static - BOOST_UBLAS_INLINE - size_type global_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { - return (std::max)(size_type(0), (std::min)(size2, index2) ); - } + // return an index between the first and (1+last) filled row + static + BOOST_UBLAS_INLINE + size_type global_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { + return (std::max)(size_type(0), (std::min)(size1, index1) ); + } + // return an index between the first and (1+last) filled column + static + BOOST_UBLAS_INLINE + size_type global_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { + return (std::max)(size_type(0), (std::min)(size2, index2) ); + } - // return an index between the first and (1+last) filled mutable row - static - BOOST_UBLAS_INLINE - size_type global_mutable_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { - return (std::max)(size_type(0), (std::min)(size1, index1) ); - } - // return an index between the first and (1+last) filled mutable column - static - BOOST_UBLAS_INLINE - size_type global_mutable_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { - return (std::max)(size_type(0), (std::min)(size2, index2) ); - } + // return an index between the first and (1+last) filled mutable row + static + BOOST_UBLAS_INLINE + size_type global_mutable_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { + return (std::max)(size_type(0), (std::min)(size1, index1) ); + } + // return an index between the first and (1+last) filled mutable column + static + BOOST_UBLAS_INLINE + size_type global_mutable_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { + return (std::max)(size_type(0), (std::min)(size2, index2) ); + } }; // the first row only contains a single 1. Thus it is not stored. @@ -1959,19 +1959,19 @@ namespace boost { namespace numeric { namespace ublas { return (std::max)(size_type(0), (std::min) (i, j)); } - // return an index between the first and (1+last) filled mutable row - static - BOOST_UBLAS_INLINE - size_type global_mutable_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { - return (std::max)(size_type(1), (std::min)(size1, index1) ); - } - // return an index between the first and (1+last) filled mutable column - static - BOOST_UBLAS_INLINE - size_type global_mutable_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { - BOOST_UBLAS_CHECK( size2 >= 1 , external_logic() ); - return (std::max)(size_type(0), (std::min)(size2-1, index2) ); - } + // return an index between the first and (1+last) filled mutable row + static + BOOST_UBLAS_INLINE + size_type global_mutable_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { + return (std::max)(size_type(1), (std::min)(size1, index1) ); + } + // return an index between the first and (1+last) filled mutable column + static + BOOST_UBLAS_INLINE + size_type global_mutable_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { + BOOST_UBLAS_CHECK( size2 >= 1 , external_logic() ); + return (std::max)(size_type(0), (std::min)(size2-1, index2) ); + } }; // the first row only contains no element. Thus it is not stored. @@ -2016,26 +2016,26 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type restrict1 (size_type i, size_type j, size_type size1, size_type size2) { - return mutable_restrict1(i, j, size1, size2); + return mutable_restrict1(i, j, size1, size2); } static BOOST_UBLAS_INLINE size_type restrict2 (size_type i, size_type j, size_type size1, size_type size2) { - return mutable_restrict2(i, j, size1, size2); + return mutable_restrict2(i, j, size1, size2); } - // return an index between the first and (1+last) filled row - static - BOOST_UBLAS_INLINE - size_type global_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { - return global_mutable_restrict1(index1, size1, index2, size2); - } - // return an index between the first and (1+last) filled column - static - BOOST_UBLAS_INLINE - size_type global_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { - return global_mutable_restrict2(index1, size1, index2, size2); - } + // return an index between the first and (1+last) filled row + static + BOOST_UBLAS_INLINE + size_type global_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { + return global_mutable_restrict1(index1, size1, index2, size2); + } + // return an index between the first and (1+last) filled column + static + BOOST_UBLAS_INLINE + size_type global_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { + return global_mutable_restrict2(index1, size1, index2, size2); + } }; diff --git a/include/boost/numeric/ublas/triangular.hpp b/include/boost/numeric/ublas/triangular.hpp index a0b39fb9..8ea510dc 100644 --- a/include/boost/numeric/ublas/triangular.hpp +++ b/include/boost/numeric/ublas/triangular.hpp @@ -296,32 +296,32 @@ namespace boost { namespace numeric { namespace ublas { const_iterator1 find1 (int rank, size_type i, size_type j) const { if (rank == 1) i = triangular_type::restrict1 (i, j, size1_, size2_); - if (rank == 0) - i = triangular_type::global_restrict1 (i, size1_, j, size2_); + if (rank == 0) + i = triangular_type::global_restrict1 (i, size1_, j, size2_); return const_iterator1 (*this, i, j); } BOOST_UBLAS_INLINE iterator1 find1 (int rank, size_type i, size_type j) { if (rank == 1) i = triangular_type::mutable_restrict1 (i, j, size1_, size2_); - if (rank == 0) - i = triangular_type::global_mutable_restrict1 (i, size1_, j, size2_); + if (rank == 0) + i = triangular_type::global_mutable_restrict1 (i, size1_, j, size2_); return iterator1 (*this, i, j); } BOOST_UBLAS_INLINE const_iterator2 find2 (int rank, size_type i, size_type j) const { if (rank == 1) j = triangular_type::restrict2 (i, j, size1_, size2_); - if (rank == 0) - j = triangular_type::global_restrict2 (i, size1_, j, size2_); + if (rank == 0) + j = triangular_type::global_restrict2 (i, size1_, j, size2_); return const_iterator2 (*this, i, j); } BOOST_UBLAS_INLINE iterator2 find2 (int rank, size_type i, size_type j) { if (rank == 1) j = triangular_type::mutable_restrict2 (i, j, size1_, size2_); - if (rank == 0) - j = triangular_type::global_mutable_restrict2 (i, size1_, j, size2_); + if (rank == 0) + j = triangular_type::global_mutable_restrict2 (i, size1_, j, size2_); return iterator2 (*this, i, j); } @@ -1153,33 +1153,33 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_iterator1 find1 (int rank, size_type i, size_type j) const { if (rank == 1) - i = triangular_type::restrict1 (i, j, size1(), size2()); - if (rank == 0) - i = triangular_type::global_restrict1 (i, size1(), j, size2()); + i = triangular_type::restrict1 (i, j, size1(), size2()); + if (rank == 0) + i = triangular_type::global_restrict1 (i, size1(), j, size2()); return const_iterator1 (*this, data ().find1 (rank, i, j)); } BOOST_UBLAS_INLINE iterator1 find1 (int rank, size_type i, size_type j) { if (rank == 1) i = triangular_type::mutable_restrict1 (i, j, size1(), size2()); - if (rank == 0) - i = triangular_type::global_mutable_restrict1 (i, size1(), j, size2()); + if (rank == 0) + i = triangular_type::global_mutable_restrict1 (i, size1(), j, size2()); return iterator1 (*this, data ().find1 (rank, i, j)); } BOOST_UBLAS_INLINE const_iterator2 find2 (int rank, size_type i, size_type j) const { if (rank == 1) j = triangular_type::restrict2 (i, j, size1(), size2()); - if (rank == 0) - j = triangular_type::global_restrict2 (i, size1(), j, size2()); + if (rank == 0) + j = triangular_type::global_restrict2 (i, size1(), j, size2()); return const_iterator2 (*this, data ().find2 (rank, i, j)); } BOOST_UBLAS_INLINE iterator2 find2 (int rank, size_type i, size_type j) { if (rank == 1) j = triangular_type::mutable_restrict2 (i, j, size1(), size2()); - if (rank == 0) - j = triangular_type::global_mutable_restrict2 (i, size1(), j, size2()); + if (rank == 0) + j = triangular_type::global_mutable_restrict2 (i, size1(), j, size2()); return iterator2 (*this, data ().find2 (rank, i, j)); } diff --git a/test/triangular_layout.cpp b/test/triangular_layout.cpp index 8906bc86..8bd27faa 100644 --- a/test/triangular_layout.cpp +++ b/test/triangular_layout.cpp @@ -14,126 +14,126 @@ namespace ublas = boost::numeric::ublas; int main(int argc, char* argv[]) { - int sz = 4; - ublas::symmetric_matrix UpCol (sz, sz); - ublas::symmetric_matrix UpRow (sz, sz); - ublas::symmetric_matrix LoCol (sz, sz); - ublas::symmetric_matrix LoRow (sz, sz); + int sz = 4; + ublas::symmetric_matrix UpCol (sz, sz); + ublas::symmetric_matrix UpRow (sz, sz); + ublas::symmetric_matrix LoCol (sz, sz); + ublas::symmetric_matrix LoRow (sz, sz); - ublas::triangular_matrix TrUpCol (sz, sz); - ublas::triangular_matrix TrUpRow (sz, sz); - ublas::triangular_matrix TrLoCol (sz, sz); - ublas::triangular_matrix TrLoRow (sz, sz); + ublas::triangular_matrix TrUpCol (sz, sz); + ublas::triangular_matrix TrUpRow (sz, sz); + ublas::triangular_matrix TrLoCol (sz, sz); + ublas::triangular_matrix TrLoRow (sz, sz); - for(int i=0; i Date: Wed, 22 Jul 2009 21:51:01 +0000 Subject: [PATCH 024/280] Add basic copyright/license to keep cmake out of the inspection report svn path=/branches/release/libs/numeric/ublas/; revision=55095 --- test/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8b2a0b8f..adb7b7af 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,9 @@ +# +# Copyright Troy D. Straszheim +# +# Distributed under the Boost Software License, Version 1.0. +# See http://www.boost.org/LICENSE_1_0.txt +# # Define features to test: # Value types: USE_FLOAT USE_DOUBLE USE_STD_COMPLEX # Proxies: USE_RANGE USE_SLICE From 54b2e3c1ee4c6d102c99f19dd63850d95f79b23a Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Tue, 8 Sep 2009 20:54:57 +0000 Subject: [PATCH 025/280] Making svn:keywords match trunk svn path=/branches/release/libs/numeric/ublas/; revision=56113 From 1e040bef45bde5ef3506c96a85c76cd416367e78 Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Mon, 5 Oct 2009 22:02:13 +0000 Subject: [PATCH 026/280] fix #2872: (possible compile failure) * merged [56606] into release svn path=/branches/release/boost/numeric/ublas/; revision=56608 --- include/boost/numeric/ublas/lu.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/numeric/ublas/lu.hpp b/include/boost/numeric/ublas/lu.hpp index a24037b8..a1b56658 100644 --- a/include/boost/numeric/ublas/lu.hpp +++ b/include/boost/numeric/ublas/lu.hpp @@ -95,7 +95,7 @@ namespace boost { namespace numeric { namespace ublas { #if BOOST_UBLAS_TYPE_CHECK matrix_type cm (m); #endif - int singular = 0; + size_type singular = 0; size_type size1 = m.size1 (); size_type size2 = m.size2 (); size_type size = (std::min) (size1, size2); @@ -131,7 +131,7 @@ namespace boost { namespace numeric { namespace ublas { #if BOOST_UBLAS_TYPE_CHECK matrix_type cm (m); #endif - int singular = 0; + size_type singular = 0; size_type size1 = m.size1 (); size_type size2 = m.size2 (); size_type size = (std::min) (size1, size2); @@ -175,7 +175,7 @@ namespace boost { namespace numeric { namespace ublas { #if BOOST_UBLAS_TYPE_CHECK matrix_type cm (m); #endif - int singular = 0; + size_type singular = 0; size_type size1 = m.size1 (); size_type size2 = m.size2 (); size_type size = (std::min) (size1, size2); From b7764d7ecd7a8ce585e6838b098d1450eec69c9d Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Mon, 5 Oct 2009 22:37:32 +0000 Subject: [PATCH 027/280] fix #3230: (coordinate_vector::set_filled() has wrong return statement) * merged [56611] into release svn path=/branches/release/boost/numeric/ublas/; revision=56612 --- include/boost/numeric/ublas/vector_sparse.hpp | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/include/boost/numeric/ublas/vector_sparse.hpp b/include/boost/numeric/ublas/vector_sparse.hpp index 2e66f2c6..6a49d060 100644 --- a/include/boost/numeric/ublas/vector_sparse.hpp +++ b/include/boost/numeric/ublas/vector_sparse.hpp @@ -53,8 +53,8 @@ namespace boost { namespace numeric { namespace ublas { else *p = s; } - - public: + + public: // Construction and destruction sparse_vector_element (vector_type &v, size_type i): container_reference (v), i_ (i) { @@ -428,7 +428,7 @@ namespace boost { namespace numeric { namespace ublas { return; data ().erase (it); } - + // Zeroing BOOST_UBLAS_INLINE void clear () { @@ -552,11 +552,11 @@ namespace boost { namespace numeric { namespace ublas { class iterator; // Element lookup - // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. + // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. const_iterator find (size_type i) const { return const_iterator (*this, data ().lower_bound (i)); } - // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. + // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. iterator find (size_type i) { return iterator (*this, data ().lower_bound (i)); } @@ -992,7 +992,7 @@ namespace boost { namespace numeric { namespace ublas { } storage_invariants (); } - + // Zeroing BOOST_UBLAS_INLINE void clear () { @@ -1143,11 +1143,11 @@ namespace boost { namespace numeric { namespace ublas { class iterator; // Element lookup - // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. + // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. const_iterator find (size_type i) const { return const_iterator (*this, detail::lower_bound (index_data_.begin (), index_data_.begin () + filled_, k_based (i), std::less ())); } - // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. + // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. iterator find (size_type i) { return iterator (*this, detail::lower_bound (index_data_.begin (), index_data_.begin () + filled_, k_based (i), std::less ())); } @@ -1479,7 +1479,6 @@ namespace boost { namespace numeric { namespace ublas { sorted_filled_ = sorted; filled_ = filled; storage_invariants (); - return filled_; } BOOST_UBLAS_INLINE index_array_type &index_data () { @@ -1627,7 +1626,7 @@ namespace boost { namespace numeric { namespace ublas { } storage_invariants (); } - + // Zeroing BOOST_UBLAS_INLINE void clear () { @@ -1636,7 +1635,7 @@ namespace boost { namespace numeric { namespace ublas { sorted_ = true; storage_invariants (); } - + // Assignment BOOST_UBLAS_INLINE coordinate_vector &operator = (const coordinate_vector &v) { @@ -1756,7 +1755,7 @@ namespace boost { namespace numeric { namespace ublas { // sort new elements and merge std::sort (iunsorted, ipa.end ()); std::inplace_merge (ipa.begin (), iunsorted, ipa.end ()); - + // sum duplicates with += and remove size_type filled = 0; for (size_type i = 1; i < filled_; ++ i) { @@ -1821,12 +1820,12 @@ namespace boost { namespace numeric { namespace ublas { class iterator; // Element lookup - // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. + // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. const_iterator find (size_type i) const { sort (); return const_iterator (*this, detail::lower_bound (index_data_.begin (), index_data_.begin () + filled_, k_based (i), std::less ())); } - // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. + // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. iterator find (size_type i) { sort (); return iterator (*this, detail::lower_bound (index_data_.begin (), index_data_.begin () + filled_, k_based (i), std::less ())); @@ -2038,7 +2037,7 @@ namespace boost { namespace numeric { namespace ublas { size_type size_; size_type capacity_; mutable typename index_array_type::size_type filled_; - mutable typename index_array_type::size_type sorted_filled_; + mutable typename index_array_type::size_type sorted_filled_; mutable bool sorted_; mutable index_array_type index_data_; mutable value_array_type value_data_; From c71b6c040a68d69a3c2dfa48b0cc3cf1738e2278 Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Mon, 5 Oct 2009 22:48:29 +0000 Subject: [PATCH 028/280] fix #3499 and fix #3501: * added inline to free helper functions * added missing concept check * fixed broken internal checks svn path=/branches/release/boost/numeric/ublas/; revision=56614 --- .../boost/numeric/ublas/detail/concepts.hpp | 45 ++++++++++++++----- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/include/boost/numeric/ublas/detail/concepts.hpp b/include/boost/numeric/ublas/detail/concepts.hpp index c0a0cfd0..d647a73c 100644 --- a/include/boost/numeric/ublas/detail/concepts.hpp +++ b/include/boost/numeric/ublas/detail/concepts.hpp @@ -499,6 +499,7 @@ namespace boost { namespace numeric { namespace ublas { void constraints () { function_requires< VectorConcept >(); + function_requires< DefaultConstructible >(); function_requires< Mutable_VectorExpressionConcept >(); size_type n (0); value_type t = value_type (); @@ -579,6 +580,7 @@ namespace boost { namespace numeric { namespace ublas { void constraints () { function_requires< MatrixConcept >(); + function_requires< DefaultConstructible >(); function_requires< Mutable_MatrixExpressionConcept >(); size_type n (0); value_type t = value_type (); @@ -636,61 +638,73 @@ namespace boost { namespace numeric { namespace ublas { T ZeroElement (T); template<> + BOOST_UBLAS_INLINE float ZeroElement (float) { return 0.f; } template<> + BOOST_UBLAS_INLINE double ZeroElement (double) { return 0.; } template<> + BOOST_UBLAS_INLINE vector ZeroElement (vector) { return zero_vector (); } template<> + BOOST_UBLAS_INLINE vector ZeroElement (vector) { return zero_vector (); } template<> + BOOST_UBLAS_INLINE matrix ZeroElement (matrix) { return zero_matrix (); } template<> + BOOST_UBLAS_INLINE matrix ZeroElement (matrix) { return zero_matrix (); } template<> + BOOST_UBLAS_INLINE std::complex ZeroElement (std::complex) { return std::complex (0.f); } template<> + BOOST_UBLAS_INLINE std::complex ZeroElement (std::complex) { return std::complex (0.); } template<> + BOOST_UBLAS_INLINE vector > ZeroElement (vector >) { return zero_vector > (); } template<> + BOOST_UBLAS_INLINE vector > ZeroElement (vector >) { return zero_vector > (); } template<> + BOOST_UBLAS_INLINE matrix > ZeroElement (matrix >) { return zero_matrix > (); } template<> + BOOST_UBLAS_INLINE matrix > ZeroElement (matrix >) { return zero_matrix > (); @@ -700,41 +714,49 @@ namespace boost { namespace numeric { namespace ublas { T OneElement (T); template<> + BOOST_UBLAS_INLINE float OneElement (float) { return 1.f; } template<> + BOOST_UBLAS_INLINE double OneElement (double) { return 1.; } template<> + BOOST_UBLAS_INLINE matrix OneElement (matrix) { return identity_matrix (); } template<> + BOOST_UBLAS_INLINE matrix OneElement (matrix) { return identity_matrix (); } template<> + BOOST_UBLAS_INLINE std::complex OneElement (std::complex) { return std::complex (1.f); } template<> + BOOST_UBLAS_INLINE std::complex OneElement (std::complex) { return std::complex (1.); } template<> + BOOST_UBLAS_INLINE matrix > OneElement (matrix >) { return identity_matrix > (); } template<> + BOOST_UBLAS_INLINE matrix > OneElement (matrix >) { return identity_matrix > (); @@ -886,6 +908,7 @@ namespace boost { namespace numeric { namespace ublas { } }; + BOOST_UBLAS_INLINE void concept_checks () { // Allow tests to be group to keep down compiler storage requirement @@ -1402,12 +1425,12 @@ namespace boost { namespace numeric { namespace ublas { function_requires< IndexedRandomAccess1DIteratorConcept >(); } - function_requires< ScalarExpressionConcept, vector_sum > > >(); - function_requires< ScalarExpressionConcept, vector_norm_1 > > >(); - function_requires< ScalarExpressionConcept, vector_norm_2 > > >(); - function_requires< ScalarExpressionConcept, vector_norm_inf > > >(); + function_requires< ScalarExpressionConcept, vector_sum > > > >(); + function_requires< ScalarExpressionConcept, vector_norm_1 > > > >(); + function_requires< ScalarExpressionConcept, vector_norm_2 > > > >(); + function_requires< ScalarExpressionConcept, vector_norm_inf > > > >(); - function_requires< ScalarExpressionConcept, vector, vector_inner_prod > > >(); + function_requires< ScalarExpressionConcept, vector, vector_inner_prod, vector, T> > > >(); #endif // Matrix Expressions @@ -1479,29 +1502,29 @@ namespace boost { namespace numeric { namespace ublas { } { - typedef matrix_vector_binary1, vector, matrix_vector_prod1 > expression_model; + typedef matrix_vector_binary1, vector, matrix_vector_prod1, vector, T> > expression_model; function_requires< VectorExpressionConcept >(); function_requires< IndexedRandomAccess1DIteratorConcept >(); function_requires< IndexedRandomAccess1DIteratorConcept >(); } { - typedef matrix_vector_binary2, matrix, matrix_vector_prod2 > expression_model; + typedef matrix_vector_binary2, matrix, matrix_vector_prod2, vector, T > > expression_model; function_requires< VectorExpressionConcept >(); function_requires< IndexedRandomAccess1DIteratorConcept >(); function_requires< IndexedRandomAccess1DIteratorConcept >(); } { - typedef matrix_matrix_binary, matrix, matrix_matrix_prod > expression_model; + typedef matrix_matrix_binary, matrix, matrix_matrix_prod, matrix, T > > expression_model; function_requires< MatrixExpressionConcept >(); function_requires< IndexedRandomAccess2DIteratorConcept >(); function_requires< IndexedRandomAccess2DIteratorConcept >(); } - function_requires< ScalarExpressionConcept, matrix_norm_1 > > >(); - function_requires< ScalarExpressionConcept, matrix_norm_frobenius > > >(); - function_requires< ScalarExpressionConcept, matrix_norm_inf > > >(); + function_requires< ScalarExpressionConcept, matrix_norm_1 > > > >(); + function_requires< ScalarExpressionConcept, matrix_norm_frobenius > > > >(); + function_requires< ScalarExpressionConcept, matrix_norm_inf > > > >(); #endif #ifdef EXTERNAL From 3cf8b6c4d0c27e829787eaa7491a53e168d52709 Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Tue, 6 Oct 2009 21:12:55 +0000 Subject: [PATCH 029/280] libs/numeric/ublas/test/triangular_access.cpp: fixed compile failure with MSVC 7.1 svn path=/branches/release/libs/numeric/ublas/; revision=56620 --- test/triangular_access.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/triangular_access.cpp b/test/triangular_access.cpp index cccf80d0..9777632b 100644 --- a/test/triangular_access.cpp +++ b/test/triangular_access.cpp @@ -14,6 +14,10 @@ #include "common/testhelper.hpp" +#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION +using boost::numeric::ublas::iterator1_tag; +using boost::numeric::ublas::iterator2_tag; +#endif template < class MAT > void test_iterator( MAT & A ) { @@ -26,8 +30,13 @@ void test_iterator( MAT & A ) { typename MAT::iterator1 it1_end = A.end1(); for ( ; it1 != it1_end; ++it1 ) { +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION typename MAT::iterator2 it2 = it1.begin(); typename MAT::iterator2 it2_end = it1.end(); +#else + typename MAT::iterator2 it2 = begin(it1, iterator1_tag()); + typename MAT::iterator2 it2_end = end(it1, iterator1_tag()); +#endif for ( ; it2 != it2_end ; ++ it2 ) { #ifndef NOMESSAGES std::cout << "( " << it2.index1() << ", " << it2.index2() << ") " << std::flush; @@ -52,8 +61,13 @@ void test_iterator2( MAT & A ) { typename MAT::iterator2 it2_end = A.end2(); for ( ; it2 != it2_end; ++it2 ) { +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION typename MAT::iterator1 it1 = it2.begin(); typename MAT::iterator1 it1_end = it2.end(); +#else + typename MAT::iterator1 it1 = begin(it2, iterator2_tag()); + typename MAT::iterator1 it1_end = end(it2, iterator2_tag()); +#endif for ( ; it1 != it1_end ; ++ it1 ) { #ifndef NOMESSAGES std::cout << "( " << it1.index1() << ", " << it1.index2() << ") " << std::flush; @@ -81,8 +95,13 @@ test_iterator3( const MAT & A ) { typename MAT::const_iterator1 it1_end = A.end1(); for ( ; it1 != it1_end; ++it1 ) { +#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION typename MAT::const_iterator2 it2 = it1.begin(); typename MAT::const_iterator2 it2_end = it1.end(); +#else + typename MAT::const_iterator2 it2 = begin(it1, iterator1_tag()); + typename MAT::const_iterator2 it2_end = end(it1, iterator1_tag()); +#endif for ( ; it2 != it2_end ; ++ it2 ) { #ifndef NOMESSAGES std::cout << "( " << it2.index1() << ", " << it2.index2() << ") " << std::flush; From 59c36260f353e1e3145574245f79b2d510d9a575 Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Tue, 6 Oct 2009 23:31:22 +0000 Subject: [PATCH 030/280] see #3397 * merged [56045] into release * add enable_if to operator* for scalar*vector, vector*scalar, scalar*matrix, matrix*scalar in order to hinder unexpected instantiation. svn path=/branches/release/boost/numeric/ublas/; revision=56625 --- include/boost/numeric/ublas/matrix_expression.hpp | 4 ++++ include/boost/numeric/ublas/vector_expression.hpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/include/boost/numeric/ublas/matrix_expression.hpp b/include/boost/numeric/ublas/matrix_expression.hpp index 37ef2204..f59045f4 100644 --- a/include/boost/numeric/ublas/matrix_expression.hpp +++ b/include/boost/numeric/ublas/matrix_expression.hpp @@ -2940,7 +2940,9 @@ namespace boost { namespace numeric { namespace ublas { // (t * m) [i] [j] = t * m [i] [j] template BOOST_UBLAS_INLINE + typename enable_if< is_convertible, typename matrix_binary_scalar1_traits >::result_type + >::type operator * (const T1 &e1, const matrix_expression &e2) { typedef typename matrix_binary_scalar1_traits >::expression_type expression_type; @@ -3373,7 +3375,9 @@ namespace boost { namespace numeric { namespace ublas { // (m * t) [i] [j] = m [i] [j] * t template BOOST_UBLAS_INLINE + typename enable_if< is_convertible, typename matrix_binary_scalar2_traits >::result_type + >::type operator * (const matrix_expression &e1, const T2 &e2) { typedef typename matrix_binary_scalar2_traits >::expression_type expression_type; diff --git a/include/boost/numeric/ublas/vector_expression.hpp b/include/boost/numeric/ublas/vector_expression.hpp index e383ab38..a5cf3104 100644 --- a/include/boost/numeric/ublas/vector_expression.hpp +++ b/include/boost/numeric/ublas/vector_expression.hpp @@ -1170,7 +1170,9 @@ namespace boost { namespace numeric { namespace ublas { // (t * v) [i] = t * v [i] template BOOST_UBLAS_INLINE + typename enable_if< is_convertible, typename vector_binary_scalar1_traits >::result_type + >::type operator * (const T1 &e1, const vector_expression &e2) { typedef typename vector_binary_scalar1_traits >::expression_type expression_type; @@ -1395,7 +1397,9 @@ namespace boost { namespace numeric { namespace ublas { // (v * t) [i] = v [i] * t template BOOST_UBLAS_INLINE + typename enable_if< is_convertible, typename vector_binary_scalar2_traits >::result_type + >::type operator * (const vector_expression &e1, const T2 &e2) { typedef typename vector_binary_scalar2_traits >::expression_type expression_type; From 75ec0271cbfff5c4a0bf8fcff3b64e327be334dd Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Tue, 6 Oct 2009 23:47:53 +0000 Subject: [PATCH 031/280] close #3293 (resized identity matrix) * merged [56163] into release svn path=/branches/release/boost/numeric/ublas/; revision=56626 --- include/boost/numeric/ublas/matrix.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/boost/numeric/ublas/matrix.hpp b/include/boost/numeric/ublas/matrix.hpp index 9dcf52e3..505726e6 100644 --- a/include/boost/numeric/ublas/matrix.hpp +++ b/include/boost/numeric/ublas/matrix.hpp @@ -2466,11 +2466,13 @@ namespace boost { namespace numeric { namespace ublas { void resize (size_type size, bool preserve = true) { size1_ = size; size2_ = size; + size_common_ = ((std::min)(size1_, size2_)); } BOOST_UBLAS_INLINE void resize (size_type size1, size_type size2, bool /*preserve*/ = true) { size1_ = size1; size2_ = size2; + size_common_ = ((std::min)(size1_, size2_)); } // Element access @@ -2487,6 +2489,7 @@ namespace boost { namespace numeric { namespace ublas { identity_matrix &operator = (const identity_matrix &m) { size1_ = m.size1_; size2_ = m.size2_; + size_common_ = m.size_common_; return *this; } BOOST_UBLAS_INLINE @@ -2501,6 +2504,7 @@ namespace boost { namespace numeric { namespace ublas { if (this != &m) { std::swap (size1_, m.size1_); std::swap (size2_, m.size2_); + std::swap (size_common_, m.size_common_); } } BOOST_UBLAS_INLINE From 7e70e61fee4c74387c73b9947ea6a057aee64254 Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Tue, 6 Oct 2009 23:53:19 +0000 Subject: [PATCH 032/280] see #3108 * merged [54232] into release svn path=/branches/release/boost/numeric/ublas/; revision=56627 --- include/boost/numeric/ublas/symmetric.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/numeric/ublas/symmetric.hpp b/include/boost/numeric/ublas/symmetric.hpp index 8aede25a..ea1bde51 100644 --- a/include/boost/numeric/ublas/symmetric.hpp +++ b/include/boost/numeric/ublas/symmetric.hpp @@ -1142,7 +1142,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator1 find1 (int rank, size_type i, size_type j) { if (rank == 1) - i = triangular_type::mutable_restrict1 (i, j); + i = triangular_type::mutable_restrict1 (i, j, size1(), size2()); return iterator1 (*this, data ().find1 (rank, i, j)); } BOOST_UBLAS_INLINE @@ -1172,7 +1172,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE iterator2 find2 (int rank, size_type i, size_type j) { if (rank == 1) - j = triangular_type::mutable_restrict2 (i, j); + j = triangular_type::mutable_restrict2 (i, j, size1(), size2()); return iterator2 (*this, data ().find2 (rank, i, j)); } From 567f8cc693fc2e34a105ee645ad1526c11df3bda Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sat, 17 Oct 2009 01:10:45 +0000 Subject: [PATCH 033/280] rm cmake from the release branch before it goes out broken. Policy dictates that you never commit to release, you commit to trunk and merge to release. svn path=/branches/release/libs/numeric/ublas/; revision=56941 --- test/CMakeLists.txt | 87 --------------------------------------------- 1 file changed, 87 deletions(-) delete mode 100644 test/CMakeLists.txt diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 7e2c8703..00000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,87 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -# Define features to test: -# Value types: USE_FLOAT USE_DOUBLE USE_STD_COMPLEX -# Proxies: USE_RANGE USE_SLICE -# Storage types: USE_BOUNDED_ARRAY USE_UNBOUNDED_ARRAY -# Vector types: USE_STD_VECTOR USE_BOUNDED_VECTOR -# Matrix types: USE_MATRIX USE_BOUNDED_MATRIX USE_VECTOR_OF_VECTOR -# Adaptors: USE_ADAPTOR - -set(UBLAS_TESTSET_DEFINES - "-DUSE_DOUBLE -DUSE_STD_COMPLEX -DUSE_RANGE -DUSE_SLICE -DUSE_UNBOUNDED_ARRAY -DUSE_STD_VECTOR -DUSE_BOUNDED_VECTOR -DUSE_MATRIX") - -# Sparse storage: USE_MAP_ARRAY USE_STD_MAP -# Sparse vectors: USE_MAPPED_VECTOR USE_COMPRESSED_VECTOR USE_COORDINATE_VECTOR -# Sparse matrices: USE_MAPPED_MATRIX USE_COMPRESSED_MATRIX USE_COORDINATE_MATRIX USE_MAPPED_VECTOR_OF_MAPPED_VECTOR USE_GENERALIZED_VECTOR_OF_VECTOR - -set(UBLAS_TESTSET_SPARSE_DEFINES - "-DUSE_DOUBLE -DUSE_STD_COMPLEX -DUSE_UNBOUNDED_ARRAY -DUSE_MAP_ARRAY -DUSE_STD_MAP -DUSE_MAPPED_VECTOR -DUSE_COMPRESSED_VECTOR -DUSE_COORDINATE_VECTOR -DUSE_MAPPED_MATRIX -DUSE_COMPRESSED_MATRIX -DUSE_COORDINATE_MATRIX") - -# Definitions for uBLAS tests -add_definitions(-DBOOST_UBLAS_NO_EXCEPTIONS) -# TODO: vacpp:"BOOST_UBLAS_NO_ELEMENT_PROXIES" - -#------------------------------------------------------------------------- -#-- Needed include directories for the tests -boost_additional_test_dependencies(numeric BOOST_DEPENDS test) -#------------------------------------------------------------------------- - - -boost_test_run(ublas_test1 - test1.cpp test11.cpp test12.cpp test13.cpp - COMPILE_FLAGS "${UBLAS_TESTSET_DEFINES}") - -boost_test_run(ublas_test2 - test2.cpp test21.cpp test22.cpp test23.cpp - COMPILE_FLAGS "${UBLAS_TESTSET_DEFINES}") - -boost_test_run(ublas_test3 - test3.cpp test31.cpp test32.cpp test33.cpp - COMPILE_FLAGS "${UBLAS_TESTSET_SPARSE_DEFINES}") - -boost_test_run(ublas_test4 - test4.cpp test42.cpp test43.cpp - COMPILE_FLAGS "${UBLAS_TESTSET_DEFINES}") - -boost_test_run(ublas_test5 - test5.cpp test52.cpp test53.cpp - COMPILE_FLAGS "${UBLAS_TESTSET_DEFINES}") - -boost_test_run(ublas_test6 - test6.cpp test62.cpp test63.cpp - COMPILE_FLAGS "${UBLAS_TESTSET_DEFINES}") - -# Test commented out because boost::interval does not behave like a scalar -# boost_test_run(test7 -# test7.cpp test71.cpp test72.cpp test73.cpp -# COMPILE_FLAGS "-DBOOST_UBLAS_USE_INTERVAL ${UBLAS_TESTSET_DEFINES}") - -boost_test_run(placement_new) - -boost_test_run(test_lu) - -boost_test_run(triangular_access - triangular_access.cpp - COMPILE_FLAGS "-DNOMESSAGES") - -boost_test_run(triangular_layout - triangular_layout.cpp) - -boost_test_run(comp_mat_erase) - -SET(test_compile_flags "-DEXTERNAL") -#-- Intel Compiler flags -IF( ${CMAKE_CXX_COMPILER} MATCHES "icpc" ) - SET(test_compile_flags "${test_compile_flags} -Xc") -ENDIF( ${CMAKE_CXX_COMPILER} MATCHES "icpc" ) - -IF (APPLE) - SET(test_compile_flags "${test_compile_flags} -fabi-version=0") -ENDIF (APPLE) - -boost_test_compile(concepts COMPILE_FLAGS "-DEXTERNAL") From 38d3b9117a3c69e8da23a89b0c897218615cc2bb Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Wed, 28 Oct 2009 23:09:57 +0000 Subject: [PATCH 034/280] see #3449: * merged [57209] into release svn path=/branches/release/libs/numeric/ublas/; revision=57210 --- doc/release_notes.htm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/release_notes.htm b/doc/release_notes.htm index 6cb560f7..55798ec3 100644 --- a/doc/release_notes.htm +++ b/doc/release_notes.htm @@ -28,6 +28,9 @@ implemented. They can be enabled by setting BOOST_UBLAS_MOVE_SEMANTICS. More details are on the preprocessor options page. +
  • Introduce new free functions. See [3449], +the new tests in libs/numeric/ublas/test and the inline documentation of the files in boost/numeric/ublas/operation/. +
  • bug fixes

    From 5442d46ffd4caa1875fe9fd4b27849d257ec1794 Mon Sep 17 00:00:00 2001 From: Gunter Winkler Date: Tue, 6 Apr 2010 20:18:13 +0000 Subject: [PATCH 035/280] fix #3501: merge changes 57202,57208,61114 into release boost/numeric/ublas/detail/concepts.hpp libs/numeric/ublas/doc/release_notes.htm svn path=/branches/release/boost/numeric/ublas/; revision=61115 --- doc/release_notes.htm | 8 +++--- .../boost/numeric/ublas/detail/concepts.hpp | 28 +++++-------------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/doc/release_notes.htm b/doc/release_notes.htm index 94ec08dc..c8833ad6 100644 --- a/doc/release_notes.htm +++ b/doc/release_notes.htm @@ -25,6 +25,8 @@
    • [3968] fixed coordinate_matrix sort problem on MSVC10
    • +
    • [3501] Moved free functions in concepts.hpp into anonymous namespace. +

    Release 1.41.1

    @@ -45,11 +47,9 @@ the new tests in libs/numeric/ublas/test and the inline documentation o

    bug fixes

      -
    • [3293]Fix resizing problem in identity_matrix +
    • [3293] Fix resizing problem in identity_matrix
    • -
    • [3499]Add DefaultConstructible to concept checks -
    • -
    • [3501]Add inline to free functions in concepts.hpp +
    • [3499] Add DefaultConstructible to concept checks
    diff --git a/include/boost/numeric/ublas/detail/concepts.hpp b/include/boost/numeric/ublas/detail/concepts.hpp index ce99744b..8133670c 100644 --- a/include/boost/numeric/ublas/detail/concepts.hpp +++ b/include/boost/numeric/ublas/detail/concepts.hpp @@ -634,77 +634,70 @@ namespace boost { namespace numeric { namespace ublas { } }; + /** introduce anonymous namespace to make following functions + * local to the current compilation unit. + */ + namespace { + template T ZeroElement (T); template<> - BOOST_UBLAS_INLINE float ZeroElement (float) { return 0.f; } template<> - BOOST_UBLAS_INLINE double ZeroElement (double) { return 0.; } template<> - BOOST_UBLAS_INLINE vector ZeroElement (vector) { return zero_vector (); } template<> - BOOST_UBLAS_INLINE vector ZeroElement (vector) { return zero_vector (); } template<> - BOOST_UBLAS_INLINE matrix ZeroElement (matrix) { return zero_matrix (); } template<> - BOOST_UBLAS_INLINE matrix ZeroElement (matrix) { return zero_matrix (); } template<> - BOOST_UBLAS_INLINE std::complex ZeroElement (std::complex) { return std::complex (0.f); } template<> - BOOST_UBLAS_INLINE std::complex ZeroElement (std::complex) { return std::complex (0.); } template<> - BOOST_UBLAS_INLINE vector > ZeroElement (vector >) { return zero_vector > (); } template<> - BOOST_UBLAS_INLINE vector > ZeroElement (vector >) { return zero_vector > (); } template<> - BOOST_UBLAS_INLINE matrix > ZeroElement (matrix >) { return zero_matrix > (); } template<> - BOOST_UBLAS_INLINE matrix > ZeroElement (matrix >) { return zero_matrix > (); @@ -714,49 +707,41 @@ namespace boost { namespace numeric { namespace ublas { T OneElement (T); template<> - BOOST_UBLAS_INLINE float OneElement (float) { return 1.f; } template<> - BOOST_UBLAS_INLINE double OneElement (double) { return 1.; } template<> - BOOST_UBLAS_INLINE matrix OneElement (matrix) { return identity_matrix (); } template<> - BOOST_UBLAS_INLINE matrix OneElement (matrix) { return identity_matrix (); } template<> - BOOST_UBLAS_INLINE std::complex OneElement (std::complex) { return std::complex (1.f); } template<> - BOOST_UBLAS_INLINE std::complex OneElement (std::complex) { return std::complex (1.); } template<> - BOOST_UBLAS_INLINE matrix > OneElement (matrix >) { return identity_matrix > (); } template<> - BOOST_UBLAS_INLINE matrix > OneElement (matrix >) { return identity_matrix > (); @@ -908,7 +893,6 @@ namespace boost { namespace numeric { namespace ublas { } }; - BOOST_UBLAS_INLINE void concept_checks () { // Allow tests to be group to keep down compiler storage requirement @@ -1549,6 +1533,8 @@ namespace boost { namespace numeric { namespace ublas { #endif } + } // end of anonymous namespace + }}} #endif From 83a1dd07f83317b7714bfe2e24b3501883921597 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sun, 9 May 2010 01:40:22 +0000 Subject: [PATCH 036/280] Merge standards-conformance fixes for Ublas svn path=/branches/release/boost/numeric/ublas/; revision=61868 --- include/boost/numeric/ublas/functional.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/numeric/ublas/functional.hpp b/include/boost/numeric/ublas/functional.hpp index 85f14d0c..3512e845 100644 --- a/include/boost/numeric/ublas/functional.hpp +++ b/include/boost/numeric/ublas/functional.hpp @@ -2016,25 +2016,25 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE size_type restrict1 (size_type i, size_type j, size_type size1, size_type size2) { - return mutable_restrict1(i, j, size1, size2); + return basic_unit_lower::mutable_restrict1(i, j, size1, size2); } static BOOST_UBLAS_INLINE size_type restrict2 (size_type i, size_type j, size_type size1, size_type size2) { - return mutable_restrict2(i, j, size1, size2); + return basic_unit_lower::mutable_restrict2(i, j, size1, size2); } // return an index between the first and (1+last) filled row static BOOST_UBLAS_INLINE size_type global_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { - return global_mutable_restrict1(index1, size1, index2, size2); + return basic_unit_lower::global_mutable_restrict1(index1, size1, index2, size2); } // return an index between the first and (1+last) filled column static BOOST_UBLAS_INLINE size_type global_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { - return global_mutable_restrict2(index1, size1, index2, size2); + return basic_unit_lower::global_mutable_restrict2(index1, size1, index2, size2); } }; From 3bfccb3730cb7bf2074c1833a60f6c76051a719e Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Fri, 2 Jul 2010 15:37:14 +0000 Subject: [PATCH 037/280] Merged changes for #2981, #4166, and #4377 to release branch svn path=/branches/release/boost/numeric/ublas/; revision=63523 --- include/boost/numeric/ublas/functional.hpp | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/include/boost/numeric/ublas/functional.hpp b/include/boost/numeric/ublas/functional.hpp index 3512e845..f5e2dcef 100644 --- a/include/boost/numeric/ublas/functional.hpp +++ b/include/boost/numeric/ublas/functional.hpp @@ -1730,22 +1730,22 @@ namespace boost { namespace numeric { namespace ublas { // FIXME: this should not be used at all static BOOST_UBLAS_INLINE - size_type restrict1 (size_type i, size_type j) { + size_type restrict1 (size_type i, size_type /* j */) { return i; } static BOOST_UBLAS_INLINE - size_type restrict2 (size_type i, size_type j) { + size_type restrict2 (size_type /* i */, size_type j) { return j; } static BOOST_UBLAS_INLINE - size_type mutable_restrict1 (size_type i, size_type j) { + size_type mutable_restrict1 (size_type i, size_type /* j */) { return i; } static BOOST_UBLAS_INLINE - size_type mutable_restrict2 (size_type i, size_type j) { + size_type mutable_restrict2 (size_type /* i */, size_type j) { return j; } }; @@ -1780,7 +1780,7 @@ namespace boost { namespace numeric { namespace ublas { template static BOOST_UBLAS_INLINE - size_type element (LAYOUT l, size_type i, size_type size_i, size_type j, size_type size_j) { + size_type element (LAYOUT /* l */, size_type i, size_type size_i, size_type j, size_type size_j) { return L::element(typename LAYOUT::transposed_layout(), j, size_j, i, size_i); } @@ -1877,7 +1877,7 @@ namespace boost { namespace numeric { namespace ublas { // return nearest valid mutable index in column j static BOOST_UBLAS_INLINE - size_type mutable_restrict1 (size_type i, size_type j, size_type size1, size_type size2) { + size_type mutable_restrict1 (size_type i, size_type j, size_type size1, size_type /* size2 */) { return (std::max)(j, (std::min) (size1, i)); } // return nearest valid mutable index in row i @@ -1890,26 +1890,26 @@ namespace boost { namespace numeric { namespace ublas { // return an index between the first and (1+last) filled row static BOOST_UBLAS_INLINE - size_type global_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { + size_type global_restrict1 (size_type index1, size_type size1, size_type /* index2 */, size_type /* size2 */) { return (std::max)(size_type(0), (std::min)(size1, index1) ); } // return an index between the first and (1+last) filled column static BOOST_UBLAS_INLINE - size_type global_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { + size_type global_restrict2 (size_type /* index1 */, size_type /* size1 */, size_type index2, size_type size2) { return (std::max)(size_type(0), (std::min)(size2, index2) ); } // return an index between the first and (1+last) filled mutable row static BOOST_UBLAS_INLINE - size_type global_mutable_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { + size_type global_mutable_restrict1 (size_type index1, size_type size1, size_type /* index2 */, size_type /* size2 */) { return (std::max)(size_type(0), (std::min)(size1, index1) ); } // return an index between the first and (1+last) filled mutable column static BOOST_UBLAS_INLINE - size_type global_mutable_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { + size_type global_mutable_restrict2 (size_type /* index1 */, size_type /* size1 */, size_type index2, size_type size2) { return (std::max)(size_type(0), (std::min)(size2, index2) ); } }; @@ -1950,25 +1950,25 @@ namespace boost { namespace numeric { namespace ublas { static BOOST_UBLAS_INLINE - size_type mutable_restrict1 (size_type i, size_type j, size_type size1, size_type size2) { + size_type mutable_restrict1 (size_type i, size_type j, size_type size1, size_type /* size2 */) { return (std::max)(j+1, (std::min) (size1, i)); } static BOOST_UBLAS_INLINE - size_type mutable_restrict2 (size_type i, size_type j, size_type size1, size_type size2) { + size_type mutable_restrict2 (size_type i, size_type j, size_type /* size1 */, size_type /* size2 */) { return (std::max)(size_type(0), (std::min) (i, j)); } // return an index between the first and (1+last) filled mutable row static BOOST_UBLAS_INLINE - size_type global_mutable_restrict1 (size_type index1, size_type size1, size_type index2, size_type size2) { + size_type global_mutable_restrict1 (size_type index1, size_type size1, size_type /* index2 */, size_type /* size2 */) { return (std::max)(size_type(1), (std::min)(size1, index1) ); } // return an index between the first and (1+last) filled mutable column static BOOST_UBLAS_INLINE - size_type global_mutable_restrict2 (size_type index1, size_type size1, size_type index2, size_type size2) { + size_type global_mutable_restrict2 (size_type /* index1 */, size_type /* size1 */, size_type index2, size_type size2) { BOOST_UBLAS_CHECK( size2 >= 1 , external_logic() ); return (std::max)(size_type(0), (std::min)(size2-1, index2) ); } From addc67857af8132ede596076cbc9d9156146501d Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Sat, 3 Jul 2010 18:37:39 +0000 Subject: [PATCH 038/280] Merged r62693, r62932, r62933, r62998, r62999, r63000, r63002, r63048, r63049, r63084, r63189, r63190, r63227, r63234, r63241, r63244, r63268, r63269, r63329, r63332, r63333, r63334, r63335, r63405, r63466, r63472, r63511, r63530, r63535, r63536, r61796, and r61841 from trunk svn path=/branches/release/boost/numeric/ublas/; revision=63554 From f0da6cb7929ef615472ef4f570742acdbe94b51a Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Sat, 3 Jul 2010 19:56:35 +0000 Subject: [PATCH 039/280] Merged r63557 from trunk svn path=/branches/release/boost/numeric/ublas/; revision=63559 From b93a2f380f3427e4c7a4446ea1598ea3862bef26 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Sun, 4 Jul 2010 22:38:38 +0000 Subject: [PATCH 040/280] Spirit: merging from trunk upto rev. 61489 svn path=/branches/release/boost/numeric/ublas/; revision=63640 --- doc/banded.htm | 4 +- doc/bounded_array.htm | 2 +- doc/container_concept.htm | 4 +- doc/expression_concept.htm | 6 +- doc/hermitian.htm | 4 +- doc/iterator_concept.htm | 16 +- doc/matrix.htm | 12 +- doc/matrix_expression.htm | 12 +- doc/matrix_proxy.htm | 12 +- doc/matrix_sparse.htm | 22 +- doc/operations_overview.htm | 8 +- doc/overview.htm | 4 +- doc/range.htm | 4 +- doc/storage_concept.htm | 4 +- doc/storage_sparse.htm | 4 +- doc/symmetric.htm | 18 +- doc/triangular.htm | 12 +- doc/unbounded_array.htm | 2 +- doc/vector.htm | 10 +- doc/vector_expression.htm | 10 +- doc/vector_proxy.htm | 4 +- doc/vector_sparse.htm | 16 +- .../boost/numeric/ublas/detail/concepts.hpp | 10 +- .../ublas/experimental/sparse_view.hpp | 190 +++++++++--------- include/boost/numeric/ublas/traits.hpp | 129 +++++++++--- test/utils.hpp | 4 +- 26 files changed, 302 insertions(+), 221 deletions(-) diff --git a/doc/banded.htm b/doc/banded.htm index a9bb1aaf..8aa483f0 100644 --- a/doc/banded.htm +++ b/doc/banded.htm @@ -15,7 +15,7 @@

    Banded Matrix

    -

    Banded Matrix

    +

    Banded Matrix

    Description

    The templated class banded_matrix<T, F, A> is the base container adaptor for banded matrices. For a (m x @@ -316,7 +316,7 @@ parameters for the adapted array are unbounded_array<T> , bounded_array<T> and std::vector<T> .

    -

    Banded Adaptor

    +

    Banded Adaptor

    Description

    The templated class banded_adaptor<M> is a banded matrix adaptor for other matrices.

    diff --git a/doc/bounded_array.htm b/doc/bounded_array.htm index a793bdfb..3168af9d 100644 --- a/doc/bounded_array.htm +++ b/doc/bounded_array.htm @@ -12,7 +12,7 @@

    Bounded Array Storage

    -

    Bounded Array

    +

    Bounded Array

    Description

    The templated class bounded_array<T, N, ALLOC> implements a bounded storage array. The bounded array is similar to a C++ array type in that its maximum size is bounded by N and is allocated on the stack instead of the heap. Similarly a bounded_array requires no secondary storage and ALLOC is only used to specify size_type and difference_type.

    diff --git a/doc/container_concept.htm b/doc/container_concept.htm index 4d2d33ca..81618117 100644 --- a/doc/container_concept.htm +++ b/doc/container_concept.htm @@ -15,7 +15,7 @@

    Container Concepts

    -

    Vector

    +

    Vector

    Description

    A Vector describes common aspects of dense, packed and sparse vectors.

    @@ -211,7 +211,7 @@ The operator[] is added purely for convenience and compatibility with the std::vector. In uBLAS however, generally operator() is used for indexing because this can be used for both vectors and matrices.

    -

    Matrix

    +

    Matrix

    Description

    A Matrix describes common aspects of dense, packed and sparse matrices.

    diff --git a/doc/expression_concept.htm b/doc/expression_concept.htm index f1b1cb3a..545c3b78 100644 --- a/doc/expression_concept.htm +++ b/doc/expression_concept.htm @@ -12,7 +12,7 @@

    Expression Concepts

    -

    Scalar Expression

    +

    Scalar Expression

    Description

    A Scalar Expression is an expression convertible to a scalar type.

    @@ -92,7 +92,7 @@ evaluated scalar expression.

  • vector_scalar_unary
  • vector_scalar_binary
  • -

    Vector Expression

    +

    Vector Expression

    Description

    A Vector Expression is an expression evaluatable to a vector. Vector Expression provides an v.rend ().

  • matrix_vector_binary2
  • -

    Matrix Expression

    +

    Matrix Expression

    Description

    A Matrix Expression is an expression evaluatable to a matrix. Matrix Expression provides an

    Hermitian Matrix

    -

    Hermitian Matrix

    +

    Hermitian Matrix

    Description

    The templated class hermitian_matrix<T, F1, F2, A> is the base container adaptor for hermitian matrices. @@ -323,7 +323,7 @@ Supported parameters for the adapted array are unbounded_array<T> , bounded_array<T> and std::vector<T> .

    -

    Hermitian Adaptor

    +

    Hermitian Adaptor

    Description

    The templated class hermitian_adaptor<M, F> is a hermitian matrix adaptor for other matrices.

    diff --git a/doc/iterator_concept.htm b/doc/iterator_concept.htm index 0657df74..c9e4c995 100644 --- a/doc/iterator_concept.htm +++ b/doc/iterator_concept.htm @@ -17,8 +17,8 @@

    An Iterator is a restricted pointer-like object pointing into a vector or matrix container.

    -

    Indexed Bidirectional Iterator

    +

    Indexed Bidirectional Iterator

    Description

    An Indexed Bidirectional Iterator is an iterator of a container that can be dereferenced, incremented, decremented and carries @@ -296,8 +296,8 @@ operator

    • sparse_vector::iterator
    -

    Indexed Random Access Iterator

    +

    Indexed Random Access Iterator

    Description

    An Indexed Random Access Iterator is an iterator of a container that can be dereferenced, moved forward, moved backward and carries @@ -526,8 +526,8 @@ it2 + (it1 - it2).

    • vector::iterator
    -

    Indexed Bidirectional Column/Row Iterator

    +

    Indexed Bidirectional Column/Row Iterator

    Description

    An Indexed Bidirectional Column/Row Iterator is an iterator of a container that can be dereferenced, incremented, decremented and @@ -923,8 +923,8 @@ it2t.index1 () for all it2t with it2t ()

  • sparse_matrix::iterator1
  • sparse_matrix::iterator2
  • -

    Indexed Random Access Column/Row Iterator

    +

    Indexed Random Access Column/Row Iterator

    Description

    An Indexed Random Access Column/Row Iterator is an iterator of a container that can be dereferenced, incremented, decremented and diff --git a/doc/matrix.htm b/doc/matrix.htm index 0c909c79..69e31eed 100644 --- a/doc/matrix.htm +++ b/doc/matrix.htm @@ -15,7 +15,7 @@

    Matrix

    -

    Matrix

    +

    Matrix

    Description

    The templated class matrix<T, F, A> is the base container adaptor for dense matrices. For a (m x @@ -298,14 +298,14 @@ the reversed matrix.

    Notes

    -

    [1] Supported parameters +

    [1] Supported parameters for the storage organization are row_major and column_major.

    -

    [2] Common parameters +

    [2] Common parameters for the storage array are unbounded_array<T> , bounded_array<T> and std::vector<T> .

    -

    Identity Matrix

    +

    Identity Matrix

    Description

    The templated class identity_matrix<T, ALLOC> represents identity matrices. For a (m x n)-dimensional @@ -455,7 +455,7 @@ end of the reversed identity_matrix. -

    Zero Matrix

    +

    Zero Matrix

    Description

    The templated class zero_matrix<T, ALLOC> represents zero matrices. For a (m x n)-dimensional zero matrix and @@ -601,7 +601,7 @@ end of the reversed zero_matrix. -

    Scalar Matrix

    +

    Scalar Matrix

    Description

    The templated class scalar_matrix<T, ALLOC> represents scalar matrices. For a (m x n)-dimensional diff --git a/doc/matrix_expression.htm b/doc/matrix_expression.htm index 3960dec6..7f0b80fe 100644 --- a/doc/matrix_expression.htm +++ b/doc/matrix_expression.htm @@ -15,7 +15,7 @@

    Matrix Expressions

    -

    Matrix Expression

    +

    Matrix Expression

    Description

    The templated class matrix_expression<E> is required to be a public base of all classes which model the Matrix Expression concept.

    @@ -63,7 +63,7 @@ const

    Notes

    The operator[], row, column, range, slice and project functions have been removed. Use the free functions defined in matrix proxy instead.

    -

    Matrix Container

    +

    Matrix Container

    Description

    The templated class matrix_container<C> is required to be a public base of all classes which model the Matrix concept. @@ -110,7 +110,7 @@ const -

    Matrix References

    +

    Matrix References

    Reference

    Description

    The templated class matrix_reference<E> @@ -259,7 +259,7 @@ the reversed expression. -

    Matrix Operations

    +

    Matrix Operations

    Unary Operation Description

    Description

    The templated classes matrix_unary1<E, F> and @@ -805,7 +805,7 @@ int main () { std::cout << m * 2.0 << std::endl; } -

    Matrix Vector Operations

    +

    Matrix Vector Operations

    Binary Operation Description

    Description

    The templated classes matrix_vector_binary1<E1, E2, @@ -1146,7 +1146,7 @@ int main () { std::cout << solve (v, m, lower_tag ()) << std::endl; } -

    Matrix Matrix Operations

    +

    Matrix Matrix Operations

    Binary Operation Description

    Description

    The templated class matrix_matrix_binary<E1, E2, diff --git a/doc/matrix_proxy.htm b/doc/matrix_proxy.htm index 56e774d9..a9ac949c 100644 --- a/doc/matrix_proxy.htm +++ b/doc/matrix_proxy.htm @@ -15,7 +15,7 @@

    Matrix Proxies

    -

    Matrix Row

    +

    Matrix Row

    Description

    The templated class matrix_row<M> allows addressing a row of a matrix.

    @@ -236,7 +236,7 @@ int main () { } } -

    Matrix Column

    +

    Matrix Column

    Description

    The templated class matrix_column<M> allows addressing a column of a matrix.

    @@ -458,7 +458,7 @@ int main () { } } -

    Vector Range

    +

    Vector Range

    Description

    The templated class matrix_vector_range<M> allows addressing a sub vector of a matrix.

    @@ -644,7 +644,7 @@ the reversed matrix_vector_range. -

    Vector Slice

    +

    Vector Slice

    Description

    The templated class matrix_vector_slice<M> allows addressing a sliced sub vector of a matrix.

    @@ -830,7 +830,7 @@ the reversed matrix_vector_slice. -

    Matrix Range

    +

    Matrix Range

    Description

    The templated class matrix_range<M> allows addressing a sub matrix of a matrix.

    @@ -1121,7 +1121,7 @@ int main () { std::cout << project (m, range (0, 3), range (0, 3)) << std::endl; } -

    Matrix Slice

    +

    Matrix Slice

    Description

    The templated class matrix_slice<M> allows addressing a sliced sub matrix of a matrix.

    diff --git a/doc/matrix_sparse.htm b/doc/matrix_sparse.htm index e08781ea..807d1786 100644 --- a/doc/matrix_sparse.htm +++ b/doc/matrix_sparse.htm @@ -15,7 +15,7 @@

    Sparse Matricies

    -

    Mapped Matrix

    +

    Mapped Matrix

    Description

    The templated class mapped_matrix<T, F, A> is the base container adaptor for sparse matricies using element maps. @@ -311,15 +311,15 @@ the reversed mapped_matrix.

    Notes

    -

    [1] Supported +

    [1] Supported parameters for the storage organization are row_major and column_major.

    -

    [2] Supported +

    [2] Supported parameters for the adapted array are map_array<std::size_t, T> and map_std<std::size_t, T>. The latter is equivalent to std::map<std::size_t, T>.

    -

    Compressed Matrix

    +

    Compressed Matrix

    Description

    The templated class compressed_matrix<T, F, IB, IA, TA> is the base container adaptor for compressed @@ -628,18 +628,18 @@ the reversed compressed_matrix.

    Notes

    -

    [1] +

    [1] Supported parameters for the storage organization are row_major and column_major.

    -

    [2] +

    [2] Supported parameters for the index base are 0 and 1 at least.

    -

    [3] +

    [3] Supported parameters for the adapted array are unbounded_array<> , bounded_array<> and std::vector<> .

    -

    Coordinate Matrix

    +

    Coordinate Matrix

    Description

    The templated class coordinate_matrix<T, F, IB, IA, TA> is the base container adaptor for compressed @@ -954,13 +954,13 @@ the reversed coordinate_matrix.

    Notes

    -

    [1] +

    [1] Supported parameters for the storage organization are row_major and column_major.

    -

    [2] +

    [2] Supported parameters for the index base are 0 and 1 at least.

    -

    [3] +

    [3] Supported parameters for the adapted array are unbounded_array<> , bounded_array<> and diff --git a/doc/operations_overview.htm b/doc/operations_overview.htm index ecb7ace1..77f8722e 100644 --- a/doc/operations_overview.htm +++ b/doc/operations_overview.htm @@ -42,7 +42,7 @@ are slices, e.g. slice(0, 1, 3) -

    Basic Linear Algebra

    +

    Basic Linear Algebra

    standard operations: addition, subtraction, multiplication by a scalar

    @@ -81,7 +81,7 @@ w = conj(u); w = real(u); w = imag(u); C = trans(A); C = conj(A); C = herm(A); C = real(A); C = imag(A);
    -

    Advanced functions

    +

    Advanced functions

    norms

    @@ -129,7 +129,7 @@ opb_prod(A, B, C, false); // C += A * B may give a speedup if A has less columns than rows, because the product is computed as a sum of outer products.

    -

    Submatrices, Subvectors

    +

    Submatrices, Subvectors

    Accessing submatrices and subvectors via proxies using project functions:

    
     w = project(u, r);         // the subvector of u specifed by the index range r
    @@ -181,7 +181,7 @@ the column with a slice with stride 0 thus:
    slice(0,0,2));

    -

    Speed improvements

    +

    Speed improvements

    Matrix / Vector assignment

    If you know for sure that the left hand expression and the right hand expression have no common storage, then assignment has diff --git a/doc/overview.htm b/doc/overview.htm index 60fce76c..ce7bb638 100644 --- a/doc/overview.htm +++ b/doc/overview.htm @@ -13,7 +13,7 @@

    logouBLAS Overview

    -

    Rationale

    +

    Rationale

    It would be nice if every kind of numeric software could be written in C++ without loss of efficiency, but unless something can be found that achieves this without compromising the C++ type @@ -265,7 +265,7 @@ development cycle. Switching from debug mode to release mode is controlled by the NDEBUG preprocessor symbol of <cassert>.

    -

    Functionality

    +

    Functionality

    Every C++ library supporting linear algebra will be measured against the long-standing Fortran package BLAS. We now describe how diff --git a/doc/range.htm b/doc/range.htm index 5e4224c5..37213bee 100644 --- a/doc/range.htm +++ b/doc/range.htm @@ -12,7 +12,7 @@

    Range and Slice Storage

    -

    Range<SizeType,DistanceType>

    +

    Range<SizeType,DistanceType>

    Description

    The class range specifies a range of indicies. The range is a sequence of indices from a start value to stop value. The indices increase by one and exlude the stop value. @@ -104,7 +104,7 @@ end of the reversed range.

  • start () <= stop ()
  • -

    Slice<SizeType,DistanceType>

    +

    Slice<SizeType,DistanceType>

    Description

    The class slice specifies a 'slice' of indicies. Slices are more general then ranges, the stride allows the sequence of indicies to increase and decrease by the specified amount between element. diff --git a/doc/storage_concept.htm b/doc/storage_concept.htm index 4d52a699..9d70eaeb 100644 --- a/doc/storage_concept.htm +++ b/doc/storage_concept.htm @@ -15,7 +15,7 @@

    Storage concept

    -

    Storage concept

    +

    Storage concept

    Description

    Storage is a variable-size container whose elements are arranged in a strict linear order.

    Storage extends the STL Container concept with some STL Sequence-like functionality. The main difference with @@ -154,4 +154,4 @@ each element value may be a previously assigned value or default construced valu })(jQuery); - \ No newline at end of file + diff --git a/doc/storage_sparse.htm b/doc/storage_sparse.htm index a16e1097..b4899d9b 100644 --- a/doc/storage_sparse.htm +++ b/doc/storage_sparse.htm @@ -15,7 +15,7 @@

    Sparse Storage

    -

    Default Standard Map

    +

    Default Standard Map

    Description

    The templated class map_std<I, T, ALLOC> provides a wrapper for the standard library associative container @@ -69,7 +69,7 @@ int main () { Container.

    Public base classes

    std::map

    -

    Map Array

    +

    Map Array

    Description

    The templated class map_array<I, T, ALLOC> implements a std::map like associative container as a sorted array. It therefore some of the Associative Container interface without having the same semantics as an std::map.

    At any time the map_array has a capacity up to which new element can be inserted. diff --git a/doc/symmetric.htm b/doc/symmetric.htm index 27af0390..0f0d1f1a 100644 --- a/doc/symmetric.htm +++ b/doc/symmetric.htm @@ -15,7 +15,7 @@

    Symmetric Matrix

    -

    Symmetric Matrix

    +

    Symmetric Matrix

    Description

    The templated class symmetric_matrix<T, F1, F2, A> is the base container adaptor for symmetric matrices. @@ -60,19 +60,19 @@ int main () { F1 Functor describing the type of the symmetric matrix. [1] +"#symmetric_matrix_1">[1] lower F2 Functor describing the storage organization. [2] +"#symmetric_matrix_2">[2] row_major A The type of the adapted array. [3] +>[3] unbounded_array<T> @@ -302,18 +302,18 @@ the reversed symmetric_matrix.

    Notes

    -

    [1] +

    [1] Supported parameters for the type of the symmetric matrix are lower and upper.

    -

    [2] +

    [2] Supported parameters for the storage organization are row_major and column_major.

    -

    [3] +

    [3] Supported parameters for the adapted array are unbounded_array<T> , bounded_array<T> and std::vector<T> .

    -

    Symmetric Adaptor

    +

    Symmetric Adaptor

    Description

    The templated class symmetric_adaptor<M, F> is a symmetric matrix adaptor for other matrices.

    @@ -567,7 +567,7 @@ the reversed symmetric_adaptor.

    Notes

    -

    [1] +

    [1] Supported parameters for the type of the symmetric adaptor are lower and upper.


    diff --git a/doc/triangular.htm b/doc/triangular.htm index 5e0a4ddf..782d9948 100644 --- a/doc/triangular.htm +++ b/doc/triangular.htm @@ -15,7 +15,7 @@

    Triangular Matrix

    -

    Triangular Matrix

    +

    Triangular Matrix

    Description

    The templated class triangular_matrix<T, F1, F2, A> is the base container adaptor for triangular matrices. @@ -317,19 +317,19 @@ the reversed triangular_matrix.

    Notes

    -

    [1] +

    [1] Supported parameters for the type of the triangular matrix are lower , unit_lower, upper and unit_upper .

    -

    [2] +

    [2] Supported parameters for the storage organization are row_major and column_major.

    -

    [3] +

    [3] Supported parameters for the adapted array are unbounded_array<T> , bounded_array<T> and std::vector<T> .

    -

    Triangular Adaptor

    +

    Triangular Adaptor

    Description

    The templated class triangular_adaptor<M, F> is a triangular matrix adaptor for other matrices.

    @@ -580,7 +580,7 @@ the reversed triangular_adaptor.

    Notes

    -

    [1] +

    [1] Supported parameters for the type of the triangular adaptor are lower , unit_lower, upper and unit_upper .

    diff --git a/doc/unbounded_array.htm b/doc/unbounded_array.htm index bd49abce..ea9ea380 100644 --- a/doc/unbounded_array.htm +++ b/doc/unbounded_array.htm @@ -12,7 +12,7 @@

    Unbounded Array Storage

    -

    Unbounded Array

    +

    Unbounded Array

    Description

    The templated class unbounded_array<T, ALLOC> implements a unbounded storage array using an allocator. The unbounded array is similar to a std::vector in that in can grow in size beyond any fixed bound. diff --git a/doc/vector.htm b/doc/vector.htm index ed73dc1f..69862084 100644 --- a/doc/vector.htm +++ b/doc/vector.htm @@ -15,7 +15,7 @@

    Vector

    -

    Vector

    +

    Vector

    Description

    The templated class vector<T, A> is the base container adaptor for dense vectors. For a n-dimensional @@ -347,11 +347,11 @@ the reversed vector.

    Notes

    -

    [1] Common parameters +

    [1] Common parameters for the Storage array are unbounded_array<T> , bounded_array<T> and std::vector<T> .

    -

    Unit Vector

    +

    Unit Vector

    Description

    The templated class unit_vector<T, ALLOC> represents canonical unit vectors. For the k-th @@ -485,7 +485,7 @@ end of the reversed unit_vector. -

    Zero Vector

    +

    Zero Vector

    Description

    The templated class zero_vector<T, ALLOC> represents zero vectors. For a n-dimensional zero vector and 0 @@ -610,7 +610,7 @@ end of the reversed zero_vector. -

    Scalar Vector

    +

    Scalar Vector

    Description

    The templated class scalar_vector<T, ALLOC> represents scalar vectors. For a n-dimensional scalar diff --git a/doc/vector_expression.htm b/doc/vector_expression.htm index 82c207f9..80a50c96 100644 --- a/doc/vector_expression.htm +++ b/doc/vector_expression.htm @@ -15,7 +15,7 @@

    Vector Expressions

    -

    Vector Expression

    +

    Vector Expression

    Description

    The templated class vector_expression<E> is required to be a public base of all classes which model the Vector Expression concept.

    @@ -64,7 +64,7 @@ const

    Notes

    The range, slice and project functions have been removed. Use the free functions defined in vector proxy instead.

    -

    Vector Container

    +

    Vector Container

    Description

    The templated class vector_container<C> is required to be a public base of all classes which model the Vector concept. @@ -112,7 +112,7 @@ const -

    Vector References

    +

    Vector References

    Reference

    Description

    The templated class vector_reference<E> @@ -214,7 +214,7 @@ the reversed expression. -

    Vector Operations

    +

    Vector Operations

    Unary Operation Description

    Description

    The templated class vector_unary<E, F> @@ -823,7 +823,7 @@ int main () { std::cout << v * 2.0 << std::endl; }

    -

    Vector Reductions

    +

    Vector Reductions

    Unary Reductions

    Prototypes

    diff --git a/doc/vector_proxy.htm b/doc/vector_proxy.htm
    index b5193224..45c70a9a 100644
    --- a/doc/vector_proxy.htm
    +++ b/doc/vector_proxy.htm
    @@ -15,7 +15,7 @@
     
     

    Vector Proxies

    -

    Vector Range

    +

    Vector Range

    Description

    The templated class vector_range<V> allows addressing a sub-range of a vector's element.

    @@ -262,7 +262,7 @@ int main () { std::cout << project (v, range (0, 3)) << std::endl; }
    -

    Vector Slice

    +

    Vector Slice

    Description

    The templated class vector_slice<V> allows addressing a slice of a vector.

    diff --git a/doc/vector_sparse.htm b/doc/vector_sparse.htm index 628a5b41..61a6a5a3 100644 --- a/doc/vector_sparse.htm +++ b/doc/vector_sparse.htm @@ -15,7 +15,7 @@

    Sparse Vector

    -

    Mapped Vector

    +

    Mapped Vector

    Description

    The templated class mapped_vector<T, A> is the base container adaptor for sparse vectors using element maps. For a @@ -253,12 +253,12 @@ the reversed mapped_vector.

    Notes

    -

    [1] Supported +

    [1] Supported parameters for the adapted array are map_array<std::size_t, T> and map_std<std::size_t, T>. The latter is equivalent to std::map<std::size_t, T>.

    -

    Compressed Vector

    +

    Compressed Vector

    Description

    The templated class compressed_vector<T, IB, IA, TA> is the base container adaptor for compressed vectors. @@ -509,15 +509,15 @@ the reversed compressed_vector.

    Notes

    -

    [1] +

    [1] Supported parameters for the index base are 0 and 1 at least.

    -

    [2] +

    [2] Supported parameters for the adapted array are unbounded_array<> , bounded_array<> and std::vector<> .

    -

    Coordinate Vector

    +

    Coordinate Vector

    Description

    The templated class coordinate_vector<T, IB, IA, TA> is the base container adaptor for compressed vectors. @@ -774,10 +774,10 @@ the reversed coordinate_vector.

    Notes

    -

    [1] +

    [1] Supported parameters for the index base are 0 and 1 at least.

    -

    [2] +

    [2] Supported parameters for the adapted array are unbounded_array<> , bounded_array<> and diff --git a/include/boost/numeric/ublas/detail/concepts.hpp b/include/boost/numeric/ublas/detail/concepts.hpp index 8133670c..45134e3a 100644 --- a/include/boost/numeric/ublas/detail/concepts.hpp +++ b/include/boost/numeric/ublas/detail/concepts.hpp @@ -499,7 +499,7 @@ namespace boost { namespace numeric { namespace ublas { void constraints () { function_requires< VectorConcept >(); - function_requires< DefaultConstructible >(); + function_requires< DefaultConstructible >(); function_requires< Mutable_VectorExpressionConcept >(); size_type n (0); value_type t = value_type (); @@ -580,7 +580,7 @@ namespace boost { namespace numeric { namespace ublas { void constraints () { function_requires< MatrixConcept >(); - function_requires< DefaultConstructible >(); + function_requires< DefaultConstructible >(); function_requires< Mutable_MatrixExpressionConcept >(); size_type n (0); value_type t = value_type (); @@ -905,8 +905,8 @@ namespace boost { namespace numeric { namespace ublas { #define INTERNAL_EXPRESSION #endif - // TODO enable this for development - // #define VIEW_CONCEPTS + // TODO enable this for development + // #define VIEW_CONCEPTS // Element value type for tests typedef float T; @@ -980,7 +980,7 @@ namespace boost { namespace numeric { namespace ublas { #endif #ifdef VIEW_CONCEPTS - // read only vectors + // read only vectors { typedef vector_view container_model; function_requires< RandomAccessContainerConcept >(); diff --git a/include/boost/numeric/ublas/experimental/sparse_view.hpp b/include/boost/numeric/ublas/experimental/sparse_view.hpp index 688d5145..cc6e28c9 100644 --- a/include/boost/numeric/ublas/experimental/sparse_view.hpp +++ b/include/boost/numeric/ublas/experimental/sparse_view.hpp @@ -26,42 +26,42 @@ namespace boost { namespace numeric { namespace ublas { template < class T > class c_array_view - : public storage_array< c_array_view > { + : public storage_array< c_array_view > { private: - typedef c_array_view self_type; - typedef T * pointer; + typedef c_array_view self_type; + typedef T * pointer; public: - // TODO: think about a const pointer - typedef const pointer array_type; + // TODO: think about a const pointer + typedef const pointer array_type; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; - typedef T value_type; - typedef const T &const_reference; - typedef const T *const_pointer; + typedef T value_type; + typedef const T &const_reference; + typedef const T *const_pointer; typedef const_pointer const_iterator; typedef std::reverse_iterator const_reverse_iterator; - // - // typedefs required by vector concept - // + // + // typedefs required by vector concept + // - typedef dense_tag storage_category; + typedef dense_tag storage_category; typedef const vector_reference const_closure_type; - c_array_view(size_type size, array_type data) : - size_(size), data_(data) - {} + c_array_view(size_type size, array_type data) : + size_(size), data_(data) + {} - ~c_array_view() - {} + ~c_array_view() + {} - // - // immutable methods of container concept - // + // + // immutable methods of container concept + // BOOST_UBLAS_INLINE size_type size () const { @@ -93,8 +93,8 @@ namespace boost { namespace numeric { namespace ublas { } private: - size_type size_; - array_type data_; + size_type size_; + array_type data_; }; @@ -133,14 +133,14 @@ namespace boost { namespace numeric { namespace ublas { // ISSUE require type consistency check // is_convertable (IA::size_type, TA::size_type) typedef typename boost::remove_cv::value_type>::type index_type; - // for compatibility, should be removed some day ... + // for compatibility, should be removed some day ... typedef index_type size_type; // size_type for the data arrays. typedef typename vector_view_traits::size_type array_size_type; typedef typename vector_view_traits::difference_type difference_type; typedef const value_type & const_reference; - // do NOT define reference type, because class is read only + // do NOT define reference type, because class is read only // typedef value_type & reference; typedef IA rowptr_array_type; @@ -149,93 +149,93 @@ namespace boost { namespace numeric { namespace ublas { typedef const matrix_reference const_closure_type; typedef matrix_reference closure_type; - // FIXME: define a corresponding temporary type + // FIXME: define a corresponding temporary type // typedef compressed_vector vector_temporary_type; - // FIXME: define a corresponding temporary type + // FIXME: define a corresponding temporary type // typedef self_type matrix_temporary_type; typedef sparse_tag storage_category; typedef typename L::orientation_category orientation_category; - // - // private types for internal use - // + // + // private types for internal use + // private: - typedef typename vector_view_traits::const_iterator const_subiterator_type; + typedef typename vector_view_traits::const_iterator const_subiterator_type; - // + // // Construction and destruction - // + // private: - /// private default constructor because data must be filled by caller + /// private default constructor because data must be filled by caller BOOST_UBLAS_INLINE compressed_matrix_view () { } public: - BOOST_UBLAS_INLINE + BOOST_UBLAS_INLINE compressed_matrix_view (index_type n_rows, index_type n_cols, array_size_type nnz - , const rowptr_array_type & iptr - , const index_array_type & jptr - , const value_array_type & values): + , const rowptr_array_type & iptr + , const index_array_type & jptr + , const value_array_type & values): matrix_expression (), size1_ (n_rows), size2_ (n_cols), nnz_ (nnz), index1_data_ (iptr), - index2_data_ (jptr), - value_data_ (values) { + index2_data_ (jptr), + value_data_ (values) { storage_invariants (); } - BOOST_UBLAS_INLINE - compressed_matrix_view(const compressed_matrix_view& o) : - size1_(size1_), size2_(size2_), - nnz_(nnz_), - index1_data_(index1_data_), - index2_data_(index2_data_), - value_data_(value_data_) - {} + BOOST_UBLAS_INLINE + compressed_matrix_view(const compressed_matrix_view& o) : + size1_(size1_), size2_(size2_), + nnz_(nnz_), + index1_data_(index1_data_), + index2_data_(index2_data_), + value_data_(value_data_) + {} - // - // implement immutable iterator types - // + // + // implement immutable iterator types + // - class const_iterator1 {}; - class const_iterator2 {}; + class const_iterator1 {}; + class const_iterator2 {}; - typedef reverse_iterator_base1 const_reverse_iterator1; + typedef reverse_iterator_base1 const_reverse_iterator1; typedef reverse_iterator_base2 const_reverse_iterator2; - // - // implement all read only methods for the matrix expression concept - // + // + // implement all read only methods for the matrix expression concept + // - //! return the number of rows - index_type size1() const { - return size1_; - } + //! return the number of rows + index_type size1() const { + return size1_; + } - //! return the number of columns - index_type size2() const { - return size2_; - } + //! return the number of columns + index_type size2() const { + return size2_; + } - //! return value at position (i,j) - value_type operator()(index_type i, index_type j) const { - const_pointer p = find_element(i,j); - if (!p) { - return zero_; - } else { - return *p; - } - } - + //! return value at position (i,j) + value_type operator()(index_type i, index_type j) const { + const_pointer p = find_element(i,j); + if (!p) { + return zero_; + } else { + return *p; + } + } + private: - // - // private helper functions - // + // + // private helper functions + // const_pointer find_element (index_type i, index_type j) const { index_type element1 (layout_type::index_M (i, j)); @@ -244,22 +244,22 @@ namespace boost { namespace numeric { namespace ublas { const array_size_type itv = zero_based( index1_data_[element1] ); const array_size_type itv_next = zero_based( index1_data_[element1+1] ); - const_subiterator_type it_start = boost::next(vector_view_traits::begin(index2_data_),itv); - const_subiterator_type it_end = boost::next(vector_view_traits::begin(index2_data_),itv_next); + const_subiterator_type it_start = boost::next(vector_view_traits::begin(index2_data_),itv); + const_subiterator_type it_end = boost::next(vector_view_traits::begin(index2_data_),itv_next); const_subiterator_type it = find_index_in_row(it_start, it_end, element2) ; - + if (it == it_end || *it != k_based (element2)) return 0; return &value_data_ [it - vector_view_traits::begin(index2_data_)]; } - const_subiterator_type find_index_in_row(const_subiterator_type it_start - , const_subiterator_type it_end - , index_type index) const { - return std::lower_bound( it_start - , it_end - , k_based (index) ); - } + const_subiterator_type find_index_in_row(const_subiterator_type it_start + , const_subiterator_type it_end + , index_type index) const { + return std::lower_bound( it_start + , it_end + , k_based (index) ); + } private: @@ -301,13 +301,13 @@ namespace boost { namespace numeric { namespace ublas { template compressed_matrix_view make_compressed_matrix_view(typename vector_view_traits::value_type n_rows - , typename vector_view_traits::value_type n_cols - , typename vector_view_traits::size_type nnz - , const IA & ia - , const JA & ja - , const TA & ta) { + , typename vector_view_traits::value_type n_cols + , typename vector_view_traits::size_type nnz + , const IA & ia + , const JA & ja + , const TA & ta) { - return compressed_matrix_view(n_rows, n_cols, nnz, ia, ja, ta); + return compressed_matrix_view(n_rows, n_cols, nnz, ia, ja, ta); } diff --git a/include/boost/numeric/ublas/traits.hpp b/include/boost/numeric/ublas/traits.hpp index 857ac5d5..5a8d50ed 100644 --- a/include/boost/numeric/ublas/traits.hpp +++ b/include/boost/numeric/ublas/traits.hpp @@ -60,6 +60,87 @@ namespace boost { namespace numeric { namespace ublas { typedef typename id::type promote_type; }; + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator+ (I in1, std::complex const& in2 ) { + return R (in1) + in2; + } + + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator+ (std::complex const& in1, I in2) { + return in1 + R (in2); + } + + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator- (I in1, std::complex const& in2) { + return R (in1) - in2; + } + + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator- (std::complex const& in1, I in2) { + return in1 - R (in2); + } + + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator* (I in1, std::complex const& in2) { + return R (in1) * in2; + } + + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator* (std::complex const& in1, I in2) { + return in1 * R(in2); + } + + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator/ (I in1, std::complex const& in2) { + return R(in1) / in2; + } + + template + typename boost::enable_if< + mpl::and_< + boost::is_float, + boost::is_integral + >, + std::complex >::type inline operator/ (std::complex const& in1, I in2) { + return in1 / R (in2); + } + + // Type traits - generic numeric properties and functions template @@ -555,7 +636,7 @@ namespace boost { namespace numeric { namespace ublas { */ template < class E > struct container_traits - : container_view_traits, mutable_container_traits { + : container_view_traits, mutable_container_traits { }; @@ -581,7 +662,7 @@ namespace boost { namespace numeric { namespace ublas { */ template < class MATRIX > struct mutable_matrix_traits - : mutable_container_traits { + : mutable_container_traits { /// row iterator for the matrix typedef typename MATRIX::iterator1 iterator1; @@ -596,7 +677,7 @@ namespace boost { namespace numeric { namespace ublas { */ template < class MATRIX > struct matrix_traits - : matrix_view_traits , mutable_matrix_traits { + : matrix_view_traits , mutable_matrix_traits { }; /** \brief Traits class to extract type information from a VECTOR. @@ -608,16 +689,16 @@ namespace boost { namespace numeric { namespace ublas { /// iterator for the VECTOR typedef typename VECTOR::const_iterator const_iterator; - /// iterator pointing to the first element - static - const_iterator begin(const VECTOR & v) { - return v.begin(); - } - /// iterator pointing behind the last element - static - const_iterator end(const VECTOR & v) { - return v.end(); - } + /// iterator pointing to the first element + static + const_iterator begin(const VECTOR & v) { + return v.begin(); + } + /// iterator pointing behind the last element + static + const_iterator end(const VECTOR & v) { + return v.end(); + } }; @@ -629,17 +710,17 @@ namespace boost { namespace numeric { namespace ublas { /// iterator for the VECTOR typedef typename VECTOR::iterator iterator; - /// iterator pointing to the first element - static - iterator begin(VECTOR & v) { - return v.begin(); - } + /// iterator pointing to the first element + static + iterator begin(VECTOR & v) { + return v.begin(); + } - /// iterator pointing behind the last element - static - iterator end(VECTOR & v) { - return v.end(); - } + /// iterator pointing behind the last element + static + iterator end(VECTOR & v) { + return v.end(); + } }; /** \brief Traits class to extract type information from a VECTOR. @@ -647,7 +728,7 @@ namespace boost { namespace numeric { namespace ublas { */ template < class VECTOR > struct vector_traits - : vector_view_traits , mutable_vector_traits { + : vector_view_traits , mutable_vector_traits { }; diff --git a/test/utils.hpp b/test/utils.hpp index d0a0c2a4..c0526ce8 100644 --- a/test/utils.hpp +++ b/test/utils.hpp @@ -14,9 +14,9 @@ #define JOIN_(x,y) x ## y #ifndef NDEBUG -# define BOOST_UBLAS_DEBUG_TRACE(x) std::cerr << "[Debug>> " << EXPAND_(x) << std::endl +# define BOOST_UBLAS_DEBUG_TRACE(x) std::cerr << "[Debug>> " << EXPAND_(x) << std::endl #else -# define BOOST_UBLAS_DEBUG_TRACE(x) /**/ +# define BOOST_UBLAS_DEBUG_TRACE(x) /**/ #endif // NDEBUG #define BOOST_UBLAS_TEST_BEGIN() unsigned int test_fails_(0) From e400b41157a66204c3ea848d3065283cd5955122 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Mon, 5 Jul 2010 03:11:56 +0000 Subject: [PATCH 041/280] Spirit: merging from trunk upto rev. 63622 svn path=/branches/release/boost/numeric/ublas/; revision=63642 From 3390a7b24f13110da87dde47cc2f9de335b2a46d Mon Sep 17 00:00:00 2001 From: David Bellot Date: Mon, 5 Jul 2010 06:06:24 +0000 Subject: [PATCH 042/280] last update for 1.44 svn path=/branches/release/boost/numeric/ublas/; revision=63644 --- include/boost/numeric/ublas/banded.hpp | 55 +- include/boost/numeric/ublas/blas.hpp | 490 +++++++++++++----- .../numeric/ublas/detail/definitions.hpp | 2 +- include/boost/numeric/ublas/exception.hpp | 9 +- .../boost/numeric/ublas/expression_types.hpp | 72 ++- include/boost/numeric/ublas/fwd.hpp | 6 +- include/boost/numeric/ublas/hermitian.hpp | 35 +- include/boost/numeric/ublas/io.hpp | 112 +++- include/boost/numeric/ublas/lu.hpp | 5 + include/boost/numeric/ublas/matrix.hpp | 119 ++++- include/boost/numeric/ublas/matrix_proxy.hpp | 22 +- include/boost/numeric/ublas/matrix_sparse.hpp | 20 +- include/boost/numeric/ublas/traits.hpp | 5 + include/boost/numeric/ublas/triangular.hpp | 18 +- include/boost/numeric/ublas/vector.hpp | 324 +++++++++++- include/boost/numeric/ublas/vector_proxy.hpp | 87 +++- include/boost/numeric/ublas/vector_sparse.hpp | 64 ++- 17 files changed, 1226 insertions(+), 219 deletions(-) diff --git a/include/boost/numeric/ublas/banded.hpp b/include/boost/numeric/ublas/banded.hpp index c67e0595..e36c1f0d 100644 --- a/include/boost/numeric/ublas/banded.hpp +++ b/include/boost/numeric/ublas/banded.hpp @@ -20,7 +20,18 @@ namespace boost { namespace numeric { namespace ublas { - // Array based banded matrix class + /** \brief A banded matrix of values of type \c T. + * + * For a \f$(mxn)\f$-dimensional banded matrix with \f$l\f$ lower and \f$u\f$ upper diagonals and + * \f$0 \leq i < m\f$ and \f$0 \leq j < n\f$, if \f$i>j+l\f$ or \f$i class banded_matrix: public matrix_container > { @@ -970,7 +981,21 @@ namespace boost { namespace numeric { namespace ublas { typename banded_matrix::const_value_type banded_matrix::zero_ = value_type/*zero*/(); - // Diagonal matrix class + /** \brief A diagonal matrix of values of type \c T, which is a specialization of a banded matrix + * + * For a \f$(m\times m)\f$-dimensional diagonal matrix, \f$0 \leq i < m\f$ and \f$0 \leq j < m\f$, + * if \f$i\neq j\f$ then \f$b_{i,j}=0\f$. The default storage for diagonal matrices is packed. + * Orientation and storage can also be specified. Default is \c row major \c unbounded_array. + * + * As a specialization of a banded matrix, the constructor of the diagonal matrix creates + * a banded matrix with 0 upper and lower diagonals around the main diagonal and the matrix is + * obviously a square matrix. Operations are optimized based on these 2 assumptions. It is + * \b not required by the storage to initialize elements of the matrix. + * + * \tparam T the type of object stored in the matrix (like double, float, complex, etc...) + * \tparam L the storage organization. It can be either \c row_major or \c column_major. Default is \c row_major + * \tparam A the type of Storage array. Default is \c unbounded_array + */ template class diagonal_matrix: public banded_matrix { @@ -1013,7 +1038,18 @@ namespace boost { namespace numeric { namespace ublas { } }; - // Banded matrix adaptor class + /** \brief A banded matrix adaptator: convert a any matrix into a banded matrix expression + * + * For a \f$(m\times n)\f$-dimensional matrix, the \c banded_adaptor will provide a banded matrix + * with \f$l\f$ lower and \f$u\f$ upper diagonals and \f$0 \leq i < m\f$ and \f$0 \leq j < n\f$, + * if \f$i>j+l\f$ or \f$i class banded_adaptor: public matrix_expression > { @@ -1987,7 +2023,18 @@ namespace boost { namespace numeric { namespace ublas { template typename banded_adaptor::const_value_type banded_adaptor::zero_ = value_type/*zero*/(); - // Diagonal matrix adaptor class + /** \brief A diagonal matrix adaptator: convert a any matrix into a diagonal matrix expression + * + * For a \f$(m\times m)\f$-dimensional matrix, the \c diagonal_adaptor will provide a diagonal matrix + * with \f$0 \leq i < m\f$ and \f$0 \leq j < m\f$, if \f$i\neq j\f$ then \f$b_{i,j}=0\f$. + * + * Storage and location are based on those of the underlying matrix. This is important because + * a \c diagonal_adaptor does not copy the matrix data to a new place. Therefore, modifying values + * in a \c diagonal_adaptor matrix will also modify the underlying matrix too. + * + * \tparam M the type of matrix used to generate the diagonal matrix + */ + template class diagonal_adaptor: public banded_adaptor { diff --git a/include/boost/numeric/ublas/blas.hpp b/include/boost/numeric/ublas/blas.hpp index e5c7c059..5032d3cd 100644 --- a/include/boost/numeric/ublas/blas.hpp +++ b/include/boost/numeric/ublas/blas.hpp @@ -16,89 +16,150 @@ #include namespace boost { namespace numeric { namespace ublas { + + /** Interface and implementation of BLAS level 1 + * This includes functions which perform \b vector-vector operations. + * More information about BLAS can be found at + * http://en.wikipedia.org/wiki/BLAS + */ namespace blas_1 { - /** \namespace boost::numeric::ublas::blas_1 - \brief wrapper functions for level 1 blas - */ - - - /** \brief 1-Norm: \f$\sum_i |x_i|\f$ - \ingroup blas1 - */ + /** 1-Norm: \f$\sum_i |x_i|\f$ (also called \f$\mathcal{L}_1\f$ or Manhattan norm) + * + * \param v a vector or vector expression + * \return the 1-Norm with type of the vector's type + * + * \tparam V type of the vector (not needed by default) + */ template typename type_traits::real_type asum (const V &v) { return norm_1 (v); } - /** \brief 2-Norm: \f$\sum_i |x_i|^2\f$ - \ingroup blas1 - */ + + /** 2-Norm: \f$\sum_i |x_i|^2\f$ (also called \f$\mathcal{L}_2\f$ or Euclidean norm) + * + * \param v a vector or vector expression + * \return the 2-Norm with type of the vector's type + * + * \tparam V type of the vector (not needed by default) + */ template typename type_traits::real_type nrm2 (const V &v) { return norm_2 (v); } - /** \brief element with larges absolute value: \f$\max_i |x_i|\f$ - \ingroup blas1 - */ + + /** Infinite-norm: \f$\max_i |x_i|\f$ (also called \f$\mathcal{L}_\infty\f$ norm) + * + * \param v a vector or vector expression + * \return the Infinite-Norm with type of the vector's type + * + * \tparam V type of the vector (not needed by default) + */ template typename type_traits::real_type amax (const V &v) { return norm_inf (v); } - /** \brief inner product of vectors \a v1 and \a v2 - \ingroup blas1 - */ + /** Inner product of vectors \f$v_1\f$ and \f$v_2\f$ + * + * \param v1 first vector of the inner product + * \param v2 second vector of the inner product + * \return the inner product of the type of the most generic type of the 2 vectors + * + * \tparam V1 type of first vector (not needed by default) + * \tparam V2 type of second vector (not needed by default) + */ template typename promote_traits::promote_type dot (const V1 &v1, const V2 &v2) { return inner_prod (v1, v2); } - /** \brief copy vector \a v2 to \a v1 - \ingroup blas1 - */ + /** Copy vector \f$v_2\f$ to \f$v_1\f$ + * + * \param v1 target vector + * \param v2 source vector + * \return a reference to the target vector + * + * \tparam V1 type of first vector (not needed by default) + * \tparam V2 type of second vector (not needed by default) + */ template - V1 & - copy (V1 &v1, const V2 &v2) { + V1 & copy (V1 &v1, const V2 &v2) + { return v1.assign (v2); } - /** \brief swap vectors \a v1 and \a v2 - \ingroup blas1 - */ - template - void swap (V1 &v1, V2 &v2) { + /** Swap vectors \f$v_1\f$ and \f$v_2\f$ + * + * \param v1 first vector + * \param v2 second vector + * + * \tparam V1 type of first vector (not needed by default) + * \tparam V2 type of second vector (not needed by default) + */ + template + void swap (V1 &v1, V2 &v2) + { v1.swap (v2); } - /** \brief scale vector \a v with scalar \a t - \ingroup blas1 - */ + /** scale vector \f$v\f$ with scalar \f$t\f$ + * + * \param v vector to be scaled + * \param t the scalar + * \return \c t*v + * + * \tparam V type of the vector (not needed by default) + * \tparam T type of the scalar (not needed by default) + */ template - V & - scal (V &v, const T &t) { + V & scal (V &v, const T &t) + { return v *= t; } - /** \brief compute \a v1 = \a v1 + \a t * \a v2 - \ingroup blas1 - */ + /** Compute \f$v_1= v_1 + t.v_2\f$ + * + * \param v1 target and first vector + * \param t the scalar + * \param v2 second vector + * \return a reference to the first and target vector + * + * \tparam V1 type of the first vector (not needed by default) + * \tparam T type of the scalar (not needed by default) + * \tparam V2 type of the second vector (not needed by default) + */ template - V1 & - axpy (V1 &v1, const T &t, const V2 &v2) { + V1 & axpy (V1 &v1, const T &t, const V2 &v2) + { return v1.plus_assign (t * v2); } - /** \brief apply plane rotation - \ingroup blas1 - */ + /** Performs rotation of points in the plane and assign the result to the first vector + * + * Each point is defined as a pair \c v1(i) and \c v2(i), being respectively + * the \f$x\f$ and \f$y\f$ coordinates. The parameters \c t1 and \t2 are respectively + * the cosine and sine of the angle of the rotation. + * Results are not returned but directly written into \c v1. + * + * \param t1 cosine of the rotation + * \param v1 vector of \f$x\f$ values + * \param t2 sine of the rotation + * \param v2 vector of \f$y\f$ values + * + * \tparam T1 type of the cosine value (not needed by default) + * \tparam V1 type of the \f$x\f$ vector (not needed by default) + * \tparam T2 type of the sine value (not needed by default) + * \tparam V2 type of the \f$y\f$ vector (not needed by default) + */ template - void - rot (const T1 &t1, V1 &v1, const T2 &t2, V2 &v2) { + void rot (const T1 &t1, V1 &v1, const T2 &t2, V2 &v2) + { typedef typename promote_traits::promote_type promote_type; vector vt (t1 * v1 + t2 * v2); v2.assign (- t2 * v1 + t1 * v2); @@ -107,46 +168,82 @@ namespace boost { namespace numeric { namespace ublas { } + /** \brief Interface and implementation of BLAS level 2 + * This includes functions which perform \b matrix-vector operations. + * More information about BLAS can be found at + * http://en.wikipedia.org/wiki/BLAS + */ namespace blas_2 { - /** \namespace boost::numeric::ublas::blas_2 - \brief wrapper functions for level 2 blas - */ - - /** \brief multiply vector \a v with triangular matrix \a m - \ingroup blas2 - \todo: check that matrix is really triangular - */ + /** \brief multiply vector \c v with triangular matrix \c m + * + * \param v a vector + * \param m a triangular matrix + * \return the result of the product + * + * \tparam V type of the vector (not needed by default) + * \tparam M type of the matrix (not needed by default) + */ template - V & - tmv (V &v, const M &m) { + V & tmv (V &v, const M &m) + { return v = prod (m, v); } - /** \brief solve \a m \a x = \a v in place, \a m is triangular matrix - \ingroup blas2 - */ + /** \brief solve \f$m.x = v\f$ in place, where \c m is a triangular matrix + * + * \param v a vector + * \param m a matrix + * \param C (this parameter is not needed) + * \return a result vector from the above operation + * + * \tparam V type of the vector (not needed by default) + * \tparam M type of the matrix (not needed by default) + * \tparam C n/a + */ template - V & - tsv (V &v, const M &m, C) { + V & tsv (V &v, const M &m, C) + { return v = solve (m, v, C ()); } - /** \brief compute \a v1 = \a t1 * \a v1 + \a t2 * (\a m * \a v2) - \ingroup blas2 - */ + /** \brief compute \f$ v_1 = t_1.v_1 + t_2.(m.v_2)\f$, a general matrix-vector product + * + * \param v1 a vector + * \param t1 a scalar + * \param t2 another scalar + * \param m a matrix + * \param v2 another vector + * \return the vector \c v1 with the result from the above operation + * + * \tparam V1 type of first vector (not needed by default) + * \tparam T1 type of first scalar (not needed by default) + * \tparam T2 type of second scalar (not needed by default) + * \tparam M type of matrix (not needed by default) + * \tparam V2 type of second vector (not needed by default) + */ template - V1 & - gmv (V1 &v1, const T1 &t1, const T2 &t2, const M &m, const V2 &v2) { + V1 & gmv (V1 &v1, const T1 &t1, const T2 &t2, const M &m, const V2 &v2) + { return v1 = t1 * v1 + t2 * prod (m, v2); } - /** \brief rank 1 update: \a m = \a m + \a t * (\a v1 * \a v2T) - \ingroup blas2 - */ + /** \brief Rank 1 update: \f$ m = m + t.(v_1.v_2^T)\f$ + * + * \param m a matrix + * \param t a scalar + * \param v1 a vector + * \param v2 another vector + * \return a matrix with the result from the above operation + * + * \tparam M type of matrix (not needed by default) + * \tparam T type of scalar (not needed by default) + * \tparam V1 type of first vector (not needed by default) + * \tparam V2type of second vector (not needed by default) + */ template - M & - gr (M &m, const T &t, const V1 &v1, const V2 &v2) { + M & gr (M &m, const T &t, const V1 &v1, const V2 &v2) + { #ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG return m += t * outer_prod (v1, v2); #else @@ -154,24 +251,41 @@ namespace boost { namespace numeric { namespace ublas { #endif } - /** \brief symmetric rank 1 update: \a m = \a m + \a t * (\a v * \a vT) - \ingroup blas2 - */ + /** \brief symmetric rank 1 update: \f$m = m + t.(v.v^T)\f$ + * + * \param m a matrix + * \param t a scalar + * \param v a vector + * \return a matrix with the result from the above operation + * + * \tparam M type of matrix (not needed by default) + * \tparam T type of scalar (not needed by default) + * \tparam V type of vector (not needed by default) + */ template - M & - sr (M &m, const T &t, const V &v) { + M & sr (M &m, const T &t, const V &v) + { #ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG return m += t * outer_prod (v, v); #else return m = m + t * outer_prod (v, v); #endif } - /** \brief hermitian rank 1 update: \a m = \a m + \a t * (\a v * \a vH) - \ingroup blas2 - */ + + /** \brief hermitian rank 1 update: \f$m = m + t.(v.v^H)\f$ + * + * \param m a matrix + * \param t a scalar + * \param v a vector + * \return a matrix with the result from the above operation + * + * \tparam M type of matrix (not needed by default) + * \tparam T type of scalar (not needed by default) + * \tparam V type of vector (not needed by default) + */ template - M & - hr (M &m, const T &t, const V &v) { + M & hr (M &m, const T &t, const V &v) + { #ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG return m += t * outer_prod (v, conj (v)); #else @@ -179,27 +293,45 @@ namespace boost { namespace numeric { namespace ublas { #endif } - /** \brief symmetric rank 2 update: \a m = \a m + \a t * - (\a v1 * \a v2T + \a v2 * \a v1T) - \ingroup blas2 + /** \brief symmetric rank 2 update: \f$ m=m+ t.(v_1.v_2^T + v_2.v_1^T)\f$ + * + * \param m a matrix + * \param t a scalar + * \param v1 a vector + * \param v2 another vector + * \return a matrix with the result from the above operation + * + * \tparam M type of matrix (not needed by default) + * \tparam T type of scalar (not needed by default) + * \tparam V1 type of first vector (not needed by default) + * \tparam V2type of second vector (not needed by default) */ template - M & - sr2 (M &m, const T &t, const V1 &v1, const V2 &v2) { + M & sr2 (M &m, const T &t, const V1 &v1, const V2 &v2) + { #ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG return m += t * (outer_prod (v1, v2) + outer_prod (v2, v1)); #else return m = m + t * (outer_prod (v1, v2) + outer_prod (v2, v1)); #endif } - /** \brief hermitian rank 2 update: \a m = \a m + - \a t * (\a v1 * \a v2H) - + \a v2 * (\a t * \a v1)H) - \ingroup blas2 - */ + + /** \brief hermitian rank 2 update: \f$m=m+t.(v_1.v_2^H) + v_2.(t.v_1)^H)\f$ + * + * \param m a matrix + * \param t a scalar + * \param v1 a vector + * \param v2 another vector + * \return a matrix with the result from the above operation + * + * \tparam M type of matrix (not needed by default) + * \tparam T type of scalar (not needed by default) + * \tparam V1 type of first vector (not needed by default) + * \tparam V2type of second vector (not needed by default) + */ template - M & - hr2 (M &m, const T &t, const V1 &v1, const V2 &v2) { + M & hr2 (M &m, const T &t, const V1 &v1, const V2 &v2) + { #ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG return m += t * outer_prod (v1, conj (v2)) + type_traits::conj (t) * outer_prod (v2, conj (v1)); #else @@ -209,82 +341,158 @@ namespace boost { namespace numeric { namespace ublas { } + /** \brief Interface and implementation of BLAS level 3 + * This includes functions which perform \b matrix-matrix operations. + * More information about BLAS can be found at + * http://en.wikipedia.org/wiki/BLAS + */ namespace blas_3 { - /** \namespace boost::numeric::ublas::blas_3 - \brief wrapper functions for level 3 blas - */ - - /** \brief triangular matrix multiplication - \ingroup blas3 - */ + /** \brief triangular matrix multiplication \f$m_1=t.m_2.m_3\f$ where \f$m_2\f$ and \f$m_3\f$ are triangular + * + * \param m1 a matrix for storing result + * \param t a scalar + * \param m2 a triangular matrix + * \param m3 a triangular matrix + * \return the matrix \c m1 + * + * \tparam M1 type of the result matrix (not needed by default) + * \tparam T type of the scalar (not needed by default) + * \tparam M2 type of the first triangular matrix (not needed by default) + * \tparam M3 type of the second triangular matrix (not needed by default) + * + */ template - M1 & - tmm (M1 &m1, const T &t, const M2 &m2, const M3 &m3) { + M1 & tmm (M1 &m1, const T &t, const M2 &m2, const M3 &m3) + { return m1 = t * prod (m2, m3); } - /** \brief triangular solve \a m2 * \a x = \a t * \a m1 in place, - \a m2 is a triangular matrix - \ingroup blas3 - */ + /** \brief triangular solve \f$ m_2.x = t.m_1\f$ in place, \f$m_2\f$ is a triangular matrix + * + * \param m1 a matrix + * \param t a scalar + * \param m2 a triangular matrix + * \param C (not used) + * \return the \f$m_1\f$ matrix + * + * \tparam M1 type of the first matrix (not needed by default) + * \tparam T type of the scalar (not needed by default) + * \tparam M2 type of the triangular matrix (not needed by default) + * \tparam C (n/a) + */ template - M1 & - tsm (M1 &m1, const T &t, const M2 &m2, C) { + M1 & tsm (M1 &m1, const T &t, const M2 &m2, C) + { return m1 = solve (m2, t * m1, C ()); } - /** \brief general matrix multiplication - \ingroup blas3 - */ + /** \brief general matrix multiplication \f$m_1=t_1.m_1 + t_2.m_2.m_3\f$ + * + * \param m1 first matrix + * \param t1 first scalar + * \param t2 second scalar + * \param m2 second matrix + * \param m3 third matrix + * \return the matrix \c m1 + * + * \tparam M1 type of the first matrix (not needed by default) + * \tparam T1 type of the first scalar (not needed by default) + * \tparam T2 type of the second scalar (not needed by default) + * \tparam M2 type of the second matrix (not needed by default) + * \tparam M3 type of the third matrix (not needed by default) + */ template - M1 & - gmm (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2, const M3 &m3) { + M1 & gmm (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2, const M3 &m3) + { return m1 = t1 * m1 + t2 * prod (m2, m3); } - /** \brief symmetric rank k update: \a m1 = \a t * \a m1 + - \a t2 * (\a m2 * \a m2T) - \ingroup blas3 - \todo use opb_prod() - */ + /** \brief symmetric rank \a k update: \f$m_1=t.m_1+t_2.(m_2.m_2^T)\f$ + * + * \param m1 first matrix + * \param t1 first scalar + * \param t2 second scalar + * \param m2 second matrix + * \return matrix \c m1 + * + * \tparam M1 type of the first matrix (not needed by default) + * \tparam T1 type of the first scalar (not needed by default) + * \tparam T2 type of the second scalar (not needed by default) + * \tparam M2 type of the second matrix (not needed by default) + * \todo use opb_prod() + */ template - M1 & - srk (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2) { + M1 & srk (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2) + { return m1 = t1 * m1 + t2 * prod (m2, trans (m2)); } - /** \brief hermitian rank k update: \a m1 = \a t * \a m1 + - \a t2 * (\a m2 * \a m2H) - \ingroup blas3 - \todo use opb_prod() - */ + + /** \brief hermitian rank \a k update: \f$m_1=t.m_1+t_2.(m_2.m2^H)\f$ + * + * \param m1 first matrix + * \param t1 first scalar + * \param t2 second scalar + * \param m2 second matrix + * \return matrix \c m1 + * + * \tparam M1 type of the first matrix (not needed by default) + * \tparam T1 type of the first scalar (not needed by default) + * \tparam T2 type of the second scalar (not needed by default) + * \tparam M2 type of the second matrix (not needed by default) + * \todo use opb_prod() + */ template - M1 & - hrk (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2) { + M1 & hrk (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2) + { return m1 = t1 * m1 + t2 * prod (m2, herm (m2)); } - /** \brief generalized symmetric rank k update: - \a m1 = \a t1 * \a m1 + \a t2 * (\a m2 * \a m3T) - + \a t2 * (\a m3 * \a m2T) - \ingroup blas3 - \todo use opb_prod() - */ + /** \brief generalized symmetric rank \a k update: \f$m_1=t_1.m_1+t_2.(m_2.m3^T)+t_2.(m_3.m2^T)\f$ + * + * \param m1 first matrix + * \param t1 first scalar + * \param t2 second scalar + * \param m2 second matrix + * \param m3 third matrix + * \return matrix \c m1 + * + * \tparam M1 type of the first matrix (not needed by default) + * \tparam T1 type of the first scalar (not needed by default) + * \tparam T2 type of the second scalar (not needed by default) + * \tparam M2 type of the second matrix (not needed by default) + * \tparam M3 type of the third matrix (not needed by default) + * \todo use opb_prod() + */ template - M1 & - sr2k (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2, const M3 &m3) { + M1 & sr2k (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2, const M3 &m3) + { return m1 = t1 * m1 + t2 * (prod (m2, trans (m3)) + prod (m3, trans (m2))); } - /** \brief generalized hermitian rank k update: - \a m1 = \a t1 * \a m1 + \a t2 * (\a m2 * \a m3H) - + (\a m3 * (\a t2 * \a m2)H) - \ingroup blas3 - \todo use opb_prod() - */ + + /** \brief generalized hermitian rank \a k update: * \f$m_1=t_1.m_1+t_2.(m_2.m_3^H)+(m_3.(t_2.m_2)^H)\f$ + * + * \param m1 first matrix + * \param t1 first scalar + * \param t2 second scalar + * \param m2 second matrix + * \param m3 third matrix + * \return matrix \c m1 + * + * \tparam M1 type of the first matrix (not needed by default) + * \tparam T1 type of the first scalar (not needed by default) + * \tparam T2 type of the second scalar (not needed by default) + * \tparam M2 type of the second matrix (not needed by default) + * \tparam M3 type of the third matrix (not needed by default) + * \todo use opb_prod() + */ template - M1 & - hr2k (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2, const M3 &m3) { - return m1 = t1 * m1 + t2 * prod (m2, herm (m3)) + type_traits::conj (t2) * prod (m3, herm (m2)); + M1 & hr2k (M1 &m1, const T1 &t1, const T2 &t2, const M2 &m2, const M3 &m3) + { + return m1 = + t1 * m1 + + t2 * prod (m2, herm (m3)) + + type_traits::conj (t2) * prod (m3, herm (m2)); } } @@ -292,5 +500,3 @@ namespace boost { namespace numeric { namespace ublas { }}} #endif - - diff --git a/include/boost/numeric/ublas/detail/definitions.hpp b/include/boost/numeric/ublas/detail/definitions.hpp index 8cf71d99..c5e1cfca 100644 --- a/include/boost/numeric/ublas/detail/definitions.hpp +++ b/include/boost/numeric/ublas/detail/definitions.hpp @@ -80,7 +80,7 @@ namespace boost { namespace numeric { namespace ublas { closure_type lval_; }; - // Improve syntax of effcient assignment where no aliases of LHS appear on the RHS + // Improve syntax of efficient assignment where no aliases of LHS appear on the RHS // noalias(lhs) = rhs_expression template BOOST_UBLAS_INLINE diff --git a/include/boost/numeric/ublas/exception.hpp b/include/boost/numeric/ublas/exception.hpp index d2beec9a..51f0804c 100644 --- a/include/boost/numeric/ublas/exception.hpp +++ b/include/boost/numeric/ublas/exception.hpp @@ -26,10 +26,13 @@ namespace boost { namespace numeric { namespace ublas { + /** \brief Exception raised when a division by zero occurs + */ struct divide_by_zero #if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS) // Inherit from standard exceptions as requested during review. - : public std::runtime_error { + : public std::runtime_error + { explicit divide_by_zero (const char *s = "divide by zero") : std::runtime_error (s) {} void raise () { @@ -47,6 +50,8 @@ namespace boost { namespace numeric { namespace ublas { #endif }; + /** \brief Expception raised when some interal errors occurs like computations errors, zeros values where you should not have zeros, etc... + */ struct internal_logic #if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS) // Inherit from standard exceptions as requested during review. @@ -113,6 +118,8 @@ namespace boost { namespace numeric { namespace ublas { #endif }; + /** + */ struct bad_size #if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS) // Inherit from standard exceptions as requested during review. diff --git a/include/boost/numeric/ublas/expression_types.hpp b/include/boost/numeric/ublas/expression_types.hpp index 86241a9f..e706f8fb 100644 --- a/include/boost/numeric/ublas/expression_types.hpp +++ b/include/boost/numeric/ublas/expression_types.hpp @@ -22,8 +22,13 @@ namespace boost { namespace numeric { namespace ublas { - // Base class for uBLAS staticaly derived expressions - see the Barton Nackman trick - // Provides numeric properties for linear algebra + /** \brief Base class for uBLAS staticaly derived expressions using the the Barton Nackman trick + * + * This class provides the numeric properties for linear algebra. + * This is a NonAssignable class + * + * \tparam E an expression type + */ template class ublas_expression { public: @@ -42,11 +47,16 @@ namespace boost { namespace numeric { namespace ublas { }; - // Base class for Scalar Expression models - - // it does not model the Scalar Expression concept but all derived types should. - // The class defines a common base type and some common interface for all - // statically derived Scalar Expression classes - // We implement the casts to the statically derived type. + /** \brief Base class for Scalar Expression models + * + * It does not model the Scalar Expression concept but all derived types should. + * The class defines a common base type and some common interface for all statically + * derived Scalar Expression classes. + * + * We implement the casts to the statically derived type. + * + * \tparam E an expression type + */ template class scalar_expression: public ublas_expression { @@ -163,11 +173,13 @@ namespace boost { namespace numeric { namespace ublas { }; - // Base class for Vector Expression models - - // it does not model the Vector Expression concept but all derived types should. - // The class defines a common base type and some common interface for all - // statically derived Vector Expression classes - // We implement the casts to the statically derived type. + /** \brief Base class for Vector Expression models + * + * it does not model the Vector Expression concept but all derived types should. + * The class defines a common base type and some common interface for all + * statically derived Vector Expression classes. + * We implement the casts to the statically derived type. + */ template class vector_expression: public ublas_expression { @@ -255,11 +267,13 @@ namespace boost { namespace numeric { namespace ublas { #endif }; - // Base class for Vector container models - - // it does not model the Vector concept but all derived types should. - // The class defines a common base type and some common interface for all - // statically derived Vector classes - // We implement the casts to the statically derived type. + /** \brief Base class for Vector container models + * + * it does not model the Vector concept but all derived types should. + * The class defines a common base type and some common interface for all + * statically derived Vector classes + * We implement the casts to the statically derived type. + */ template class vector_container: public vector_expression { @@ -283,11 +297,13 @@ namespace boost { namespace numeric { namespace ublas { }; - // Base class for Matrix Expression models - - // it does not model the Matrix Expression concept but all derived types should. - // The class defines a common base type and some common interface for all - // statically derived Matrix Expression classes - // We implement the casts to the statically derived type. + /** \brief Base class for Matrix Expression models + * + * it does not model the Matrix Expression concept but all derived types should. + * The class defines a common base type and some common interface for all + * statically derived Matrix Expression classes + * We implement the casts to the statically derived type. + */ template class matrix_expression: public ublas_expression { @@ -458,11 +474,13 @@ namespace boost { namespace numeric { namespace ublas { } #endif - // Base class for Matrix container models - - // it does not model the Matrix concept but all derived types should. - // The class defines a common base type and some common interface for all - // statically derived Matrix classes - // We implement the casts to the statically derived type. + /** \brief Base class for Matrix container models + * + * it does not model the Matrix concept but all derived types should. + * The class defines a common base type and some common interface for all + * statically derived Matrix classes + * We implement the casts to the statically derived type. + */ template class matrix_container: public matrix_expression { diff --git a/include/boost/numeric/ublas/fwd.hpp b/include/boost/numeric/ublas/fwd.hpp index 17ff588d..88855ebc 100644 --- a/include/boost/numeric/ublas/fwd.hpp +++ b/include/boost/numeric/ublas/fwd.hpp @@ -1,6 +1,6 @@ // -// Copyright (c) 2000-2002 -// Joerg Walter, Mathias Koch +// Copyright (c) 2000-2010 +// Joerg Walter, Mathias Koch, David Bellot // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -10,6 +10,8 @@ // GeNeSys mbH & Co. KG in producing this work. // +/// \file fwd.hpp is essentially used to forward declare the main types + #ifndef BOOST_UBLAS_FWD_H #define BOOST_UBLAS_FWD_H diff --git a/include/boost/numeric/ublas/hermitian.hpp b/include/boost/numeric/ublas/hermitian.hpp index b6001e9a..e98f4de0 100644 --- a/include/boost/numeric/ublas/hermitian.hpp +++ b/include/boost/numeric/ublas/hermitian.hpp @@ -1,6 +1,6 @@ // -// Copyright (c) 2000-2002 -// Joerg Walter, Mathias Koch +// Copyright (c) 2000-2010 +// Joerg Walter, Mathias Koch, David Bellot // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -222,8 +222,24 @@ namespace boost { namespace numeric { namespace ublas { }; #endif - - // Array based hermitian matrix class + /** \brief A hermitian matrix of values of type \c T + * + * For a \f$(n \times n)\f$-dimensional matrix and \f$ 0 \leq i < n, 0 \leq j < n\f$, every element + * \f$m_{i,j}\f$ is mapped to the \f$(i.n + j)\f$-th element of the container for row major orientation + * or the \f$(i + j.m)\f$-th element of the container for column major orientation. And + * \f$\forall i,j\f$, \f$m_{i,j} = \overline{m_{i,j}}\f$. + * + * Orientation and storage can also be specified, otherwise a row major and unbounded array are used. + * It is \b not required by the storage to initialize elements of the matrix. + * Moreover, only the given triangular matrix is stored and the storage of hermitian matrices is packed. + * + * See http://en.wikipedia.org/wiki/Hermitian_matrix for more details on hermitian matrices. + * + * \tparam T the type of object stored in the matrix (like double, float, complex, etc...) + * \tparam TRI the type of triangular matrix is either \c lower or \c upper. Default is \c lower + * \tparam L the storage organization. It is either \c row_major or \c column_major. Default is \c row_major + * \tparam A the type of Storage array. Default is \unbounded_array. + */ template class hermitian_matrix: public matrix_container > { @@ -1127,8 +1143,15 @@ namespace boost { namespace numeric { namespace ublas { array_type data_; }; - - // Hermitian matrix adaptor class + /** \brief A Hermitian matrix adaptator: convert a any matrix into a Hermitian matrix expression + * + * For a \f$(m\times n)\f$-dimensional matrix, the \c hermitian_adaptor will provide a hermitian matrix. + * Storage and location are based on those of the underlying matrix. This is important because + * a \c hermitian_adaptor does not copy the matrix data to a new place. Therefore, modifying values + * in a \c hermitian_adaptor matrix will also modify the underlying matrix too. + * + * \tparam M the type of matrix used to generate a hermitian matrix + */ template class hermitian_adaptor: public matrix_expression > { diff --git a/include/boost/numeric/ublas/io.hpp b/include/boost/numeric/ublas/io.hpp index 795dd9bd..1dee6afc 100644 --- a/include/boost/numeric/ublas/io.hpp +++ b/include/boost/numeric/ublas/io.hpp @@ -1,6 +1,6 @@ // -// Copyright (c) 2000-2002 -// Joerg Walter, Mathias Koch +// Copyright (c) 2000-2010 +// Joerg Walter, Mathias Koch, David Bellot // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -21,6 +21,28 @@ namespace boost { namespace numeric { namespace ublas { + /** \brief output stream operator for vector expressions + * + * Any vector expressions can be written to a standard output stream + * as defined in the C++ standard library. For example: + * \code + * vector v1(3),v2(3); + * for(size_t i=0; i<3; i++) + * { + * v1(i) = i+0.2; + * v2(i) = i+0.3; + * } + * cout << v1+v2 << endl; + * \endcode + * will display the some of the 2 vectors like this: + * \code + * [3](0.5,2.5,4.5) + * \endcode + * + * \param os is a standard basic output stream + * \param v is a vector expression + * \return a reference to the resulting output stream + */ template // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. std::basic_ostream &operator << (std::basic_ostream &os, @@ -40,6 +62,28 @@ namespace boost { namespace numeric { namespace ublas { return os << s.str ().c_str (); } + /** \brief input stream operator for vectors + * + * This is used to feed in vectors with data stored as an ASCII representation + * from a standard input stream. + * + * From a file or any valid stream, the format is: + * \c [](,,...) like for example: + * \code + * [5](1,2.1,3.2,3.14,0.2) + * \endcode + * + * You can use it like this + * \code + * my_input_stream >> my_vector; + * \endcode + * + * You can only put data into a valid \c vector<> not a \c vector_expression + * + * \param is is a standard basic input stream + * \param v is a vector + * \return a reference to the resulting input stream + */ template // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. std::basic_istream &operator >> (std::basic_istream &is, @@ -78,6 +122,29 @@ namespace boost { namespace numeric { namespace ublas { return is; } + /** \brief output stream operator for matrix expressions + * + * it outpus the content of a \f$(M \times N)\f$ matrix to a standard output + * stream using the following format: + * \c[,]((,,...,),...,(,,...,)) + * + * For example: + * \code + * matrix m(3,3) = scalar_matrix(3,3,1.0) - diagonal_matrix(3,3,1.0); + * cout << m << endl; + * \encode + * will display + * \code + * [3,3]((0,1,1),(1,0,1),(1,1,0)) + * \endcode + * This output is made for storing and retrieving matrices in a simple way but you can + * easily recognize the following: + * \f[ \left( \begin{array}{ccc} 1 & 1 & 1\\ 1 & 1 & 1\\ 1 & 1 & 1 \end{array} \right) - \left( \begin{array}{ccc} 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{array} \right) = \left( \begin{array}{ccc} 0 & 1 & 1\\ 1 & 0 & 1\\ 1 & 1 & 0 \end{array} \right) \f] + * + * \param os is a standard basic output stream + * \param m is a matrix expression + * \return a reference to the resulting output stream + */ template // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. std::basic_ostream &operator << (std::basic_ostream &os, @@ -110,6 +177,25 @@ namespace boost { namespace numeric { namespace ublas { return os << s.str ().c_str (); } + /** \brief input stream operator for matrices + * + * This is used to feed in matrices with data stored as an ASCII representation + * from a standard input stream. + * + * From a file or any valid standard stream, the format is: + * \c[,]((,,...,),...,(,,...,)) + * + * You can use it like this + * \code + * my_input_stream >> my_matrix; + * \endcode + * + * You can only put data into a valid \c matrix<> not a \c matrix_expression + * + * \param is is a standard basic input stream + * \param m is a matrix + * \return a reference to the resulting input stream + */ template // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. std::basic_istream &operator >> (std::basic_istream &is, @@ -171,7 +257,27 @@ namespace boost { namespace numeric { namespace ublas { return is; } - // Special input operator for symmetrix_matrix + /** \brief special input stream operator for symmetric matrices + * + * This is used to feed in symmetric matrices with data stored as an ASCII + * representation from a standard input stream. + * + * You can simply write your matrices in a file or any valid stream and read them again + * at a later time with this function. The format is the following: + * \code [,]((,,...,),...,(,,...,)) \endcode + * + * You can use it like this + * \code + * my_input_stream >> my_symmetric_matrix; + * \endcode + * + * You can only put data into a valid \c symmetric_matrix<>, not in a \c matrix_expression + * This function also checks that input data form a valid symmetric matrix + * + * \param is is a standard basic input stream + * \param m is a \c symmetric_matrix + * \return a reference to the resulting input stream + */ template // BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it. std::basic_istream &operator >> (std::basic_istream &is, diff --git a/include/boost/numeric/ublas/lu.hpp b/include/boost/numeric/ublas/lu.hpp index a1b56658..f35f4d16 100644 --- a/include/boost/numeric/ublas/lu.hpp +++ b/include/boost/numeric/ublas/lu.hpp @@ -23,6 +23,11 @@ namespace boost { namespace numeric { namespace ublas { + /** \brief + * + * \tparam T + * \tparam A + */ template > class permutation_matrix: public vector { diff --git a/include/boost/numeric/ublas/matrix.hpp b/include/boost/numeric/ublas/matrix.hpp index 505726e6..1a46d0d5 100644 --- a/include/boost/numeric/ublas/matrix.hpp +++ b/include/boost/numeric/ublas/matrix.hpp @@ -1,6 +1,6 @@ // -// Copyright (c) 2000-2007 -// Joerg Walter, Mathias Koch, Gunter Winkler +// Copyright (c) 2000-2010 +// Joerg Walter, Mathias Koch, Gunter Winkler, David Bellot // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -22,7 +22,22 @@ // Iterators based on ideas of Jeremy Siek -namespace boost { namespace numeric { namespace ublas { +namespace boost { namespace numeric { + + /** \brief main namespace of uBLAS. + * + * Use this namespace for all operations with uBLAS. It can also be abbreviated with + * \code namespace ublas = boost::numeric::ublas; \endcode + * + * A common practice is to bring this namespace into the current scope with + * \code using namespace boost::numeric::ublas; \endcode. + * + * However, be warned that using the ublas namespace and the std::vector at the same time can lead to the compiler to confusion. + * The solution is simply to prefix each ublas vector like \c boost::numeric::ublas::vector. If you think it's too long to + * write, you can define a new namespace like \c namespace ublas = boost::numeric::ublas and then just declare your vectors + * with \c ublas::vector. STL vectors will be declared as vector. No need to prefix with \c std:: + */ + namespace ublas { namespace detail { using namespace boost::numeric::ublas; @@ -57,8 +72,20 @@ namespace boost { namespace numeric { namespace ublas { } } - - // Array based matrix class + /** \brief A dense matrix of values of type \c T. + * + * For a \f$(m \times n)\f$-dimensional matrix and \f$ 0 \leq i < m, 0 \leq j < n\f$, every element \f$ m_{i,j} \f$ is mapped to + * the \f$(i.n + j)\f$-th element of the container for row major orientation or the \f$ (i + j.m) \f$-th element of + * the container for column major orientation. In a dense matrix all elements are represented in memory in a + * contiguous chunk of memory by definition. + * + * Orientation and storage can also be specified, otherwise a \c row_major and \c unbounded_array are used. It is \b not + * required by the storage to initialize elements of the matrix. + * + * \tparam T the type of object stored in the matrix (like double, float, complex, etc...) + * \tparam L the storage organization. It can be either \c row_major or \c column_major. Default is \c row_major + * \tparam A the type of Storage array. Default is \c unbounded_array + */ template class matrix: public matrix_container > { @@ -981,8 +1008,22 @@ namespace boost { namespace numeric { namespace ublas { array_type data_; }; - - // Bounded matrix class + /** \brief A dense matrix of values of type \c T with a variable size bounded to a maximum of \f$M\f$ by \f$N\f$. + * + * For a \f$(m \times n)\f$-dimensional matrix and \f$ 0 \leq i < m, 0 \leq j < n\f$, every element \f$m_{i,j}\f$ is mapped + * to the \f$(i.n + j)\f$-th element of the container for row major orientation or the \f$(i + j.m)\f$-th element + * of the container for column major orientation. Finally in a dense matrix all elements are represented in memory + * in a contiguous chunk of memory. + * + * Orientation can be specified. Default is \c row_major + * The default constructor creates the matrix with size \f$M\f$ by \f$N\f$. Elements are constructed by the storage + * type \c bounded_array, which need not initialise their value. + * + * \tparam T the type of object stored in the matrix (like double, float, complex, etc...) + * \tparam M maximum and default number of rows (if not specified at construction) + * \tparam N maximum and default number of columns (if not specified at construction) + * \tparam L the storage organization. It can be either \c row_major or \c column_major. Default is \c row_major + */ template class bounded_matrix: public matrix > { @@ -1050,8 +1091,21 @@ namespace boost { namespace numeric { namespace ublas { } }; - - // Array based matrix class + /** \brief A dense matrix of values of type \c T stored as a vector of vectors. + * + * Rows or columns are not stored into contiguous chunks of memory but data inside rows (or columns) are. + * Orientation and storage can also be specified, otherwise a row major and unbounded arrays are used. + * The data is stored as a vector of vectors, meaning that rows or columns might not be stored into contiguous chunks + * of memory. Orientation and storage can also be specified, otherwise a row major and unbounded arrays are used. + * The storage type defaults to \c unbounded_array> and orientation is \c row_major. It is \b not + * required by the storage to initialize elements of the matrix. For a \f$(m \times n)\f$-dimensional matrix and + * \f$ 0 \leq i < m, 0 \leq j < n\f$, every element \f$m_{i,j}\f$ is mapped to the \f$(i.n + j)\f$-th element of the + * container for row major orientation or the \f$(i + j.m)\f$-th element of the container for column major orientation. + * + * \tparam T the type of object stored in the matrix (like double, float, complex, etc...) + * \tparam L the storage organization. It can be either \c row_major or \c column_major. By default it is \c row_major + * \tparam A the type of Storage array. By default, it is an \unbounded_array> + */ template class vector_of_vector: public matrix_container > { @@ -2032,7 +2086,14 @@ namespace boost { namespace numeric { namespace ublas { }; - // Zero matrix class + /** \brief A matrix with all values of type \c T equal to zero + * + * Changing values does not affect the matrix, however assigning it to a normal matrix will put zero + * everywhere in the target matrix. All accesses are constant time, due to the trivial value. + * + * \tparam T the type of object stored in the matrix (like double, float, complex, etc...) + * \tparam ALLOC an allocator for storing the zero element. By default, a standar allocator is used. + */ template class zero_matrix: public matrix_container > { @@ -2411,8 +2472,15 @@ namespace boost { namespace numeric { namespace ublas { template const typename zero_matrix::value_type zero_matrix::zero_ = T(/*zero*/); - - // Identity matrix class + /** \brief An identity matrix with values of type \c T + * + * Elements or cordinates \f$(i,i)\f$ are equal to 1 (one) and all others to 0 (zero). + * Changing values does not affect the matrix, however assigning it to a normal matrix will + * make the matrix equal to an identity matrix. All accesses are constant du to the trivial values. + * + * \tparam T the type of object stored in the matrix (like double, float, complex, etc...) + * \tparam ALLOC an allocator for storing the zeros and one elements. By default, a standar allocator is used. + */ template class identity_matrix: public matrix_container > { @@ -2821,7 +2889,14 @@ namespace boost { namespace numeric { namespace ublas { const typename identity_matrix::value_type identity_matrix::one_ (1); // ISSUE: need 'one'-traits here - // Scalar matrix class + /** \brief A matrix with all values of type \c T equal to the same value + * + * Changing one value has the effect of changing all the values. Assigning it to a normal matrix will copy + * the same value everywhere in this matrix. All accesses are constant time, due to the trivial value. + * + * \tparam T the type of object stored in the matrix (like double, float, complex, etc...) + * \tparam ALLOC an allocator for storing the unique value. By default, a standar allocator is used. + */ template class scalar_matrix: public matrix_container > { @@ -3275,7 +3350,23 @@ namespace boost { namespace numeric { namespace ublas { }; - // Array based matrix class + /** \brief An array based matrix class which size is defined at type specification or object instanciation + * + * This matrix is directly based on a predefined C-style arry of data, thus providing the fastest + * implementation possible. The constraint is that dimensions of the matrix must be specified at + * the instanciation or the type specification. + * + * For instance, \code typedef c_matrix my_4by4_matrix \endcode + * defines a 4 by 4 double-precision matrix. You can also instantiate it directly with + * \code c_matrix my_fast_matrix \endcode. This will make a 8 by 5 integer matrix. The + * price to pay for this speed is that you cannot resize it to a size larger than the one defined + * in the template parameters. In the previous example, a size of 4 by 5 or 3 by 2 is acceptable, + * but a new size of 9 by 5 or even 10 by 10 will raise a bad_size() exception. + * + * \tparam T the type of object stored in the matrix (like double, float, complex, etc...) + * \tparam N the default maximum number of rows + * \tparam M the default maximum number of columns + */ template class c_matrix: public matrix_container > { diff --git a/include/boost/numeric/ublas/matrix_proxy.hpp b/include/boost/numeric/ublas/matrix_proxy.hpp index d097af79..0aa6f9b1 100644 --- a/include/boost/numeric/ublas/matrix_proxy.hpp +++ b/include/boost/numeric/ublas/matrix_proxy.hpp @@ -22,7 +22,8 @@ namespace boost { namespace numeric { namespace ublas { - // Matrix based row vector class + /** \brief + */ template class matrix_row: public vector_expression > { @@ -1856,6 +1857,7 @@ namespace boost { namespace numeric { namespace ublas { : vector_temporary_traits< M > {} ; // Matrix based vector indirection class + template class matrix_vector_indirect: public vector_expression > { @@ -4162,6 +4164,24 @@ namespace boost { namespace numeric { namespace ublas { // Matrix based indirection class // Contributed by Toon Knapen. // Extended and optimized by Kresimir Fresl. + /** \brief A matrix referencing a non continuous submatrix of elements given another matrix of indices. + * + * It is the most general version of any submatrices because it uses another matrix of indices to reference + * the submatrix. + * + * The matrix of indices can be of any type with the restriction that its elements must be + * type-compatible with the size_type \c of the container. In practice, the following are good candidates: + * - \c boost::numeric::ublas::indirect_array where \c A can be \c int, \c size_t, \c long, etc... + * - \c boost::numeric::ublas::matrix can work too (\c int can be replaced by another integer type) + * - etc... + * + * An indirect matrix can be used as a normal matrix in any expression. If the specified indirect matrix + * falls outside that of the indices of the matrix, then the \c matrix_indirect is not a well formed + * \i Matrix \i Expression and access to an element outside of indices of the matrix is \b undefined. + * + * \tparam V the type of the referenced matrix, for example \c matrix) + * \tparam IA the type of index matrix. Default is \c ublas::indirect_array<> + */ template class matrix_indirect: public matrix_expression > { diff --git a/include/boost/numeric/ublas/matrix_sparse.hpp b/include/boost/numeric/ublas/matrix_sparse.hpp index baa3b5a8..9324108e 100644 --- a/include/boost/numeric/ublas/matrix_sparse.hpp +++ b/include/boost/numeric/ublas/matrix_sparse.hpp @@ -246,8 +246,24 @@ namespace boost { namespace numeric { namespace ublas { #endif - - // Index map based sparse matrix class + /** \brief Index map based sparse matrix of values of type \c T + * + * This class represents a matrix by using a \c key to value mapping. The default type is + * \code template > class mapped_matrix; \endcode + * So, by default a STL map container is used to associate keys and values. The key is computed depending on + * the layout type \c L as \code key = layout_type::element(i, size1_, j, size2_); \endcode + * which means \code key = (i*size2+j) \endcode for a row major matrix. + * Limitations: The matrix size must not exceed \f$(size1*size2) < \f$ \code std::limits \endcode. + * The \ref find1() and \ref find2() operations have a complexity of at least \f$\mathcal{O}(log(nnz))\f$, depending + * on the efficiency of \c std::lower_bound on the key set of the map. + * Orientation and storage can also be specified, otherwise a row major orientation is used. + * It is \b not required by the storage to initialize elements of the matrix. By default, the orientation is \c row_major. + * + * \sa fwd.hpp, storage_sparse.hpp + * + * \tparam T the type of object stored in the matrix (like double, float, complex, etc...) + * \tparam L the storage organization. It can be either \c row_major or \c column_major. By default it is \c row_major + */ template class mapped_matrix: public matrix_container > { diff --git a/include/boost/numeric/ublas/traits.hpp b/include/boost/numeric/ublas/traits.hpp index 5a8d50ed..6964031c 100644 --- a/include/boost/numeric/ublas/traits.hpp +++ b/include/boost/numeric/ublas/traits.hpp @@ -23,6 +23,11 @@ #include #include +#include +#include +#include +#include +#include // anonymous namespace to avoid ADL issues namespace { diff --git a/include/boost/numeric/ublas/triangular.hpp b/include/boost/numeric/ublas/triangular.hpp index 8ea510dc..b537df96 100644 --- a/include/boost/numeric/ublas/triangular.hpp +++ b/include/boost/numeric/ublas/triangular.hpp @@ -57,7 +57,23 @@ namespace boost { namespace numeric { namespace ublas { } } - // Array based triangular matrix class + /** \brief A triangular matrix of values of type \c T. + * + * For a \f$(n \times n )\f$-dimensional lower triangular matrix and if \f$0 \leq i < n\f$, \f$0 \leq j < n\f$ and \f$i>j\f$ holds, + * \f$m_{i,j}=0\f$. Furthermore if \f$m_{i,i}=1\f$, the matrix is called unit lower triangular. + * + * For a \f$(n \times n )\f$-dimensional upper triangular matrix and if \f$0 \leq i < n\f$, \f$0 \leq j < n\f$ and \f$i class triangular_matrix: public matrix_container > { diff --git a/include/boost/numeric/ublas/vector.hpp b/include/boost/numeric/ublas/vector.hpp index 29366fb3..00b9b913 100644 --- a/include/boost/numeric/ublas/vector.hpp +++ b/include/boost/numeric/ublas/vector.hpp @@ -1,6 +1,6 @@ // -// Copyright (c) 2000-2002 -// Joerg Walter, Mathias Koch +// Copyright (c) 2000-2010 +// Joerg Walter, Mathias Koch, David Bellot // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -9,6 +9,9 @@ // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. // +// And we acknowledge the support from all contributors. + +/// \file vector.hpp Definition for the class vector and its derivative #ifndef _BOOST_UBLAS_VECTOR_ #define _BOOST_UBLAS_VECTOR_ @@ -19,11 +22,20 @@ #include #include + // Iterators based on ideas of Jeremy Siek namespace boost { namespace numeric { namespace ublas { - // Array based vector class + /** \brief A dense vector of values of type \c T. + * + * For a \f$n\f$-dimensional vector \f$v\f$ and \f$0\leq i < n\f$ every element \f$v_i\f$ is mapped + * to the \f$i\f$-th element of the container. A storage type \c A can be specified which defaults to \c unbounded_array. + * Elements are constructed by \c A, which need not initialise their value. + * + * \tparam T type of the objects stored in the vector (like int, double, complex,...) + * \tparam A The type of the storage array of the vector. Default is \c unbounded_array. \c and \c std::vector can also be used + */ template class vector: public vector_container > { @@ -33,7 +45,8 @@ namespace boost { namespace numeric { namespace ublas { #ifdef BOOST_UBLAS_ENABLE_PROXY_SHORTCUTS using vector_container::operator (); #endif - typedef typename A::size_type size_type; + + typedef typename A::size_type size_type; typedef typename A::difference_type difference_type; typedef T value_type; typedef typename type_traits::const_reference const_reference; @@ -47,27 +60,60 @@ namespace boost { namespace numeric { namespace ublas { typedef dense_tag storage_category; // Construction and destruction + + /// \brief Constructor of a vector + /// By default it is empty, i.e. \c size()==0. BOOST_UBLAS_INLINE vector (): vector_container (), data_ () {} + + /// \brief Constructor of a vector with a predefined size + /// By default, its elements are initialized to 0. + /// \param size initial size of the vector explicit BOOST_UBLAS_INLINE vector (size_type size): vector_container (), data_ (size) { } + + /// \brief Constructor of a vector by copying from another container + /// This type has the generic name \c array_typ within the vector definition. + /// \param size initial size of the vector \bug this value is not used + /// \param data container of type \c A + /// \todo remove this definition because \c size is not used BOOST_UBLAS_INLINE vector (size_type size, const array_type &data): vector_container (), data_ (data) {} + + /// \brief Constructor of a vector by copying from another container + /// This type has the generic name \c array_typ within the vector definition. + /// \param data container of type \c A + BOOST_UBLAS_INLINE + vector (const array_type &data): + vector_container (), + data_ (data) {} + + /// \brief Constructor of a vector with a predefined size and a unique initial value + /// \param size of the vector + /// \param init value to assign to each element of the vector BOOST_UBLAS_INLINE vector (size_type size, const value_type &init): vector_container (), data_ (size, init) {} + + /// \brief Copy-constructor of a vector + /// \param v is the vector to be duplicated BOOST_UBLAS_INLINE vector (const vector &v): vector_container (), data_ (v.data_) {} + + /// \brief Copy-constructor of a vector from a vector_expression + /// Depending on the vector_expression, this constructor can have the cost of the computations + /// of the expression (trivial to say it, but it is to take into account in your complexity calculations). + /// \param ae the vector_expression which values will be duplicated into the vector template BOOST_UBLAS_INLINE vector (const vector_expression &ae): @@ -76,33 +122,58 @@ namespace boost { namespace numeric { namespace ublas { vector_assign (*this, ae); } + // ----------------------- // Random Access Container + // ----------------------- + + /// \brief Return the maximum size of the data container. + /// Return the upper bound (maximum size) on the data container. Depending on the container, it can be bigger than the current size of the vector. BOOST_UBLAS_INLINE size_type max_size () const { return data_.max_size (); } + /// \brief Return true if the vector is empty (\c size==0) + /// \return \c true if empty, \c false otherwise BOOST_UBLAS_INLINE bool empty () const { return data_.size () == 0; } + + // --------- // Accessors + // --------- + + /// \brief Return the size of the vector BOOST_UBLAS_INLINE size_type size () const { return data_.size (); } + // ----------------- // Storage accessors + // ----------------- + + /// \brief Return a \c const reference to the container. Useful to access data directly for specific type of container. BOOST_UBLAS_INLINE const array_type &data () const { return data_; } + + /// \brief Return a reference to the container. Useful to speed-up write operations to the data in very specific case. BOOST_UBLAS_INLINE array_type &data () { return data_; } + // -------- // Resizing + // -------- + + /// \brief Resize the vector + /// Resize the vector to a new size. If \c preserve is true, data are copied otherwise data are lost. If the new size is bigger, the remaining values are filled in with the initial value (0 by default) in the case of \c unbounded_array, which is the container by default. If the new size is smaller, last values are lost. This behaviour can be different if you explicitely specify another type of container. + /// \param size new size of the vector + /// \param preserve if true, keep values BOOST_UBLAS_INLINE void resize (size_type size, bool preserve = true) { if (preserve) @@ -111,46 +182,85 @@ namespace boost { namespace numeric { namespace ublas { data ().resize (size); } + // --------------- // Element support + // --------------- + + /// \brief Return a pointer to the element \f$i\f$ + /// \param i index of the element + // XXX this semantic is not the one expected by the name of this method BOOST_UBLAS_INLINE pointer find_element (size_type i) { return const_cast (const_cast(*this).find_element (i)); } + + /// \brief Return a const pointer to the element \f$i\f$ + /// \param i index of the element + // XXX this semantic is not the one expected by the name of this method BOOST_UBLAS_INLINE const_pointer find_element (size_type i) const { return & (data () [i]); } + // -------------- // Element access + // -------------- + + /// \brief Return a const reference to the element \f$i\f$ + /// Return a const reference to the element \f$i\f$. With some compilers, this notation will be faster than \c[i] + /// \param i index of the element BOOST_UBLAS_INLINE const_reference operator () (size_type i) const { return data () [i]; } + + /// \brief Return a reference to the element \f$i\f$ + /// Return a reference to the element \f$i\f$. With some compilers, this notation will be faster than \c[i] + /// \param i index of the element BOOST_UBLAS_INLINE reference operator () (size_type i) { return data () [i]; } + /// \brief Return a const reference to the element \f$i\f$ + /// \param i index of the element BOOST_UBLAS_INLINE const_reference operator [] (size_type i) const { return (*this) (i); } + + /// \brief Return a reference to the element \f$i\f$ + /// \param i index of the element BOOST_UBLAS_INLINE reference operator [] (size_type i) { return (*this) (i); } + // ------------------ // Element assignment + // ------------------ + + /// \brief Set element \f$i\f$ to the value \c t + /// \param i index of the element + /// \param t reference to the value to be set + // XXX semantic of this is to insert a new element and therefore size=size+1 ? BOOST_UBLAS_INLINE reference insert_element (size_type i, const_reference t) { return (data () [i] = t); } + + /// \brief Set element \f$i\f$ to the \e zero value + /// \param i index of the element BOOST_UBLAS_INLINE void erase_element (size_type i) { data () [i] = value_type/*zero*/(); } + // ------- // Zeroing + // ------- + + /// \brief Clear the vector, i.e. set all values to the \c zero value. BOOST_UBLAS_INLINE void clear () { std::fill (data ().begin (), data ().end (), value_type/*zero*/()); @@ -159,6 +269,9 @@ namespace boost { namespace numeric { namespace ublas { // Assignment #ifdef BOOST_UBLAS_MOVE_SEMANTICS + /// \brief Assign a full vector (\e RHS-vector) to the current vector (\e LHS-vector) + /// \param v is the source vector + /// \return a reference to a vector (i.e. the destination vector) /*! @note "pass by value" the key idea to enable move semantics */ BOOST_UBLAS_INLINE vector &operator = (vector v) { @@ -166,12 +279,20 @@ namespace boost { namespace numeric { namespace ublas { return *this; } #else + /// \brief Assign a full vector (\e RHS-vector) to the current vector (\e LHS-vector) + /// \param v is the source vector + /// \return a reference to a vector (i.e. the destination vector) BOOST_UBLAS_INLINE vector &operator = (const vector &v) { data () = v.data (); return *this; } #endif + + /// \brief Assign a full vector (\e RHS-vector) to the current vector (\e LHS-vector) + /// Assign a full vector (\e RHS-vector) to the current vector (\e LHS-vector). This method does not create any temporary. + /// \param v is the source vector container + /// \return a reference to a vector (i.e. the destination vector) template // Container assignment without temporary BOOST_UBLAS_INLINE vector &operator = (const vector_container &v) { @@ -179,17 +300,33 @@ namespace boost { namespace numeric { namespace ublas { assign (v); return *this; } + + /// \brief Assign a full vector (\e RHS-vector) to the current vector (\e LHS-vector) + /// \param v is the source vector + /// \return a reference to a vector (i.e. the destination vector) BOOST_UBLAS_INLINE vector &assign_temporary (vector &v) { swap (v); return *this; } + + /// \brief Assign the result of a vector_expression to the vector + /// Assign the result of a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. + /// \tparam AE is the type of the vector_expression + /// \param ae is a const reference to the vector_expression + /// \return a reference to the resulting vector template BOOST_UBLAS_INLINE vector &operator = (const vector_expression &ae) { self_type temporary (ae); return assign_temporary (temporary); } + + /// \brief Assign the result of a vector_expression to the vector + /// Assign the result of a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. + /// \tparam AE is the type of the vector_expression + /// \param ae is a const reference to the vector_expression + /// \return a reference to the resulting vector template BOOST_UBLAS_INLINE vector &assign (const vector_expression &ae) { @@ -197,49 +334,106 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // ------------------- // Computed assignment + // ------------------- + + /// \brief Assign the sum of the vector and a vector_expression to the vector + /// Assign the sum of the vector and a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. + /// A temporary is created for the computations. + /// \tparam AE is the type of the vector_expression + /// \param ae is a const reference to the vector_expression + /// \return a reference to the resulting vector template BOOST_UBLAS_INLINE vector &operator += (const vector_expression &ae) { self_type temporary (*this + ae); return assign_temporary (temporary); } + + /// \brief Assign the sum of the vector and a vector_expression to the vector + /// Assign the sum of the vector and a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. + /// No temporary is created. Computations are done and stored directly into the resulting vector. + /// \tparam AE is the type of the vector_expression + /// \param ae is a const reference to the vector_expression + /// \return a reference to the resulting vector template // Container assignment without temporary BOOST_UBLAS_INLINE vector &operator += (const vector_container &v) { plus_assign (v); return *this; } + + /// \brief Assign the sum of the vector and a vector_expression to the vector + /// Assign the sum of the vector and a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. + /// No temporary is created. Computations are done and stored directly into the resulting vector. + /// \tparam AE is the type of the vector_expression + /// \param ae is a const reference to the vector_expression + /// \return a reference to the resulting vector template BOOST_UBLAS_INLINE vector &plus_assign (const vector_expression &ae) { vector_assign (*this, ae); return *this; } + + /// \brief Assign the difference of the vector and a vector_expression to the vector + /// Assign the difference of the vector and a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. + /// A temporary is created for the computations. + /// \tparam AE is the type of the vector_expression + /// \param ae is a const reference to the vector_expression template BOOST_UBLAS_INLINE vector &operator -= (const vector_expression &ae) { self_type temporary (*this - ae); return assign_temporary (temporary); } + + /// \brief Assign the difference of the vector and a vector_expression to the vector + /// Assign the difference of the vector and a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. + /// No temporary is created. Computations are done and stored directly into the resulting vector. + /// \tparam AE is the type of the vector_expression + /// \param ae is a const reference to the vector_expression + /// \return a reference to the resulting vector template // Container assignment without temporary BOOST_UBLAS_INLINE vector &operator -= (const vector_container &v) { minus_assign (v); return *this; } + + /// \brief Assign the difference of the vector and a vector_expression to the vector + /// Assign the difference of the vector and a vector_expression to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. + /// No temporary is created. Computations are done and stored directly into the resulting vector. + /// \tparam AE is the type of the vector_expression + /// \param ae is a const reference to the vector_expression + /// \return a reference to the resulting vector template BOOST_UBLAS_INLINE vector &minus_assign (const vector_expression &ae) { vector_assign (*this, ae); return *this; } + + /// \brief Assign the product of the vector and a scalar to the vector + /// Assign the product of the vector and a scalar to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. + /// No temporary is created. Computations are done and stored directly into the resulting vector. + /// \tparam AE is the type of the vector_expression + /// \param at is a const reference to the scalar + /// \return a reference to the resulting vector template BOOST_UBLAS_INLINE vector &operator *= (const AT &at) { vector_assign_scalar (*this, at); return *this; } + + /// \brief Assign the division of the vector by a scalar to the vector + /// Assign the division of the vector by a scalar to the vector. This is lazy-compiled and will be optimized out by the compiler on any type of expression. + /// No temporary is created. Computations are done and stored directly into the resulting vector. + /// \tparam AE is the type of the vector_expression + /// \param at is a const reference to the scalar + /// \return a reference to the resulting vector template BOOST_UBLAS_INLINE vector &operator /= (const AT &at) { @@ -247,13 +441,22 @@ namespace boost { namespace numeric { namespace ublas { return *this; } + // -------- // Swapping + // -------- + + /// \brief Swap the content of the vector with another vector + /// \param v is the vector to be swapped with BOOST_UBLAS_INLINE void swap (vector &v) { if (this != &v) { data ().swap (v.data ()); } } + + /// \brief Swap the content of two vectors + /// \param v1 is the first vector. It takes values from v2 + /// \param v2 is the second vector It takes values from v1 BOOST_UBLAS_INLINE friend void swap (vector &v1, vector &v2) { v1.swap (v2); @@ -274,7 +477,12 @@ namespace boost { namespace numeric { namespace ublas { class iterator; #endif + // -------------- // Element lookup + // -------------- + + /// \brief Return a const iterator to the element \e i + /// \param i index of the element BOOST_UBLAS_INLINE const_iterator find (size_type i) const { #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -283,6 +491,9 @@ namespace boost { namespace numeric { namespace ublas { return const_iterator (*this, i); #endif } + + /// \brief Return an iterator to the element \e i + /// \param i index of the element BOOST_UBLAS_INLINE iterator find (size_type i) { #ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR @@ -303,7 +514,11 @@ namespace boost { namespace numeric { namespace ublas { typedef typename vector::const_reference reference; typedef const typename vector::pointer pointer; + // ---------------------------- // Construction and destruction + // ---------------------------- + + BOOST_UBLAS_INLINE const_iterator (): container_const_reference (), it_ () {} @@ -314,45 +529,69 @@ namespace boost { namespace numeric { namespace ublas { const_iterator (const typename self_type::iterator &it): // ISSUE vector:: stops VC8 using std::iterator here container_const_reference (it ()), it_ (it.it_) {} + // ---------- // Arithmetic + // ---------- + + /// \brief Increment by 1 the position of the iterator + /// \return a reference to the const iterator BOOST_UBLAS_INLINE const_iterator &operator ++ () { ++ it_; return *this; } + + /// \brief Decrement by 1 the position of the iterator + /// \return a reference to the const iterator BOOST_UBLAS_INLINE const_iterator &operator -- () { -- it_; return *this; } + + /// \brief Increment by \e n the position of the iterator + /// \return a reference to the const iterator BOOST_UBLAS_INLINE const_iterator &operator += (difference_type n) { it_ += n; return *this; } + + /// \brief Decrement by \e n the position of the iterator + /// \return a reference to the const iterator BOOST_UBLAS_INLINE const_iterator &operator -= (difference_type n) { it_ -= n; return *this; } + + /// \brief Return the different in number of positions between 2 iterators BOOST_UBLAS_INLINE difference_type operator - (const const_iterator &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); return it_ - it.it_; } - // Dereference + /// \brief Dereference an iterator + /// Dereference an iterator: a bounds' check is done before returning the value. A bad_index() expection is returned if out of bounds. + /// \return a const reference to the value pointed by the iterator BOOST_UBLAS_INLINE const_reference operator * () const { BOOST_UBLAS_CHECK (it_ >= (*this) ().begin ().it_ && it_ < (*this) ().end ().it_, bad_index ()); return *it_; } + + /// \brief Dereference an iterator at the n-th forward value + /// Dereference an iterator at the n-th forward value, that is the value pointed by iterator+n. + /// A bounds' check is done before returning the value. A bad_index() expection is returned if out of bounds. + /// \return a const reference BOOST_UBLAS_INLINE const_reference operator [] (difference_type n) const { return *(it_ + n); } // Index + /// \brief return the index of the element referenced by the iterator BOOST_UBLAS_INLINE size_type index () const { BOOST_UBLAS_CHECK (it_ >= (*this) ().begin ().it_ && it_ < (*this) ().end ().it_, bad_index ()); @@ -361,6 +600,7 @@ namespace boost { namespace numeric { namespace ublas { // Assignment BOOST_UBLAS_INLINE + /// \brief assign the value of an iterator to the iterator const_iterator &operator = (const const_iterator &it) { container_const_reference::assign (&it ()); it_ = it.it_; @@ -368,11 +608,17 @@ namespace boost { namespace numeric { namespace ublas { } // Comparison + /// \brief compare the value of two itetarors + /// \return true if they reference the same element BOOST_UBLAS_INLINE bool operator == (const const_iterator &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); return it_ == it.it_; } + + + /// \brief compare the value of two iterators + /// \return return true if the left-hand-side iterator refers to a value placed before the right-hand-side iterator BOOST_UBLAS_INLINE bool operator < (const const_iterator &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); @@ -386,10 +632,13 @@ namespace boost { namespace numeric { namespace ublas { }; #endif + /// \brief return an iterator on the first element of the vector BOOST_UBLAS_INLINE const_iterator begin () const { return find (0); } + + /// \brief return an iterator after the last element of the vector BOOST_UBLAS_INLINE const_iterator end () const { return find (data_.size ()); @@ -487,10 +736,13 @@ namespace boost { namespace numeric { namespace ublas { }; #endif + /// \brief Return an iterator on the first element of the vector BOOST_UBLAS_INLINE iterator begin () { return find (0); } + + /// \brief Return an iterator at the end of the vector BOOST_UBLAS_INLINE iterator end () { return find (data_.size ()); @@ -500,24 +752,37 @@ namespace boost { namespace numeric { namespace ublas { typedef reverse_iterator_base const_reverse_iterator; typedef reverse_iterator_base reverse_iterator; + /// \brief Return a const reverse iterator before the first element of the reversed vector (i.e. end() of normal vector) BOOST_UBLAS_INLINE const_reverse_iterator rbegin () const { return const_reverse_iterator (end ()); } + + /// \brief Return a const reverse iterator on the end of the reverse vector (i.e. first element of the normal vector) BOOST_UBLAS_INLINE const_reverse_iterator rend () const { return const_reverse_iterator (begin ()); } + + /// \brief Return a const reverse iterator before the first element of the reversed vector (i.e. end() of normal vector) BOOST_UBLAS_INLINE reverse_iterator rbegin () { return reverse_iterator (end ()); } + + /// \brief Return a const reverse iterator on the end of the reverse vector (i.e. first element of the normal vector) BOOST_UBLAS_INLINE reverse_iterator rend () { return reverse_iterator (begin ()); } + // ------------- // Serialization + // ------------- + + /// Serialize a vector into and archive as defined in Boost + /// \param ar Archive object. Can be a flat file, an XML file or any other stream + /// \param file_version Optional file version (not yet used) template void serialize(Archive & ar, const unsigned int /* file_version */){ ar & serialization::make_nvp("data",data_); @@ -528,7 +793,13 @@ namespace boost { namespace numeric { namespace ublas { }; + // -------------------- // Bounded vector class + // -------------------- + + /// \brief a dense vector of values of type \c T, of variable size but with maximum \f$N\f$. + /// A dense vector of values of type \c T, of variable size but with maximum \f$N\f$. The default constructor + /// creates the vector with size \f$N\f$. Elements are constructed by the storage type \c bounded_array, which \b need \b not \b initialise their value. template class bounded_vector: public vector > { @@ -596,7 +867,14 @@ namespace boost { namespace numeric { namespace ublas { }; + // ----------------- // Zero vector class + // ----------------- + + /// \brief A zero vector of type \c T and a given \c size + /// A zero vector of type \c T and a given \c size. This is a virtual vector in the sense that no memory is allocated + /// for storing the zero values: it still acts like any other vector. However assigning values to it will not change the zero + /// vector into a normal vector. It must first be assigned to another normal vector by any suitable means. Its memory footprint is constant. template class zero_vector: public vector_container > { @@ -797,6 +1075,11 @@ namespace boost { namespace numeric { namespace ublas { // Unit vector class + /// \brief unit_vector represents a canonical unit vector + /// unit_vector represents a canonical unit vector. The \e k-th unit vector of dimension \f$n\f$ holds 0 for every value \f$u_i\f$ s.t. \f$i \neq k\f$ and 1 when \f$i=k\f$. + /// At construction, the value \e k is given after the dimension of the vector. + /// \tparam T is the type of elements in the vector. They must be 0 and 1 assignable in order for the vector to have its unit-vector semantic. + /// \tparam ALLOC a specific allocator can be specified if needed. Most of the time this parameter is omited. template class unit_vector: public vector_container > { @@ -817,36 +1100,55 @@ namespace boost { namespace numeric { namespace ublas { typedef sparse_tag storage_category; // Construction and destruction + /// \brief Simple constructor with dimension and index 0 BOOST_UBLAS_INLINE unit_vector (): vector_container (), size_ (0), index_ (0) {} + + /// \brief Constructor of unit_vector + /// \param size is the dimension of the vector + /// \param index is the order of the vector BOOST_UBLAS_INLINE explicit unit_vector (size_type size, size_type index = 0): vector_container (), size_ (size), index_ (index) {} + + /// \brief Copy-constructor BOOST_UBLAS_INLINE unit_vector (const unit_vector &v): vector_container (), size_ (v.size_), index_ (v.index_) {} // Accessors + //---------- + + /// \brief Return the size (dimension) of the vector BOOST_UBLAS_INLINE size_type size () const { return size_; } + + /// \brief Return the order of the unit vector BOOST_UBLAS_INLINE size_type index () const { return index_; } // Resizing + // -------- + + /// \brief Resize the vector. The values are preserved by default (i.e. the index does not change) + /// \param size is the new size of the vector BOOST_UBLAS_INLINE void resize (size_type size, bool /*preserve*/ = true) { size_ = size; } // Element support + // --------------- + + /// \brief Return a const pointer to the element of index i BOOST_UBLAS_INLINE const_pointer find_element (size_type i) const { if (i == index_) @@ -1020,8 +1322,11 @@ namespace boost { namespace numeric { namespace ublas { template typename unit_vector::const_value_type unit_vector::one_ (1); // ISSUE: need 'one'-traits here - - // Scalar vector class + /// \brief A scalar (i.e. unique value) vector of type \c T and a given \c size + /// A scalar (i.e. unique value) vector of type \c T and a given \c size. This is a virtual vector in the sense that no memory is allocated + /// for storing the unique value more than once: it still acts like any other vector. However assigning a new value will change all the value at once. + /// vector into a normal vector. It must first be assigned to another normal vector by any suitable means. Its memory footprint is constant. + /// \tparam T type of the objects stored in the vector: it can be anything even if most of the time, scalar types will be used like \c double or \c int. Complex types can be used, or even classes like boost::interval. template class scalar_vector: public vector_container > { @@ -1257,8 +1562,11 @@ namespace boost { namespace numeric { namespace ublas { value_type value_; }; - + // ------------------------ // Array based vector class + // ------------------------ + + /// \brief A dense vector of values of type \c T with the given \c size. The data is stored as an ordinary C++ array \c T \c data_[M] template class c_vector: public vector_container > { diff --git a/include/boost/numeric/ublas/vector_proxy.hpp b/include/boost/numeric/ublas/vector_proxy.hpp index 6e80a27c..d6e2b777 100644 --- a/include/boost/numeric/ublas/vector_proxy.hpp +++ b/include/boost/numeric/ublas/vector_proxy.hpp @@ -21,7 +21,15 @@ namespace boost { namespace numeric { namespace ublas { - // Vector based range class + /** \brief A vector referencing a continuous subvector of elements of vector \c v containing all elements specified by \c range. + * + * A vector range can be used as a normal vector in any expression. + * If the specified range falls outside that of the index range of the vector, then + * the \c vector_range is not a well formed \i Vector \i Expression and access to an + * element outside of index range of the vector is \b undefined. + * + * \tparam V the type of vector referenced (for example \c vector) + */ template class vector_range: public vector_expression > { @@ -476,13 +484,27 @@ namespace boost { namespace numeric { namespace ublas { range_type r_; }; + // ------------------ // Simple Projections + // ------------------ + + /** \brief Return a \c vector_range on a specified vector, a start and stop index. + * Return a \c vector_range on a specified vector, a start and stop index. The resulting \c vector_range can be manipulated like a normal vector. + * If the specified range falls outside that of of the index range of the vector, then the resulting \c vector_range is not a well formed + * Vector Expression and access to an element outside of index range of the vector is \b undefined. + */ template BOOST_UBLAS_INLINE vector_range subrange (V &data, typename V::size_type start, typename V::size_type stop) { typedef basic_range range_type; return vector_range (data, range_type (start, stop)); } + + /** \brief Return a \c const \c vector_range on a specified vector, a start and stop index. + * Return a \c const \c vector_range on a specified vector, a start and stop index. The resulting \c const \c vector_range can be manipulated like a normal vector. + *If the specified range falls outside that of of the index range of the vector, then the resulting \c vector_range is not a well formed + * Vector Expression and access to an element outside of index range of the vector is \b undefined. + */ template BOOST_UBLAS_INLINE vector_range subrange (const V &data, typename V::size_type start, typename V::size_type stop) { @@ -490,23 +512,49 @@ namespace boost { namespace numeric { namespace ublas { return vector_range (data, range_type (start, stop)); } + // ------------------- // Generic Projections + // ------------------- + + /** \brief Return a \c const \c vector_range on a specified vector and \c range + * Return a \c const \c vector_range on a specified vector and \c range. The resulting \c vector_range can be manipulated like a normal vector. + * If the specified range falls outside that of of the index range of the vector, then the resulting \c vector_range is not a well formed + * Vector Expression and access to an element outside of index range of the vector is \b undefined. + */ template BOOST_UBLAS_INLINE vector_range project (V &data, typename vector_range::range_type const &r) { return vector_range (data, r); } + + /** \brief Return a \c vector_range on a specified vector and \c range + * Return a \c vector_range on a specified vector and \c range. The resulting \c vector_range can be manipulated like a normal vector. + * If the specified range falls outside that of of the index range of the vector, then the resulting \c vector_range is not a well formed + * Vector Expression and access to an element outside of index range of the vector is \b undefined. + */ template BOOST_UBLAS_INLINE const vector_range project (const V &data, typename vector_range::range_type const &r) { // ISSUE was: return vector_range (const_cast (data), r); return vector_range (data, r); - } + } + + /** \brief Return a \c const \c vector_range on a specified vector and const \c range + * Return a \c const \c vector_range on a specified vector and const \c range. The resulting \c vector_range can be manipulated like a normal vector. + * If the specified range falls outside that of of the index range of the vector, then the resulting \c vector_range is not a well formed + * Vector Expression and access to an element outside of index range of the vector is \b undefined. + */ template BOOST_UBLAS_INLINE vector_range project (vector_range &data, const typename vector_range::range_type &r) { return data.project (r); } + + /** \brief Return a \c vector_range on a specified vector and const \c range + * Return a \c vector_range on a specified vector and const \c range. The resulting \c vector_range can be manipulated like a normal vector. + * If the specified range falls outside that of of the index range of the vector, then the resulting \c vector_range is not a well formed + * Vector Expression and access to an element outside of index range of the vector is \b undefined. + */ template BOOST_UBLAS_INLINE const vector_range project (const vector_range &data, const typename vector_range::range_type &r) { @@ -522,7 +570,20 @@ namespace boost { namespace numeric { namespace ublas { : vector_temporary_traits< V > {} ; - // Vector based slice class + /** \brief A vector referencing a non continuous subvector of elements of vector v containing all elements specified by \c slice. + * + * A vector slice can be used as a normal vector in any expression. + * If the specified slice falls outside that of the index slice of the vector, then + * the \c vector_slice is not a well formed \i Vector \i Expression and access to an + * element outside of index slice of the vector is \b undefined. + * + * A slice is a generalization of a range. In a range going from \f$a\f$ to \f$b\f$, + * all elements belong to the range. In a slice, a \i \f$step\f$ can be specified meaning to + * take one element over \f$step\f$ in the range specified from \f$a\f$ to \f$b\f$. + * Obviously, a slice with a \f$step\f$ of 1 is equivalent to a range. + * + * \tparam V the type of vector referenced (for example \c vector) + */ template class vector_slice: public vector_expression > { @@ -1046,6 +1107,26 @@ namespace boost { namespace numeric { namespace ublas { // Vector based indirection class // Contributed by Toon Knapen. // Extended and optimized by Kresimir Fresl. + + /** \brief A vector referencing a non continuous subvector of elements given another vector of indices. + * + * It is the most general version of any subvectors because it uses another vector of indices to reference + * the subvector. + * + * The vector of indices can be of any type with the restriction that its elements must be + * type-compatible with the size_type \c of the container. In practice, the following are good candidates: + * - \c boost::numeric::ublas::indirect_array where \c A can be \c int, \c size_t, \c long, etc... + * - \c std::vector where \c A can \c int, \c size_t, \c long, etc... + * - \c boost::numeric::ublas::vector can work too (\c int can be replaced by another integer type) + * - etc... + * + * An indirect vector can be used as a normal vector in any expression. If the specified indirect vector + * falls outside that of the indices of the vector, then the \c vector_indirect is not a well formed + * \i Vector \i Expression and access to an element outside of indices of the vector is \b undefined. + * + * \tparam V the type of vector referenced (for example \c vector) + * \tparam IA the type of index vector. Default is \c ublas::indirect_array<> + */ template class vector_indirect: public vector_expression > { diff --git a/include/boost/numeric/ublas/vector_sparse.hpp b/include/boost/numeric/ublas/vector_sparse.hpp index 6a49d060..99dcbcec 100644 --- a/include/boost/numeric/ublas/vector_sparse.hpp +++ b/include/boost/numeric/ublas/vector_sparse.hpp @@ -260,7 +260,22 @@ namespace boost { namespace numeric { namespace ublas { #endif - // Index map based sparse vector class + /** \brief Index map based sparse vector + * + * A sparse vector of values of type T of variable size. The sparse storage type A can be + * \c std::map or \c map_array. This means that only non-zero elements + * are effectively stored. + * + * For a \f$n\f$-dimensional sparse vector, and 0 <= i < n the non-zero elements \f$v_i\f$ + * are mapped to consecutive elements of the associative container, i.e. for elements + * \f$k = v_{i_1}\f$ and \f$k + 1 = v_{i_2}\f$ of the container, holds \f$i_1 < i_2\f$. + * + * Supported parameters for the adapted array are \c map_array and + * \c map_std. The latter is equivalent to \c std::map. + * + * \tparam T the type of object stored in the vector (like double, float, complex, etc...) + * \tparam A the type of Storage array + */ template class mapped_vector: public vector_container > { @@ -755,8 +770,29 @@ namespace boost { namespace numeric { namespace ublas { const typename mapped_vector::value_type mapped_vector::zero_ = value_type/*zero*/(); - // Compressed array based sparse vector class // Thanks to Kresimir Fresl for extending this to cover different index bases. + + /** \brief Compressed array based sparse vector + * + * a sparse vector of values of type T of variable size. The non zero values are stored as + * two seperate arrays: an index array and a value array. The index array is always sorted + * and there is at most one entry for each index. Inserting an element can be time consuming. + * If the vector contains a few zero entries, then it is better to have a normal vector. + * If the vector has a very high dimension with a few non-zero values, then this vector is + * very memory efficient (at the cost of a few more computations). + * + * For a \f$n\f$-dimensional compressed vector and \f$0 \leq i < n\f$ the non-zero elements + * \f$v_i\f$ are mapped to consecutive elements of the index and value container, i.e. for + * elements \f$k = v_{i_1}\f$ and \f$k + 1 = v_{i_2}\f$ of these containers holds \f$i_1 < i_2\f$. + * + * Supported parameters for the adapted array (indices and values) are \c unbounded_array<> , + * \c bounded_array<> and \c std::vector<>. + * + * \tparam T the type of object stored in the vector (like double, float, complex, etc...) + * \tparam IB the index base of the compressed vector. Default is 0. Other supported value is 1 + * \tparam IA the type of adapted array for indices. Default is \c unbounded_array + * \tparam TA the type of adapted array for values. Default is unbounded_array + */ template class compressed_vector: public vector_container > { @@ -1374,9 +1410,29 @@ namespace boost { namespace numeric { namespace ublas { template const typename compressed_vector::value_type compressed_vector::zero_ = value_type/*zero*/(); - - // Coordimate array based sparse vector class // Thanks to Kresimir Fresl for extending this to cover different index bases. + + /** \brief Coordimate array based sparse vector + * + * a sparse vector of values of type \c T of variable size. The non zero values are stored + * as two seperate arrays: an index array and a value array. The arrays may be out of order + * with multiple entries for each vector element. If there are multiple values for the same + * index the sum of these values is the real value. It is way more efficient for inserting values + * than a \c compressed_vector but less memory efficient. Also linearly parsing a vector can + * be longer in specific cases than a \c compressed_vector. + * + * For a n-dimensional sorted coordinate vector and \f$ 0 \leq i < n\f$ the non-zero elements + * \f$v_i\f$ are mapped to consecutive elements of the index and value container, i.e. for + * elements \f$k = v_{i_1}\f$ and \f$k + 1 = v_{i_2}\f$ of these containers holds \f$i_1 < i_2\f$. + * + * Supported parameters for the adapted array (indices and values) are \c unbounded_array<> , + * \c bounded_array<> and \c std::vector<>. + * + * \tparam T the type of object stored in the vector (like double, float, complex, etc...) + * \tparam IB the index base of the compressed vector. Default is 0. Other supported value is 1 + * \tparam IA the type of adapted array for indices. Default is \c unbounded_array + * \tparam TA the type of adapted array for values. Default is unbounded_array + */ template class coordinate_vector: public vector_container > { From 77d2da7780a672a198a800b40ba2561408e72aeb Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Mon, 5 Jul 2010 15:21:33 +0000 Subject: [PATCH 043/280] Merged r63654 and r63655 from trunk svn path=/branches/release/boost/numeric/ublas/; revision=63656 From c94956415d4037af917660c5a5c934f890f0abb3 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Mon, 5 Jul 2010 15:38:37 +0000 Subject: [PATCH 044/280] Merged r63657 from trunk svn path=/branches/release/boost/numeric/ublas/; revision=63658 From d1eb3d0fff4938bd4bd2ec004764e94b85cfe230 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Mon, 5 Jul 2010 16:17:38 +0000 Subject: [PATCH 045/280] Merged various changes from trunk svn path=/branches/release/boost/numeric/ublas/; revision=63662 From a5fbf28bf8ab3b44798bb55da649d748ada618e8 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Mon, 5 Jul 2010 16:40:23 +0000 Subject: [PATCH 046/280] Merged more changes from trunk, including r63643 (new patches for LLP64) svn path=/branches/release/boost/numeric/ublas/; revision=63664 From fd74ba82258e57e977f73d86a93289de62b07b86 Mon Sep 17 00:00:00 2001 From: David Bellot Date: Mon, 5 Jul 2010 18:13:41 +0000 Subject: [PATCH 047/280] whoops, 2 files where missing during the merge ! svn path=/branches/release/boost/numeric/ublas/; revision=63669 --- include/boost/numeric/ublas/assignment.hpp | 1281 ++++++++++++++++++++ include/boost/numeric/ublas/doxydoc.hpp | 65 + 2 files changed, 1346 insertions(+) create mode 100644 include/boost/numeric/ublas/assignment.hpp create mode 100644 include/boost/numeric/ublas/doxydoc.hpp diff --git a/include/boost/numeric/ublas/assignment.hpp b/include/boost/numeric/ublas/assignment.hpp new file mode 100644 index 00000000..65ae12d5 --- /dev/null +++ b/include/boost/numeric/ublas/assignment.hpp @@ -0,0 +1,1281 @@ +// +// Copyright (c) 2010 Athanasios Iliopoulos +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef ASSIGNMENT_HPP +#define ASSIGNMENT_HPP +#include +#include + +/*! \file assignment.hpp + \brief uBlas assignment operator <<=. +*/ + +namespace boost { namespace numeric { namespace ublas { + +/** \brief A CRTP and Barton-Nackman trick index manipulator wrapper class. + * + * This class is not meant to be used directly. + */ +template +class index_manipulator { +public: + typedef TV type; + BOOST_UBLAS_INLINE + const type &operator () () const { + return *static_cast (this); + } + BOOST_UBLAS_INLINE + type &operator () () { + return *static_cast (this); + } +}; + +/** \brief A move_to vector index manipulator. + * + * When member function \c manip is called the referenced + * index will be set to the manipulators' index. + * + * \sa move_to(T i) + */ +template +class vector_move_to_manip: public index_manipulator > { +public: + BOOST_UBLAS_INLINE + vector_move_to_manip(const T &k): i(k) { } + + template + BOOST_UBLAS_INLINE + void manip(V &k) const { k=i; } +private: + T i; +}; + +/** \brief An object generator that returns a move_to vector index manipulator + * + * \param i The element number the manipulator will move to when \c manip member function is called + * \return A move_to vector manipulator + * + * Example usage: + * \code + * vector a(6, 0); + * a <<= 1, 2, move_to(5), 3; + * \endcode + * will result in: + * \code + * 1 2 0 0 0 3 + * \endcode + * + * \tparam T Size type + * \sa move_to() + */ +template +BOOST_UBLAS_INLINE vector_move_to_manip move_to(T i) { + return vector_move_to_manip(i); +} + +/** \brief A static move to vector manipulator. + * + * When member function \c manip is called the referenced + * index will be set to the manipulators' index + * + * \sa move_to(T i) and move_to() +*/ +template +class static_vector_move_to_manip: public index_manipulator > { +public: + template + BOOST_UBLAS_INLINE + void manip(V &k) const { k=I; } +}; + +/** \brief An object generator that returns a static move_to vector index manipulator. + * + * Typically faster than the dynamic version, but can be used only when the + * values are known at compile time. + * + * \return A static move_to vector manipulator + * + * Example usage: + * \code + * vector a(6, 0); + * a <<= 1, 2, move_to<5>(), 3; + * \endcode + * will result in: + * \code + * 1 2 0 0 0 3 + * \endcode + * + * \tparam I The number of elements the manipulator will traverse the index when \c manip function is called + */ +template +BOOST_UBLAS_INLINE static_vector_move_to_manip move_to() { + return static_vector_move_to_manip(); +} + +/** \brief A move vector index manipulator. + * + * When member function traverse is called the manipulators' + * index will be added to the referenced index. + * + * \see move(T i) + */ +template +class vector_move_manip: public index_manipulator > { +public: + BOOST_UBLAS_INLINE + vector_move_manip(const T &k): i(k) { } + + template + BOOST_UBLAS_INLINE void manip(V &k) const { k+=i; } +private: + T i; +}; + +/** +* \brief An object generator that returns a move vector index manipulator +* +* \tparam T Size type +* \param i The number of elements the manipulator will traverse the index when \c manip +* member function is called. Negative values can be used. +* \return A move vector manipulator +* +* Example usage: +* \code +* vector a(6, 0); +* a <<= 1, 2, move(3), 3; +* \endcode +* will result in: +* \code +* 1 2 0 0 0 3 +* \endcode +* +*/ +template +BOOST_UBLAS_INLINE vector_move_manip move(T i) { + return vector_move_manip(i); +} + +/** +* \brief A static move vector manipulator +* +* When member function \c manip is called the manipulators +* index will be added to the referenced index +* +* \sa move() +* +* \todo Doxygen has some problems with similar template functions. Correct that. +*/ +template +class static_vector_move_manip: public index_manipulator > { +public: + template + BOOST_UBLAS_INLINE void manip(V &k) const { k+=I; } +}; + +/** +* \brief An object generator that returns a static move vector index manipulator. +* +* Typically faster than the dynamic version, but can be used only when the +* values are known at compile time. +* \tparam I The Number of elements the manipulator will traverse the index when \c manip +* function is called.Negative values can be used. +* \return A static move vector manipulator +* +* Example usage: +* \code +* vector a(6, 0); +* a <<= 1, 2, move<3>(), 3; +* \endcode +* will result in: +* \code +* 1 2 0 0 0 3 +* \endcode +* +* \todo Doxygen has some problems with similar template functions. Correct that. +*/ +template +BOOST_UBLAS_INLINE static_vector_move_manip move() { + return static_vector_move_manip(); +} + +/** +* \brief A move_to matrix manipulator +* +* When member function \c manip is called the referenced +* index will be set to the manipulators' index +* +* \sa move_to(T i, T j) +* +* \todo Doxygen has some problems with similar template functions. Correct that. +*/ +template +class matrix_move_to_manip: public index_manipulator > { +public: + BOOST_UBLAS_INLINE + matrix_move_to_manip(T k, T l): i(k), j(l) { } + + template + BOOST_UBLAS_INLINE + void manip(V1 &k, V2 &l) const { + k=i; + l=j; + } +private: + T i, j; +}; + +/** +* \brief An object generator that returns a "move_to" matrix index manipulator +* +* \tparam size type +* \param i The row number the manipulator will move to when \c manip +* member function is called +* \param j The column number the manipulator will move to when \c manip +* member function is called +* \return A move matrix manipulator +* +* Example usage: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, move_to(A.size1()-1, A.size1()-1), 3; +* \endcode +* will result in: +* \code +* 1 2 0 +* 0 0 0 +* 0 0 3 +* \endcode +* \sa move_to(T i, T j) and static_matrix_move_to_manip +* +* \todo Doxygen has some problems with similar template functions. Correct that. +*/ +template +BOOST_UBLAS_INLINE matrix_move_to_manip move_to(T i, T j) { + return matrix_move_to_manip(i, j); +} + + +/** +* \brief A static move_to matrix manipulator +* When member function traverse is called the referenced +* index will be set to the manipulators' index +* +* \sa move_to() +* +* \todo Doxygen has some problems with similar template functions. Correct that. +*/ +template +class static_matrix_move_to_manip: public index_manipulator > { +public: + template + BOOST_UBLAS_INLINE + void manip(V &k, K &l) const { + k=I; + l=J; + } +}; + +/** +* \brief An object generator that returns a static move_to matrix index manipulator. +* +* Typically faster than the dynamic version, but can be used only when the +* values are known at compile time. +* \tparam I The row number the manipulator will set the matrix assigner index to. +* \tparam J The column number the manipulator will set the matrix assigner index to. +* \return A static move_to matrix manipulator +* +* Example usage: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, move_to<2,2>, 3; +* \endcode +* will result in: +* \code +* 1 2 0 +* 0 0 0 +* 0 0 3 +* \endcode +* \sa move_to(T i, T j) and static_matrix_move_to_manip +*/ +template +BOOST_UBLAS_INLINE static_matrix_move_to_manip move_to() { + return static_matrix_move_to_manip(); +} + +/** +* \brief A move matrix index manipulator. +* +* When member function \c manip is called the manipulator's +* index will be added to the referenced' index. +* +* \sa move(T i, T j) +*/ +template +class matrix_move_manip: public index_manipulator > { +public: + BOOST_UBLAS_INLINE + matrix_move_manip(T k, T l): i(k), j(l) { } + + template + BOOST_UBLAS_INLINE + void manip(V &k, K &l) const { + k+=i; + l+=j; + } +private: + T i, j; +}; + +/** +* \brief An object generator that returns a move matrix index manipulator +* +* \tparam size type +* \param i The number of rows the manipulator will traverse the index when "manip" +* member function is called +* \param j The number of columns the manipulator will traverse the index when "manip" +* member function is called +* \return A move matrix manipulator +* +* Example: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, move(1,0), +* 3,; +* \endcode +* will result in: +* \code +* 1 2 0 +* 0 0 3 +* 0 0 0 +* \endcode +*/ +template +BOOST_UBLAS_INLINE matrix_move_manip move(T i, T j) { + return matrix_move_manip(i, j); +} + +/** +* \brief A static move matrix index manipulator. +* +* When member function traverse is called the manipulator's +* index will be added to the referenced' index. +* +* \sa move() +* +* \todo Doxygen has some problems with similar template functions. Correct that. +*/ +template +class static_matrix_move_manip: public index_manipulator > { +public: + template + BOOST_UBLAS_INLINE + void manip(V &k, K &l) const { + k+=I; + l+=J; + } +}; + +/** +* \brief An object generator that returns a static "move" matrix index manipulator. +* +* Typically faster than the dynamic version, but can be used only when the +* values are known at compile time. Negative values can be used. +* \tparam I The number of rows the manipulator will trasverse the matrix assigner index. +* \tparam J The number of columns the manipulator will trasverse the matrix assigner index. +* \tparam size type +* \return A static move matrix manipulator +* +* Example: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, move<1,0>(), +* 3,; +* \endcode +* will result in: +* \code +* 1 2 0 +* 0 0 3 +* 0 0 0 +* \endcode +* +* \sa move_to() +* +* \todo Doxygen has some problems with similar template functions. Correct that. +*/ +template +BOOST_UBLAS_INLINE static_matrix_move_manip move() { + return static_matrix_move_manip(); +} + +/** +* \brief A begining of row manipulator +* +* When member function \c manip is called the referenced +* index will be be set to the begining of the row (i.e. column = 0) +* +* \sa begin1() +*/ +class begin1_manip: public index_manipulator { +public: + template + BOOST_UBLAS_INLINE + void manip(V & k, K &/*l*/) const { + k=0; + } +}; + +/** +* \brief An object generator that returns a begin1 manipulator. +* +* The resulted manipulator will traverse the index to the begining +* of the current column when its' \c manip member function is called. +* +* \return A begin1 matrix index manipulator +* +* Example usage: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, next_row(), +* 3, 4, begin1(), 1; +* \endcode +* will result in: +* \code +* 1 2 1 +* 3 4 0 +* 0 0 0 +* \endcode +* \sa begin2() +*/ +BOOST_UBLAS_INLINE begin1_manip begin1() { + return begin1_manip(); +} + +/** +* \brief A begining of column manipulator +* +* When member function \c manip is called the referenced +* index will be be set to the begining of the column (i.e. row = 0). +* +* +* \sa begin2() +*/ +class begin2_manip: public index_manipulator { +public: + template + BOOST_UBLAS_INLINE + void manip(V &/*k*/, K &l) const { + l=0; + } +}; + +/** +* \brief An object generator that returns a begin2 manipulator to be used to traverse a matrix. +* +* The resulted manipulator will traverse the index to the begining +* of the current row when its' \c manip member function is called. +* +* \return A begin2 matrix manipulator +* +* Example: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, move<1,0>(), +* 3, begin2(), 1; +* \endcode +* will result in: +* \code +* 1 2 0 +* 1 0 3 +* 0 0 0 +* \endcode +* \sa begin1() begin2_manip +*/ +BOOST_UBLAS_INLINE begin2_manip begin2() { + return begin2_manip(); +} + + +/** +* \brief A next row matrix manipulator. +* +* When member function traverse is called the referenced +* index will be traveresed to the begining of next row. +* +* \sa next_row() +*/ +class next_row_manip: public index_manipulator { +public: + template + BOOST_UBLAS_INLINE + void manip(V &k, K &l) const { + k++; + l=0; + } +}; + +/** +* \brief An object generator that returns a next_row manipulator. +* +* The resulted manipulator will traverse the index to the begining +* of the next row when it's manip member function is called. +* +* \return A next_row matrix manipulator. +* +* Example: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, next_row(), +* 3, 4; +* \endcode +* will result in: +* \code +* 1 2 0 +* 3 4 0 +* 0 0 0 +* \endcode +* \sa next_column() +*/ +BOOST_UBLAS_INLINE next_row_manip next_row() { + return next_row_manip(); +} + +/** +* \brief A next column matrix manipulator. +* +* When member function traverse is called the referenced +* index will be traveresed to the begining of next column. +* +* \sa next_column() +*/ +class next_column_manip: public index_manipulator { +public: + template + BOOST_UBLAS_INLINE + void manip(V &k, K &l) const { + k=0; + l++; + } +}; + +/** +* \brief An object generator that returns a next_row manipulator. +* +* The resulted manipulator will traverse the index to the begining +* of the next column when it's manip member function is called. +* +* \return A next_column matrix manipulator. +* +* Example: +* \code: +* matrix A(3, 3, 0); +* A <<= 1, 2, 0, +* 3, next_column(), 4; +* \endcode +* will result in: +* \code +* 1 2 4 +* 3 0 0 +* 0 0 0 +* \endcode +* +*/ +BOOST_UBLAS_INLINE next_column_manip next_column() { + return next_column_manip(); +} + +/** +* \brief A wrapper for fill policy classes +* +*/ +template +class fill_policy_wrapper { +public: + typedef T type; +}; + +// Collection of the fill policies +namespace fill_policy { + + /** + * \brief An index assign policy + * + * This policy is used to for the simplified ublas assign through + * normal indexing. + * + * + */ + class index_assign :public fill_policy_wrapper { + public: + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const V &v) { + e()(i) = v; + } + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const S &j, const V &v) { + e()(i, j) = v; + } + }; + + /** + * \brief An index plus assign policy + * + * This policy is used when the assignment is desired to be followed + * by an addition. + * + * + */ + class index_plus_assign :public fill_policy_wrapper { + public: + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const V &v) { + e()(i) += v; + } + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const S &j, const V &v) { + e()(i, j) += v; + } + }; + + /** + * \brief An index minus assign policy + * + * This policy is used when the assignment is desired to be followed + * by a substraction. + * + * + */ + class index_minus_assign :public fill_policy_wrapper { + public: + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const V &v) { + e()(i) -= v; + } + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const S &j, const V &v) { + e()(i, j) -= v; + } + }; + + /** + * \brief The sparse push_back fill policy. + * + * This policy is adequate for sparse types, when fast filling is required, where indexing + * assign is pretty slow. + + * It is important to note that push_back assign cannot be used to add elements before elements + * already existing in a sparse container. To achieve that please use the sparse_insert fill policy. + */ + class sparse_push_back :public fill_policy_wrapper { + public: + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const V &v) { + e().push_back(i, v); + } + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const S &j, const V &v) { + e().push_back(i,j, v); + } + }; + + /** + * \brief The sparse insert fill policy. + * + * This policy is adequate for sparse types, when fast filling is required, where indexing + * assign is pretty slow. It is slower than sparse_push_back fill policy, but it can be used to + * insert elements anywhere inside the container. + */ + class sparse_insert :public fill_policy_wrapper { + public: + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const V &v) { + e().insert_element(i, v); + } + template + BOOST_UBLAS_INLINE + static void apply(T &e, const S &i, const S &j, const V &v) { + e().insert_element(i,j, v); + } + }; + +} + +/** \brief A wrapper for traverse policy classes +* +*/ +template +class traverse_policy_wrapper { +public: + typedef T type; +}; + +// Collection of the traverse policies +namespace traverse_policy { + + + /** + * \brief The no wrap policy. + * + * The no wrap policy does not allow wrapping when assigning to a matrix + */ + struct no_wrap { + /** + * \brief Element wrap method + */ + template + BOOST_UBLAS_INLINE + static void apply1(const S1 &/*s*/, S2 &/*i*/, S3 &/*j*/) { + } + + /** + * \brief Matrix block wrap method + */ + template + BOOST_UBLAS_INLINE + static void apply2(const S1 &/*s1*/, const S1 &/*s2*/, S2 &/*i1*/, S3 &/*i2*/) { + } + }; + + /** + * \brief The wrap policy. + * + * The wrap policy enables element wrapping when assigning to a matrix + */ + struct wrap { + /** + * \brief Element wrap method + */ + template + BOOST_UBLAS_INLINE + static void apply1(const S1 &s, S2 &i1, S3 &i2) { + if (i2>=s) { + i1++; + i2=0; + } + } + + /** + * \brief Matrix block wrap method + */ + template + BOOST_UBLAS_INLINE + static void apply2(const S1 &s1, const S1 &s2, S2 &i1, S3 &i2) { + if (i2>=s2) i2=0; // Wrap to the next block + else i1-=s1; // Move up (or right) one block + } + }; + + /** + * \brief The row_by_row traverse policy + * + * This policy is used when the assignment is desired to happen + * row_major wise for performance or other reasons. + * + * This is the default behaviour. To change it globally please define BOOST_UBLAS_DEFAULT_ASSIGN_BY_COLUMN + * in the compilation options or in an adequate header file. + * + * Please see EXAMPLES_LINK for usage information. + * + * \todo Add examples link + */ + template + class by_row_policy :public traverse_policy_wrapper > { + public: + template + BOOST_UBLAS_INLINE + static void advance(S1 &/*i*/, S2 &j) { j++;} + + template + BOOST_UBLAS_INLINE + static bool next(const E1 &e, const E2 &me, S1 &i, S2 &j, const S3 &/*i0*/, const S3 &j0, S4 &k, S5 &l) { + l++; j++; + if (l>=e().size2()) { + l=0; k++; j=j0; i++; + // It is assumed that the iteration starts from 0 and happens only using this function from within + // an assigner object. + // Otherwise (i.e. if it is called outside the assigner object) apply2 should have been + // outside the if statement. + if (k>=e().size1()) { + j=j0+e().size2(); + Wrap::apply2(e().size1(), me().size2(), i, j); + return false; + } + } + return true; + } + + template + BOOST_UBLAS_INLINE + static void apply_wrap(const E& e, S1 &i, S2 &j) { + Wrap::apply1(e().size2(), i, j); + } + }; + + /** + * \brief The column_by_column traverse policy + * + * This policy is used when the assignment is desired to happen + * column_major wise, for performance or other reasons. + * + * This is the NOT the default behaviour. To set this as the default define BOOST_UBLAS_DEFAULT_ASSIGN_BY_COLUMN + * in the compilation options or in an adequate header file. + * + * Please see EXAMPLES_LINK for usage information. + * + * \todo Add examples link + */ + template + class by_column_policy :public traverse_policy_wrapper > { + public: + template + BOOST_UBLAS_INLINE + static void advance(S1 &i, S2 &/*j*/) { i++;} + + template + BOOST_UBLAS_INLINE + static bool next(const E1 &e, const E2 &me, S1 &i, S2 &j, const S3 &i0, const S3 &/*j0*/, S4 &k, S5 &l) { + k++; i++; + if (k>=e().size1()) { + k=0; l++; i=i0; j++; + // It is assumed that the iteration starts from 0 and happens only using this function from within + // an assigner object. + // Otherwise (i.e. if it is called outside the assigner object) apply2 should have been + // outside the if statement. + if (l>=e().size2()) { + i=i0+e().size1(); + Wrap::apply2(e().size2(), me().size1(), j, i); + return false; + } + } + return true; + } + + template + BOOST_UBLAS_INLINE + static void apply_wrap(const E& e, S1 &i, S2 &j) { + Wrap::apply1(e().size1(), j, i); + } + }; +} +#ifndef BOOST_UBLAS_DEFAULT_NO_WRAP_POLICY + typedef traverse_policy::wrap DEFAULT_WRAP_POLICY; +#else + typedef traverse_policy::no_wrap DEFAULT_WRAP_POLICY; +#endif + +#ifndef BOOST_UBLAS_DEFAULT_ASSIGN_BY_COLUMN + typedef traverse_policy::by_row_policy DEFAULT_TRAVERSE_POLICY; +#else + typedef traverse_policy::by_column DEFAULT_TRAVERSE_POLICY; +#endif + + // Traverse policy namespace +namespace traverse_policy { + + by_row_policy by_row() { + return by_row_policy(); + } + + by_row_policy by_row_wrap() { + return by_row_policy(); + } + + by_row_policy by_row_no_wrap() { + return by_row_policy(); + } + + by_column_policy by_column() { + return by_column_policy(); + } + + by_column_policy by_column_wrap() { + return by_column_policy(); + } + + by_column_policy by_column_no_wrap() { + return by_column_policy(); + } + +} + +/** +* \brief An assigner object used to fill a vector using operator <<= and operator, (comma) +* +* This object is meant to be created by appropriate object generators. +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +class vector_expression_assigner { +public: + typedef typename E::expression_type::value_type value_type; + typedef typename E::expression_type::size_type size_type; + + BOOST_UBLAS_INLINE + vector_expression_assigner(E &e):ve(e), i(0) { + } + + BOOST_UBLAS_INLINE + vector_expression_assigner(size_type k, E &e):ve(e), i(k) { + // Overloaded like that so it can be differentiated from (E, val). + // Otherwise there would be an ambiquity when value_type == size_type. + } + + BOOST_UBLAS_INLINE + vector_expression_assigner(E &e, value_type val):ve(e), i(0) { + operator,(val); + } + + template + BOOST_UBLAS_INLINE + vector_expression_assigner(E &e, const vector_expression &nve):ve(e), i(0) { + operator,(nve); + } + + template + BOOST_UBLAS_INLINE + vector_expression_assigner(E &e, const index_manipulator &ta):ve(e), i(0) { + operator,(ta); + } + + BOOST_UBLAS_INLINE + vector_expression_assigner &operator, (const value_type& val) { + apply(val); + return *this; + } + + template + BOOST_UBLAS_INLINE + vector_expression_assigner &operator, (const vector_expression &nve) { + for (typename AE::size_type k = 0; k!= nve().size(); k++) + operator,(nve()(k)); + return *this; + } + + template + BOOST_UBLAS_INLINE + vector_expression_assigner &operator, (const index_manipulator &ta) { + ta().manip(i); + return *this; + } + + template + BOOST_UBLAS_INLINE + vector_expression_assigner operator, (fill_policy_wrapper) const { + return vector_expression_assigner(i, ve); + } + +private: + BOOST_UBLAS_INLINE + vector_expression_assigner &apply(const typename E::expression_type::value_type& val) { + Fill_Policy::apply(ve, i++, val); + return *this; + } + +private: + E &ve; + size_type i; +}; + +/* +// The following static assigner is about 30% slower than the dynamic one, probably due to the recursive creation of assigner objects. +// It remains commented here for future reference. + +template +class static_vector_expression_assigner { +public: + typedef typename E::expression_type::value_type value_type; + typedef typename E::expression_type::size_type size_type; + + BOOST_UBLAS_INLINE + static_vector_expression_assigner(E &e):ve(e) { + } + + BOOST_UBLAS_INLINE + static_vector_expression_assigner(E &e, value_type val):ve(e) { + operator,(val); + } + + BOOST_UBLAS_INLINE + static_vector_expression_assigner operator, (const value_type& val) { + return apply(val); + } + +private: + BOOST_UBLAS_INLINE + static_vector_expression_assigner apply(const typename E::expression_type::value_type& val) { + ve()(I)=val; + return static_vector_expression_assigner(ve); + } + +private: + E &ve; +}; + +template +BOOST_UBLAS_INLINE +static_vector_expression_assigner, 1 > test_static(vector_expression &v, const typename E::value_type &val) { + v()(0)=val; + return static_vector_expression_assigner, 1 >(v); +} +*/ + + +/** +* \brief A vector_expression_assigner generator used with operator<<= for simple types +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +vector_expression_assigner > operator<<=(vector_expression &v, const typename E::value_type &val) { + return vector_expression_assigner >(v,val); +} + +/** +* \brief ! A vector_expression_assigner generator used with operator<<= for vector expressions +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +vector_expression_assigner > operator<<=(vector_expression &v, const vector_expression &ve) { + return vector_expression_assigner >(v,ve); +} + +/** +* \brief A vector_expression_assigner generator used with operator<<= for traverse manipulators +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +vector_expression_assigner > operator<<=(vector_expression &v, const index_manipulator &nv) { + return vector_expression_assigner >(v,nv); +} + +/** +* \brief A vector_expression_assigner generator used with operator<<= for choice of fill policy +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +vector_expression_assigner, T> operator<<=(vector_expression &v, fill_policy_wrapper) { + return vector_expression_assigner, T>(v); +} + +/** +* \brief An assigner object used to fill a vector using operator <<= and operator, (comma) +* +* This object is meant to be created by appropriate object generators. +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +class matrix_expression_assigner { +public: + typedef typename E::expression_type::size_type size_type; + + BOOST_UBLAS_INLINE + matrix_expression_assigner(E &e): me(e), i(0), j(0) { + } + + BOOST_UBLAS_INLINE + matrix_expression_assigner(E &e, size_type k, size_type l): me(e), i(k), j(l) { + } + + BOOST_UBLAS_INLINE + matrix_expression_assigner(E &e, typename E::expression_type::value_type val): me(e), i(0), j(0) { + operator,(val); + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner(E &e, const vector_expression &nve):me(e), i(0), j(0) { + operator,(nve); + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner(E &e, const matrix_expression &nme):me(e), i(0), j(0) { + operator,(nme); + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner(E &e, const index_manipulator &ta):me(e), i(0), j(0) { + operator,(ta); + } + + BOOST_UBLAS_INLINE + matrix_expression_assigner &operator, (const typename E::expression_type::value_type& val) { + Traverse_Policy::apply_wrap(me, i ,j); + return apply(val); + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner &operator, (const vector_expression &nve) { + for (typename AE::size_type k = 0; k!= nve().size(); k++) { + operator,(nve()(k)); + } + return *this; + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner &operator, (const matrix_expression &nme) { + return apply(nme); + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner &operator, (const index_manipulator &ta) { + ta().manip(i, j); + return *this; + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner operator, (fill_policy_wrapper) const { + return matrix_expression_assigner(me, i, j); + } + + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner operator, (traverse_policy_wrapper) { + Traverse_Policy::apply_wrap(me, i ,j); + return matrix_expression_assigner(me, i, j); + } + +private: + BOOST_UBLAS_INLINE + matrix_expression_assigner &apply(const typename E::expression_type::value_type& val) { + Fill_Policy::apply(me, i, j, val); + Traverse_Policy::advance(i,j); + return *this; + } + + template + BOOST_UBLAS_INLINE + matrix_expression_assigner &apply(const matrix_expression &nme) { + size_type bi = i; + size_type bj = j; + typename AE::size_type k=0, l=0; + Fill_Policy::apply(me, i, j, nme()(k, l)); + while (Traverse_Policy::next(nme, me, i, j, bi, bj, k, l)) + Fill_Policy::apply(me, i, j, nme()(k, l)); + return *this; + } + +private: + E &me; + size_type i, j; +}; + +/** +* \brief A matrix_expression_assigner generator used with operator<<= for simple types +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +matrix_expression_assigner > operator<<=(matrix_expression &me, const typename E::value_type &val) { + return matrix_expression_assigner >(me,val); +} + +/** +* \brief A matrix_expression_assigner generator used with operator<<= for choice of fill policy +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +matrix_expression_assigner, T> operator<<=(matrix_expression &me, fill_policy_wrapper) { + return matrix_expression_assigner, T>(me); +} + +/** +* \brief A matrix_expression_assigner generator used with operator<<= for traverse manipulators +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +matrix_expression_assigner > operator<<=(matrix_expression &me, const index_manipulator &ta) { + return matrix_expression_assigner >(me,ta); +} + +/** +* \brief A matrix_expression_assigner generator used with operator<<= for traverse manipulators +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +matrix_expression_assigner, fill_policy::index_assign, T> operator<<=(matrix_expression &me, traverse_policy_wrapper) { + return matrix_expression_assigner, fill_policy::index_assign, T>(me); +} + +/** +* \brief A matrix_expression_assigner generator used with operator<<= for vector expressions +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +matrix_expression_assigner > operator<<=(matrix_expression &me, const vector_expression &ve) { + return matrix_expression_assigner >(me,ve); +} + +/** +* \brief A matrix_expression_assigner generator used with operator<<= for matrix expressions +* +* Please see EXAMPLES_LINK for usage information. +* +* \todo Add examples link +*/ +template +BOOST_UBLAS_INLINE +matrix_expression_assigner > operator<<=(matrix_expression &me1, const matrix_expression &me2) { + return matrix_expression_assigner >(me1,me2); +} + +} } } + +#endif // ASSIGNMENT_HPP diff --git a/include/boost/numeric/ublas/doxydoc.hpp b/include/boost/numeric/ublas/doxydoc.hpp new file mode 100644 index 00000000..f3d749bb --- /dev/null +++ b/include/boost/numeric/ublas/doxydoc.hpp @@ -0,0 +1,65 @@ +// +// Copyright (c) 2010 +// David Bellot +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// And we acknowledge the support from all contributors. + +/** \mainpage BOOST uBLAS: a Linear Algebra Library + * + * This is the API Reference Documentation. + * + * For introduction, documentations and tutorial, please refer + * to http://www.boost.org/doc/libs/1_44_0/libs/numeric/ublas/doc/index.htm + * + * \section main_classes Main classes + * + * \subsection listvector Vectors + * - \link #boost::numeric::ublas::vector vector \endlink + * - \link #boost::numeric::ublas::bounded_vector bounded_vector \endlink + * - \link #boost::numeric::ublas::zero_vector zero_vector \endlink + * - \link #boost::numeric::ublas::unit_vector unit_vector \endlink + * - \link #boost::numeric::ublas::scalar_vector scalar_vector \endlink + * - \link #boost::numeric::ublas::c_vector c_vector \endlink + * - \link #boost::numeric::ublas::vector_slice vector_slice \endlink + * - \link #boost::numeric::ublas::vector_range vector_range \endlink + * - \link #boost::numeric::ublas::vector_indirect vector_indirect \endlink + * - \link #boost::numeric::ublas::mapped_vector mapped_vector \endlink + * - \link #boost::numeric::ublas::compressed_vector compressed_vector \endlink + * - \link #boost::numeric::ublas::coordinate_vector coordinate_vector \endlink + * - \link #boost::numeric::ublas::matrix_row matrix_row \endlink + * - \link #boost::numeric::ublas::matrix_column matrix_column \endlink + * + * \subsection listmatrix Matrices + * - \link #boost::numeric::ublas::matrix matrix \endlink + * - \link #boost::numeric::ublas::banded_matrix banded_matrix \endlink + * - \link #boost::numeric::ublas::diagonal_matrix diagonal_matrix \endlink + * - \link #boost::numeric::ublas::banded_adaptor banded_adaptor \endlink + * - \link #boost::numeric::ublas::diagonal_adaptor diagonal_adaptor \endlink + * - \link #boost::numeric::ublas::hermitian_matrix hermitian_matrix \endlink + * - \link #boost::numeric::ublas::hermitian_adaptor hermitian_adaptor \endlink + * - \link #boost::numeric::ublas::symmetric_matrix symmetric_matrix \endlink + * - \link #boost::numeric::ublas::symmetric_adaptor symmetric_adaptor \endlink + * - \link #boost::numeric::ublas::triangular_matrix triangular_matrix \endlink + * - \link #boost::numeric::ublas::triangular_adaptor triangular_adaptor \endlink + * - \link #boost::numeric::ublas::vector_of_vector vector_of_vector \endlink + * - \link #boost::numeric::ublas::bounded_matrix bounded_matrix \endlink + * - \link #boost::numeric::ublas::zero_matrix zero_matrix \endlink + * - \link #boost::numeric::ublas::identity_matrix identity_matrix \endlink + * - \link #boost::numeric::ublas::scalar_matrix scalar_matrix \endlink + * - \link #boost::numeric::ublas::c_matrix c_matrix \endlink + * - \link #boost::numeric::ublas::matrix_vector_range matrix_vector_range \endlink + * - \link #boost::numeric::ublas::matrix_vector_slice matrix_vector_slice \endlink + * - \link #boost::numeric::ublas::matrix_vector_indirect matrix_vector_indirect \endlink + * - \link #boost::numeric::ublas::matrix_range matrix_range \endlink + * - \link #boost::numeric::ublas::matrix_slice matrix_slice \endlink + * - \link #boost::numeric::ublas::matrix_indirect matrix_indirect \endlink + * - \link #boost::numeric::ublas::mapped_matrix mapped_matrix \endlink + * - \link #boost::numeric::ublas::mapped_vector_of_mapped_vector mapped_vector_of_mapped_vector \endlink + * - \link #boost::numeric::ublas::compressed_matrix compressed_matrix \endlink + * - \link #boost::numeric::ublas::coordinate_matrix coordinate_matrix \endlink + * - \link #boost::numeric::ublas::generalized_vector_of_vector generalized_vector_of_vector \endlink + */ From abb10f349e1944cc2849127695e1f5fb498d41df Mon Sep 17 00:00:00 2001 From: David Bellot Date: Mon, 5 Jul 2010 18:20:58 +0000 Subject: [PATCH 048/280] whoops another file missing. Now it's correct, kdiff3 gives 100% between trunk and release svn path=/branches/release/libs/numeric/ublas/; revision=63670 --- test/sparse_view_test.cpp | 107 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 test/sparse_view_test.cpp diff --git a/test/sparse_view_test.cpp b/test/sparse_view_test.cpp new file mode 100644 index 00000000..ce4602c6 --- /dev/null +++ b/test/sparse_view_test.cpp @@ -0,0 +1,107 @@ + +/* Test program to test find functions of triagular matrices + * + * author: Gunter Winkler ( guwi17 at gmx dot de ) + */ + + +// ublas headers + +#include + +#include +#include +#include + +#include + +// other boost headers + +// headers for testcase + +#define BOOST_TEST_MODULE SparseMatrixErasureTest +#include + +// standard and system headers + +#include +#include + +namespace ublas = boost::numeric::ublas; + + /* + sparse input matrix: + + 1 2 0 0 + 0 3 9 0 + 0 1 4 0 + */ + + static const std::string inputMatrix = "[3,4]((1,2,0,0),(0,3,9,0),(0,1,4,0))\n"; + + const unsigned int NNZ = 6; + const unsigned int IB = 1; + const double VA[] = { 1.0, 2.0, 3.0, 9.0, 1.0, 4.0 }; + const unsigned int IA[] = { 1, 3, 5, 7 }; + const unsigned int JA[] = { 1, 2, 2, 3, 2, 3 }; + +BOOST_AUTO_TEST_CASE( test_construction_and_basic_operations ) +{ + + typedef ublas::matrix DENSE_MATRIX; + + // prepare data + + DENSE_MATRIX A; + + std::istringstream iss(inputMatrix); + iss >> A; + + std::cout << A << std::endl; + + std::cout << ( ublas::make_compressed_matrix_view(3,4,NNZ,IA,JA,VA) ) << std::endl; + + typedef ublas::compressed_matrix_view COMPMATVIEW; + + COMPMATVIEW viewA(3,4,NNZ,IA,JA,VA); + + std::cout << viewA << std::endl; + +} + + + +BOOST_AUTO_TEST_CASE( test_construction_from_pointers ) +{ + + std::cout << ( ublas::make_compressed_matrix_view(4,3,NNZ + , ublas::c_array_view(4,&(IA[0])) + , ublas::c_array_view(6,&(JA[0])) + , ublas::c_array_view(6,&(VA[0]))) ) << std::endl; + + unsigned int * ia = new unsigned int[4](); + unsigned int * ja = new unsigned int[6](); + double * va = new double[6](); + + std::copy(&(IA[0]),&(IA[4]),ia); + std::copy(&(JA[0]),&(JA[6]),ja); + std::copy(&(VA[0]),&(VA[6]),va); + + typedef ublas::compressed_matrix_view + , ublas::c_array_view + , ublas::c_array_view > COMPMATVIEW; + + COMPMATVIEW viewA(4,3,NNZ + , ublas::c_array_view(4,ia) + , ublas::c_array_view(6,ja) + , ublas::c_array_view(6,va)); + + std::cout << viewA << std::endl; + + delete[] va; + delete[] ja; + delete[] ia; + +} From 187951bb625abe37fb0d36aabee823e31c7fbc7b Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Mon, 5 Jul 2010 20:23:31 +0000 Subject: [PATCH 049/280] Spirit: merged another missing revision svn path=/branches/release/boost/numeric/ublas/; revision=63675 From 8fd8675566e4146d22a4d285b3511e489cf04f0a Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Tue, 6 Jul 2010 04:49:47 +0000 Subject: [PATCH 050/280] Merged from trunk. ........ r63568 | chris_kohlhoff | 2010-07-04 16:49:18 +1000 (Sun, 04 Jul 2010) | 2 lines Fix coroutine macros to work with MSVC's edit-and-continue debug settings. ........ r63569 | chris_kohlhoff | 2010-07-04 16:53:57 +1000 (Sun, 04 Jul 2010) | 2 lines Reworked timeout examples. ........ r63570 | chris_kohlhoff | 2010-07-04 16:57:32 +1000 (Sun, 04 Jul 2010) | 2 lines Ensure arguments to handlers are passed as const types. ........ r63571 | chris_kohlhoff | 2010-07-04 17:19:30 +1000 (Sun, 04 Jul 2010) | 2 lines Fences for arm. ........ r63572 | chris_kohlhoff | 2010-07-04 17:20:18 +1000 (Sun, 04 Jul 2010) | 2 lines Fences for arm. ........ r63573 | chris_kohlhoff | 2010-07-04 17:21:24 +1000 (Sun, 04 Jul 2010) | 2 lines Fix forward declaration. ........ r63574 | chris_kohlhoff | 2010-07-04 17:23:27 +1000 (Sun, 04 Jul 2010) | 2 lines Add cancellation of reactor operations. ........ r63575 | chris_kohlhoff | 2010-07-04 17:26:36 +1000 (Sun, 04 Jul 2010) | 2 lines Fixes in non_blocking_read. ........ r63576 | chris_kohlhoff | 2010-07-04 17:28:20 +1000 (Sun, 04 Jul 2010) | 2 lines Make more tolerant of different platform sdk variants. ........ r63577 | chris_kohlhoff | 2010-07-04 17:37:42 +1000 (Sun, 04 Jul 2010) | 2 lines Eliminate unnecessary uses of hash_map. ........ r63578 | chris_kohlhoff | 2010-07-04 17:43:23 +1000 (Sun, 04 Jul 2010) | 2 lines Point docs at new timeout examples. ........ r63592 | chris_kohlhoff | 2010-07-04 23:11:14 +1000 (Sun, 04 Jul 2010) | 2 lines Add missing operator+ overload. Fixes #4382. ........ r63594 | chris_kohlhoff | 2010-07-04 23:42:41 +1000 (Sun, 04 Jul 2010) | 2 lines Fix unused parameters. ........ r63646 | chris_kohlhoff | 2010-07-05 17:43:22 +1000 (Mon, 05 Jul 2010) | 2 lines Add missing parameter. ........ svn path=/branches/release/boost/numeric/ublas/; revision=63682 From 8ac8774bdb901903130db09580afd371d902ff61 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 7 Jul 2010 21:58:43 +0000 Subject: [PATCH 051/280] Merged revisions 63724 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r63724 | eric_niebler | 2010-07-07 11:55:56 -0400 (Wed, 07 Jul 2010) | 1 line add missing include to docs for covariance ........ svn path=/branches/release/boost/numeric/ublas/; revision=63727 From 9ffba8bf638b94604683b59d3089611b4cb18130 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 8 Jul 2010 23:13:28 +0000 Subject: [PATCH 052/280] Merge more rebuilt documentation. svn path=/branches/release/boost/numeric/ublas/; revision=63771 From 0276a8707450b0ed4903c63324c2c3b4eed951e6 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Fri, 9 Jul 2010 21:46:57 +0000 Subject: [PATCH 053/280] Spirit: merging from trunk svn path=/branches/release/boost/numeric/ublas/; revision=63798 From 2c55dec6a09f787899b2f678fef3630d98fabcb8 Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Sun, 11 Jul 2010 23:42:34 +0000 Subject: [PATCH 054/280] Merge from trunk. ........ r63776 | chris_kohlhoff | 2010-07-09 23:43:05 +1000 (Fri, 09 Jul 2010) | 2 lines Fence class for hppa. ........ r63836 | chris_kohlhoff | 2010-07-11 14:12:51 +1000 (Sun, 11 Jul 2010) | 2 lines Note that hppa fence is just a placeholder at this time. ........ r63837 | chris_kohlhoff | 2010-07-11 14:15:19 +1000 (Sun, 11 Jul 2010) | 2 lines Add macro for disabling fenced blocks. ........ r63838 | chris_kohlhoff | 2010-07-11 14:16:10 +1000 (Sun, 11 Jul 2010) | 2 lines Preserve error value. ........ svn path=/branches/release/boost/numeric/ublas/; revision=63899 From 0de814a4a676c25bb39a843d9f4367d870bb0663 Mon Sep 17 00:00:00 2001 From: Daniel Walker Date: Mon, 12 Jul 2010 01:36:38 +0000 Subject: [PATCH 055/280] merged changeset 63726 from trunk svn path=/branches/release/boost/numeric/ublas/; revision=63907 From c77b191ede65c5f5ecdb9e60bfe3712275a71306 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Tue, 13 Jul 2010 19:10:52 +0000 Subject: [PATCH 056/280] Spirit: merging from trunk svn path=/branches/release/boost/numeric/ublas/; revision=63993 From 032d2244745084d4e2a5a5f951a334ce60c07805 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Thu, 15 Jul 2010 15:37:46 +0000 Subject: [PATCH 057/280] Merged r64016 and r64035 (both on filtered_graph.hpp) from trunk svn path=/branches/release/boost/numeric/ublas/; revision=64046 From a92470ee054fb2ada50e9732c5e84d89a264c023 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Thu, 15 Jul 2010 15:41:18 +0000 Subject: [PATCH 058/280] Merged r64026 (adding unordered_set to set_contains) from trunk svn path=/branches/release/boost/numeric/ublas/; revision=64047 From a970b53c47ddc6ccebacf8ab34612962407c01e8 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Thu, 15 Jul 2010 15:47:31 +0000 Subject: [PATCH 059/280] Merged r64024 (astar_search named parameter stuff and related changes to named parameters in general) from trunk svn path=/branches/release/boost/numeric/ublas/; revision=64048 From 27efccee76bfbb4cd388fbf490a1ef10fd275bf0 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Thu, 15 Jul 2010 15:52:14 +0000 Subject: [PATCH 060/280] Merged r64025 and r64030 (detail qualification on override_const_property) from trunk svn path=/branches/release/boost/numeric/ublas/; revision=64049 From 5399e0cf057672b6ca34eef3869b5c076d6b5a0b Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Thu, 15 Jul 2010 16:01:00 +0000 Subject: [PATCH 061/280] Merged r64017 and r64023 (documentation bug fixes) from trunk svn path=/branches/release/boost/numeric/ublas/; revision=64051 From 22398c770c0b90ee01512e8f693762f2f743874f Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 15 Jul 2010 21:19:14 +0000 Subject: [PATCH 062/280] Merge some link fixes. [64006] and [64059]. svn path=/branches/release/boost/numeric/ublas/; revision=64061 From 26cac357d6df5be011d488ff8a8469b97c12a2c0 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Sun, 18 Jul 2010 15:22:52 +0000 Subject: [PATCH 063/280] Merged revisions 64122-64123 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r64122 | eric_niebler | 2010-07-18 10:25:32 -0400 (Sun, 18 Jul 2010) | 1 line proto can no longer be found in the File Vault ........ r64123 | eric_niebler | 2010-07-18 10:30:38 -0400 (Sun, 18 Jul 2010) | 1 line xpressive can no longer be found in the File Vault ........ svn path=/branches/release/boost/numeric/ublas/; revision=64127 From a296513f36dd7ae0da37004319a0b97edc0f3ac8 Mon Sep 17 00:00:00 2001 From: Daniel Walker Date: Mon, 19 Jul 2010 00:46:31 +0000 Subject: [PATCH 064/280] merged [64144] from trunk svn path=/branches/release/boost/numeric/ublas/; revision=64146 From 821b46d76bfa9c2693b6eb278193cbdf73ad530e Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 19 Jul 2010 23:29:09 +0000 Subject: [PATCH 065/280] Merge documentation changes. svn path=/branches/release/boost/numeric/ublas/; revision=64186 From 33d5a8174804faf88d6bd6be1f11e5023b89b7d5 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Mon, 26 Jul 2010 15:04:50 +0000 Subject: [PATCH 066/280] Spirit: merging from trunk: documentation updates, comment fixes, formatting issues (tabs), added a new test, etc. svn path=/branches/release/boost/numeric/ublas/; revision=64366 From 5930ec590c8d8f8f63f3d4ee2286396be3157141 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Fri, 30 Jul 2010 18:33:17 +0000 Subject: [PATCH 067/280] Merged revisions 64479 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r64479 | eric_niebler | 2010-07-30 14:18:30 -0400 (Fri, 30 Jul 2010) | 1 line Gennaro Prota is no longer a maintainer of dynamic_bitset ........ svn path=/branches/release/boost/numeric/ublas/; revision=64481 From 050f8f3e9b439ff2bdfb14d479247d7554fec180 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 4 Aug 2010 02:50:36 +0000 Subject: [PATCH 068/280] Merged revisions 64584,64588 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r64584 | eric_niebler | 2010-08-03 18:54:38 -0400 (Tue, 03 Aug 2010) | 1 line add release notes for Boost.1.44 ........ r64588 | eric_niebler | 2010-08-03 22:37:54 -0400 (Tue, 03 Aug 2010) | 1 line fix typo ........ svn path=/branches/release/boost/numeric/ublas/; revision=64589 From 36d580b280ea49a0b5ce4fe9acd11b48ec4250d5 Mon Sep 17 00:00:00 2001 From: Daniel Walker Date: Wed, 11 Aug 2010 17:04:29 +0000 Subject: [PATCH 069/280] merged [64705] MPL documentation from trunk svn path=/branches/release/boost/numeric/ublas/; revision=64743 From bee896dcaa851656ee69dbbaa782d16933f7a3ac Mon Sep 17 00:00:00 2001 From: Daniel Walker Date: Wed, 11 Aug 2010 18:15:46 +0000 Subject: [PATCH 070/280] merged [64695] and [64696] result_of docs from trunk svn path=/branches/release/boost/numeric/ublas/; revision=64745 From e1fa7cbd2751afaa5cf57ffa8c1da2f96335af7c Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 26 Aug 2010 22:44:53 +0000 Subject: [PATCH 071/280] Merge prep for 1.45 svn path=/branches/release/boost/numeric/ublas/; revision=65046 From 8a9b61e76c4f3e63c0661ca361060c5b74a08512 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Fri, 27 Aug 2010 12:29:04 +0000 Subject: [PATCH 072/280] Spirit: Merging version fix from trunk svn path=/branches/release/boost/numeric/ublas/; revision=65050 From 87893b7724ac4fde78881847d133d2e25d0b3a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hunold?= Date: Wed, 1 Sep 2010 16:18:07 +0000 Subject: [PATCH 073/280] Merge r65004 from trunk Fix #4551,#4553,#4575 by removing unused parameter. svn path=/branches/release/boost/numeric/ublas/; revision=65168 From 58aa475c3575450d2a35510ac0df96c284793fa8 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 4 Sep 2010 11:02:21 +0000 Subject: [PATCH 074/280] Merge r64010, wherein jam has been moved. svn path=/branches/release/boost/numeric/ublas/; revision=65233 From e5ebc05f1f1cba3d29ad9fcb1000204e55384cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hunold?= Date: Tue, 7 Sep 2010 05:52:45 +0000 Subject: [PATCH 075/280] Merge 65318,65319 from ^/trunk ------------------------------------------------------------------------ r65318 | jhunold | 2010-09-06 10:43:06 +0200 (Mo, 06 Sep 2010) | 3 lines Suppress msvc warning 4251 about templates as base classes not having a dll-interface. Suppress msvc warning 4275 about base class std::logic_error not having a dll-interface. ------------------------------------------------------------------------ r65319 | jhunold | 2010-09-06 16:14:09 +0200 (Mo, 06 Sep 2010) | 2 lines Fix: windows does not have wait(), use own macros instead. ------------------------------------------------------------------------ svn path=/branches/release/boost/numeric/ublas/; revision=65326 From 95924df81d9fd94504165eb246c1e53110a78463 Mon Sep 17 00:00:00 2001 From: Christopher Schmidt Date: Sun, 3 Oct 2010 09:46:00 +0000 Subject: [PATCH 076/280] Fusion: merge from trunk svn path=/branches/release/boost/numeric/ublas/; revision=65735 From 4664febfc0f9fe6cd584ad3c2f708d64faabb17c Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Mon, 4 Oct 2010 18:50:40 +0000 Subject: [PATCH 077/280] Merged changes r64063 (W. P. McNeill examples), r65590 (stoer_wagner_min_cut from Daniel Trebbien), 64187 (DIMACS reader updates), and 64762 (DIMACS reader updates) svn path=/branches/release/boost/numeric/ublas/; revision=65751 From 22982ca3bf0b683c045dee1d96f7537be2e285e0 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Tue, 5 Oct 2010 17:42:47 +0000 Subject: [PATCH 078/280] Merged r64074, r64645, r64935, r65198, r65385, r65764 (all related to bundled graph properties as far as I remember) svn path=/branches/release/boost/numeric/ublas/; revision=65766 From 385b821b2bfb38403897215d85b2dde5810d6e29 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Tue, 5 Oct 2010 17:53:09 +0000 Subject: [PATCH 079/280] Merged r64209 (addition to users list), r64223 (fix to users list), r64763 (improved interfaces to smallest_last_ordering), r65593 (patches to stoer_wagner_min_cut) from trunk svn path=/branches/release/boost/numeric/ublas/; revision=65767 From a402f4c9995e2ea26539b4b1947046adc71539d0 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Tue, 5 Oct 2010 18:06:09 +0000 Subject: [PATCH 080/280] Merged r64065 (fixes to implicit_graph example), r65199 and r65386 (documentation fixes), plus copied test_graphs.cpp from trunk svn path=/branches/release/boost/numeric/ublas/; revision=65768 From de39d9911c2d49591002a7c87229edd95788e554 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Tue, 5 Oct 2010 18:08:27 +0000 Subject: [PATCH 081/280] Merged r64064 (quote fix in example) from trunk svn path=/branches/release/boost/numeric/ublas/; revision=65769 From eb63288bc02bcce0a27a56df4ff0117178603059 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 6 Oct 2010 21:36:44 +0000 Subject: [PATCH 082/280] Merged revisions 65515 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r65515 | eric_niebler | 2010-09-21 07:37:31 -0700 (Tue, 21 Sep 2010) | 1 line make auto_any ctor explicit ........ svn path=/branches/release/boost/numeric/ublas/; revision=65792 From a80d29240a1d51bc5cb06c316f321257edbe9c3b Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Thu, 7 Oct 2010 00:57:44 +0000 Subject: [PATCH 083/280] Merged revisions 64371,64661,65793,65796-65797 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r64371 | eric_niebler | 2010-07-26 13:04:15 -0700 (Mon, 26 Jul 2010) | 1 line make proto work on msvc with /clr option ........ r64661 | eric_niebler | 2010-08-07 07:44:27 -0700 (Sat, 07 Aug 2010) | 1 line fix proto::matches bug with lambda_matches, array types and the wildcard ........ r65793 | eric_niebler | 2010-10-06 15:13:27 -0700 (Wed, 06 Oct 2010) | 1 line knock down value of proto::N, fixed #4602 ........ r65796 | eric_niebler | 2010-10-06 16:24:23 -0700 (Wed, 06 Oct 2010) | 1 line vc9 needs workaround, too ........ r65797 | eric_niebler | 2010-10-06 16:39:36 -0700 (Wed, 06 Oct 2010) | 1 line one more time ........ svn path=/branches/release/boost/numeric/ublas/; revision=65798 From 6302900e843680ff615d4541730c1bb46d0ca150 Mon Sep 17 00:00:00 2001 From: Christopher Schmidt Date: Thu, 7 Oct 2010 22:58:44 +0000 Subject: [PATCH 084/280] Fusion: merge from trunk svn path=/branches/release/boost/numeric/ublas/; revision=65821 From f3ce8a4acde3334084e494258db8b03353e23cec Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Fri, 8 Oct 2010 18:06:41 +0000 Subject: [PATCH 085/280] Merged r65836 (fix for #4715) from trunk; refs #4715 svn path=/branches/release/boost/numeric/ublas/; revision=65839 From fb5848de1b9bc205856d3c486d9c070b6fdff49d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hunold?= Date: Sat, 9 Oct 2010 11:37:15 +0000 Subject: [PATCH 086/280] Merge 65838 from ^/trunk ------------------------------------------------------------------------ r65838 | jhunold | 2010-10-08 19:48:40 +0200 (Fr, 08 Okt 2010) | 2 lines Fix: adjust toolset-tag to changed toolset definition. ------------------------------------------------------------------------ svn path=/branches/release/boost/numeric/ublas/; revision=65856 From f2120216a1f498cb6ad176469f61f7477a5323a7 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Sat, 9 Oct 2010 18:59:48 +0000 Subject: [PATCH 087/280] Merged revisions 65788 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r65788 | eric_niebler | 2010-10-06 12:02:04 -0700 (Wed, 06 Oct 2010) | 1 line as() handles wide sub_match objects correctly, fixes #4496 ........ svn path=/branches/release/boost/numeric/ublas/; revision=65866 From 344115876eb0ee4693b250891feb58552ce003d8 Mon Sep 17 00:00:00 2001 From: Christopher Schmidt Date: Sun, 10 Oct 2010 20:57:01 +0000 Subject: [PATCH 088/280] Fusion: merge from trunk - fixed minor doc typos svn path=/branches/release/boost/numeric/ublas/; revision=65895 From befea449f31780d179a1f01437ed5f0b59fe7877 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Fri, 15 Oct 2010 03:39:14 +0000 Subject: [PATCH 089/280] Wave merging from trunk svn path=/branches/release/boost/numeric/ublas/; revision=65968 From 5e7d3fc824d387889992b472686e7520a375a77d Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Sat, 16 Oct 2010 19:23:02 +0000 Subject: [PATCH 090/280] Merged revisions 65843,65864 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r65843 | eric_niebler | 2010-10-08 13:35:43 -0700 (Fri, 08 Oct 2010) | 1 line support non-rtti compilers ........ r65864 | eric_niebler | 2010-10-09 11:30:55 -0700 (Sat, 09 Oct 2010) | 1 line add const-qualified overloads of proto::eval ........ svn path=/branches/release/boost/numeric/ublas/; revision=66027 From 65646fe9cee06b8292c78255f34cd39eb582720b Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Sun, 17 Oct 2010 12:24:50 +0000 Subject: [PATCH 091/280] Merge from trunk. ........ r65998 | chris_kohlhoff | 2010-10-16 15:30:12 +1100 (Sat, 16 Oct 2010) | 2 lines Make unit tests build faster. ........ r66002 | chris_kohlhoff | 2010-10-16 16:13:46 +1100 (Sat, 16 Oct 2010) | 2 lines Add a test case for bug where a deadline timer never fires if the io_service is run in a background thread. N.B. fails only on platforms that use kqueue. Fixes #4568. ........ r66004 | chris_kohlhoff | 2010-10-16 16:43:03 +1100 (Sat, 16 Oct 2010) | 2 lines Fix the way the kqueue_reactor is interrupted when a new timer is scheduled. Fixes #4568. ........ r66005 | chris_kohlhoff | 2010-10-16 17:27:45 +1100 (Sat, 16 Oct 2010) | 2 lines Fix a const-correctness issue that prevents valid uses of has_service<> from compiling. Fixes #4638. ........ r66006 | chris_kohlhoff | 2010-10-16 18:06:18 +1100 (Sat, 16 Oct 2010) | 2 lines Use lower-case to keep MinGW cross-compilers happy. Fixes #4491. ........ r66007 | chris_kohlhoff | 2010-10-16 18:24:47 +1100 (Sat, 16 Oct 2010) | 2 lines Don't use deprecated system functions. Fixes #4672. ........ r66008 | chris_kohlhoff | 2010-10-16 20:47:11 +1100 (Sat, 16 Oct 2010) | 2 lines Ensure close()/closesocket() failures are correctly propagated. Fixes #4573. ........ r66009 | chris_kohlhoff | 2010-10-16 21:01:14 +1100 (Sat, 16 Oct 2010) | 2 lines Check return code of InitializeCriticalSectionAndSpinCount. Fixes #4574. ........ r66010 | chris_kohlhoff | 2010-10-16 22:04:08 +1100 (Sat, 16 Oct 2010) | 2 lines Add support for hardware flow control on QNX. Fixes #4625. ........ r66014 | chris_kohlhoff | 2010-10-16 22:39:13 +1100 (Sat, 16 Oct 2010) | 2 lines Always use pselect() on HP-UX, if it is available. Fixes #4578. ........ r66017 | chris_kohlhoff | 2010-10-16 23:23:56 +1100 (Sat, 16 Oct 2010) | 2 lines Ensure handler arguments are passed as lvalues. Fixes #4744. ........ r66018 | chris_kohlhoff | 2010-10-16 23:39:06 +1100 (Sat, 16 Oct 2010) | 2 lines Fix Windows build when thread support is disabled. Fixes #4680. ........ r66020 | chris_kohlhoff | 2010-10-16 23:59:29 +1100 (Sat, 16 Oct 2010) | 3 lines Timers with expiry times set more than 5 minutes in the future need the waitable timer to be periodic. Fixes #4745. ........ r66035 | chris_kohlhoff | 2010-10-17 22:33:28 +1100 (Sun, 17 Oct 2010) | 2 lines Version bump. ........ svn path=/branches/release/boost/numeric/ublas/; revision=66037 From 7664bf8250dd9d4a8e0c6ff7d041f3a2dc4ccb53 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Mon, 18 Oct 2010 12:14:32 +0000 Subject: [PATCH 092/280] Spirit: merging from trunk svn path=/branches/release/boost/numeric/ublas/; revision=66073 From 79564ad367171ff6b9b661a9187e9e833426dc86 Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Mon, 18 Oct 2010 12:58:10 +0000 Subject: [PATCH 093/280] Merge from trunk. ........ r66022 | chris_kohlhoff | 2010-10-17 00:15:51 +1100 (Sun, 17 Oct 2010) | 2 lines Pass NULL for servname rather than empty string, as per POSIX. Fixes #4690. ........ r66056 | chris_kohlhoff | 2010-10-18 08:24:55 +1100 (Mon, 18 Oct 2010) | 2 lines Fix so that read operations do not accept const_buffers_1 arguments. Fixes #4746. ........ svn path=/branches/release/boost/numeric/ublas/; revision=66080 From bc5ec5013ce23ced08ed2a94a058424c5c7dfb9f Mon Sep 17 00:00:00 2001 From: David Bellot Date: Tue, 19 Oct 2010 07:01:35 +0000 Subject: [PATCH 094/280] beta ublas for 1.45 svn path=/branches/release/boost/numeric/ublas/; revision=66085 --- doc/index.htm | 5 +- doc/index.html | 33 +- .../numeric/ublas/detail/matrix_assign.hpp | 61 ++- .../boost/numeric/ublas/expression_types.hpp | 9 +- include/boost/numeric/ublas/functional.hpp | 2 +- include/boost/numeric/ublas/matrix.hpp | 47 ++ .../boost/numeric/ublas/operation/size.hpp | 507 ++++++++++-------- test/comp_mat_erase.cpp | 2 +- test/test11.cpp | 7 + 9 files changed, 402 insertions(+), 271 deletions(-) diff --git a/doc/index.htm b/doc/index.htm index 80fac07b..4adac4dc 100644 --- a/doc/index.htm +++ b/doc/index.htm @@ -373,8 +373,7 @@ programs reside Boost

    +Michael Stevens, Benedikt Weber, Martin Weiser, Gunter Winkler, Marc Zimmermann, David Bellot, Marco Guazzone, Nasos Iliopoulus, the members of Boost and all others contributors around the world. I promise I will try to add their names to this list.

    Frequently Asked Questions

    @@ -402,7 +401,7 @@ prod<matrix_type > (B, C)).


    -

    Copyright (©) 2000-2009 Joerg Walter, Mathias Koch, Gunter Winkler
    +

    Copyright (©) 2000-2010 Joerg Walter, Mathias Koch, Gunter Winkler, David Bellot
    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 ).

    diff --git a/doc/index.html b/doc/index.html index 35f0862f..8268f1b5 100644 --- a/doc/index.html +++ b/doc/index.html @@ -1,22 +1,19 @@ - + - - - -index.html not found - + + + Boost::ublas : index.html not found + -

    Please update your bookmarks to point to index.htm. You will be redirected in a second.

    -

    - Copyright (©) 2000-2004 Michael Stevens, Mathias Koch, - Joerg Walter, Gunter Winkler
    - 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 - ). -

    +

    Please update your bookmarks to index.htm. + You will be redirected in a second. If not, please click on the previous link.

    +

    +

    + Copyright (©) 2000-2010 Michael Stevens, Mathias Koch, Joerg Walter, Gunter Winkler, David Bellot
    + 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 ). +
    +

    diff --git a/include/boost/numeric/ublas/detail/matrix_assign.hpp b/include/boost/numeric/ublas/detail/matrix_assign.hpp index 36bca28d..3bc48ee0 100644 --- a/include/boost/numeric/ublas/detail/matrix_assign.hpp +++ b/include/boost/numeric/ublas/detail/matrix_assign.hpp @@ -13,6 +13,7 @@ #ifndef _BOOST_UBLAS_MATRIX_ASSIGN_ #define _BOOST_UBLAS_MATRIX_ASSIGN_ +#include // Required for make_conformant storage #include @@ -90,7 +91,7 @@ namespace detail { break; } else if (compare > 0) { if (conformant_restrict_type::other (it2e.index1 (), it2e.index2 ())) - if (*it2e != value_type/*zero*/()) + if (static_cast(*it2e) != value_type/*zero*/()) index.push_back (std::pair (it2e.index1 (), it2e.index2 ())); ++ it2e; if (it2e != it2e_end) @@ -102,7 +103,7 @@ namespace detail { } while (it2e != it2e_end) { if (conformant_restrict_type::other (it2e.index1 (), it2e.index2 ())) - if (*it2e != value_type/*zero*/()) + if (static_cast(*it2e) != value_type/*zero*/()) index.push_back (std::pair (it2e.index1 (), it2e.index2 ())); ++ it2e; } @@ -119,7 +120,7 @@ namespace detail { #endif while (it2e != it2e_end) { if (conformant_restrict_type::other (it2e.index1 (), it2e.index2 ())) - if (*it2e != value_type/*zero*/()) + if (static_cast(*it2e) != value_type/*zero*/()) index.push_back (std::pair (it2e.index1 (), it2e.index2 ())); ++ it2e; } @@ -136,7 +137,7 @@ namespace detail { #endif while (it2e != it2e_end) { if (conformant_restrict_type::other (it2e.index1 (), it2e.index2 ())) - if (*it2e != value_type/*zero*/()) + if (static_cast(*it2e) != value_type/*zero*/()) index.push_back (std::pair (it2e.index1 (), it2e.index2 ())); ++ it2e; } @@ -193,7 +194,7 @@ namespace detail { break; } else if (compare > 0) { if (conformant_restrict_type::other (it1e.index1 (), it1e.index2 ())) - if (*it1e != value_type/*zero*/()) + if (static_cast(*it1e) != value_type/*zero*/()) index.push_back (std::pair (it1e.index1 (), it1e.index2 ())); ++ it1e; if (it1e != it1e_end) @@ -205,7 +206,7 @@ namespace detail { } while (it1e != it1e_end) { if (conformant_restrict_type::other (it1e.index1 (), it1e.index2 ())) - if (*it1e != value_type/*zero*/()) + if (static_cast(*it1e) != value_type/*zero*/()) index.push_back (std::pair (it1e.index1 (), it1e.index2 ())); ++ it1e; } @@ -222,7 +223,7 @@ namespace detail { #endif while (it1e != it1e_end) { if (conformant_restrict_type::other (it1e.index1 (), it1e.index2 ())) - if (*it1e != value_type/*zero*/()) + if (static_cast(*it1e) != value_type/*zero*/()) index.push_back (std::pair (it1e.index1 (), it1e.index2 ())); ++ it1e; } @@ -239,7 +240,7 @@ namespace detail { #endif while (it1e != it1e_end) { if (conformant_restrict_type::other (it1e.index1 (), it1e.index2 ())) - if (*it1e != value_type/*zero*/()) + if (static_cast(*it1e) != value_type/*zero*/()) index.push_back (std::pair (it1e.index1 (), it1e.index2 ())); ++ it1e; } @@ -636,7 +637,8 @@ namespace detail { template