Re: [eigen] Constructing a matrix by scalar*
• 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
• 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 wrote:
[UPDATE: Gael beats me to it as usual)

What you're after is Eigen::Map.

float array[3];
....

Map<Vector3f> m(array);

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().

Cheers,
Benoit

2008/11/27 Benjamin Schindler <bschindler@xxxxxxxxxxxxxxx>:
> Hi
>
> 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?
>
> Thanks
> Benjamin
>
> ---
>
>

---

 Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/