Re: [eigen] Constructing a matrix by scalar*

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]




On Thu, Nov 27, 2008 at 3:59 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
[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.

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/