|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: "Benoit Jacob" <jacob.benoit.1@xxxxxxxxx>
- Date: Thu, 27 Nov 2008 15:59:50 +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 :content-transfer-encoding:content-disposition:references; bh=oRwQZ2pXQWPOSfrjYOIj06NsMJOMoyrFyRXMXldqGKg=; b=MSebOgAQZr1XRRkAsu+phgjivJkYsjrS9rdOep5wZDzOZZzJ2rBbjxKEJJ9Swk/xRe XMG53bGPtrEcARHMeAuuwIxiDfhirFZpo6LA6X64hAr63bvDbsFoxKG6M67dk1vFDGYa Uao02KiCQ/TZHN3MUz9nr7klsTVbufmz+4nCc=
- 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:content-transfer-encoding:content-disposition :references; b=o1KOE5tsFQAOl+toz57MbEe7VE4jw4KRuZdOV+YrmmFZ3vEQ89DZIZc+JPxAnvEUt5 k8rlAD8rj3pILvQg5t40dLi9y/nTaKdF2g8A2aFoAWxGW25lGCNXJc8KH6N9nlX3p0AT rEfeiVX6LINTxRjlPKLwA55+Ss7NzgiI7gAl4=
[UPDATE: Gael beats me to it as usual)
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?