Boost logo

Ublas :

Subject: Re: [ublas] Accessing the indices of non-zero elements in a UBLAS sparse vector
From: John Reid (j.reid_at_[hidden])
Date: 2011-09-24 04:40:04


OK I get you, you're saying the non-const iterator only iterates over
the non-zero elements in any case. AFAICT this is true for all the
sparse vector types.

Thanks,
John.

On 24/09/11 07:50, Oswin Krause wrote:
> Hi,
>
> for(mapped_iterator<double>::iterator v = vector.begin(); v !=
> vector.end(); ++v){
> std::cout<<v.index()<<""<<*v<std::endl;
> }
>
>>
>>
>> On 23/09/11 11:53, Oswin Krause wrote:
>>> Hi,
>>>
>>> maybe i have to correct myself, my information seems to be outdated.
>>>
>>> the source code for mapped_vector::iterator states:
>>>
>>> BOOST_UBLAS_INLINE
>>> iterator&operator ++ () {
>>> ++ it_;
>>> return *this;
>>> }
>>> BOOST_UBLAS_INLINE
>>> reference operator * () const {
>>> BOOST_UBLAS_CHECK (index ()< (*this) ().size (), bad_index ());
>>> return (*it_).second;
>>> }
>>>
>>> So it should work out of the box without the index workaround. Sorry for
>>> the inconvenience caused...finally i can beatify some of my own code :)
>>> (after i have checked whether this is also true for the sparse matrices.
>>> unfortunately, THAT code is a mess).
>>
>> What does "out of the box" mean here? Can you give a line of code?
>>
>>
>>
>> _______________________________________________
>> ublas mailing list
>> ublas_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/ublas
>> Sent to: Oswin.Krause_at_[hidden]
>>
>
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: gclbu-ublas-dev-3_at_[hidden]
>