Boost logo

Boost :

From: George Katsirelos (gkatsi_at_[hidden])
Date: 2002-07-15 10:36:05

Indeed, that fixes this specific problem, but is there a way to actually
remove the element from the matrix so that it does not appear when
iterating over it? (similar to what map does)

The desired output in this case would not include the line 5 == 0 at all.

If that's not possible/convenient, would it then be possible that
zero'ed elements do not appear when the vector is copied to a new one?
Right now, I have to use the following piece of code function, which
seems like a kludge:

template<class Vector>
void resparsify(Vector& d) {
   typedef typename Vector::iterator iter;
   Vector newd(d.size());
   for(iter i = d.begin(); i != d.end(); ++i)
       if( *i != 0.0 )
           newd[i.index()] = *i;


Joerg Walter wrote:
> ----- Original Message -----
> From: "George Katsirelos" <gkatsi_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Saturday, July 13, 2002 7:03 PM
> Subject: [boost] Bug in ublas?
>>The piece of code at the end of this mail produces unexpected output.
>>Briefly, calling erase() on a sparse vector does weird things to the
>>contents of that vector, even though the iterators still work (somewhat)
>>Note that after the call to d.erase(5), elements 2 and 3 do not appear
>>in the output, even though they are there when iterating. Also note the
>>0 == 0 that appears.
>>The compiler is gcc 3.1.
>>This seems like a bug or, if not, very counterintuitive behavior.
> That's definitely a bug.

Boost list run by bdawes at, gregod at, cpdaniel at, john at