Boost logo

Ublas :

From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2005-06-15 02:30:46

christopher diggins <cdiggins_at_[hidden]> wrote:
>> What does it mean for the library to *use* aliases? How does the
>> know whether arguments are aliases (except in some special cases) ?
>It doesn't, but a matrix and vector library does not have to allow aliasing
>in the first place.

So IIUC you are suggesting that the uBLAS should not have views (like
matrix_row, matrix_col, matrix_range etc). Of if uBLAS would have views that
they are not implemented as being a proxy to the original data but instead
copy the data.

This is certainly a good idea in many cases. For instance if you're going to
perform a lot of operations on a matrix_range, it might be much better for
performance to make sure that the data in the matrix_range is continuous in
memory. Currently I advise people to assign their matrix_range to another
matrix in such cases. At the end of the operations they should however not
forget that they need to assign the matrix to the matrix_range if their
intention was to modify the matrix that is pointed to by the matrix_range.

To conclude I think both approaches (proxy-views and deep-copy views) are
both necessary. Deep-copy views however can be implemented using proxy-views
(as I described above). And actually deep-copy views are plain containers
instead of being views. And whenever we have expressions with containers
instead of views we can safely ignore aliasing.