Following my original request:
Is it possible to adapt e.g. a pointer to double in to a ublas::matrix<double>, or construct a matrix from a pointer to double?
And the following suggestion,
You could write your own storage class (see the Storage concept in the uBLAS documentation) which is an adaptor for a pointer and you can assign set the pointer via the data() member function of matrix<double>.
-- François Duranleau LIGUM, Université de Montréal
I have found the following seems to work. That said I would like
comments on this solution. Is this the "right" way to achieve what I
want? If not, what is?
If this is the best way, I recommend adding a note to the
ublas:....matrix|vector documentation to this effect, perhaps with
something like this as an example. I imagine that this would be a
common requirement for many people.
Regards,
-ed
/**
*
* Example of constructing a boost matrix and vector object from
* previously allocated heap memory using an array_adaptor.
*
* Comments please on the legitamacy of this and potential catches.
*
* ej.grace@imperial.ac.uk
*/
// Why should I have to define the following in order to use
// shallow_array_adaptor?
#define BOOST_UBLAS_SHALLOW_ARRAY_ADAPTOR
// Definitions for vector and matrix.
#include