Boost logo

Ublas :

Subject: Re: [ublas] Slicing
From: Markus Weimer (mailinglists2008_at_[hidden])
Date: 2008-11-28 02:54:33


Hello,

>>> ublas::row(G, i) = ublas::row(ublas::prod(GF, X), j);
>
> This should exactly give what you desire: compute only the j-th row of
> GF*X and assign this to the i-th row of G

Yes, this works as intended indeed. And it's fast, too (with NDEBUG).

But what I want is slightly more complex: Not all columns of G shall
be updated. And not all columns of X should contribute to the prod().
In fact, I want to exclude the same range of columns from both.

I can do this by copying the result of the prod() into a vector and
then copying only the values I am interested in into G. That works,
but I wonder whether there is a more elegant way that might even save
me a temporary.

> The expression "prod(GF,X)" does not mean "compute GF*X" - it is
> only an expression template. The real computation is done during
> the assignment for exactly the elements that are assigned. (This is
> a good example how expression templates provide the effect of lazy
> computation.)

I have no idea how to code expression templates, but I am always happy
to use one for exactly these reasons. ;)

Thanks again,

Markus