Boost logo

Ublas :

From: Vassilis Virvilis (vasvir_at_[hidden])
Date: 2006-11-04 02:22:39


Gunter Winkler wrote:

> PS: please try to modify coordinate_vector the same way (the difference
> is marginal: one call to sort() before any modification).
>

The coordinate vector:

First there is this warning upon coordinate_vector::resize(). compiler == g++-4.0.2 Suse Linux

/home/vasvir/local/include/boost/numeric/ublas/storage.hpp: In copy constructor 'boost::numeric::ublas::index_pair<V>::index_pair(const boost::numeric::ublas::index_pair<V>&) [with V = boost::numeric::ublas::index_pair_array<boost::numeric::ublas::unbounded_array<size_t, std::allocator<size_t> >, boost::numeric::ublas::unbounded_array<Real, std::allocator<Real> > >]':
/usr/include/c++/4.0.2/bits/stl_algo.h:2498: instantiated from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = boost::numeric::ublas::indexed_iterator<boost::numeric::ublas::index_pair_array<boost::numeric::ublas::unbounded_array<size_t, std::allocator<size_t> >, boost::numeric::ublas::unbounded_array<Real, std::allocator<Real> > >, std::random_access_iterator_tag>, _Size = long int]'
/usr/include/c++/4.0.2/bits/stl_algo.h:2569: instantiated from 'void std::sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = boost::numeric::ublas::indexed_iterator<boost::numeric::ublas::index_pair_array<boost::numeric::ublas::unbounded_array<size_t, std::allocator<size_t> >, boost::numeric::ublas::unbounded_array<Real, std::allocator<Real> > >, std::random_access_iterator_tag>]'
/home/vasvir/local/include/boost/numeric/ublas/vector_sparse.hpp:1730: instantiated from 'void boost::numeric::ublas::coordinate_vector<T, IB, IA, TA>::sort() const [with T = Real, long unsigned int IB = 0ul, IA = boost::numeric::ublas::unbounded_array<size_t, std::allocator<size_t> >, TA = boost::numeric::ublas::unbounded_array<Real, std::allocator<Real> >]'
/home/vasvir/local/include/boost/numeric/ublas/vector_sparse.hpp:1482: instantiated from 'void boost::numeric::ublas::coordinate_vector<T, IB, IA, TA>::resize(typename IA::value_type, bool) [with T = Real, long unsigned int IB = 0ul, IA = boost::numeric::ublas::unbounded_array<size_t, std::allocator<size_t> >, TA = boost::numeric::ublas::unbounded_array<Real, std::allocator<Real> >]'
main.cpp:27: instantiated from here
/home/vasvir/local/include/boost/numeric/ublas/storage.hpp:1550: warning: base class 'class boost::noncopyable_::noncopyable' should be explicitly initialized in the copy constructor

The output after the resize is like this

size: 9 nnz_Ccapacity: 2 nnz: 2
0:0
1:0
2:0
3:0
4:0
5:0
6:0
7:0
8:1

which is buggy. nnz must be 1 after resize()

Hmm... in coordinate vector there is sorted_filled_. I don't know about that. sort() is called before I
trim filled_. Anyway the attached patch looks ok. Test program<coordinate_vector> has now the following
output.
size: 9 nnz_Ccapacity: 2 nnz: 1

If there are complications because of sorted_filled_ please let me know.

    .bill