Boost logo

Ublas :

Subject: Re: [ublas] submatrix with indexvector
From: Ralf Denzer (Ralf.Denzer_at_[hidden])
Date: 2010-07-29 11:03:44


>This will work, but for some reason the indirect_array has the contradiction that although it provides only const iterators (hence doesn't allow you to change the data in the
>container), it does return non-const reference (so you can change the container by indexing or by std algorithms using Ralf's suggestion).

>I am not sure about the design decision and whether this should be filed as a bug (the indirect_array concept declares the iterator constant as well, so why return non-const
> reference?). If the concept is to be made consistent, non-const reference may not be allowed (your code and Ralf's may not work in the future).

You are right. There is some inconsistency.
The problem with the indirect_array<> is, that it is around for a very long time but was never documented.
But indirect_array's are very useful for submatrices, assembly of larger matrices from smaller ones, ...

> On the other hand if constness is forced, it may break many peoples' code. After all why should the indirect_array be immutable? Maybe the simplest thing is that we just provide
> regular iterators and change the concept as well.

> Nevertheless, what seems like complying with the concept and I find unlikely to change is:

> ublas::indirect_array<vector_type> ia(data.size(), data);

Yes, that looks better.

Neu: WEB.DE De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
Jetzt De-Mail-Adresse reservieren: