Re: [eigen] What's the best way to copy an Eigen::Vector into a std::vector? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] What's the best way to copy an Eigen::Vector into a std::vector?
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Wed, 4 Nov 2009 13:32:25 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=+lHN3DQeGApyvogRx+shq8ScubyIQtD8KmopOfmdA1g=; b=I4zCTSDzljsNqN8NKE/ksnvFeh3cIxuSxcpQ8zvnaDWS/QJquQNbx/x6z6xwXHh3Ww Lgcd6s23uI5rp5trtFYx1OAz6kLnb00VuPxcV3XumnsQh/yUDzyLLpjWrPaGgYuvg/T4 guLtptJa+BUmzOtSnfnp818KVrXLgm3Aogztw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=NWFuap5m1GE++kwY7ElX0HhmkPPv2PKC2vzFOCQf30pdOdxb4FupPmPBZbY7lpcAQG aAAkLH6hxJqvpztq91U1ZZd+cZdzxulaSvBelnEZnWr311ravlh3q6kbhrf7EAS1d5s0 Rj6IyRYP34xIqMqK0GYLeRDngSDDxvWnLwYuA=
2009/11/4 Robert Lupton the Good <rhl@xxxxxxxxxxxxxxxxxxx>:
> Dear Mr. Eigen,
>
> What's the best way to copy an Eigen::Vector into a std::vector?
>
> I'd use
> std::copy(evec.begin(), evec.end(), stdvec.begin());
> if Eigen supported begin and and, but it doesn't seem to. I don't know what
> Eigen's start() and end() are supposed to do, but the following doesn't
> compile:
>
> #include <algorithm>
> #include <vector>
> #include "Eigen/Core"
>
> int main() {
> Eigen::VectorXd evec(10);
> std::vector<double> stdvec(10);
> std::copy(evec.start(), evec.end(), stdvec.begin());
> }
>
> although the doxygen docs refer to start(void).
>
> I see the headers Eigen/StdVec and Eigen/NewStdVec, but they don't seem to
> do what I want.
These are to allow doing stuff like std::vector<Vector4f,
aligned_allocator> and making sure that the alignment is actually
honored.
In addition to Hauke's method, you can equivalently wrap your
std::vector with Map and assign to that.
Benoit
>
> R
>
>
>
>