|Re: [eigen] Constructing a matrix by scalar*|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Constructing a matrix by scalar*
- From: "Gael Guennebaud" <gael.guennebaud@xxxxxxxxx>
- Date: Thu, 27 Nov 2008 16:05:28 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=d1FHXQueyTG9Cc21ZFYs83xH0ljj/0/DB3QSIa+bOEU=; b=cWAXg0xAVFtz/TzqVQ9auJFXc9lbReJOQOuGrGtRGYEH7hOTT49Grn7K4y/q/mQbY3 4qdsNgna0JzHUSIPowkAG7hHg/4DCOA2fqdXghnQ4nZDjHGDMtWkqVa/f92J9YH17hKw vmx9kIPKFNvQfWFXyGFPegBbIMQiPxBzsEl70=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=fzDDG4fY7/3NOfdJjQKMVMMmreFbgfTC6TddFSKLKYOaKNf4WJ935V4pWfr8Q8Ij2F M3apLYi4y8GOqOGrim57llOGQMuSrP/OiD29kg6GfyNXGfetCzEK5qvXNwTJP+sZn68r scSL01x7Ow2S6W+ppDoptxExg7bpzdOhd/Rlg=
On Thu, Nov 27, 2008 at 3:59 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
[UPDATE: Gael beats me to it as usual)
this is only because, as usual, your answer is more complete....
What you're after is Eigen::Map.
Now use m as if it were a usual vector.
If you only want to construct a temporary Map object in an _expression_
you can use the Map() static method (you need trunk for that, beta1's
not enough). For example if you want to double every float in the
array, you can do:
Vector3f::Map(array) *= 2;
In order to benefit more from vectorization (which doesn't apply to
Vector3f anyway, but say Vector4f or VectorXf), use a 128bit aligned
array and use Map<Vector4f, Aligned> or Vector4f::MapAligned().
2008/11/27 Benjamin Schindler <bschindler@xxxxxxxxxxxxxxx>:
> I'm currently working with vtk and it has a pretty ugly way of dealing with
> vectors /- /at least in my opinion. So I thought I could use eigen2 to do
> some of the fixed-size vector-math I'm doing. I found that Matrix has a
> data() function which returns a raw pointer to the data so that's good. But
> What I'm missing is a constructor which constructs a i.e. vector3f from a
> float pointer without copying the data. If I want to efficiently interact
> between vtk and eigen, I think this is very crucial.
> Is this somehow possibel?