Boost logo

Ublas :

Subject: Re: [ublas] Is coordinate_matrixelement assignment/insertion broken in 1.42?
From: Rutger ter Borg (rutger_at_[hidden])
Date: 2010-03-01 11:05:38

Thomas Klimpel wrote:

> Very helpful, thanks. I had misread "MSVC2008SP1" as MSVC8SP1 = "Visual
> Studio 2005". However, I don't have time to try to reproduce this now (->
> later...).
> Regards,
> Thomas

I have another idea of what it could be. The compressed_matrix is doing
modifications by means of sort() in an observing function (which should be
forbidden, by the way!). This gives faster inserts for someone who is
inserting element-by-element -- the reason why STL provides iterator ranges
for bulk inserts. I.e.,

// modifiers
insert( element )
insert( begin, end )

// observers
at( i, j ) const

// further down the class
// need to counter the const of the observer by adding mutable
mutable some_container;

Now, although I have limited experience with errors due to keywords
{mutable, volatile} (because I don't use them), it could be that there's
something optimized out in the observing function. To counter that again,
you could try to add volatile to the observing function,

// observers
at( i, j ) const volatile

to ensure the compiler doesn't optimize away some stuff. Not sure if it
works, but I guess it's worth the try.