Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2007-03-06 07:31:15


Am Dienstag, 6. März 2007 11:42 schrieb Sourabh:

> The above operation is taking 1 second for 200000 iterations. Not for
> 1 iteration.
>
>
> Just a strange thing, if I change the statement
> densevector (i) = othervector (it.index ());
>
> to
>
> densevector (i) = (it.index ());
>
> time taken is increased. What could be the possible reason ?

You should always define NDEBUG and use -O2 to have a meaningful time.
Otherwise there will be index checks and some internal consistency
checks on all operations.

BTW. if you really want to select some elements out of a vector you
should consider

indirect_array (array of indices)
vector_indirect (vector of a subset of elements of another vector)

please look at the archives for the discussion about indirect array
http://article.gmane.org/gmane.comp.lib.boost.ublas/1839

mfg
Gunter