Re: [eigen] Support for true Array |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Support for true Array
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Wed, 25 Nov 2009 07:48:00 -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; bh=l1gM1GXBhzS/C77qDT8ae11LrzjrZz/kle27NbqhqY0=; b=X0tHoMKMyBhevYLVtTnC2QFZHTCfXlM2+bVkaj+Jkas2hs8jvmWiRMGwpHvC+HrEak DDL0FoePuuPz4vbcSkIyOk2gZQNs4N0v2OxqQUAx7Qlb/dotqOMP4SSWz/NFquuwbc20 Iv57Ek75JbqBfppDhRNCQzxaozHJgov/XNArw=
- 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; b=PBG5n9fIlYtG8D0AZFCzzEcwHMwuscX614fKiOZWcabQ1o9cQnpEXE6NABcwL+J4+p GzvsY5mid0jDz7l+wStv3S14Kia+gGEuBluDXaoVySgjoIU4GSZKAdlzZiO1oOcjTdTO +G6qcU1GQvClVukyaSwnVQ8sOnRM0h8+BrPCg=
2009/11/25 Rohit Garg <rpg.314@xxxxxxxxx>:
> 1) Are there any other benefits to having an array class apart from
> getting rid of .cwise() to do element wise multiplications?
Well, that in itself is already a big advantage, as many people would
like to use Eigen's xpr templates and vectorization on plain arrays,
using only cwise ops.
But to answer your question, there is another benefit, as we mentioned
above: such an Array class could be used as Scalar type, so a
Matrix<Array...,3,1> would behave like an array of Vector3's but each
scalar operation would become an array operation. So if you are
interested in SIMD on Vector3's and you have a large number of them,
this approach allows you to get it!
> 2) I haven't understood how this would help the quaternion class and
> the related things.
Currently the question is: how to add xpr templates to Quaternion and
eventually DualQuaternion without rewriting all the xpr classes? Gael
had to solve the same problem for Array and his solution was to have a
class that has an array interface but can wrap an arbitrary xpr. Then
the operator+ between arrays can just return a usual 'sum' xpr, but
wrapper like that in an array interface! Thus, only operators/methods
need to be rewritten for Array, but the underlying xpr classes that
they return don't have to be rewritten.
Then I thought: why not do the same in Quaternion? We could have a
QuaternionWrapper class that wraps any MatrixBase for its array of 4
coefficients; then the operator+ between quaternions returns a
QuaternionWrapper<ordinary sum xpr>....
> 3) A million Vector3f's would still not be vectorized as they are not
> a multiple of packet size, or will they? Is there a possibility to
> automagically handle the SOA form instead of the usual AOS form with
> this proposal?
Yes, this is exactly what I meant. (Dont quite remember what AOS
stands for but that seems to be it).
This is about creating an Array class that can be used as a scalar
type, and on which the arithmetic ops are vectorized. So when you have
Matrix<Array,3,1> u,v,w;
and you do:
u = v+w;
this expands (thanks to Eigen xpr templates and unrollers) to:
u[0] = v[0]+w[0];
u[1] = v[1]+w[1];
u[2] = v[2]+w[2];
Each of these 3 lines is now an operation on Array objects and expands
to a vectorized loop doing the addition.
Benoit