Re: [eigen] Support for true Array

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


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



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