I am using boost::numeric::ublas::vector<double>
(http://www.boost.org/doc/libs/1_41_0/libs/numeric/ublas/doc/vector.htm).
How can I get an internal data pointer to the double?
I need the internal pointer because I want to copy the vector to CUDA (i.e. using cudaMemcpy)
. Or is there any elegant way to copy my boost vectors/matrices across?
I know I can do something like:
boost::numeric::ublas::vector<double> vector;
double* ptr = &vector[0];
but is there a more elegant way?
I think that if you instantiate your vector using an
unbounded_array
as the storage model:then you can do something like this:
This works because the
unbounded_array
iterator is a standard C++ pointer to the type being stored.