Boost logo

Boost :

From: Michael Stevens (support-1_at_[hidden])
Date: 2002-07-16 06:17:21

>Date: Mon, 15 Jul 2002 10:38:08 -0400
>From: "David Abrahams" <david.abrahams_at_[hidden]>
>>>> > One idea to consider:
>>>> >
>>>> > x.assign() = blah blah blah
>>>> >
>>>> > would at least set the LHS off from the rhs a little better.
>>> Or add some policy to the matrices and vectors to indicate if they are
>>> aliased. e.g. 'matrix< double, column_major, restrict > a(10,10);'
This is very intersting. Similar to what I was thinking regarding syntax
and alias problems. Providing/using more traits information to/in
assigment operators could be very useful.At the moment we have the
situation where if you use
        A = B;
then a temporay is created incase the right hand side is a expression
with an alias of A. Of course we can use
    A.assign (B);
but it is rather ugle.
I believe it is true that if the expression (B in this case) is a
container then direct assignment is safe; even if B is an alias for A.
Similarly for vector proxies:
    v = row(B, 2)
is always safe if B is a container.

In the future this may become more important as more high level linear
algerbra objects are added. At the moment (soon) we already have a
temporary creating prod<xx>(a,b). If I implemented a Cholesky
factorisation in uBLAS I would probably have the object constructed from
a symmetric matix and store the factorisation in a triangular class
member. I think it will be a common property of all factorisations that
they cannot be efficiently evaluted by the index/iterated expression
template mechanism without creating a temporary first. Therefore
factorisation object will always have the safe direct assigment property
as above. It would be nice to avoid the .assign() syntax and be able to use
        UT = cholesky(M);

There may already be enough traits information in uBLAS expressions to
make operator= choose an appropriate (temporary free) assignment. If
nobody can see any dangers in this I will try to develop some uBLAS
patches to try this out.

> a .noalias= x * y;
>would be nice, or possibly
Mmmm this looks very nice. Has the advantage that it works even when not
using the uBLAS namespace.

> a /noalias = x * y;
> a [noalias]= x * y;
>Mmm, that last one's tasty...
Or even
        a = noalias(x*y)
which could simply use the above traits mechanism and wrap the result of
x*y with a trair to indicate safe direct assigment.


Boost list run by bdawes at, gregod at, cpdaniel at, john at