Boost logo

Ublas :

From: Karl Meerbergen (Karl.Meerbergen_at_[hidden])
Date: 2005-06-20 03:22:10


On Monday 20 June 2005 09:44, Michael Stevens wrote:

> a) Most expressions don't involve and unsafe lvalue alias so the user has
> to type noalias() a lot!
Would it be easy to detect? I guess this is so for some expressions.
For example, we could introduce
safe( x ) = expression
where safe creates a temporary whenever it is not sure a temporary is not
needed. This would be an alternative to
alias( x ) = expression
that always creates a temporary.

> b) The general experience from BLAS is that no temporaries are used to make
> thing safe. uBLAS avoids temporaries except in this case.
I am not sure I understand this. The user of BLAS calls has to make sure that
arrays do not overlap (except for read only arrays I suppose). So the user
may have to create temporaries to avoid possible messing up of arrays.
Do I understand something wrongly?

Generally speaking, we have two potential classes of users: those who want
efficient code and reduce the creation of a large number of temporaries,
where this may lead to a significant overhead. And those who want safe code.
Both mechanisms should be there, and the syntax might be a bit more
complicated for the experienced programmer, i.e. those who want efficient
code. The 'safe' could avoid aliasing when possible, as explained above.

Karl