Boost logo

Ublas :

Subject: Re: [ublas] How to instantiate ublas vector from std::vector
From: Jeremy Conlin (jeremit0_at_[hidden])
Date: 2009-04-10 08:38:21

On Fri, Apr 10, 2009 at 8:05 AM, Jesse Manning <manning.jesse_at_[hidden]>wrote:

> That should be possible, but you will have to copy the data from the
> std::vector to the ublas::vector. The syntax you used in the first post
> would suggest that you want to use a std::vector as the underlying storage
> of a ublas::vector. As far as my experience goes you can use any of the
> standard algorithms on ublas vectors just as you would with std::vector
> which would allow them to be used almost interchangeably in most situations
> (except for dynamic size changing supported by the std::vector).
> something like this perhaps:
> std::vector<double> svd(3,1.0);
> ublas::vector<double> uvd(svd.size());
> std::copy(svd.begin(), svd.end(), uvd.begin());
That's what I resorted to when I discovered there was nothing like I was
hoping for. I guess I would like to avoid copying the data. That could
probably be done, but would not be a great solution.