Re: [eigen] is MAP oneway ? (urgent) |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] is MAP oneway ? (urgent)
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Wed, 24 Jun 2009 14:45:18 +0200
- 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=uqaypm8wqbE0IP2TO4XlGX0i8h4W+/D8GYDy9CaZV94=; b=bGbKjCsA6CNtOIKj2VDcXe2aEU49S9HbK5G4Bh15jHW0n1dyFR96k6d5CvTgVri8Th 28EdLy1W2fMeraOHj+NSUm3G/Fc8FodX+NltKYSvkBwnOVRIp3Fk8SRUVetwK/fhCrfM zvMVFmbHJ/8K/WxeB1h+K9PM+ySq+z4CdY8YE=
- 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=hYdxrqyuQ7Y5IX8Ow6+EHWWwTUBUFIg0JE4a74mMPm+wAZ2Mmj4vKXA8dYH/NQ6n9V h/HWzU+0tSDRt6m+0CogI31l3ypzT3R0svvnPsJi/76b3jb4kWwbSfKvigxf3HOmFYcT WzvIO9DJX8h9cE04R1Nt3KCDaUqzrdNptzvzQ=
2009/6/24 Helmut Jarausch <jarausch@xxxxxxxxxxxxxxxxxxx>:
> On 24 Jun, Gael Guennebaud wrote:
>> On Wed, Jun 24, 2009 at 2:13 PM, Helmut
>> Jarausch<jarausch@xxxxxxxxxxxxxxxxxxx> wrote:
>
>>> Is there something like "overlaying" an Eigen-Vector onto some raw
>>> C-array?
>>
>> this is exactly what Map do, however you have to deal with Map object
>> directly, e.g.
>>
>> double* c_like_data = whatever;
>>
>> Eigen::Map<VectorXd> v(c_like_data, size);
>>
>> then you can use "v" just like any other Eigen matrix/vector:
>>
>> v *= 10;
>>
>> is equivalent to:
>> for (int i=0; i<size; ++i)
>> c_like_data[i] *= 10;
>>
>
> But now, I have the ugly problem with reference types
> #include <iostream>
> using std::cerr; using std::endl;
> #include <Eigen/Core>
> // import most common Eigen types
> USING_PART_OF_NAMESPACE_EIGEN
>
> void process(VectorXd& DATA);
>
> int main() {
> double data[4] = {1, 2, 3, 4};
>
> Eigen::Map<VectorXd> D(data,4);
> process(D); // ERROR! invalid initialization of reference
> // of type 'Eigen::VectorXd& ....
Of course: process takes a VectorXd reference, but D is not a VectorXd.
The biggest common denominator between VectorXd and Map<VectorXd> is
MatrixBase, so you want process to take a MatrixBase reference:
template<typename Derived>
void process(const MatrixBase<Derived>& DATA);
Benoit