Boost logo

Ublas :

From: Vardan Akopian (vakopian_at_[hidden])
Date: 2007-06-13 13:22:25

> I guess getting a vector-view onto a matrix is not possible in uBLAS.

Getting a vector-view onto a dense matrix is possible in uBLAS,
although admittedly a bit awkward:

matrix<double> mat(10, 20);
// ...
size_t data_size =;
shallow_array_adaptor<double> shared(data_size,;
vector<double, shallow_array_adaptor<double> > vec(data_size, shared);

This approach allows to have any kind of "reshaping" operations (a la
Matlab reshape), without copying the data.
Note, that this requires BOOST_UBLAS_SHALLOW_ARRAY_ADAPTOR to be defined.