Re: [eigen] const Static Vector/Matrix howto |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] const Static Vector/Matrix howto
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Thu, 4 Feb 2010 17:32:51 -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=dwrBiuFR5VztXJLuL+rZM1TxWsfLnqImnOO0ccBKs4U=; b=Ua6LSZHy2e6lWStde2Lz/NYzGw4rlXQn3v6jy1p0m5rjdfDFdn8P7JxitplsiVgJKk TecF7/ozghMHh95ASjyKB8SgyuvMyNQF2zV/c2S+h2nSlALkbrte8yf9B485gv5ON3Qg cVLbsMfKMvOSUF2U518SAqa+eN0w64PiyyTDY=
- 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=EDzDBxuaudzQn/NsEbB/ZDMmUXILSAR4jfGuXiu25XE2YTyr32ZWyAjBpP0GZiI37j WwZNOgeMcxZZAETu26oXRqhlq8DZuguLwm/bsdiH73UxqGuhFZd8KZZqorFvSAZ+S8T/ 3qZ8WhREvMCUDB8GuichLTwA77HQdXrRdlyeI=
If it makes your life easier to allow the Matrix contructor taking
x,y,z,w for 2x2 matrices, then I'm OK with that and that is a very
simple change in Matrix.h : remember that matrix.coeffRef(int index)
is allowed for all matrices, not just vectors.
Benoit
2010/2/4 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> I think you can do this:
>
> EIGEN_ALIGN16 double matrix_data[] = { 1., 2., 3. ,4. };
> Matrix2d::AlignedMapType m(matrix_data);
>
> There are no copies involved and the matrix m is aligned.
>
> - Hauke
>
> On Thu, Feb 4, 2010 at 3:40 PM, Thomas Capricelli <orzel@xxxxxxxxxxxxxxx> wrote:
>>
>> Hi,
>>
>> I'd like to ask about a problem i often encounter. I need to allocate a static const Vector or matrix. That is, i already know the coefficients.
>>
>> I currently do something like this:
>>
>> static double matrix_data[] = { 1., 2., 3. ,4. };
>> static Eigen::Matrix< double, 2, 2 > m(matrix_data);
>>
>> Which is far from perfect because i guess the data is copied, so we have both an allocation and a copy that are not really needed.
>>
>> I thought about using ::map:
>>
>> Map<Eigen::Matrix< double, 2, 2 > > m(matrix_data);
>>
>> but i'm not sure how efficient this is.. i guess in my first try the constructor of ::Matrix ensure alignement while in the second case, the data is where matrix_data is, which has no guaranty of being aligned, is it ?
>>
>> So what would you suggest ? Should i ensure (how?) that matrix_data is aligned and use the Map stuff ? Any other idea?
>>
>> ++
>> Thomas
>> --
>> Thomas Capricelli <orzel@xxxxxxxxxxxxxxx>
>> http://www.freehackers.org/thomas
>>
>>
>>
>
>
>