Subject: Re: [ublas] How to instantiate ublas vector from std::vector
From: Jesse Manning (manning.jesse_at_[hidden])
Date: 2009-04-10 08:05:22
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::copy(svd.begin(), svd.end(), uvd.begin());
On Thu, Apr 9, 2009 at 10:59 PM, Jeremy Conlin <jeremit0_at_[hidden]> wrote:
> On Thu, Apr 9, 2009 at 6:24 PM, Kenneth Porter <shiva_at_[hidden]>wrote:
>> On Thursday, April 09, 2009 1:34 PM -0400 Jeremy Conlin <
>> jeremit0_at_[hidden]> wrote:
>> But such a constructor does not exist. I thought that using a
>>> std::vector for the storage type of a ublas vector allowed me to do this.
>>> Can someone help me understand how I can do this (or some workaround)?
>> I don't know the answer, but it might be useful to know why you want to do
>> that. I recall reading that the ublas::vector needs to remain a fixed size
>> for its lifetime, so you have to be careful not to do anything to its
>> storage to break its assumptions.
> Yes, of course. I would like to be able to use std::vectors and ublas
> vectors (almost) interchangeably. I was hoping that if a function returned
> a std::vector and the calling function assigned that to a ublas vector then
> all would work out without any trouble. Is this not a possibility?
> ublas mailing list