Update of /cvsroot/boost/boost/boost/numeric/ublas
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv12675/boost/numeric/ublas
Modified Files:
vector_sparse.hpp
Log Message:
[uBLAS] CHANGE implement uBLAS preserve option in vector resize.
Thanks to Gunter Winkler and Vassilis Virvilis
Index: vector_sparse.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/numeric/ublas/vector_sparse.hpp,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- vector_sparse.hpp 4 Feb 2006 15:13:25 -0000 1.76
+++ vector_sparse.hpp 16 Nov 2006 09:47:44 -0000 1.77
@@ -868,13 +868,21 @@
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 ();
}
@@ -1316,6 +1324,7 @@
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 +1480,15 @@
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 +1496,6 @@
filled_ = 0;
}
sorted_filled_ = filled_;
- size_ = size;
storage_invariants ();
}
// Reserving
@@ -1977,6 +1989,7 @@
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_;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs